]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
39236c6e | 2 | * Copyright (c) 2000-2013 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_ |
39236c6e | 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 */ |
91447636 | 73 | #define PR_SLOWHZ 2 /* 2 slow timeouts per second */ |
91447636 | 74 | |
39236c6e A |
75 | #ifdef KERNEL_PRIVATE |
76 | #include <sys/socket.h> | |
77 | #include <sys/socketvar.h> | |
78 | #include <sys/queue.h> | |
79 | #include <kern/locks.h> | |
91447636 | 80 | |
9bccf70c A |
81 | /* Forward declare these structures referenced from prototypes below. */ |
82 | struct mbuf; | |
83 | struct proc; | |
84 | struct sockaddr; | |
85 | struct socket; | |
86 | struct sockopt; | |
91447636 | 87 | struct socket_filter; |
39236c6e A |
88 | #ifdef XNU_KERNEL_PRIVATE |
89 | struct domain_old; | |
90 | #endif /* XNU_KERNEL_PRIVATE */ | |
91 | ||
92 | #pragma pack(4) | |
9bccf70c | 93 | |
39236c6e A |
94 | #ifdef XNU_KERNEL_PRIVATE |
95 | /* | |
96 | * Legacy protocol switch table. | |
97 | * | |
98 | * NOTE: Do not modify this structure, as there are modules outside of xnu | |
99 | * which rely on the size and layout for binary compatibility. This structure | |
100 | * is simply used by the exported net_{add,del}_proto_old, pffindproto_old | |
101 | * routines, and by the domain_old structure. Internally, protocol switch | |
102 | * tables are stored in the private variant of protosw defined down below. | |
103 | */ | |
104 | struct protosw_old { | |
105 | #else | |
106 | struct protosw { | |
107 | #endif /* !XNU_KERNEL_PRIVATE */ | |
108 | short pr_type; /* socket type used for */ | |
109 | struct domain *pr_domain; /* domain protocol a member of */ | |
110 | short pr_protocol; /* protocol number */ | |
111 | unsigned int pr_flags; /* see below */ | |
112 | /* | |
113 | * protocol-protocol hooks | |
114 | */ | |
115 | void (*pr_input) /* input to protocol (from below) */ | |
116 | (struct mbuf *, int len); | |
117 | int (*pr_output) /* output to protocol (from above) */ | |
118 | (struct mbuf *m, struct socket *so); | |
119 | void (*pr_ctlinput) /* control input (from below) */ | |
120 | (int, struct sockaddr *, void *); | |
121 | int (*pr_ctloutput) /* control output (from above) */ | |
122 | (struct socket *, struct sockopt *); | |
123 | /* | |
124 | * user-protocol hook | |
125 | */ | |
126 | void *pr_ousrreq; | |
127 | /* | |
128 | * utility hooks | |
129 | */ | |
130 | void (*pr_init)(void); /* initialization hook */ | |
131 | void (*pr_unused)(void); /* placeholder - fasttimo is removed */ | |
132 | void (*pr_unused2)(void); /* placeholder - slowtimo is removed */ | |
133 | void (*pr_drain)(void); /* flush any excess space possible */ | |
134 | int (*pr_sysctl) /* sysctl for protocol */ | |
135 | (int *, u_int, void *, size_t *, void *, size_t); | |
136 | #ifdef XNU_KERNEL_PRIVATE | |
137 | struct pr_usrreqs_old *pr_usrreqs; /* supersedes pr_usrreq() */ | |
138 | #else | |
139 | struct pr_usrreqs *pr_usrreqs; /* supersedes pr_usrreq() */ | |
140 | #endif /* !XNU_KERNEL_PRIVATE */ | |
141 | int (*pr_lock) /* lock function for protocol */ | |
142 | (struct socket *so, int locktype, void *debug); | |
143 | int (*pr_unlock) /* unlock for protocol */ | |
144 | (struct socket *so, int locktype, void *debug); | |
145 | lck_mtx_t *(*pr_getlock) /* retrieve protocol lock */ | |
146 | (struct socket *so, int locktype); | |
147 | /* | |
148 | * Implant hooks | |
149 | */ | |
150 | TAILQ_HEAD(, socket_filter) pr_filter_head; | |
151 | #ifdef XNU_KERNEL_PRIVATE | |
152 | struct protosw_old *pr_next; /* chain for domain */ | |
153 | #else | |
154 | struct protosw *pr_next; /* chain for domain */ | |
155 | #endif /* !XNU_KERNEL_PRIVATE */ | |
156 | u_int32_t reserved[1]; /* padding for future use */ | |
157 | }; | |
158 | ||
159 | #pragma pack() | |
160 | ||
161 | #ifdef XNU_KERNEL_PRIVATE | |
1c79356b A |
162 | /* |
163 | * Protocol switch table. | |
164 | * | |
165 | * Each protocol has a handle initializing one of these structures, | |
166 | * which is used for protocol-protocol and system-protocol communication. | |
167 | * | |
168 | * A protocol is called through the pr_init entry before any other. | |
39236c6e A |
169 | * The system will call the pr_drain entry if it is low on space and this |
170 | * should throw away any non-critical data. | |
1c79356b A |
171 | * |
172 | * Protocols pass data between themselves as chains of mbufs using | |
173 | * the pr_input and pr_output hooks. Pr_input passes data up (towards | |
9bccf70c | 174 | * the users) and pr_output passes it down (towards the interfaces); control |
1c79356b A |
175 | * information passes up and down on pr_ctlinput and pr_ctloutput. |
176 | * The protocol is responsible for the space occupied by any the | |
177 | * arguments to these entries and must dispose it. | |
178 | * | |
179 | * The userreq routine interfaces protocols to the system and is | |
180 | * described below. | |
39236c6e A |
181 | * |
182 | * After a protocol is attached, its pr_domain will be set to the domain | |
183 | * which the protocol belongs to, and its pr_protosw will be set to the | |
184 | * address of the protosw instance. The latter is useful for finding | |
185 | * the real/original protosw instance, in the event so_proto is altered | |
186 | * to point to an alternative/derivative protosw. E.g. the list of | |
187 | * socket filters is only applicable on the original protosw instance. | |
188 | * | |
189 | * Internal, private and extendable representation of protosw. | |
1c79356b | 190 | */ |
1c79356b | 191 | struct protosw { |
39236c6e | 192 | TAILQ_ENTRY(protosw) pr_entry; /* chain for domain */ |
1c79356b | 193 | struct domain *pr_domain; /* domain protocol a member of */ |
39236c6e A |
194 | struct protosw *pr_protosw; /* pointer to self */ |
195 | u_int16_t pr_type; /* socket type used for */ | |
196 | u_int16_t pr_protocol; /* protocol number */ | |
197 | u_int32_t pr_flags; /* see below */ | |
198 | /* | |
199 | * protocol-protocol hooks | |
200 | */ | |
201 | void (*pr_input) /* input to protocol (from below) */ | |
202 | (struct mbuf *, int len); | |
203 | int (*pr_output) /* output to protocol (from above) */ | |
204 | (struct mbuf *m, struct socket *so); | |
205 | void (*pr_ctlinput) /* control input (from below) */ | |
206 | (int, struct sockaddr *, void *); | |
207 | int (*pr_ctloutput) /* control output (from above) */ | |
208 | (struct socket *, struct sockopt *); | |
209 | /* | |
210 | * user-protocol hook | |
211 | */ | |
212 | struct pr_usrreqs *pr_usrreqs; /* user request; see list below */ | |
213 | /* | |
214 | * utility hooks | |
215 | */ | |
216 | void (*pr_init) /* initialization hook */ | |
217 | (struct protosw *, struct domain *); | |
218 | void (*pr_drain)(void); /* flush any excess space possible */ | |
219 | int (*pr_sysctl) /* sysctl for protocol */ | |
220 | (int *, u_int, void *, size_t *, void *, size_t); | |
221 | int (*pr_lock) /* lock function for protocol */ | |
222 | (struct socket *so, int locktype, void *debug); | |
223 | int (*pr_unlock) /* unlock for protocol */ | |
224 | (struct socket *so, int locktype, void *debug); | |
225 | lck_mtx_t *(*pr_getlock) /* retrieve protocol lock */ | |
226 | (struct socket *so, int locktype); | |
227 | /* | |
228 | * misc | |
229 | */ | |
91447636 | 230 | TAILQ_HEAD(, socket_filter) pr_filter_head; |
39236c6e | 231 | struct protosw_old *pr_old; |
1c79356b | 232 | }; |
39236c6e | 233 | #endif /* XNU_KERNEL_PRIVATE */ |
1c79356b A |
234 | |
235 | /* | |
236 | * Values for pr_flags. | |
237 | * PR_ADDR requires PR_ATOMIC; | |
238 | * PR_ADDR and PR_CONNREQUIRED are mutually exclusive. | |
9bccf70c A |
239 | * PR_IMPLOPCL means that the protocol allows sendto without prior connect, |
240 | * and the protocol understands the MSG_EOF flag. The first property is | |
241 | * is only relevant if PR_CONNREQUIRED is set (otherwise sendto is allowed | |
242 | * anyhow). | |
1c79356b | 243 | */ |
39236c6e A |
244 | #define PR_ATOMIC 0x01 /* exchange atomic messages only */ |
245 | #define PR_ADDR 0x02 /* addresses given with messages */ | |
246 | #define PR_CONNREQUIRED 0x04 /* connection required by protocol */ | |
247 | #define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */ | |
248 | #define PR_RIGHTS 0x10 /* passes capabilities */ | |
249 | #define PR_IMPLOPCL 0x20 /* implied open/close */ | |
250 | #define PR_LASTHDR 0x40 /* enforce ipsec policy; last header */ | |
251 | #define PR_PROTOLOCK 0x80 /* protocol takes care of it's own locking */ | |
252 | #define PR_PCBLOCK 0x100 /* protocol supports per pcb locking */ | |
253 | #define PR_DISPOSE 0x200 /* protocol requires late lists disposal */ | |
254 | #ifdef BSD_KERNEL_PRIVATE | |
255 | #define PR_INITIALIZED 0x400 /* protocol has been initialized */ | |
256 | #define PR_ATTACHED 0x800 /* protocol is attached to a domain */ | |
257 | #define PR_MULTICONN 0x1000 /* supports multiple connect calls */ | |
258 | #define PR_EVCONNINFO 0x2000 /* protocol generates conninfo event */ | |
259 | #define PR_OLD 0x10000000 /* added via net_add_proto */ | |
260 | ||
261 | /* pseudo-public domain flags */ | |
262 | #define PRF_USERFLAGS \ | |
263 | (PR_ATOMIC|PR_ADDR|PR_CONNREQUIRED|PR_WANTRCVD|PR_RIGHTS| \ | |
264 | PR_IMPLOPCL|PR_LASTHDR|PR_PROTOLOCK|PR_PCBLOCK|PR_DISPOSE) | |
265 | #endif /* BSD_KERNEL_PRIVATE */ | |
266 | ||
267 | #ifdef BSD_KERNEL_PRIVATE | |
268 | /* | |
269 | * The arguments to the ctlinput routine are | |
270 | * (*protosw[].pr_ctlinput)(cmd, sa, arg); | |
271 | * where cmd is one of the commands below, sa is a pointer to a sockaddr, | |
272 | * and arg is a `void *' argument used within a protocol family. | |
273 | */ | |
274 | #define PRC_IFDOWN 0 /* interface transition */ | |
275 | #define PRC_ROUTEDEAD 1 /* select new route if possible ??? */ | |
276 | #define PRC_IFUP 2 /* interface has come back up */ | |
277 | #define PRC_QUENCH2 3 /* DEC congestion bit says slow down */ | |
278 | #define PRC_QUENCH 4 /* some one said to slow down */ | |
279 | #define PRC_MSGSIZE 5 /* message size forced drop */ | |
280 | #define PRC_HOSTDEAD 6 /* host appears to be down */ | |
281 | #define PRC_HOSTUNREACH 7 /* deprecated (use PRC_UNREACH_HOST) */ | |
282 | #define PRC_UNREACH_NET 8 /* no route to network */ | |
283 | #define PRC_UNREACH_HOST 9 /* no route to host */ | |
284 | #define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */ | |
285 | #define PRC_UNREACH_PORT 11 /* bad port # */ | |
286 | /* was PRC_UNREACH_NEEDFRAG 12 (use PRC_MSGSIZE) */ | |
287 | #define PRC_UNREACH_SRCFAIL 13 /* source route failed */ | |
288 | #define PRC_REDIRECT_NET 14 /* net routing redirect */ | |
289 | #define PRC_REDIRECT_HOST 15 /* host routing redirect */ | |
290 | #define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */ | |
291 | #define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */ | |
292 | #define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */ | |
293 | #define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */ | |
294 | #define PRC_PARAMPROB 20 /* header incorrect */ | |
295 | #define PRC_UNREACH_ADMIN_PROHIB 21 /* packet administrativly prohibited */ | |
296 | ||
297 | #define PRC_NCMDS 22 | |
298 | ||
299 | #define PRC_IS_REDIRECT(cmd) \ | |
300 | ((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST) | |
301 | ||
302 | #ifdef PRCREQUESTS | |
303 | char *prcrequests[] = { | |
304 | "IFDOWN", "ROUTEDEAD", "IFUP", "DEC-BIT-QUENCH2", | |
305 | "QUENCH", "MSGSIZE", "HOSTDEAD", "#7", | |
306 | "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH", | |
307 | "#12", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT", | |
308 | "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS", | |
309 | "PARAMPROB", "ADMIN-UNREACH" | |
310 | }; | |
311 | #endif /* PRCREQUESTS */ | |
1c79356b A |
312 | |
313 | /* | |
39236c6e A |
314 | * The arguments to ctloutput are: |
315 | * (*protosw[].pr_ctloutput)(req, so, level, optname, optval, p); | |
316 | * req is one of the actions listed below, so is a (struct socket *), | |
317 | * level is an indication of which protocol layer the option is intended. | |
318 | * optname is a protocol dependent socket option request, | |
319 | * optval is a pointer to a mbuf-chain pointer, for value-return results. | |
320 | * The protocol is responsible for disposal of the mbuf chain *optval | |
321 | * if supplied, | |
322 | * the caller is responsible for any space held by *optval, when returned. | |
1c79356b A |
323 | * A non-zero return from usrreq gives an |
324 | * UNIX error number which should be passed to higher level software. | |
325 | */ | |
39236c6e A |
326 | #define PRCO_GETOPT 0 |
327 | #define PRCO_SETOPT 1 | |
328 | ||
329 | #define PRCO_NCMDS 2 | |
330 | ||
331 | #ifdef PRCOREQUESTS | |
332 | char *prcorequests[] = { | |
333 | "GETOPT", "SETOPT", | |
334 | }; | |
335 | #endif /* PRCOREQUESTS */ | |
336 | ||
337 | /* | |
338 | * In earlier BSD network stacks, a single pr_usrreq() function pointer was | |
339 | * invoked with an operation number indicating what operation was desired. | |
340 | * We now provide individual function pointers which protocols can implement, | |
341 | * which offers a number of benefits (such as type checking for arguments). | |
342 | * These older constants are still present in order to support TCP debugging. | |
343 | */ | |
1c79356b A |
344 | #define PRU_ATTACH 0 /* attach protocol to up */ |
345 | #define PRU_DETACH 1 /* detach protocol from up */ | |
346 | #define PRU_BIND 2 /* bind socket to address */ | |
347 | #define PRU_LISTEN 3 /* listen for connection */ | |
348 | #define PRU_CONNECT 4 /* establish connection to peer */ | |
349 | #define PRU_ACCEPT 5 /* accept connection from peer */ | |
350 | #define PRU_DISCONNECT 6 /* disconnect from peer */ | |
351 | #define PRU_SHUTDOWN 7 /* won't send any more data */ | |
352 | #define PRU_RCVD 8 /* have taken data; more room now */ | |
353 | #define PRU_SEND 9 /* send this data */ | |
354 | #define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */ | |
355 | #define PRU_CONTROL 11 /* control operations on protocol */ | |
356 | #define PRU_SENSE 12 /* return status into m */ | |
357 | #define PRU_RCVOOB 13 /* retrieve out of band data */ | |
358 | #define PRU_SENDOOB 14 /* send out of band data */ | |
359 | #define PRU_SOCKADDR 15 /* fetch socket's address */ | |
360 | #define PRU_PEERADDR 16 /* fetch peer's address */ | |
361 | #define PRU_CONNECT2 17 /* connect two sockets */ | |
362 | /* begin for protocols internal use */ | |
363 | #define PRU_FASTTIMO 18 /* 200ms timeout */ | |
364 | #define PRU_SLOWTIMO 19 /* 500ms timeout */ | |
365 | #define PRU_PROTORCV 20 /* receive from below */ | |
366 | #define PRU_PROTOSEND 21 /* send to below */ | |
367 | /* end for protocol's internal use */ | |
39236c6e A |
368 | #define PRU_SEND_EOF 22 /* send and close */ |
369 | #define PRU_NREQ 22 | |
1c79356b A |
370 | |
371 | #ifdef PRUREQUESTS | |
372 | char *prurequests[] = { | |
373 | "ATTACH", "DETACH", "BIND", "LISTEN", | |
374 | "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN", | |
375 | "RCVD", "SEND", "ABORT", "CONTROL", | |
376 | "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR", | |
377 | "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO", | |
39236c6e | 378 | "PROTORCV", "PROTOSEND", "SEND_EOF", |
1c79356b | 379 | }; |
39236c6e A |
380 | #endif /* PRUREQUESTS */ |
381 | #endif /* BSD_KERNEL_PRIVATE */ | |
1c79356b A |
382 | |
383 | struct ifnet; | |
384 | struct stat; | |
385 | struct ucred; | |
386 | struct uio; | |
387 | ||
39236c6e | 388 | #ifdef XNU_KERNEL_PRIVATE |
1c79356b | 389 | /* |
39236c6e A |
390 | * Legacy user-protocol hooks. |
391 | * | |
392 | * NOTE: Do not modify this structure, as there are modules outside of xnu | |
393 | * which rely on the size and layout for binary compatibility. This structure | |
394 | * is simply used by the protosw_old structure. Internally, user-protocol | |
395 | * hooks use the private variant of pr_usrreqs defined down below. | |
1c79356b | 396 | */ |
39236c6e A |
397 | struct pr_usrreqs_old { |
398 | #else | |
1c79356b | 399 | struct pr_usrreqs { |
39236c6e | 400 | #endif /* !XNU_KERNEL_PRIVATE */ |
91447636 A |
401 | int (*pru_abort)(struct socket *so); |
402 | int (*pru_accept)(struct socket *so, struct sockaddr **nam); | |
403 | int (*pru_attach)(struct socket *so, int proto, struct proc *p); | |
404 | int (*pru_bind)(struct socket *so, struct sockaddr *nam, | |
39236c6e | 405 | struct proc *p); |
91447636 | 406 | int (*pru_connect)(struct socket *so, struct sockaddr *nam, |
39236c6e | 407 | struct proc *p); |
91447636 A |
408 | int (*pru_connect2)(struct socket *so1, struct socket *so2); |
409 | int (*pru_control)(struct socket *so, u_long cmd, caddr_t data, | |
39236c6e | 410 | struct ifnet *ifp, struct proc *p); |
91447636 A |
411 | int (*pru_detach)(struct socket *so); |
412 | int (*pru_disconnect)(struct socket *so); | |
413 | int (*pru_listen)(struct socket *so, struct proc *p); | |
414 | int (*pru_peeraddr)(struct socket *so, struct sockaddr **nam); | |
415 | int (*pru_rcvd)(struct socket *so, int flags); | |
416 | int (*pru_rcvoob)(struct socket *so, struct mbuf *m, int flags); | |
39236c6e A |
417 | int (*pru_send)(struct socket *so, int flags, struct mbuf *m, |
418 | struct sockaddr *addr, struct mbuf *control, | |
419 | struct proc *p); | |
2d21ac55 | 420 | int (*pru_sense)(struct socket *so, void *sb, int isstat64); |
91447636 A |
421 | int (*pru_shutdown)(struct socket *so); |
422 | int (*pru_sockaddr)(struct socket *so, struct sockaddr **nam); | |
91447636 | 423 | int (*pru_sosend)(struct socket *so, struct sockaddr *addr, |
39236c6e A |
424 | struct uio *uio, struct mbuf *top, struct mbuf *control, |
425 | int flags); | |
426 | int (*pru_soreceive)(struct socket *so, struct sockaddr **paddr, | |
427 | struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, | |
428 | int *flagsp); | |
429 | int (*pru_sopoll)(struct socket *so, int events, | |
430 | struct ucred *cred, void *); | |
1c79356b A |
431 | }; |
432 | ||
39236c6e | 433 | #ifdef XNU_KERNEL_PRIVATE |
1c79356b | 434 | /* |
39236c6e A |
435 | * If the ordering here looks odd, that's because it's alphabetical. These |
436 | * should eventually be merged back into struct protosw. | |
437 | * | |
438 | * Internal, private and extendable representation of pr_usrreqs. | |
439 | * | |
440 | * NOTE: When adding new ones, also add default callbacks in pru_sanitize(). | |
1c79356b | 441 | */ |
39236c6e A |
442 | struct pr_usrreqs { |
443 | uint32_t pru_flags; /* see PRUF flags below */ | |
444 | int (*pru_abort)(struct socket *); | |
445 | int (*pru_accept)(struct socket *, struct sockaddr **); | |
446 | int (*pru_attach)(struct socket *, int proto, struct proc *); | |
447 | int (*pru_bind)(struct socket *, struct sockaddr *, struct proc *); | |
448 | int (*pru_connect)(struct socket *, struct sockaddr *, | |
449 | struct proc *); | |
450 | int (*pru_connect2)(struct socket *, struct socket *); | |
451 | int (*pru_connectx)(struct socket *, struct sockaddr_list **, | |
452 | struct sockaddr_list **, struct proc *, uint32_t, | |
453 | associd_t, connid_t *, uint32_t, void *, uint32_t); | |
454 | int (*pru_control)(struct socket *, u_long, caddr_t, | |
455 | struct ifnet *, struct proc *); | |
456 | int (*pru_detach)(struct socket *); | |
457 | int (*pru_disconnect)(struct socket *); | |
458 | int (*pru_disconnectx)(struct socket *, associd_t, connid_t); | |
459 | int (*pru_listen)(struct socket *, struct proc *); | |
460 | int (*pru_peeloff)(struct socket *, associd_t, struct socket **); | |
461 | int (*pru_peeraddr)(struct socket *, struct sockaddr **); | |
462 | int (*pru_rcvd)(struct socket *, int); | |
463 | int (*pru_rcvoob)(struct socket *, struct mbuf *, int); | |
464 | int (*pru_send)(struct socket *, int, struct mbuf *, | |
465 | struct sockaddr *, struct mbuf *, struct proc *); | |
466 | #define PRUS_OOB 0x1 | |
467 | #define PRUS_EOF 0x2 | |
468 | #define PRUS_MORETOCOME 0x4 | |
469 | int (*pru_sense)(struct socket *, void *, int); | |
470 | int (*pru_shutdown)(struct socket *); | |
471 | int (*pru_sockaddr)(struct socket *, struct sockaddr **); | |
472 | int (*pru_sopoll)(struct socket *, int, struct ucred *, void *); | |
473 | int (*pru_soreceive)(struct socket *, struct sockaddr **, | |
474 | struct uio *, struct mbuf **, struct mbuf **, int *); | |
475 | int (*pru_sosend)(struct socket *, struct sockaddr *, | |
476 | struct uio *, struct mbuf *, struct mbuf *, int); | |
477 | int (*pru_socheckopt)(struct socket *, struct sockopt *); | |
1c79356b | 478 | }; |
1c79356b | 479 | |
39236c6e A |
480 | /* Values for pru_flags */ |
481 | #define PRUF_OLD 0x10000000 /* added via net_add_proto */ | |
1c79356b | 482 | |
39236c6e | 483 | #endif /* XNU_KERNEL_PRIVATE */ |
91447636 A |
484 | |
485 | __BEGIN_DECLS | |
39236c6e A |
486 | extern int pru_abort_notsupp(struct socket *so); |
487 | extern int pru_accept_notsupp(struct socket *so, struct sockaddr **nam); | |
488 | extern int pru_attach_notsupp(struct socket *so, int proto, struct proc *p); | |
489 | extern int pru_bind_notsupp(struct socket *so, struct sockaddr *nam, | |
490 | struct proc *p); | |
491 | extern int pru_connect_notsupp(struct socket *so, struct sockaddr *nam, | |
492 | struct proc *p); | |
493 | extern int pru_connect2_notsupp(struct socket *so1, struct socket *so2); | |
494 | #ifdef XNU_KERNEL_PRIVATE | |
495 | extern int pru_connectx_notsupp(struct socket *, struct sockaddr_list **, | |
496 | struct sockaddr_list **, struct proc *, uint32_t, associd_t, connid_t *, | |
497 | uint32_t, void *, uint32_t); | |
498 | extern int pru_disconnectx_notsupp(struct socket *, associd_t, connid_t); | |
499 | extern int pru_socheckopt_null(struct socket *, struct sockopt *); | |
500 | extern int pru_peeloff_notsupp(struct socket *, associd_t, struct socket **); | |
501 | #endif /* XNU_KERNEL_PRIVATE */ | |
502 | extern int pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data, | |
503 | struct ifnet *ifp, struct proc *p); | |
504 | extern int pru_detach_notsupp(struct socket *so); | |
505 | extern int pru_disconnect_notsupp(struct socket *so); | |
506 | extern int pru_listen_notsupp(struct socket *so, struct proc *p); | |
507 | extern int pru_peeraddr_notsupp(struct socket *so, struct sockaddr **nam); | |
508 | extern int pru_rcvd_notsupp(struct socket *so, int flags); | |
509 | extern int pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags); | |
510 | extern int pru_send_notsupp(struct socket *so, int flags, struct mbuf *m, | |
511 | struct sockaddr *addr, struct mbuf *control, struct proc *p); | |
512 | extern int pru_sense_null(struct socket *so, void * sb, int isstat64); | |
513 | extern int pru_shutdown_notsupp(struct socket *so); | |
514 | extern int pru_sockaddr_notsupp(struct socket *so, struct sockaddr **nam); | |
515 | extern int pru_sosend_notsupp(struct socket *so, struct sockaddr *addr, | |
516 | struct uio *uio, struct mbuf *top, struct mbuf *control, int flags); | |
517 | extern int pru_soreceive_notsupp(struct socket *so, | |
518 | struct sockaddr **paddr, struct uio *uio, struct mbuf **mp0, | |
519 | struct mbuf **controlp, int *flagsp); | |
520 | extern int pru_sopoll_notsupp(struct socket *so, int events, | |
521 | struct ucred *cred, void *); | |
522 | #ifdef XNU_KERNEL_PRIVATE | |
523 | extern void pru_sanitize(struct pr_usrreqs *); | |
524 | extern void domaininit(void); | |
525 | extern void domainfin(void); | |
526 | extern void pfctlinput(int, struct sockaddr *); | |
527 | extern void pfctlinput2(int, struct sockaddr *, void *); | |
528 | extern struct protosw *pffindproto_locked(int, int, int); | |
529 | extern struct protosw *pffindprotonotype(int, int); | |
530 | extern struct protosw *pffindtype(int, int); | |
531 | extern struct protosw_old *pffindproto_old(int, int, int); | |
532 | extern int net_add_proto(struct protosw *, struct domain *, int); | |
533 | extern void net_init_proto(struct protosw *, struct domain *); | |
1c79356b | 534 | extern int net_del_proto(int, int, struct domain *); |
39236c6e A |
535 | extern int net_add_proto_old(struct protosw_old *, struct domain_old *); |
536 | extern int net_del_proto_old(int, int, struct domain_old *); | |
537 | extern void net_update_uptime(void); | |
538 | extern void net_update_uptime_secs(uint64_t secs); | |
6d2010ae | 539 | extern u_int64_t net_uptime(void); |
39236c6e A |
540 | extern void net_uptime2timeval(struct timeval *); |
541 | #else | |
542 | extern int net_add_proto(struct protosw *, struct domain *); | |
543 | extern int net_del_proto(int, int, struct domain *); | |
544 | #endif /* XNU_KERNEL_PRIVATE */ | |
545 | extern struct protosw *pffindproto(int family, int protocol, int type); | |
91447636 | 546 | __END_DECLS |
39236c6e | 547 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 548 | #endif /* !_SYS_PROTOSW_H_ */ |