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