]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* Copyright (c) 1997, 1998 Apple Computer, Inc. All Rights Reserved */ | |
26 | /* | |
27 | * @(#)ndrv.h 1.1 (MacOSX) 6/10/43 | |
28 | * Justin Walker - 970604 | |
29 | */ | |
7b1edb79 | 30 | #include <net/dlil.h> |
1c79356b A |
31 | |
32 | #ifndef _NET_NDRV_H | |
33 | #define _NET_NDRV_H | |
9bccf70c | 34 | #include <sys/appleapiopts.h> |
1c79356b | 35 | |
7b1edb79 | 36 | |
1c79356b | 37 | struct sockaddr_ndrv |
7b1edb79 A |
38 | { |
39 | unsigned char snd_len; | |
1c79356b A |
40 | unsigned char snd_family; |
41 | unsigned char snd_name[IFNAMSIZ]; /* from if.h */ | |
42 | }; | |
43 | ||
44 | /* | |
7b1edb79 | 45 | * Support for user-mode protocol handlers |
1c79356b | 46 | */ |
1c79356b | 47 | |
7b1edb79 A |
48 | #define NDRV_DEMUXTYPE_ETHERTYPE DLIL_DESC_ETYPE2 |
49 | #define NDRV_DEMUXTYPE_SAP DLIL_DESC_SAP | |
50 | #define NDRV_DEMUXTYPE_SNAP DLIL_DESC_SNAP | |
1c79356b | 51 | |
7b1edb79 | 52 | #define NDRVPROTO_NDRV 0 |
1c79356b A |
53 | |
54 | /* | |
7b1edb79 A |
55 | * Struct: ndrv_demux_desc |
56 | * Purpose: | |
57 | * To uniquely identify a packet based on its low-level framing information. | |
58 | * | |
59 | * Fields: | |
60 | * type : type of protocol in data field, must be understood by | |
61 | * the interface family of the interface the socket is bound to | |
62 | * length : length of protocol data in "data" field | |
63 | * data : union of framing-specific data, in network byte order | |
64 | * ether_type : ethernet type in network byte order, assuming | |
65 | * ethernet type II framing | |
66 | * sap : first 3 bytes of sap header, network byte order | |
67 | * snap : first 5 bytes of snap header, network byte order | |
68 | * other : up to 28 bytes of protocol data for different protocol type | |
69 | * | |
70 | * Examples: | |
71 | * 1) 802.1x uses ether_type 0x888e, so the descriptor would be set as: | |
72 | * struct ndrv_demux_desc desc; | |
73 | * desc.type = NDRV_DEMUXTYPE_ETHERTYPE | |
74 | * desc.length = sizeof(unsigned short); | |
75 | * desc.ether_type = htons(0x888e); | |
76 | * 2) AppleTalk uses SNAP 0x080007809B | |
77 | * struct ndrv_demux_desc desc; | |
78 | * desc.type = NDRV_DEMUXTYPE_SNAP; | |
79 | * desc.length = 5; | |
80 | * desc.data.snap[0] = 08; | |
81 | * desc.data.snap[1] = 00; | |
82 | * desc.data.snap[2] = 07; | |
83 | * desc.data.snap[3] = 80; | |
84 | * desc.data.snap[4] = 9B; | |
1c79356b | 85 | */ |
7b1edb79 A |
86 | struct ndrv_demux_desc |
87 | { | |
88 | u_int16_t type; | |
89 | u_int16_t length; | |
90 | union | |
91 | { | |
92 | u_int16_t ether_type; | |
93 | u_int8_t sap[3]; | |
94 | u_int8_t snap[5]; | |
95 | u_int8_t other[28]; | |
96 | } data; | |
97 | }; | |
98 | ||
99 | #define NDRV_PROTOCOL_DESC_VERS 1 | |
1c79356b | 100 | |
7b1edb79 A |
101 | /* |
102 | * Struct: ndrv_protocol_desc | |
103 | * Purpose: | |
104 | * Used to "bind" an NDRV socket so that packets that match | |
105 | * given protocol demux descriptions can be received: | |
106 | * Field: | |
107 | * version : must be NDRV_PROTOCOL_DESC_VERS | |
108 | * protocol_family : unique identifier for this protocol | |
109 | * demux_count : number of demux_list descriptors in demux_list | |
110 | * demux_list : pointer to array of demux descriptors | |
111 | */ | |
112 | struct ndrv_protocol_desc | |
113 | { | |
114 | u_int32_t version; | |
115 | u_int32_t protocol_family; | |
116 | u_int32_t demux_count; | |
117 | struct ndrv_demux_desc* demux_list; | |
1c79356b A |
118 | }; |
119 | ||
7b1edb79 A |
120 | #define SOL_NDRVPROTO NDRVPROTO_NDRV /* Use this socket level */ |
121 | /* NDRV_DMXSPEC 0x01 Obsolete */ | |
122 | #define NDRV_DELDMXSPEC 0x02 /* Delete the registered protocol */ | |
123 | /* NDRV_DMXSPECCNT 0x03 Obsolete */ | |
124 | #define NDRV_SETDMXSPEC 0x04 /* Set the protocol spec */ | |
9bccf70c A |
125 | #define NDRV_ADDMULTICAST 0x05 /* Add a physical multicast address */ |
126 | #define NDRV_DELMULTICAST 0x06 /* Delete a phyiscal multicast */ | |
1c79356b | 127 | |
9bccf70c A |
128 | /* |
129 | * SOL_NDRVPROTO - use this for the socket level when calling setsocketopt | |
130 | * NDRV_DELDMXSPEC - removes the registered protocol and all related demuxes | |
131 | * NDRV_SETDMXSPEC - set the protocol to receive, use struct ndrv_protocol_desc | |
132 | * as the parameter. | |
133 | * NDRV_ADDMULTICAST - Enable reception of a phyiscal multicast address, use | |
134 | * a sockaddr of the appropriate type for the media in use. | |
135 | * NDRV_DELMULTICAST - Disable reception of a phyiscal multicast address, use | |
136 | * a sockaddr of the appropriate type for the media in use. | |
137 | * | |
138 | * When adding multicasts, the multicasts are ref counted. If the multicast is | |
139 | * already registered in the kernel, the count will be bumped. When deleting | |
140 | * the multicast, the count is decremented. If the count reaches zero the | |
141 | * multicast is removed. If your process is killed, PF_NDRV will unregister | |
142 | * the mulitcasts you've added. You can only delete multicasts you've added | |
143 | * on the same socket. | |
144 | * | |
145 | * If the interface goes away while your socket is open, your protocol is | |
146 | * immediately detached and sending/receiving is disabled on the socket. | |
147 | * If you need a chance to do something, please file a bug and we can give | |
148 | * you a second or two. | |
149 | */ | |
150 | ||
151 | #ifdef KERNEL | |
152 | #ifdef __APPLE_API_UNSTABLE | |
7b1edb79 A |
153 | /* Additional Kernel APIs */ |
154 | struct ifnet* ndrv_get_ifp(caddr_t ndrv_pcb); | |
9bccf70c | 155 | #endif /* __APPLE_API_UNSTABLE */ |
1c79356b | 156 | #endif |
7b1edb79 | 157 | |
1c79356b | 158 | #endif /* _NET_NDRV_H */ |