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