]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/net/iso88025.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / net / iso88025.h
1 /*-
2  * Copyright (c) 1998, Larry Lile
3  * All rights reserved.
4  *
5  * For latest sources and information on this driver, please
6  * go to http://anarchy.stdio.com.
7  *
8  * Questions, comments or suggestions should be directed to
9  * Larry Lile <lile@stdio.com>.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice unmodified, this list of conditions, and the following
16  *    disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * $FreeBSD$
34  *
35  * Information gathered from tokenring@freebsd, /sys/net/ethernet.h and
36  * the Mach token ring driver.
37  */
38
39 /*
40  * Fundamental constants relating to iso 802.5
41  */
42
43 #ifndef _NET_ISO88025_H_
44 #define _NET_ISO88025_H_
45
46 /*
47  * General ISO 802.5 definitions
48  */
49 #define ISO88025_ADDR_LEN       6
50 #define ISO88025_CF_LEN         2
51 #define ISO88025_HDR_LEN        (ISO88025_CF_LEN + (ISO88025_ADDR_LEN * 2))
52 #define RCF_LEN                 2
53 #define RIF_MAX_RD              14
54 #define RIF_MAX_LEN             16
55
56 #define TR_AC                   0x10
57 #define TR_LLC_FRAME            0x40
58
59 #define TR_4MBPS                4000000
60 #define TR_16MBPS               16000000
61 #define TR_100MBPS              100000000
62
63 /*
64  * Source routing 
65  */
66 #define TR_RII                  0x80
67 #define TR_RCF_BCST_MASK        0xe000
68 #define TR_RCF_LEN_MASK         0x1f00
69 #define TR_RCF_DIR              0x0080
70 #define TR_RCF_LF_MASK          0x0070
71
72 #define TR_RCF_RIFLEN(x)        ((ntohs(x) & TR_RCF_LEN_MASK) >> 8)
73
74 /*
75  * Minimum and maximum packet payload lengths.
76  */
77 #define ISO88025_MIN_LEN        0 
78 #define ISO88025_MAX_LEN_4      4464
79 #define ISO88025_MAX_LEN_16     17960   
80 #define ISO88025_MAX_LEN        ISO88025_MAX_LEN_16
81
82 /*
83  * A macro to validate a length with
84  */
85 #define ISO88025_IS_VALID_LEN(foo)      \
86         ((foo) >= ISO88025_MIN_LEN && (foo) <= ISO88025_MAX_LEN)
87
88 /* Access Control field */
89 #define AC_PRI_MASK             0xe0    /* Priority bits                */
90 #define AC_TOKEN                0x10    /* Token bit: 0=Token, 1=Frame  */
91 #define AC_MONITOR              0x08    /* Monitor                      */
92 #define AC_RESV_MASK            0x07    /* Reservation bits             */
93
94 /* Frame Control field */
95 #define FC_FT_MASK              0xc0    /* Frame Type                   */
96 #define FC_FT_MAC               0x00    /* MAC frame                    */
97 #define FC_FT_LLC               0x40    /* LLC frame                    */
98 #define FC_ATTN_MASK            0x0f    /* Attention bits               */
99 #define FC_ATTN_EB              0x01    /* Express buffer               */
100 #define FC_ATTN_BE              0x02    /* Beacon                       */
101 #define FC_ATTN_CT              0x03    /* Claim token                  */
102 #define FC_ATTN_RP              0x04    /* Ring purge                   */
103 #define FC_ATTN_AMP             0x05    /* Active monitor present       */
104 #define FC_ATTN_SMP             0x06    /* Standby monitor present      */
105
106 /* Token Ring destination address */
107 #define DA_IG                   0x80    /* Individual/group address.    */
108                                         /* 0=Individual, 1=Group        */
109 #define DA_UL                   0x40    /* Universal/local address.     */
110                                         /* 0=Universal, 1=Local         */
111 /* Token Ring source address */
112 #define SA_RII                  0x80    /* Routing information indicator */
113 #define SA_IG                   0x40    /* Individual/group address     */
114                                         /* 0=Group, 1=Individual        */
115
116 /*
117  * ISO 802.5 physical header
118  */
119 struct iso88025_header {
120         u_int8_t        ac;                                 /* access control field */
121         u_int8_t        fc;                                 /* frame control field */
122         u_int8_t        iso88025_dhost[ISO88025_ADDR_LEN];  /* destination address */
123         u_int8_t        iso88025_shost[ISO88025_ADDR_LEN];  /* source address */
124         u_int16_t       rcf;                                /* route control field */
125         u_int16_t       rd[RIF_MAX_RD];                     /* routing designators */
126 } __packed;
127
128 struct iso88025_rif {
129         u_int16_t       rcf;                                /* route control field */
130         u_int16_t       rd[RIF_MAX_RD];                     /* routing designators */
131 } __packed;
132
133 struct iso88025_sockaddr_data {
134         u_char ether_dhost[ISO88025_ADDR_LEN];
135         u_char ether_shost[ISO88025_ADDR_LEN];
136         u_char ac;
137         u_char fc;
138 };
139
140 struct iso88025_sockaddr_dl_data {
141         u_short  trld_rcf;
142         u_short *trld_route[RIF_MAX_LEN];
143 };
144
145 #define ISO88025_MAX(a, b)      (((a)>(b))?(a):(b))
146 #define SDL_ISO88025(s)         ((struct iso88025_sockaddr_dl_data *)   \
147                                  ((s)->sdl_data + \
148                                   ISO88025_MAX((s)->sdl_nlen + (s)->sdl_alen + \
149                                                (s)->sdl_slen, 12)))
150
151 /*
152  * Structure of a 48-bit iso 802.5 address.
153  *  ( We could also add the 16 bit addresses as a union)
154  */
155 struct  iso88025_addr {
156         u_char octet[ISO88025_ADDR_LEN];
157 };
158
159 #define ISO88025_MAX_MTU                18000
160 #define ISO88025_DEFAULT_MTU            1500
161
162 #define ISO88025_BPF_UNSUPPORTED        0
163 #define ISO88025_BPF_SUPPORTED          1
164
165 void    iso88025_ifattach       (struct ifnet *, const u_int8_t *, int);
166 void    iso88025_ifdetach       (struct ifnet *, int);
167 int     iso88025_ioctl          (struct ifnet *, u_long, caddr_t );
168 int     iso88025_output         (struct ifnet *, struct mbuf *, struct sockaddr *,
169                                  struct route *);
170 void    iso88025_input          (struct ifnet *, struct mbuf *);
171
172 #endif