token.h revision 98527
1/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.3 2000/10/03 02:55:03 itojun Exp $ (LBL) */
2/*
3 * Copyright (c) 1998, Larry Lile
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice unmodified, this list of conditions, and the following
11 *    disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/contrib/tcpdump/token.h 98527 2002-06-21 00:49:02Z fenner $
29 */
30
31#define TOKEN_HDRLEN		14
32#define TOKEN_RING_MAC_LEN	6
33#define ROUTING_SEGMENT_MAX	16
34#define IS_SOURCE_ROUTED(trp)	((trp)->token_shost[0] & 0x80)
35#define FRAME_TYPE(trp)		(((trp)->token_fc & 0xC0) >> 6)
36#define TOKEN_FC_LLC		1
37
38#define BROADCAST(trp)		((ntohs((trp)->token_rcf) & 0xE000) >> 13)
39#define RIF_LENGTH(trp)		((ntohs((trp)->token_rcf) & 0x1f00) >> 8)
40#define DIRECTION(trp)		((ntohs((trp)->token_rcf) & 0x0080) >> 7)
41#define LARGEST_FRAME(trp)	((ntohs((trp)->token_rcf) & 0x0070) >> 4)
42#define RING_NUMBER(trp, x)	((ntohs((trp)->token_rseg[x]) & 0xfff0) >> 4)
43#define BRIDGE_NUMBER(trp, x)	((ntohs((trp)->token_rseg[x]) & 0x000f))
44#define SEGMENT_COUNT(trp)	((RIF_LENGTH(trp) - 2) / 2)
45
46struct token_header {
47	u_int8_t  token_ac;
48	u_int8_t  token_fc;
49	u_int8_t  token_dhost[TOKEN_RING_MAC_LEN];
50	u_int8_t  token_shost[TOKEN_RING_MAC_LEN];
51	u_int16_t token_rcf;
52	u_int16_t token_rseg[ROUTING_SEGMENT_MAX];
53};
54