]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/ndrv.h
xnu-201.14.tar.gz
[apple/xnu.git] / bsd / net / ndrv.h
CommitLineData
1c79356b
A
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 */
7b1edb79 27#include <net/dlil.h>
1c79356b
A
28
29#ifndef _NET_NDRV_H
30#define _NET_NDRV_H
31
7b1edb79 32
1c79356b 33struct sockaddr_ndrv
7b1edb79
A
34{
35 unsigned char snd_len;
1c79356b
A
36 unsigned char snd_family;
37 unsigned char snd_name[IFNAMSIZ]; /* from if.h */
38};
39
40/*
7b1edb79 41 * Support for user-mode protocol handlers
1c79356b 42 */
1c79356b 43
7b1edb79
A
44#define NDRV_DEMUXTYPE_ETHERTYPE DLIL_DESC_ETYPE2
45#define NDRV_DEMUXTYPE_SAP DLIL_DESC_SAP
46#define NDRV_DEMUXTYPE_SNAP DLIL_DESC_SNAP
1c79356b 47
7b1edb79 48#define NDRVPROTO_NDRV 0
1c79356b
A
49
50/*
7b1edb79
A
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;
1c79356b 81 */
7b1edb79
A
82struct 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
1c79356b 96
7b1edb79
A
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 */
108struct 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;
1c79356b
A
114};
115
7b1edb79
A
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 */
1c79356b
A
121
122#if KERNEL
7b1edb79
A
123/* Additional Kernel APIs */
124struct ifnet* ndrv_get_ifp(caddr_t ndrv_pcb);
1c79356b 125#endif
7b1edb79 126
1c79356b 127#endif /* _NET_NDRV_H */