token.h revision 50514
185815Sobrien/* 285815Sobrien * Copyright (c) 1998, Larry Lile 385815Sobrien * All rights reserved. 4218822Sdim * 5218822Sdim * Redistribution and use in source and binary forms, with or without 685815Sobrien * modification, are permitted provided that the following conditions 7218822Sdim * are met: 8218822Sdim * 1. Redistributions of source code must retain the above copyright 985815Sobrien * notice unmodified, this list of conditions, and the following 10218822Sdim * disclaimer. 1185815Sobrien * 2. Redistributions in binary form must reproduce the above copyright 12218822Sdim * notice, this list of conditions and the following disclaimer in the 13218822Sdim * documentation and/or other materials provided with the distribution. 14218822Sdim * 15218822Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1685815Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17218822Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18218822Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19218822Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20218822Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2185815Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22218822Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23218822Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24218822Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2585815Sobrien * SUCH DAMAGE. 2685815Sobrien * 2785815Sobrien */ 2885815Sobrien 2985815Sobrien#define TOKEN_HDR_LEN 14 3085815Sobrien#define TOKEN_RING_MAC_LEN 6 3185815Sobrien#define ROUTING_SEGMENT_MAX 16 3285815Sobrien#define IS_SOURCE_ROUTED (tp->ether_shost[0] & 0x80) 3385815Sobrien#define BROADCAST ((ntohs(tp->rcf) & 0xE000) >> 13) 3485815Sobrien#define RIF_LENGTH ((ntohs(tp->rcf) & 0x1f00) >> 8) 3585815Sobrien#define DIRECTION ((ntohs(tp->rcf) & 0x0080) >> 7) 3685815Sobrien#define LARGEST_FRAME ((ntohs(tp->rcf) & 0x0070) >> 4) 3789857Sobrien#define RING_NUMBER(x) ((ntohs(tp->rseg[x]) & 0xfff0) >> 4) 3889857Sobrien#define BRIDGE_NUMBER(x) ((ntohs(tp->rseg[x]) & 0x000f)) 3989857Sobrien#define SEGMENT_COUNT ((RIF_LENGTH - 2) / 2) 4085815Sobrien 4189857Sobrienchar *broadcast_indicator[] = { "Non-Broadcast", "Non-Broadcast", 4285815Sobrien "Non-Broadcast", "Non-Broadcast", 4389857Sobrien "All-routes", "All-routes", 4485815Sobrien "Single-route", "Single-route"}; 4585815Sobrien 4685815Sobrienchar *direction[] = { "Forward", "Backward"}; 47130561Sobrien 4885815Sobrienchar *largest_frame[] = { "516", "1500", "2052", "4472", "8144", 4989857Sobrien "11407", "17800", ""}; 5085815Sobrien 5189857Sobrien 5289857Sobrienstruct token_header { 5389857Sobrien u_char ac; 5489857Sobrien u_char fc; 5589857Sobrien u_char ether_dhost[TOKEN_RING_MAC_LEN]; 5689857Sobrien u_char ether_shost[TOKEN_RING_MAC_LEN]; 5789857Sobrien u_short rcf; 5889857Sobrien u_short rseg[ROUTING_SEGMENT_MAX]; 5989857Sobrien}; 6089857Sobrien