1 /* $NetBSD: if_token.h,v 1.17 2015/12/16 05:44:59 ozaki-r Exp $ */ 2 3 /* 4 * Copyright (c) 1982, 1986, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following 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 * 3. Neither the name of the University nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * from: NetBSD: if_fddi.h,v 1.2 1995/08/19 04:35:28 cgd Exp 32 */ 33 34 #ifndef _NET_IF_TOKEN_H_ 35 #define _NET_IF_TOKEN_H_ 36 37 #define ISO88025_ADDR_LEN 6 38 39 /* Token Ring physical header */ 40 struct token_header { 41 uint8_t token_ac; /* access control field */ 42 uint8_t token_fc; /* frame control field */ 43 uint8_t token_dhost[ISO88025_ADDR_LEN]; /* dest. address */ 44 uint8_t token_shost[ISO88025_ADDR_LEN]; /* source address */ 45 } __packed; 46 47 #define TOKEN_MAX_BRIDGE 8 48 49 /* Token Ring routing information field */ 50 struct token_rif { 51 uint16_t tr_rcf; /* route control field */ 52 uint16_t tr_rdf[TOKEN_MAX_BRIDGE]; /* route-designator fields */ 53 } __packed; 54 55 /* standard values for address control and frame control field */ 56 #define TOKEN_AC 0x10 57 #define TOKEN_FC 0x40 58 59 #define TOKEN_RI_PRESENT 0x80 /* routing info present bit */ 60 #define TOKEN_RCF_LEN_MASK 0x1f00 61 #define TOKEN_RCF_BROADCAST_MASK 0xe000 62 #define TOKEN_RCF_BROADCAST_ALL 0x8000 /* all routes broadcast */ 63 #define TOKEN_RCF_BROADCAST_SINGLE 0xc000 /* single route broadcast */ 64 65 /* 66 * A Token-ring frame consists of 67 * header + rif + llcinfo + fcs 68 * 14 + 2 * (0 ... 9) + x + 4 octets 69 * where llcinfo contains the llcsnap header (8 octets) and the IP frame 70 */ 71 /* LLC INFO (802.5PD-2) */ 72 #define TOKEN_RCF_FRAME0 0x0000 /* 516 */ 73 #define TOKEN_RCF_FRAME1 0x0010 /* 1500 */ 74 #define TOKEN_RCF_FRAME2 0x0020 /* 2052 */ 75 #define TOKEN_RCF_FRAME3 0x0030 /* 4472 */ 76 #define TOKEN_RCF_FRAME4 0x0040 /* 8144 */ 77 #define TOKEN_RCF_FRAME5 0x0050 /* 11407 */ 78 #define TOKEN_RCF_FRAME6 0x0060 /* 17800 */ 79 #define TOKEN_RCF_FRAME7 0x0070 /* 65535 */ 80 #define TOKEN_RCF_FRAME_MASK 0x0070 81 82 #define TOKEN_RCF_DIRECTION 0x0080 83 84 /* 85 * According to RFC 1042 86 */ 87 #define IPMTU_4MBIT_MAX 4464 88 #define IPMTU_16MBIT_MAX 8188 89 90 /* 91 * RFC 1042: 92 * It is recommended that all implementations support IP packets 93 * of at least 2002 octets. 94 */ 95 #define ISO88025_MTU 2002 96 97 /* 98 * This assumes that route information fields are appended to token_header. 99 */ 100 #define TOKEN_RIF(x) ((struct token_rif *) ((x) + 1)) 101 102 #define TOKEN_RIF_LLE(lle) ((struct token_rif *) (lle)->la_opaque) 103 #define TOKEN_RIF_LLE_ASSERT(lle) KASSERT((lle)->la_opaque != NULL) 104 105 /* 106 * This is a kludge to get at the token ring mac header and the source route 107 * information after m_adj() has been used on the mbuf. 108 * Note that m is always an mbuf with a packet header. 109 */ 110 #define M_TRHSTART(m) \ 111 (ALIGN(((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf : &(m)->m_pktdat[0]) \ 112 + sizeof (struct token_header)) - sizeof(struct token_header)) 113 114 #if defined(_KERNEL) 115 /* 116 * XXX we need if_ethersubr.c with all these defines 117 */ 118 #define tokenbroadcastaddr etherbroadcastaddr 119 #define token_ipmulticast_min ether_ipmulticast_min 120 #define token_ipmulticast_max ether_ipmulticast_max 121 #define token_sprintf ether_sprintf 122 123 void token_ifattach(struct ifnet *, void *); 124 void token_ifdetach(struct ifnet *); 125 #endif 126 127 #endif /* !_NET_IF_TOKEN_H_ */ 128