]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/kext_net.h
xnu-344.23.tar.gz
[apple/xnu.git] / bsd / net / kext_net.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
de355530
A
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.
1c79356b 11 *
de355530
A
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
de355530
A
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.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/* Copyright (C) 1999 Apple Computer, Inc. */
23/*
24 * Support for network filter kernel extensions
25 * Justin C. Walker, 990319
26 */
27#ifndef NET_KEXT_NET_H
28#define NET_KEXT_NET_H
9bccf70c 29#include <sys/appleapiopts.h>
1c79356b
A
30
31#include <sys/queue.h>
32#include <sys/socketvar.h>
33
34struct mbuf;
35struct socket;
36struct uio;
37struct sockbuf;
38struct sockaddr;
39struct kextcb;
40struct protosw;
41struct sockif;
42struct sockutil;
43struct sockopt;
44
9bccf70c
A
45#ifdef __APPLE_API_UNSTABLE
46
1c79356b
A
47/*
48 * This structure gives access to the functionality of the filter.
49 * The kextcb provides the link from the socket structure.
50 */
51struct NFDescriptor
52{ TAILQ_ENTRY(NFDescriptor) nf_next; /* protosw chain */
53 TAILQ_ENTRY(NFDescriptor) nf_list; /* descriptor list */
54 unsigned int nf_handle; /* Identifier */
55 int nf_flags;
56 /* Dispatch for PF_FILTER control */
57 int (*nf_connect)(); /* Make contact */
58 void (*nf_disconnect)(); /* Break contact */
59 int (*nf_read)(); /* Get data from filter */
60 int (*nf_write)(); /* Send data to filter */
61 int (*nf_get)(); /* Get filter config */
62 int (*nf_set)(); /* Set filter config */
63 /*
64 * Socket function dispatch vectors - copied to kextcb
65 * during socreate()
66 */
67 struct sockif *nf_soif; /* Socket functions */
68 struct sockutil *nf_soutil; /* Sockbuf utility functions */
0b4e3aa0 69 u_long reserved[4]; /* for future use if needed */
1c79356b
A
70};
71
72#define NFD_GLOBAL 0x01
73#define NFD_PROG 0x02
74#define NFD_VISIBLE 0x80000000
75
76#define NFF_BEFORE 0x01
77#define NFF_AFTER 0x02
78
79#ifdef KERNEL
80/* How to register: filter, insert location, target protosw, flags */
81extern int register_sockfilter(struct NFDescriptor *,
82 struct NFDescriptor *,
83 struct protosw *, int);
84/* How to unregister: filter, original protosw, flags */
85extern int unregister_sockfilter(struct NFDescriptor *, struct protosw *, int);
86
9bccf70c 87#ifdef __APPLE_API_PRIVATE
1c79356b
A
88TAILQ_HEAD(nf_list, NFDescriptor);
89
90extern struct nf_list nf_list;
9bccf70c 91#endif /* __APPLE_API_PRIVATE */
1c79356b
A
92#endif
93
94#define NKE_OK 0
95#define NKE_REMOVE -1
96
97/*
98 * Interface structure for inserting an installed socket NKE into an
99 * existing socket.
100 * 'handle' is the NKE to be inserted, 'where' is an insertion point,
101 * and flags dictate the position of the to-be-inserted NKE relative to
102 * the 'where' NKE. If the latter is NULL, the flags indicate "first"
103 * or "last"
104 */
105struct so_nke
106{ unsigned int nke_handle;
107 unsigned int nke_where;
108 int nke_flags; /* NFF_BEFORE, NFF_AFTER: net/kext_net.h */
0b4e3aa0 109 unsigned long reserved[4]; /* for future use */
1c79356b
A
110};
111
112/*
113 * sockif:
114 * Contains socket interface:
115 * dispatch vector abstracting the interface between protocols and
116 * the socket layer.
117 * TODO: add sf_sosense()
118 */
119struct sockif
120{ int (*sf_soabort)(struct socket *, struct kextcb *);
121 int (*sf_soaccept)(struct socket *, struct sockaddr **,
122 struct kextcb *);
123 int (*sf_sobind)(struct socket *, struct sockaddr *, struct kextcb *);
124 int (*sf_soclose)(struct socket *, struct kextcb *);
125 int (*sf_soconnect)(struct socket *, struct sockaddr *,
126 struct kextcb *);
127 int (*sf_soconnect2)(struct socket *, struct socket *,
128 struct kextcb *);
129 int (*sf_socontrol)(struct socket *, struct sockopt *,
130 struct kextcb *);
131 int (*sf_socreate)(struct socket *, struct protosw *, struct kextcb *);
132 int (*sf_sodisconnect)(struct socket *, struct kextcb *);
133 int (*sf_sofree)(struct socket *, struct kextcb *);
134 int (*sf_sogetopt)(struct socket *, int, int, struct mbuf **,
135 struct kextcb *);
136 int (*sf_sohasoutofband)(struct socket *, struct kextcb *);
137 int (*sf_solisten)(struct socket *, struct kextcb *);
138 int (*sf_soreceive)(struct socket *, struct sockaddr **, struct uio **,
139 struct mbuf **, struct mbuf **, int *,
140 struct kextcb *);
141 int (*sf_sorflush)(struct socket *, struct kextcb *);
142 int (*sf_sosend)(struct socket *, struct sockaddr **, struct uio **,
143 struct mbuf **, struct mbuf **, int *,
144 struct kextcb *);
145 int (*sf_sosetopt)(struct socket *, int, int, struct mbuf *,
146 struct kextcb *);
147 int (*sf_soshutdown)(struct socket *, int, struct kextcb *);
148 /* Calls sorwakeup() */
149 int (*sf_socantrcvmore)(struct socket *, struct kextcb *);
150 /* Calls sowwakeup() */
151 int (*sf_socantsendmore)(struct socket *, struct kextcb *);
152 /* Calls soqinsque(), sorwakeup(), sowwakeup() */
153 int (*sf_soisconnected)(struct socket *, struct kextcb *);
154 int (*sf_soisconnecting)(struct socket *, struct kextcb *);
155 /* Calls sowwakeup(), sorwakeup() */
156 int (*sf_soisdisconnected)(struct socket *, struct kextcb *);
157 /* Calls sowwakeup(), sorwakeup() */
158 int (*sf_soisdisconnecting)(struct socket *, struct kextcb *);
159 /* Calls soreserve(), soqinsque(), soqremque(), sorwakeup() */
9bccf70c 160 int (*sf_sonewconn)(struct socket *, int, struct kextcb *);
1c79356b
A
161 int (*sf_soqinsque)(struct socket *, struct socket *, int,
162 struct kextcb *);
163 int (*sf_soqremque)(struct socket *, int, struct kextcb *);
164 int (*sf_soreserve)(struct socket *, u_long, u_long, struct kextcb *);
165 int (*sf_sowakeup)(struct socket *, struct sockbuf *,
166 struct kextcb *);
0b4e3aa0 167 u_long reserved[4];
1c79356b
A
168};
169
170
171/*
172 * sockutil:
173 * Contains the utility functions for socket layer access
174 */
175struct sockutil
176{ /* Sleeps if locked */
177 int (*su_sb_lock)(struct sockbuf *, struct kextcb *);
178 /* Conditionally calls sbappendrecord, Calls sbcompress */
179 int (*su_sbappend)(struct sockbuf *, struct mbuf *, struct kextcb *);
180 /* Calls sbspace(), sballoc() */
181 int (*su_sbappendaddr)(struct sockbuf *, struct sockaddr *,
182 struct mbuf *, struct mbuf *, struct kextcb *);
183 /* Calls sbspace(), sballoc() */
184 int (*su_sbappendcontrol)(struct sockbuf *, struct mbuf *,
185 struct mbuf *, struct kextcb *);
186 /* Calls sballoc(), sbcompress() */
187 int (*su_sbappendrecord)(struct sockbuf *, struct mbuf *,
188 struct kextcb *);
189 /* Calls sballoc() */
190 int (*su_sbcompress)(struct sockbuf *, struct mbuf *, struct mbuf *,
191 struct kextcb *);
192 /* Calls sbfree() */
193 int (*su_sbdrop)(struct sockbuf *, int, struct kextcb *);
194 /* Calls sbfree() */
195 int (*su_sbdroprecord)(struct sockbuf *, struct kextcb *);
196 /* Calls sbdrop() */
197 int (*su_sbflush)(struct sockbuf *, struct kextcb *);
198 /* Calls sballoc(), sbcompress() */
199 int (*su_sbinsertoob)(struct sockbuf *, struct mbuf *,
200 struct kextcb *);
201 /* Calls sbflush() */
202 int (*su_sbrelease)(struct sockbuf *, struct kextcb *);
203 int (*su_sbreserve)(struct sockbuf *, u_long, struct kextcb *);
204 /* Calls tsleep() */
205 int (*su_sbwait)(struct sockbuf *, struct kextcb *);
0b4e3aa0 206 u_long reserved[4];
1c79356b 207};
9bccf70c 208#endif /* __APPLE_API_UNSTABLE */
1c79356b
A
209
210#endif