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