Watt-32 tcp/ip  2.2 dev-rel.10
if_media.h
Go to the documentation of this file.
1 
5 /* $NetBSD: if_media.h,v 1.3 1997/03/26 01:19:27 thorpej Exp $ */
6 
7 /*
8  * Copyright (c) 1997
9  * Jonathan Stone and Jason R. Thorpe. All rights reserved.
10  *
11  * This software is derived from information provided by Matt Thomas.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution.
21  * 3. All advertising materials mentioning features or use of this software
22  * must display the following acknowledgement:
23  * This product includes software developed by Jonathan Stone
24  * and Jason R. Thorpe for the NetBSD Project.
25  * 4. The names of the authors may not be used to endorse or promote products
26  * derived from this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
29  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
35  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38  * SUCH DAMAGE.
39  */
40 
41 #ifndef __NET_IF_MEDIA_H
42 #define __NET_IF_MEDIA_H
43 
44 /*
45  * Prototypes and definitions for BSD/OS-compatible network interface
46  * media selection.
47  *
48  * Where it is safe to do so, this code strays slightly from the BSD/OS
49  * design. Software which uses the API (device drivers, basically)
50  * shouldn't notice any difference.
51  *
52  * Many thanks to Matt Thomas for providing the information necessary
53  * to implement this interface.
54  */
55 
56 
57 /*
58  * if_media Options word:
59  * Bits Use
60  * ---- -------
61  * 0-3 Media variant
62  * 4 RFU
63  * 5-7 Media type
64  * 8-15 Type specific options
65  * 16-19 RFU
66  * 20-27 Shared (global) options
67  * 28-31 Instance
68  */
69 
70 /*
71  * Ethernet
72  */
73 #define IFM_ETHER 0x00000020
74 #define IFM_10_T 3 /* 10BaseT - RJ45 */
75 #define IFM_10_2 4 /* 10Base2 - Thinnet */
76 #define IFM_10_5 5 /* 10Base5 - AUI */
77 #define IFM_100_TX 6 /* 100BaseTX - RJ45 */
78 #define IFM_100_FX 7 /* 100BaseFX - Fiber */
79 #define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */
80 #define IFM_100_VG 9 /* 100VG-AnyLAN */
81 #define IFM_100_T2 10 /* 100BaseT2 */
82 
83 /*
84  * Token ring
85  */
86 #define IFM_TOKEN 0x00000040
87 #define IFM_TOK_STP4 3 /* Shielded twisted pair 4m - DB9 */
88 #define IFM_TOK_STP16 4 /* Shielded twisted pair 16m - DB9 */
89 #define IFM_TOK_UTP4 5 /* Unshielded twisted pair 4m - RJ45 */
90 #define IFM_TOK_UTP16 6 /* Unshielded twisted pair 16m - RJ45 */
91 #define IFM_TOK_ETR 0x00000200 /* Early token release */
92 #define IFM_TOK_SRCRT 0x00000400 /* Enable source routing features */
93 #define IFM_TOK_ALLR 0x00000800 /* All routes / Single route bcast */
94 
95 /*
96  * FDDI
97  */
98 #define IFM_FDDI 0x00000060
99 #define IFM_FDDI_SMF 3 /* Single-mode fiber */
100 #define IFM_FDDI_MMF 4 /* Multi-mode fiber */
101 #define IFM_FDDI_UTP 5 /* CDDI / UTP */
102 #define IFM_FDDI_DA 0x00000100 /* Dual attach / single attach */
103 
104 /*
105  * Shared media sub-types
106  */
107 #define IFM_AUTO 0 /* Autoselect best media */
108 #define IFM_MANUAL 1 /* Jumper/dipswitch selects media */
109 #define IFM_NONE 2 /* Deselect all media */
110 
111 /*
112  * Shared options
113  */
114 #define IFM_FDX 0x00100000 /* Force full duplex */
115 #define IFM_HDX 0x00200000 /* Force half duplex */
116 #define IFM_FLAG0 0x01000000 /* Driver defined flag */
117 #define IFM_FLAG1 0x02000000 /* Driver defined flag */
118 #define IFM_FLAG2 0x04000000 /* Driver defined flag */
119 #define IFM_LOOP 0x08000000 /* Put hardware in loopback */
120 
121 /*
122  * Masks
123  */
124 #define IFM_NMASK 0x000000e0 /* Network type */
125 #define IFM_TMASK 0x0000000f /* Media sub-type */
126 #define IFM_IMASK 0xf0000000 /* Instance */
127 #define IFM_ISHIFT 28 /* Instance shift */
128 #define IFM_OMASK 0x0000ff00 /* Type specific options */
129 #define IFM_GMASK 0x0ff00000 /* Global options */
130 
131 /*
132  * Status bits
133  */
134 #define IFM_AVALID 0x00000001 /* Active bit valid */
135 #define IFM_ACTIVE 0x00000002 /* Interface attached to working net */
136 
137 /*
138  * Macros to extract various bits of information from the media word.
139  */
140 #define IFM_TYPE(x) ((x) & IFM_NMASK)
141 #define IFM_SUBTYPE(x) ((x) & IFM_TMASK)
142 #define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT)
143 
144 /*
145  * NetBSD extension not defined in the BSDI API. This is used in various
146  * places to get the canonical description for a given type/subtype.
147  *
148  * NOTE: all but the top-level type descriptions must contain NO whitespace!
149  * Otherwise, parsing these in ifconfig(8) would be a nightmare.
150  */
152  int ifmt_word; /* word value; may be masked */
153  const char *ifmt_string; /* description */
154 };
155 
156 #define IFM_TYPE_DESCRIPTIONS { \
157  { IFM_ETHER, "Ethernet" }, \
158  { IFM_TOKEN, "Token ring" }, \
159  { IFM_FDDI, "FDDI" }, \
160  { 0, NULL }, \
161 }
162 
163 #define IFM_SUBTYPE_ETHERNET_DESCRIPTIONS { \
164  { IFM_10_T, "10baseT/UTP" }, \
165  { IFM_10_2, "10base2/BNC" }, \
166  { IFM_10_5, "10base5/AUI" }, \
167  { IFM_100_TX, "100baseTX" }, \
168  { IFM_100_FX, "100baseFX" }, \
169  { IFM_100_T4, "100baseT4" }, \
170  { IFM_100_VG, "100baseVG" }, \
171  { IFM_100_T2, "100baseT2" }, \
172  { 0, NULL }, \
173 }
174 
175 #define IFM_SUBTYPE_ETHERNET_ALIASES { \
176  { IFM_10_T, "UTP" }, \
177  { IFM_10_T, "10UTP" }, \
178  { IFM_10_2, "BNC" }, \
179  { IFM_10_2, "10BNC" }, \
180  { IFM_10_5, "AUI" }, \
181  { IFM_10_5, "10AUI" }, \
182  { IFM_100_TX, "100TX" }, \
183  { IFM_100_FX, "100FX" }, \
184  { IFM_100_T4, "100T4" }, \
185  { IFM_100_VG, "100VG" }, \
186  { IFM_100_T2, "100T2" }, \
187  { 0, NULL }, \
188 }
189 
190 #define IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS { \
191  { 0, NULL }, \
192 }
193 
194 #define IFM_SUBTYPE_TOKENRING_DESCRIPTIONS { \
195  { IFM_TOK_STP4, "DB9/4Mbit" }, \
196  { IFM_TOK_STP16, "DB9/16Mbit" }, \
197  { IFM_TOK_UTP4, "UTP/4Mbit" }, \
198  { IFM_TOK_UTP16, "UTP/16Mbit" }, \
199  { 0, NULL }, \
200 }
201 
202 #define IFM_SUBTYPE_TOKENRING_ALIASES { \
203  { IFM_TOK_STP4, "4STP" }, \
204  { IFM_TOK_STP16, "16STP" }, \
205  { IFM_TOK_UTP4, "4UTP" }, \
206  { IFM_TOK_UTP16, "16UTP" }, \
207  { 0, NULL }, \
208 }
209 
210 #define IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS { \
211  { IFM_TOK_ETR, "EarlyTokenRelease" }, \
212  { IFM_TOK_SRCRT, "SourceRouting" }, \
213  { IFM_TOK_ALLR, "AllRoutes" }, \
214  { 0, NULL }, \
215 }
216 
217 #define IFM_SUBTYPE_FDDI_DESCRIPTIONS { \
218  { IFM_FDDI_SMF, "Single-mode" }, \
219  { IFM_FDDI_MMF, "Multi-mode" }, \
220  { IFM_FDDI_UTP, "UTP" }, \
221  { 0, NULL }, \
222 }
223 
224 #define IFM_SUBTYPE_FDDI_ALIASES { \
225  { IFM_FDDI_SMF, "SMF" }, \
226  { IFM_FDDI_MMF, "MMF" }, \
227  { IFM_FDDI_UTP, "CDDI" }, \
228  { 0, NULL }, \
229 }
230 
231 #define IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS { \
232  { IFM_FDDI_DA, "Dual-attach" }, \
233  { 0, NULL }, \
234 }
235 
236 #define IFM_SUBTYPE_SHARED_DESCRIPTIONS { \
237  { IFM_AUTO, "autoselect" }, \
238  { IFM_MANUAL, "manual" }, \
239  { IFM_NONE, "none" }, \
240  { 0, NULL }, \
241 }
242 
243 #define IFM_SUBTYPE_SHARED_ALIASES { \
244  { IFM_AUTO, "auto" }, \
245  { 0, NULL }, \
246 }
247 
248 #define IFM_SHARED_OPTION_DESCRIPTIONS { \
249  { IFM_FDX, "full-duplex" }, \
250  { IFM_HDX, "half-duplex" }, \
251  { IFM_FLAG0, "flag0" }, \
252  { IFM_FLAG1, "flag1" }, \
253  { IFM_FLAG2, "flag2" }, \
254  { IFM_LOOP, "hw-loopback" }, \
255  { 0, NULL }, \
256 }
257 
258 #endif