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