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