1 /* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.6 2002/12/11 07:14:12 guy 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 */ 29 30 #define TOKEN_HDRLEN 14 31 #define TOKEN_RING_MAC_LEN 6 32 #define ROUTING_SEGMENT_MAX 16 33 #define IS_SOURCE_ROUTED(trp) ((trp)->token_shost[0] & 0x80) 34 #define FRAME_TYPE(trp) (((trp)->token_fc & 0xC0) >> 6) 35 #define TOKEN_FC_LLC 1 36 37 #define BROADCAST(trp) ((ntohs((trp)->token_rcf) & 0xE000) >> 13) 38 #define RIF_LENGTH(trp) ((ntohs((trp)->token_rcf) & 0x1f00) >> 8) 39 #define DIRECTION(trp) ((ntohs((trp)->token_rcf) & 0x0080) >> 7) 40 #define LARGEST_FRAME(trp) ((ntohs((trp)->token_rcf) & 0x0070) >> 4) 41 #define RING_NUMBER(trp, x) ((ntohs((trp)->token_rseg[x]) & 0xfff0) >> 4) 42 #define BRIDGE_NUMBER(trp, x) ((ntohs((trp)->token_rseg[x]) & 0x000f)) 43 #define SEGMENT_COUNT(trp) ((int)((RIF_LENGTH(trp) - 2) / 2)) 44 45 struct token_header { 46 u_int8_t token_ac; 47 u_int8_t token_fc; 48 u_int8_t token_dhost[TOKEN_RING_MAC_LEN]; 49 u_int8_t token_shost[TOKEN_RING_MAC_LEN]; 50 u_int16_t token_rcf; 51 u_int16_t token_rseg[ROUTING_SEGMENT_MAX]; 52 }; 53