]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
3e170ce0 | 2 | * Copyright (c) 2000-2015 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
39236c6e | 5 | * |
2d21ac55 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. | |
39236c6e | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
39236c6e | 17 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
39236c6e | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */ | |
29 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
30 | /* | |
31 | * Copyright (c) 1982, 1986, 1993 | |
32 | * The Regents of the University of California. All rights reserved. | |
33 | * | |
34 | * Redistribution and use in source and binary forms, with or without | |
35 | * modification, are permitted provided that the following conditions | |
36 | * are met: | |
37 | * 1. Redistributions of source code must retain the above copyright | |
38 | * notice, this list of conditions and the following disclaimer. | |
39 | * 2. Redistributions in binary form must reproduce the above copyright | |
40 | * notice, this list of conditions and the following disclaimer in the | |
41 | * documentation and/or other materials provided with the distribution. | |
42 | * 3. All advertising materials mentioning features or use of this software | |
43 | * must display the following acknowledgement: | |
44 | * This product includes software developed by the University of | |
45 | * California, Berkeley and its contributors. | |
46 | * 4. Neither the name of the University nor the names of its contributors | |
47 | * may be used to endorse or promote products derived from this software | |
48 | * without specific prior written permission. | |
49 | * | |
50 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
51 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
52 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
53 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
56 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
57 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
58 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
59 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
60 | * SUCH DAMAGE. | |
61 | * | |
62 | * @(#)protosw.h 8.1 (Berkeley) 6/2/93 | |
9bccf70c | 63 | * $FreeBSD: src/sys/sys/protosw.h,v 1.28.2.2 2001/07/03 11:02:01 ume Exp $ |
1c79356b A |
64 | */ |
65 | ||
9bccf70c | 66 | #ifndef _SYS_PROTOSW_H_ |
0a7de745 | 67 | #define _SYS_PROTOSW_H_ |
9bccf70c | 68 | |
91447636 A |
69 | #include <sys/appleapiopts.h> |
70 | #include <sys/cdefs.h> | |
71 | ||
39236c6e | 72 | /* XXX: this will go away */ |
0a7de745 | 73 | #define PR_SLOWHZ 2 /* 2 slow timeouts per second */ |
91447636 | 74 | |
5ba3f43e A |
75 | /* |
76 | * The arguments to the ctlinput routine are | |
77 | * (*protosw[].pr_ctlinput)(cmd, sa, arg); | |
78 | * where cmd is one of the commands below, sa is a pointer to a sockaddr, | |
79 | * and arg is a `void *' argument used within a protocol family. | |
80 | */ | |
0a7de745 A |
81 | #define PRC_IFDOWN 0 /* interface transition */ |
82 | #define PRC_ROUTEDEAD 1 /* select new route if possible ??? */ | |
83 | #define PRC_IFUP 2 /* interface has come back up */ | |
84 | #define PRC_QUENCH2 3 /* DEC congestion bit says slow down */ | |
85 | #define PRC_QUENCH 4 /* some one said to slow down */ | |
86 | #define PRC_MSGSIZE 5 /* message size forced drop */ | |
87 | #define PRC_HOSTDEAD 6 /* host appears to be down */ | |
88 | #define PRC_HOSTUNREACH 7 /* deprecated (use PRC_UNREACH_HOST) */ | |
89 | #define PRC_UNREACH_NET 8 /* no route to network */ | |
90 | #define PRC_UNREACH_HOST 9 /* no route to host */ | |
91 | #define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */ | |
92 | #define PRC_UNREACH_PORT 11 /* bad port # */ | |
5ba3f43e | 93 | /* was PRC_UNREACH_NEEDFRAG 12 (use PRC_MSGSIZE) */ |
0a7de745 A |
94 | #define PRC_UNREACH_SRCFAIL 13 /* source route failed */ |
95 | #define PRC_REDIRECT_NET 14 /* net routing redirect */ | |
96 | #define PRC_REDIRECT_HOST 15 /* host routing redirect */ | |
97 | #define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */ | |
98 | #define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */ | |
99 | #define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */ | |
100 | #define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */ | |
101 | #define PRC_PARAMPROB 20 /* header incorrect */ | |
102 | #define PRC_UNREACH_ADMIN_PROHIB 21 /* packet administrativly prohibited */ | |
5ba3f43e | 103 | |
0a7de745 | 104 | #define PRC_NCMDS 22 |
5ba3f43e | 105 | |
0a7de745 | 106 | #define PRC_IS_REDIRECT(cmd) \ |
5ba3f43e A |
107 | ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST) |
108 | ||
109 | #ifdef BSD_KERNEL_PRIVATE | |
110 | #include <sys/eventhandler.h> | |
111 | #endif | |
112 | ||
39236c6e A |
113 | #ifdef KERNEL_PRIVATE |
114 | #include <sys/socket.h> | |
115 | #include <sys/socketvar.h> | |
116 | #include <sys/queue.h> | |
117 | #include <kern/locks.h> | |
91447636 | 118 | |
9bccf70c A |
119 | /* Forward declare these structures referenced from prototypes below. */ |
120 | struct mbuf; | |
121 | struct proc; | |
122 | struct sockaddr; | |
123 | struct socket; | |
124 | struct sockopt; | |
91447636 | 125 | struct socket_filter; |
3e170ce0 | 126 | struct uio; |
5ba3f43e | 127 | struct ifnet; |
39236c6e A |
128 | #ifdef XNU_KERNEL_PRIVATE |
129 | struct domain_old; | |
130 | #endif /* XNU_KERNEL_PRIVATE */ | |
131 | ||
132 | #pragma pack(4) | |
9bccf70c | 133 | |
39236c6e A |
134 | #ifdef XNU_KERNEL_PRIVATE |
135 | /* | |
136 | * Legacy protocol switch table. | |
137 | * | |
138 | * NOTE: Do not modify this structure, as there are modules outside of xnu | |
139 | * which rely on the size and layout for binary compatibility. This structure | |
140 | * is simply used by the exported net_{add,del}_proto_old, pffindproto_old | |
141 | * routines, and by the domain_old structure. Internally, protocol switch | |
142 | * tables are stored in the private variant of protosw defined down below. | |
143 | */ | |
144 | struct protosw_old { | |
145 | #else | |
146 | struct protosw { | |
147 | #endif /* !XNU_KERNEL_PRIVATE */ | |
0a7de745 A |
148 | short pr_type; /* socket type used for */ |
149 | struct domain *pr_domain; /* domain protocol a member of */ | |
150 | short pr_protocol; /* protocol number */ | |
151 | unsigned int pr_flags; /* see below */ | |
39236c6e A |
152 | /* |
153 | * protocol-protocol hooks | |
154 | */ | |
0a7de745 A |
155 | void (*pr_input) /* input to protocol (from below) */ |
156 | (struct mbuf *, int len); | |
157 | int (*pr_output) /* output to protocol (from above) */ | |
158 | (struct mbuf *m, struct socket *so); | |
159 | void (*pr_ctlinput) /* control input (from below) */ | |
160 | (int, struct sockaddr *, void *, struct ifnet *); | |
161 | int (*pr_ctloutput) /* control output (from above) */ | |
162 | (struct socket *, struct sockopt *); | |
39236c6e A |
163 | /* |
164 | * user-protocol hook | |
165 | */ | |
0a7de745 | 166 | void *pr_ousrreq; |
39236c6e A |
167 | /* |
168 | * utility hooks | |
169 | */ | |
0a7de745 A |
170 | void (*pr_init)(void); /* initialization hook */ |
171 | void (*pr_unused)(void); /* placeholder - fasttimo is removed */ | |
172 | void (*pr_unused2)(void); /* placeholder - slowtimo is removed */ | |
173 | void (*pr_drain)(void); /* flush any excess space possible */ | |
174 | int (*pr_sysctl) /* sysctl for protocol */ | |
175 | (int *, u_int, void *, size_t *, void *, size_t); | |
39236c6e | 176 | #ifdef XNU_KERNEL_PRIVATE |
0a7de745 | 177 | struct pr_usrreqs_old *pr_usrreqs; /* supersedes pr_usrreq() */ |
39236c6e | 178 | #else |
0a7de745 | 179 | struct pr_usrreqs *pr_usrreqs; /* supersedes pr_usrreq() */ |
39236c6e | 180 | #endif /* !XNU_KERNEL_PRIVATE */ |
0a7de745 A |
181 | int (*pr_lock) /* lock function for protocol */ |
182 | (struct socket *so, int refcnt, void *debug); | |
183 | int (*pr_unlock) /* unlock for protocol */ | |
184 | (struct socket *so, int refcnt, void *debug); | |
185 | lck_mtx_t *(*pr_getlock) /* retrieve protocol lock */ | |
186 | (struct socket *so, int flags); | |
39236c6e A |
187 | /* |
188 | * Implant hooks | |
189 | */ | |
190 | TAILQ_HEAD(, socket_filter) pr_filter_head; | |
191 | #ifdef XNU_KERNEL_PRIVATE | |
0a7de745 | 192 | struct protosw_old *pr_next; /* chain for domain */ |
39236c6e | 193 | #else |
0a7de745 | 194 | struct protosw *pr_next; /* chain for domain */ |
39236c6e | 195 | #endif /* !XNU_KERNEL_PRIVATE */ |
0a7de745 | 196 | u_int32_t reserved[1]; /* padding for future use */ |
39236c6e A |
197 | }; |
198 | ||
199 | #pragma pack() | |
200 | ||
201 | #ifdef XNU_KERNEL_PRIVATE | |
1c79356b A |
202 | /* |
203 | * Protocol switch table. | |
204 | * | |
205 | * Each protocol has a handle initializing one of these structures, | |
206 | * which is used for protocol-protocol and system-protocol communication. | |
207 | * | |
208 | * A protocol is called through the pr_init entry before any other. | |
39236c6e A |
209 | * The system will call the pr_drain entry if it is low on space and this |
210 | * should throw away any non-critical data. | |
1c79356b A |
211 | * |
212 | * Protocols pass data between themselves as chains of mbufs using | |
213 | * the pr_input and pr_output hooks. Pr_input passes data up (towards | |
9bccf70c | 214 | * the users) and pr_output passes it down (towards the interfaces); control |
1c79356b A |
215 | * information passes up and down on pr_ctlinput and pr_ctloutput. |
216 | * The protocol is responsible for the space occupied by any the | |
217 | * arguments to these entries and must dispose it. | |
218 | * | |
219 | * The userreq routine interfaces protocols to the system and is | |
220 | * described below. | |
39236c6e A |
221 | * |
222 | * After a protocol is attached, its pr_domain will be set to the domain | |
223 | * which the protocol belongs to, and its pr_protosw will be set to the | |
224 | * address of the protosw instance. The latter is useful for finding | |
225 | * the real/original protosw instance, in the event so_proto is altered | |
226 | * to point to an alternative/derivative protosw. E.g. the list of | |
227 | * socket filters is only applicable on the original protosw instance. | |
228 | * | |
229 | * Internal, private and extendable representation of protosw. | |
1c79356b | 230 | */ |
1c79356b | 231 | struct protosw { |
39236c6e | 232 | TAILQ_ENTRY(protosw) pr_entry; /* chain for domain */ |
0a7de745 A |
233 | struct domain *pr_domain; /* domain protocol a member of */ |
234 | struct protosw *pr_protosw; /* pointer to self */ | |
235 | u_int16_t pr_type; /* socket type used for */ | |
236 | u_int16_t pr_protocol; /* protocol number */ | |
237 | u_int32_t pr_flags; /* see below */ | |
39236c6e A |
238 | /* |
239 | * protocol-protocol hooks | |
240 | */ | |
0a7de745 A |
241 | void (*pr_input) /* input to protocol (from below) */ |
242 | (struct mbuf *, int len); | |
243 | int (*pr_output) /* output to protocol (from above) */ | |
244 | (struct mbuf *m, struct socket *so); | |
245 | void (*pr_ctlinput) /* control input (from below) */ | |
246 | (int, struct sockaddr *, void *, struct ifnet *); | |
247 | int (*pr_ctloutput) /* control output (from above) */ | |
248 | (struct socket *, struct sockopt *); | |
39236c6e A |
249 | /* |
250 | * user-protocol hook | |
251 | */ | |
0a7de745 | 252 | struct pr_usrreqs *pr_usrreqs; /* user request; see list below */ |
39236c6e A |
253 | /* |
254 | * utility hooks | |
255 | */ | |
0a7de745 A |
256 | void (*pr_init) /* initialization hook */ |
257 | (struct protosw *, struct domain *); | |
258 | void (*pr_drain)(void); /* flush any excess space possible */ | |
259 | int (*pr_sysctl) /* sysctl for protocol */ | |
260 | (int *, u_int, void *, size_t *, void *, size_t); | |
261 | int (*pr_lock) /* lock function for protocol */ | |
262 | (struct socket *so, int refcnt, void *debug); | |
263 | int (*pr_unlock) /* unlock for protocol */ | |
264 | (struct socket *so, int refcnt, void *debug); | |
265 | lck_mtx_t *(*pr_getlock) /* retrieve protocol lock */ | |
266 | (struct socket *so, int flags); | |
39236c6e A |
267 | /* |
268 | * misc | |
269 | */ | |
91447636 | 270 | TAILQ_HEAD(, socket_filter) pr_filter_head; |
39236c6e | 271 | struct protosw_old *pr_old; |
1c79356b | 272 | }; |
5ba3f43e A |
273 | |
274 | /* | |
275 | * Values for the flags argument of pr_getlock | |
276 | */ | |
0a7de745 | 277 | #define PR_F_WILLUNLOCK 0x01 /* Will unlock (e.g., msleep) after the pr_getlock call */ |
5ba3f43e | 278 | |
39236c6e | 279 | #endif /* XNU_KERNEL_PRIVATE */ |
1c79356b A |
280 | |
281 | /* | |
282 | * Values for pr_flags. | |
283 | * PR_ADDR requires PR_ATOMIC; | |
284 | * PR_ADDR and PR_CONNREQUIRED are mutually exclusive. | |
9bccf70c A |
285 | * PR_IMPLOPCL means that the protocol allows sendto without prior connect, |
286 | * and the protocol understands the MSG_EOF flag. The first property is | |
287 | * is only relevant if PR_CONNREQUIRED is set (otherwise sendto is allowed | |
288 | * anyhow). | |
1c79356b | 289 | */ |
0a7de745 A |
290 | #define PR_ATOMIC 0x01 /* exchange atomic messages only */ |
291 | #define PR_ADDR 0x02 /* addresses given with messages */ | |
292 | #define PR_CONNREQUIRED 0x04 /* connection required by protocol */ | |
293 | #define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */ | |
294 | #define PR_RIGHTS 0x10 /* passes capabilities */ | |
295 | #define PR_IMPLOPCL 0x20 /* implied open/close */ | |
296 | #define PR_LASTHDR 0x40 /* enforce ipsec policy; last header */ | |
297 | #define PR_PROTOLOCK 0x80 /* protocol takes care of it's own locking */ | |
298 | #define PR_PCBLOCK 0x100 /* protocol supports per pcb locking */ | |
299 | #define PR_DISPOSE 0x200 /* protocol requires late lists disposal */ | |
39236c6e | 300 | #ifdef BSD_KERNEL_PRIVATE |
0a7de745 A |
301 | #define PR_INITIALIZED 0x400 /* protocol has been initialized */ |
302 | #define PR_ATTACHED 0x800 /* protocol is attached to a domain */ | |
303 | #define PR_MULTICONN 0x1000 /* supports multiple connect calls */ | |
304 | #define PR_EVCONNINFO 0x2000 /* protocol generates conninfo event */ | |
305 | #define PR_PRECONN_WRITE 0x4000 /* protocol supports preconnect write */ | |
306 | #define PR_DATA_IDEMPOTENT 0x8000 /* protocol supports idempotent data at connectx-time */ | |
307 | #define PR_OLD 0x10000000 /* added via net_add_proto */ | |
39236c6e A |
308 | |
309 | /* pseudo-public domain flags */ | |
0a7de745 A |
310 | #define PRF_USERFLAGS \ |
311 | (PR_ATOMIC|PR_ADDR|PR_CONNREQUIRED|PR_WANTRCVD|PR_RIGHTS| \ | |
39236c6e A |
312 | PR_IMPLOPCL|PR_LASTHDR|PR_PROTOLOCK|PR_PCBLOCK|PR_DISPOSE) |
313 | #endif /* BSD_KERNEL_PRIVATE */ | |
314 | ||
315 | #ifdef BSD_KERNEL_PRIVATE | |
39236c6e | 316 | #ifdef PRCREQUESTS |
0a7de745 | 317 | char *prcrequests[] = { |
39236c6e A |
318 | "IFDOWN", "ROUTEDEAD", "IFUP", "DEC-BIT-QUENCH2", |
319 | "QUENCH", "MSGSIZE", "HOSTDEAD", "#7", | |
320 | "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH", | |
321 | "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT", | |
322 | "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS", | |
323 | "PARAMPROB", "ADMIN-UNREACH" | |
324 | }; | |
325 | #endif /* PRCREQUESTS */ | |
1c79356b A |
326 | |
327 | /* | |
39236c6e A |
328 | * The arguments to ctloutput are: |
329 | * (*protosw[].pr_ctloutput)(req, so, level, optname, optval, p); | |
330 | * req is one of the actions listed below, so is a (struct socket *), | |
331 | * level is an indication of which protocol layer the option is intended. | |
332 | * optname is a protocol dependent socket option request, | |
333 | * optval is a pointer to a mbuf-chain pointer, for value-return results. | |
334 | * The protocol is responsible for disposal of the mbuf chain *optval | |
335 | * if supplied, | |
336 | * the caller is responsible for any space held by *optval, when returned. | |
1c79356b A |
337 | * A non-zero return from usrreq gives an |
338 | * UNIX error number which should be passed to higher level software. | |
339 | */ | |
0a7de745 A |
340 | #define PRCO_GETOPT 0 |
341 | #define PRCO_SETOPT 1 | |
39236c6e | 342 | |
0a7de745 | 343 | #define PRCO_NCMDS 2 |
39236c6e A |
344 | |
345 | #ifdef PRCOREQUESTS | |
0a7de745 | 346 | char *prcorequests[] = { |
39236c6e A |
347 | "GETOPT", "SETOPT", |
348 | }; | |
349 | #endif /* PRCOREQUESTS */ | |
350 | ||
351 | /* | |
352 | * In earlier BSD network stacks, a single pr_usrreq() function pointer was | |
353 | * invoked with an operation number indicating what operation was desired. | |
354 | * We now provide individual function pointers which protocols can implement, | |
355 | * which offers a number of benefits (such as type checking for arguments). | |
356 | * These older constants are still present in order to support TCP debugging. | |
357 | */ | |
0a7de745 A |
358 | #define PRU_ATTACH 0 /* attach protocol to up */ |
359 | #define PRU_DETACH 1 /* detach protocol from up */ | |
360 | #define PRU_BIND 2 /* bind socket to address */ | |
361 | #define PRU_LISTEN 3 /* listen for connection */ | |
362 | #define PRU_CONNECT 4 /* establish connection to peer */ | |
363 | #define PRU_ACCEPT 5 /* accept connection from peer */ | |
364 | #define PRU_DISCONNECT 6 /* disconnect from peer */ | |
365 | #define PRU_SHUTDOWN 7 /* won't send any more data */ | |
366 | #define PRU_RCVD 8 /* have taken data; more room now */ | |
367 | #define PRU_SEND 9 /* send this data */ | |
368 | #define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */ | |
369 | #define PRU_CONTROL 11 /* control operations on protocol */ | |
370 | #define PRU_SENSE 12 /* return status into m */ | |
371 | #define PRU_RCVOOB 13 /* retrieve out of band data */ | |
372 | #define PRU_SENDOOB 14 /* send out of band data */ | |
373 | #define PRU_SOCKADDR 15 /* fetch socket's address */ | |
374 | #define PRU_PEERADDR 16 /* fetch peer's address */ | |
375 | #define PRU_CONNECT2 17 /* connect two sockets */ | |
1c79356b | 376 | /* begin for protocols internal use */ |
0a7de745 A |
377 | #define PRU_FASTTIMO 18 /* 200ms timeout */ |
378 | #define PRU_SLOWTIMO 19 /* 500ms timeout */ | |
379 | #define PRU_PROTORCV 20 /* receive from below */ | |
380 | #define PRU_PROTOSEND 21 /* send to below */ | |
1c79356b | 381 | /* end for protocol's internal use */ |
0a7de745 A |
382 | #define PRU_SEND_EOF 22 /* send and close */ |
383 | #define PRU_NREQ 22 | |
1c79356b A |
384 | |
385 | #ifdef PRUREQUESTS | |
386 | char *prurequests[] = { | |
0a7de745 A |
387 | "ATTACH", "DETACH", "BIND", "LISTEN", |
388 | "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN", | |
389 | "RCVD", "SEND", "ABORT", "CONTROL", | |
390 | "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR", | |
391 | "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO", | |
392 | "PROTORCV", "PROTOSEND", "SEND_EOF", | |
1c79356b | 393 | }; |
39236c6e A |
394 | #endif /* PRUREQUESTS */ |
395 | #endif /* BSD_KERNEL_PRIVATE */ | |
1c79356b | 396 | |
1c79356b A |
397 | struct stat; |
398 | struct ucred; | |
399 | struct uio; | |
3e170ce0 | 400 | struct recv_msg_elem; |
1c79356b | 401 | |
39236c6e | 402 | #ifdef XNU_KERNEL_PRIVATE |
1c79356b | 403 | /* |
39236c6e A |
404 | * Legacy user-protocol hooks. |
405 | * | |
406 | * NOTE: Do not modify this structure, as there are modules outside of xnu | |
407 | * which rely on the size and layout for binary compatibility. This structure | |
408 | * is simply used by the protosw_old structure. Internally, user-protocol | |
409 | * hooks use the private variant of pr_usrreqs defined down below. | |
1c79356b | 410 | */ |
39236c6e A |
411 | struct pr_usrreqs_old { |
412 | #else | |
1c79356b | 413 | struct pr_usrreqs { |
39236c6e | 414 | #endif /* !XNU_KERNEL_PRIVATE */ |
0a7de745 A |
415 | int (*pru_abort)(struct socket *so); |
416 | int (*pru_accept)(struct socket *so, struct sockaddr **nam); | |
417 | int (*pru_attach)(struct socket *so, int proto, struct proc *p); | |
418 | int (*pru_bind)(struct socket *so, struct sockaddr *nam, | |
419 | struct proc *p); | |
420 | int (*pru_connect)(struct socket *so, struct sockaddr *nam, | |
421 | struct proc *p); | |
422 | int (*pru_connect2)(struct socket *so1, struct socket *so2); | |
423 | int (*pru_control)(struct socket *so, u_long cmd, caddr_t data, | |
424 | struct ifnet *ifp, struct proc *p); | |
425 | int (*pru_detach)(struct socket *so); | |
426 | int (*pru_disconnect)(struct socket *so); | |
427 | int (*pru_listen)(struct socket *so, struct proc *p); | |
428 | int (*pru_peeraddr)(struct socket *so, struct sockaddr **nam); | |
429 | int (*pru_rcvd)(struct socket *so, int flags); | |
430 | int (*pru_rcvoob)(struct socket *so, struct mbuf *m, int flags); | |
431 | int (*pru_send)(struct socket *so, int flags, struct mbuf *m, | |
432 | struct sockaddr *addr, struct mbuf *control, | |
433 | struct proc *p); | |
434 | int (*pru_sense)(struct socket *so, void *sb, int isstat64); | |
435 | int (*pru_shutdown)(struct socket *so); | |
436 | int (*pru_sockaddr)(struct socket *so, struct sockaddr **nam); | |
437 | int (*pru_sosend)(struct socket *so, struct sockaddr *addr, | |
438 | struct uio *uio, struct mbuf *top, struct mbuf *control, | |
439 | int flags); | |
440 | int (*pru_soreceive)(struct socket *so, struct sockaddr **paddr, | |
441 | struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, | |
442 | int *flagsp); | |
443 | int (*pru_sopoll)(struct socket *so, int events, | |
444 | struct ucred *cred, void *); | |
1c79356b A |
445 | }; |
446 | ||
39236c6e | 447 | #ifdef XNU_KERNEL_PRIVATE |
1c79356b | 448 | /* |
39236c6e A |
449 | * If the ordering here looks odd, that's because it's alphabetical. These |
450 | * should eventually be merged back into struct protosw. | |
451 | * | |
452 | * Internal, private and extendable representation of pr_usrreqs. | |
453 | * | |
454 | * NOTE: When adding new ones, also add default callbacks in pru_sanitize(). | |
1c79356b | 455 | */ |
39236c6e | 456 | struct pr_usrreqs { |
0a7de745 A |
457 | uint32_t pru_flags; /* see PRUF flags below */ |
458 | int (*pru_abort)(struct socket *); | |
459 | int (*pru_accept)(struct socket *, struct sockaddr **); | |
460 | int (*pru_attach)(struct socket *, int proto, struct proc *); | |
461 | int (*pru_bind)(struct socket *, struct sockaddr *, struct proc *); | |
462 | int (*pru_connect)(struct socket *, struct sockaddr *, | |
463 | struct proc *); | |
464 | int (*pru_connect2)(struct socket *, struct socket *); | |
465 | int (*pru_connectx)(struct socket *, struct sockaddr *, | |
466 | struct sockaddr *, struct proc *, uint32_t, | |
467 | sae_associd_t, sae_connid_t *, uint32_t, void *, uint32_t, | |
468 | struct uio *, user_ssize_t *); | |
469 | int (*pru_control)(struct socket *, u_long, caddr_t, | |
470 | struct ifnet *, struct proc *); | |
471 | int (*pru_detach)(struct socket *); | |
472 | int (*pru_disconnect)(struct socket *); | |
473 | int (*pru_disconnectx)(struct socket *, | |
474 | sae_associd_t, sae_connid_t); | |
475 | int (*pru_listen)(struct socket *, struct proc *); | |
476 | int (*pru_peeraddr)(struct socket *, struct sockaddr **); | |
477 | int (*pru_rcvd)(struct socket *, int); | |
478 | int (*pru_rcvoob)(struct socket *, struct mbuf *, int); | |
479 | int (*pru_send)(struct socket *, int, struct mbuf *, | |
480 | struct sockaddr *, struct mbuf *, struct proc *); | |
481 | int (*pru_send_list)(struct socket *, int, struct mbuf *, | |
482 | struct sockaddr *, struct mbuf *, struct proc *); | |
483 | #define PRUS_OOB 0x1 | |
484 | #define PRUS_EOF 0x2 | |
485 | #define PRUS_MORETOCOME 0x4 | |
486 | int (*pru_sense)(struct socket *, void *, int); | |
487 | int (*pru_shutdown)(struct socket *); | |
488 | int (*pru_sockaddr)(struct socket *, struct sockaddr **); | |
489 | int (*pru_sopoll)(struct socket *, int, struct ucred *, void *); | |
490 | int (*pru_soreceive)(struct socket *, struct sockaddr **, | |
491 | struct uio *, struct mbuf **, struct mbuf **, int *); | |
492 | int (*pru_soreceive_list)(struct socket *, struct recv_msg_elem *, u_int, | |
493 | int *); | |
494 | int (*pru_sosend)(struct socket *, struct sockaddr *, | |
495 | struct uio *, struct mbuf *, struct mbuf *, int); | |
496 | int (*pru_sosend_list)(struct socket *, struct uio **, u_int, int); | |
497 | int (*pru_socheckopt)(struct socket *, struct sockopt *); | |
498 | int (*pru_preconnect)(struct socket *so); | |
1c79356b | 499 | }; |
1c79356b | 500 | |
39236c6e | 501 | /* Values for pru_flags */ |
0a7de745 | 502 | #define PRUF_OLD 0x10000000 /* added via net_add_proto */ |
1c79356b | 503 | |
5ba3f43e A |
504 | #ifdef BSD_KERNEL_PRIVATE |
505 | /* | |
506 | * For faster access than net_uptime(), bypassing the initialization. | |
507 | */ | |
508 | extern u_int64_t _net_uptime; | |
509 | #endif /* BSD_KERNEL_PRIVATE */ | |
39236c6e | 510 | #endif /* XNU_KERNEL_PRIVATE */ |
91447636 A |
511 | |
512 | __BEGIN_DECLS | |
39236c6e A |
513 | extern int pru_abort_notsupp(struct socket *so); |
514 | extern int pru_accept_notsupp(struct socket *so, struct sockaddr **nam); | |
515 | extern int pru_attach_notsupp(struct socket *so, int proto, struct proc *p); | |
516 | extern int pru_bind_notsupp(struct socket *so, struct sockaddr *nam, | |
517 | struct proc *p); | |
518 | extern int pru_connect_notsupp(struct socket *so, struct sockaddr *nam, | |
519 | struct proc *p); | |
520 | extern int pru_connect2_notsupp(struct socket *so1, struct socket *so2); | |
521 | #ifdef XNU_KERNEL_PRIVATE | |
813fb2f6 A |
522 | extern int pru_connectx_notsupp(struct socket *, struct sockaddr *, |
523 | struct sockaddr *, struct proc *, uint32_t, sae_associd_t, | |
3e170ce0 A |
524 | sae_connid_t *, uint32_t, void *, uint32_t, struct uio *, user_ssize_t *); |
525 | extern int pru_disconnectx_notsupp(struct socket *, sae_associd_t, | |
526 | sae_connid_t); | |
39236c6e | 527 | extern int pru_socheckopt_null(struct socket *, struct sockopt *); |
39236c6e A |
528 | #endif /* XNU_KERNEL_PRIVATE */ |
529 | extern int pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data, | |
530 | struct ifnet *ifp, struct proc *p); | |
531 | extern int pru_detach_notsupp(struct socket *so); | |
532 | extern int pru_disconnect_notsupp(struct socket *so); | |
533 | extern int pru_listen_notsupp(struct socket *so, struct proc *p); | |
534 | extern int pru_peeraddr_notsupp(struct socket *so, struct sockaddr **nam); | |
535 | extern int pru_rcvd_notsupp(struct socket *so, int flags); | |
536 | extern int pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags); | |
537 | extern int pru_send_notsupp(struct socket *so, int flags, struct mbuf *m, | |
538 | struct sockaddr *addr, struct mbuf *control, struct proc *p); | |
fe8ab488 A |
539 | extern int pru_send_list_notsupp(struct socket *so, int flags, struct mbuf *m, |
540 | struct sockaddr *addr, struct mbuf *control, struct proc *p); | |
39236c6e A |
541 | extern int pru_sense_null(struct socket *so, void * sb, int isstat64); |
542 | extern int pru_shutdown_notsupp(struct socket *so); | |
543 | extern int pru_sockaddr_notsupp(struct socket *so, struct sockaddr **nam); | |
544 | extern int pru_sosend_notsupp(struct socket *so, struct sockaddr *addr, | |
0a7de745 | 545 | struct uio *uio, struct mbuf *top, struct mbuf *control, int flags); |
3e170ce0 A |
546 | extern int pru_sosend_list_notsupp(struct socket *so, struct uio **uio, |
547 | u_int, int flags); | |
39236c6e A |
548 | extern int pru_soreceive_notsupp(struct socket *so, |
549 | struct sockaddr **paddr, struct uio *uio, struct mbuf **mp0, | |
550 | struct mbuf **controlp, int *flagsp); | |
3e170ce0 A |
551 | extern int pru_soreceive_list_notsupp(struct socket *, struct recv_msg_elem *, u_int, |
552 | int *); | |
39236c6e A |
553 | extern int pru_sopoll_notsupp(struct socket *so, int events, |
554 | struct ucred *cred, void *); | |
555 | #ifdef XNU_KERNEL_PRIVATE | |
556 | extern void pru_sanitize(struct pr_usrreqs *); | |
557 | extern void domaininit(void); | |
558 | extern void domainfin(void); | |
559 | extern void pfctlinput(int, struct sockaddr *); | |
560 | extern void pfctlinput2(int, struct sockaddr *, void *); | |
561 | extern struct protosw *pffindproto_locked(int, int, int); | |
562 | extern struct protosw *pffindprotonotype(int, int); | |
563 | extern struct protosw *pffindtype(int, int); | |
564 | extern struct protosw_old *pffindproto_old(int, int, int); | |
565 | extern int net_add_proto(struct protosw *, struct domain *, int); | |
566 | extern void net_init_proto(struct protosw *, struct domain *); | |
1c79356b | 567 | extern int net_del_proto(int, int, struct domain *); |
39236c6e A |
568 | extern int net_add_proto_old(struct protosw_old *, struct domain_old *); |
569 | extern int net_del_proto_old(int, int, struct domain_old *); | |
570 | extern void net_update_uptime(void); | |
5ba3f43e | 571 | extern void net_update_uptime_with_time(const struct timeval *); |
6d2010ae | 572 | extern u_int64_t net_uptime(void); |
39236c6e A |
573 | extern void net_uptime2timeval(struct timeval *); |
574 | #else | |
575 | extern int net_add_proto(struct protosw *, struct domain *); | |
576 | extern int net_del_proto(int, int, struct domain *); | |
577 | #endif /* XNU_KERNEL_PRIVATE */ | |
578 | extern struct protosw *pffindproto(int family, int protocol, int type); | |
91447636 | 579 | __END_DECLS |
39236c6e | 580 | #endif /* KERNEL_PRIVATE */ |
0a7de745 | 581 | #endif /* !_SYS_PROTOSW_H_ */ |