]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
b0d623f7 | 2 | * Copyright (c) 2008 Apple Computer, Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
0a7de745 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
2d21ac55 A |
18 | * The Original Code and all software distributed under the License are |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1997, 1998 Apple Computer, Inc. All Rights Reserved */ | |
29 | /* | |
30 | * @(#)ndrv.h 1.1 (MacOSX) 6/10/43 | |
31 | * Justin Walker - 970604 | |
32 | */ | |
7b1edb79 | 33 | #include <net/dlil.h> |
1c79356b A |
34 | |
35 | #ifndef _NET_NDRV_H | |
36 | #define _NET_NDRV_H | |
9bccf70c | 37 | #include <sys/appleapiopts.h> |
1c79356b | 38 | |
7b1edb79 | 39 | |
0a7de745 A |
40 | struct sockaddr_ndrv { |
41 | unsigned char snd_len; | |
1c79356b A |
42 | unsigned char snd_family; |
43 | unsigned char snd_name[IFNAMSIZ]; /* from if.h */ | |
44 | }; | |
45 | ||
46 | /* | |
7b1edb79 | 47 | * Support for user-mode protocol handlers |
1c79356b | 48 | */ |
1c79356b | 49 | |
0a7de745 A |
50 | #define NDRV_DEMUXTYPE_ETHERTYPE 4 |
51 | #define NDRV_DEMUXTYPE_SAP 5 | |
52 | #define NDRV_DEMUXTYPE_SNAP 6 | |
1c79356b | 53 | |
0a7de745 | 54 | #define NDRVPROTO_NDRV 0 |
1c79356b A |
55 | |
56 | /* | |
7b1edb79 A |
57 | * Struct: ndrv_demux_desc |
58 | * Purpose: | |
59 | * To uniquely identify a packet based on its low-level framing information. | |
60 | * | |
61 | * Fields: | |
62 | * type : type of protocol in data field, must be understood by | |
63 | * the interface family of the interface the socket is bound to | |
0a7de745 | 64 | * length : length of protocol data in "data" field |
7b1edb79 A |
65 | * data : union of framing-specific data, in network byte order |
66 | * ether_type : ethernet type in network byte order, assuming | |
67 | * ethernet type II framing | |
68 | * sap : first 3 bytes of sap header, network byte order | |
69 | * snap : first 5 bytes of snap header, network byte order | |
70 | * other : up to 28 bytes of protocol data for different protocol type | |
71 | * | |
72 | * Examples: | |
73 | * 1) 802.1x uses ether_type 0x888e, so the descriptor would be set as: | |
74 | * struct ndrv_demux_desc desc; | |
75 | * desc.type = NDRV_DEMUXTYPE_ETHERTYPE | |
76 | * desc.length = sizeof(unsigned short); | |
77 | * desc.ether_type = htons(0x888e); | |
78 | * 2) AppleTalk uses SNAP 0x080007809B | |
79 | * struct ndrv_demux_desc desc; | |
80 | * desc.type = NDRV_DEMUXTYPE_SNAP; | |
81 | * desc.length = 5; | |
82 | * desc.data.snap[0] = 08; | |
83 | * desc.data.snap[1] = 00; | |
84 | * desc.data.snap[2] = 07; | |
85 | * desc.data.snap[3] = 80; | |
86 | * desc.data.snap[4] = 9B; | |
1c79356b | 87 | */ |
0a7de745 A |
88 | struct ndrv_demux_desc { |
89 | u_int16_t type; | |
90 | u_int16_t length; | |
91 | union{ | |
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; | |
7b1edb79 A |
97 | }; |
98 | ||
0a7de745 | 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: | |
b0d623f7 A |
107 | * version : must be NDRV_PROTOCOL_DESC_VERS |
108 | * protocol_family : unique identifier for this protocol | |
6d2010ae | 109 | * demux_count : number of demux_list descriptors in demux_list; maximum of 10 |
b0d623f7 | 110 | * demux_list : pointer to array of demux descriptors |
7b1edb79 | 111 | */ |
0a7de745 A |
112 | struct ndrv_protocol_desc { |
113 | u_int32_t version; | |
114 | u_int32_t protocol_family; | |
115 | u_int32_t demux_count; | |
116 | struct ndrv_demux_desc *demux_list; | |
1c79356b A |
117 | }; |
118 | ||
2d21ac55 | 119 | #ifdef KERNEL_PRIVATE |
0a7de745 | 120 | /* LP64 version of ndrv_protocol_desc. all pointers |
2d21ac55 A |
121 | * grow when we're dealing with a 64-bit process. |
122 | * WARNING - keep in sync with ndrv_protocol_desc | |
123 | */ | |
124 | struct ndrv_protocol_desc64 { | |
0a7de745 A |
125 | u_int32_t version; |
126 | u_int32_t protocol_family; | |
127 | u_int32_t demux_count; | |
128 | user64_addr_t demux_list __attribute__((aligned(8))); | |
2d21ac55 A |
129 | }; |
130 | ||
b0d623f7 | 131 | struct ndrv_protocol_desc32 { |
0a7de745 A |
132 | u_int32_t version; |
133 | u_int32_t protocol_family; | |
134 | u_int32_t demux_count; | |
135 | user32_addr_t demux_list; | |
b0d623f7 A |
136 | }; |
137 | #endif /* KERNEL_PRIVATE */ | |
2d21ac55 | 138 | |
0a7de745 A |
139 | #define SOL_NDRVPROTO NDRVPROTO_NDRV /* Use this socket level */ |
140 | #define NDRV_DELDMXSPEC 0x02 /* Delete the registered protocol */ | |
141 | #define NDRV_SETDMXSPEC 0x04 /* Set the protocol spec */ | |
142 | #define NDRV_ADDMULTICAST 0x05 /* Add a physical multicast address */ | |
143 | #define NDRV_DELMULTICAST 0x06 /* Delete a phyiscal multicast */ | |
1c79356b | 144 | |
9bccf70c A |
145 | /* |
146 | * SOL_NDRVPROTO - use this for the socket level when calling setsocketopt | |
147 | * NDRV_DELDMXSPEC - removes the registered protocol and all related demuxes | |
148 | * NDRV_SETDMXSPEC - set the protocol to receive, use struct ndrv_protocol_desc | |
149 | * as the parameter. | |
150 | * NDRV_ADDMULTICAST - Enable reception of a phyiscal multicast address, use | |
151 | * a sockaddr of the appropriate type for the media in use. | |
152 | * NDRV_DELMULTICAST - Disable reception of a phyiscal multicast address, use | |
153 | * a sockaddr of the appropriate type for the media in use. | |
154 | * | |
155 | * When adding multicasts, the multicasts are ref counted. If the multicast is | |
156 | * already registered in the kernel, the count will be bumped. When deleting | |
157 | * the multicast, the count is decremented. If the count reaches zero the | |
158 | * multicast is removed. If your process is killed, PF_NDRV will unregister | |
159 | * the mulitcasts you've added. You can only delete multicasts you've added | |
160 | * on the same socket. | |
161 | * | |
162 | * If the interface goes away while your socket is open, your protocol is | |
163 | * immediately detached and sending/receiving is disabled on the socket. | |
164 | * If you need a chance to do something, please file a bug and we can give | |
165 | * you a second or two. | |
166 | */ | |
167 | ||
316670eb | 168 | /* Max number of descriptions allowed by default */ |
0a7de745 A |
169 | #define NDRV_DMUX_MAX_DESCR 1024 |
170 | ||
316670eb A |
171 | /* |
172 | * sysctl MIB tags at the kern.ipc.nrdv level | |
173 | */ | |
0a7de745 | 174 | #define NRDV_MULTICAST_ADDRS_PER_SOCK 1 /* to toggle NDRV_DMUX_MAX_DESCR value */ |
316670eb | 175 | |
0a7de745 | 176 | #endif /* _NET_NDRV_H */ |