]> git.saurik.com Git - apple/xnu.git/blob - bsd/net/ndrv.h
7140ed56c43506b8a39e3639709db0b2d696c1c7
[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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /* Copyright (c) 1997, 1998 Apple Computer, Inc. All Rights Reserved */
23 /*
24 * @(#)ndrv.h 1.1 (MacOSX) 6/10/43
25 * Justin Walker - 970604
26 */
27 #include <net/dlil.h>
28
29 #ifndef _NET_NDRV_H
30 #define _NET_NDRV_H
31
32
33 struct sockaddr_ndrv
34 {
35 unsigned char snd_len;
36 unsigned char snd_family;
37 unsigned char snd_name[IFNAMSIZ]; /* from if.h */
38 };
39
40 /*
41 * Support for user-mode protocol handlers
42 */
43
44 #define NDRV_DEMUXTYPE_ETHERTYPE DLIL_DESC_ETYPE2
45 #define NDRV_DEMUXTYPE_SAP DLIL_DESC_SAP
46 #define NDRV_DEMUXTYPE_SNAP DLIL_DESC_SNAP
47
48 #define NDRVPROTO_NDRV 0
49
50 /*
51 * Struct: ndrv_demux_desc
52 * Purpose:
53 * To uniquely identify a packet based on its low-level framing information.
54 *
55 * Fields:
56 * type : type of protocol in data field, must be understood by
57 * the interface family of the interface the socket is bound to
58 * length : length of protocol data in "data" field
59 * data : union of framing-specific data, in network byte order
60 * ether_type : ethernet type in network byte order, assuming
61 * ethernet type II framing
62 * sap : first 3 bytes of sap header, network byte order
63 * snap : first 5 bytes of snap header, network byte order
64 * other : up to 28 bytes of protocol data for different protocol type
65 *
66 * Examples:
67 * 1) 802.1x uses ether_type 0x888e, so the descriptor would be set as:
68 * struct ndrv_demux_desc desc;
69 * desc.type = NDRV_DEMUXTYPE_ETHERTYPE
70 * desc.length = sizeof(unsigned short);
71 * desc.ether_type = htons(0x888e);
72 * 2) AppleTalk uses SNAP 0x080007809B
73 * struct ndrv_demux_desc desc;
74 * desc.type = NDRV_DEMUXTYPE_SNAP;
75 * desc.length = 5;
76 * desc.data.snap[0] = 08;
77 * desc.data.snap[1] = 00;
78 * desc.data.snap[2] = 07;
79 * desc.data.snap[3] = 80;
80 * desc.data.snap[4] = 9B;
81 */
82 struct ndrv_demux_desc
83 {
84 u_int16_t type;
85 u_int16_t length;
86 union
87 {
88 u_int16_t ether_type;
89 u_int8_t sap[3];
90 u_int8_t snap[5];
91 u_int8_t other[28];
92 } data;
93 };
94
95 #define NDRV_PROTOCOL_DESC_VERS 1
96
97 /*
98 * Struct: ndrv_protocol_desc
99 * Purpose:
100 * Used to "bind" an NDRV socket so that packets that match
101 * given protocol demux descriptions can be received:
102 * Field:
103 * version : must be NDRV_PROTOCOL_DESC_VERS
104 * protocol_family : unique identifier for this protocol
105 * demux_count : number of demux_list descriptors in demux_list
106 * demux_list : pointer to array of demux descriptors
107 */
108 struct ndrv_protocol_desc
109 {
110 u_int32_t version;
111 u_int32_t protocol_family;
112 u_int32_t demux_count;
113 struct ndrv_demux_desc* demux_list;
114 };
115
116 #define SOL_NDRVPROTO NDRVPROTO_NDRV /* Use this socket level */
117 /* NDRV_DMXSPEC 0x01 Obsolete */
118 #define NDRV_DELDMXSPEC 0x02 /* Delete the registered protocol */
119 /* NDRV_DMXSPECCNT 0x03 Obsolete */
120 #define NDRV_SETDMXSPEC 0x04 /* Set the protocol spec */
121
122 #if KERNEL
123 /* Additional Kernel APIs */
124 struct ifnet* ndrv_get_ifp(caddr_t ndrv_pcb);
125 #endif
126
127 #endif /* _NET_NDRV_H */