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