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