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