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