Line data Source code
1 : /* $OpenBSD: socket.h,v 1.96 2018/04/08 18:57:39 guenther Exp $ */
2 : /* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */
3 :
4 : /*
5 : * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
6 : * The Regents of the University of California. All rights reserved.
7 : *
8 : * Redistribution and use in source and binary forms, with or without
9 : * modification, are permitted provided that the following conditions
10 : * are met:
11 : * 1. Redistributions of source code must retain the above copyright
12 : * notice, this list of conditions and the following disclaimer.
13 : * 2. Redistributions in binary form must reproduce the above copyright
14 : * notice, this list of conditions and the following disclaimer in the
15 : * documentation and/or other materials provided with the distribution.
16 : * 3. Neither the name of the University nor the names of its contributors
17 : * may be used to endorse or promote products derived from this software
18 : * without specific prior written permission.
19 : *
20 : * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 : * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 : * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 : * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 : * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 : * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 : * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 : * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 : * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 : * SUCH DAMAGE.
31 : *
32 : * @(#)socket.h 8.4 (Berkeley) 2/21/94
33 : */
34 :
35 : #ifndef _SYS_SOCKET_H_
36 : #define _SYS_SOCKET_H_
37 :
38 : /* get the definitions for struct iovec, size_t, ssize_t, and <sys/cdefs.h> */
39 : #include <sys/uio.h>
40 :
41 : #if __BSD_VISIBLE
42 : #include <sys/types.h> /* for off_t, uid_t, and gid_t */
43 : #endif
44 :
45 : #ifndef _SOCKLEN_T_DEFINED_
46 : #define _SOCKLEN_T_DEFINED_
47 : typedef __socklen_t socklen_t; /* length type for network syscalls */
48 : #endif
49 :
50 : #ifndef _SA_FAMILY_T_DEFINED_
51 : #define _SA_FAMILY_T_DEFINED_
52 : typedef __sa_family_t sa_family_t; /* sockaddr address family type */
53 : #endif
54 :
55 :
56 : /*
57 : * Definitions related to sockets: types, address families, options.
58 : */
59 :
60 : /*
61 : * Types
62 : */
63 : #define SOCK_STREAM 1 /* stream socket */
64 : #define SOCK_DGRAM 2 /* datagram socket */
65 : #define SOCK_RAW 3 /* raw-protocol interface */
66 : #define SOCK_RDM 4 /* reliably-delivered message */
67 : #define SOCK_SEQPACKET 5 /* sequenced packet stream */
68 : #ifdef _KERNEL
69 : #define SOCK_TYPE_MASK 0x000F /* mask that covers the above */
70 : #endif
71 :
72 : /*
73 : * Socket creation flags
74 : */
75 : #if __BSD_VISIBLE
76 : #define SOCK_CLOEXEC 0x8000 /* set FD_CLOEXEC */
77 : #define SOCK_NONBLOCK 0x4000 /* set O_NONBLOCK */
78 : #ifdef _KERNEL
79 : #define SOCK_NONBLOCK_INHERIT 0x2000 /* inherit O_NONBLOCK from listener */
80 : #endif
81 : #define SOCK_DNS 0x1000 /* set SS_DNS */
82 : #endif /* __BSD_VISIBLE */
83 :
84 : /*
85 : * Option flags per-socket.
86 : */
87 : #define SO_DEBUG 0x0001 /* turn on debugging info recording */
88 : #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
89 : #define SO_REUSEADDR 0x0004 /* allow local address reuse */
90 : #define SO_KEEPALIVE 0x0008 /* keep connections alive */
91 : #define SO_DONTROUTE 0x0010 /* just use interface addresses */
92 : #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
93 : #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
94 : #define SO_LINGER 0x0080 /* linger on close if data present */
95 : #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
96 : #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
97 : #define SO_TIMESTAMP 0x0800 /* timestamp received dgram traffic */
98 : #define SO_BINDANY 0x1000 /* allow bind to any address */
99 : #define SO_ZEROIZE 0x2000 /* zero out all mbufs sent over socket */
100 :
101 : /*
102 : * Additional options, not kept in so_options.
103 : */
104 : #define SO_SNDBUF 0x1001 /* send buffer size */
105 : #define SO_RCVBUF 0x1002 /* receive buffer size */
106 : #define SO_SNDLOWAT 0x1003 /* send low-water mark */
107 : #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
108 : #define SO_SNDTIMEO 0x1005 /* send timeout */
109 : #define SO_RCVTIMEO 0x1006 /* receive timeout */
110 : #define SO_ERROR 0x1007 /* get error status and clear */
111 : #define SO_TYPE 0x1008 /* get socket type */
112 : #define SO_NETPROC 0x1020 /* multiplex; network processing */
113 : #define SO_RTABLE 0x1021 /* routing table to be used */
114 : #define SO_PEERCRED 0x1022 /* get connect-time credentials */
115 : #define SO_SPLICE 0x1023 /* splice data to other socket */
116 :
117 : /*
118 : * Structure used for manipulating linger option.
119 : */
120 : struct linger {
121 : int l_onoff; /* option on/off */
122 : int l_linger; /* linger time */
123 : };
124 :
125 : #if __BSD_VISIBLE
126 :
127 : #ifndef _TIMEVAL_DECLARED
128 : #define _TIMEVAL_DECLARED
129 : struct timeval {
130 : time_t tv_sec; /* seconds */
131 : suseconds_t tv_usec; /* and microseconds */
132 : };
133 : #endif
134 :
135 : /*
136 : * Structure used for manipulating splice option.
137 : */
138 : struct splice {
139 : int sp_fd; /* drain socket file descriptor */
140 : off_t sp_max; /* if set, maximum bytes to splice */
141 : struct timeval sp_idle; /* idle timeout */
142 : };
143 :
144 : /*
145 : * Maximum number of alternate routing tables
146 : */
147 : #define RT_TABLEID_MAX 255
148 : #define RT_TABLEID_BITS 8
149 : #define RT_TABLEID_MASK 0xff
150 :
151 : #endif /* __BSD_VISIBLE */
152 :
153 : /*
154 : * Level number for (get/set)sockopt() to apply to socket itself.
155 : */
156 : #define SOL_SOCKET 0xffff /* options for socket level */
157 :
158 : /*
159 : * Address families.
160 : */
161 : #define AF_UNSPEC 0 /* unspecified */
162 : #define AF_UNIX 1 /* local to host */
163 : #define AF_LOCAL AF_UNIX /* draft POSIX compatibility */
164 : #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
165 : #define AF_IMPLINK 3 /* arpanet imp addresses */
166 : #define AF_PUP 4 /* pup protocols: e.g. BSP */
167 : #define AF_CHAOS 5 /* mit CHAOS protocols */
168 : #define AF_NS 6 /* XEROX NS protocols */
169 : #define AF_ISO 7 /* ISO protocols */
170 : #define AF_OSI AF_ISO
171 : #define AF_ECMA 8 /* european computer manufacturers */
172 : #define AF_DATAKIT 9 /* datakit protocols */
173 : #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
174 : #define AF_SNA 11 /* IBM SNA */
175 : #define AF_DECnet 12 /* DECnet */
176 : #define AF_DLI 13 /* DEC Direct data link interface */
177 : #define AF_LAT 14 /* LAT */
178 : #define AF_HYLINK 15 /* NSC Hyperchannel */
179 : #define AF_APPLETALK 16 /* Apple Talk */
180 : #define AF_ROUTE 17 /* Internal Routing Protocol */
181 : #define AF_LINK 18 /* Link layer interface */
182 : #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
183 : #define AF_COIP 20 /* connection-oriented IP, aka ST II */
184 : #define AF_CNT 21 /* Computer Network Technology */
185 : #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
186 : #define AF_IPX 23 /* Novell Internet Protocol */
187 : #define AF_INET6 24 /* IPv6 */
188 : #define pseudo_AF_PIP 25 /* Help Identify PIP packets */
189 : #define AF_ISDN 26 /* Integrated Services Digital Network*/
190 : #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
191 : #define AF_NATM 27 /* native ATM access */
192 : #define AF_ENCAP 28
193 : #define AF_SIP 29 /* Simple Internet Protocol */
194 : #define AF_KEY 30
195 : #define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers
196 : in interface output routine */
197 : #define AF_BLUETOOTH 32 /* Bluetooth */
198 : #define AF_MPLS 33 /* MPLS */
199 : #define pseudo_AF_PFLOW 34 /* pflow */
200 : #define pseudo_AF_PIPEX 35 /* PIPEX */
201 : #define AF_MAX 36
202 :
203 : /*
204 : * Structure used by kernel to store most
205 : * addresses.
206 : */
207 : struct sockaddr {
208 : __uint8_t sa_len; /* total length */
209 : sa_family_t sa_family; /* address family */
210 : char sa_data[14]; /* actually longer; address value */
211 : };
212 :
213 : /*
214 : * Sockaddr type which can hold any sockaddr type available
215 : * in the system.
216 : *
217 : * Note: __ss_{len,family} is defined in RFC2553. During RFC2553 discussion
218 : * the field name went back and forth between ss_len and __ss_len,
219 : * and RFC2553 specifies it to be __ss_len. openbsd picked ss_len.
220 : * For maximum portability, userland programmer would need to
221 : * (1) make the code never touch ss_len portion (cast it into sockaddr and
222 : * touch sa_len), or (2) add "-Dss_len=__ss_len" into CFLAGS to unify all
223 : * occurrences (including header file) to __ss_len.
224 : */
225 : struct sockaddr_storage {
226 : __uint8_t ss_len; /* total length */
227 : sa_family_t ss_family; /* address family */
228 : unsigned char __ss_pad1[6]; /* align to quad */
229 : __uint64_t __ss_pad2; /* force alignment for stupid compilers */
230 : unsigned char __ss_pad3[240]; /* pad to a total of 256 bytes */
231 : };
232 :
233 : #ifdef _KERNEL
234 : /*
235 : * Structure used by kernel to pass protocol
236 : * information in raw sockets.
237 : */
238 : struct sockproto {
239 : unsigned short sp_family; /* address family */
240 : unsigned short sp_protocol; /* protocol */
241 : };
242 : #endif /* _KERNEL */
243 :
244 : /*
245 : * Protocol families, same as address families for now.
246 : */
247 : #define PF_UNSPEC AF_UNSPEC
248 : #define PF_LOCAL AF_LOCAL
249 : #define PF_UNIX AF_UNIX
250 : #define PF_INET AF_INET
251 : #define PF_IMPLINK AF_IMPLINK
252 : #define PF_PUP AF_PUP
253 : #define PF_CHAOS AF_CHAOS
254 : #define PF_NS AF_NS
255 : #define PF_ISO AF_ISO
256 : #define PF_OSI AF_ISO
257 : #define PF_ECMA AF_ECMA
258 : #define PF_DATAKIT AF_DATAKIT
259 : #define PF_CCITT AF_CCITT
260 : #define PF_SNA AF_SNA
261 : #define PF_DECnet AF_DECnet
262 : #define PF_DLI AF_DLI
263 : #define PF_LAT AF_LAT
264 : #define PF_HYLINK AF_HYLINK
265 : #define PF_APPLETALK AF_APPLETALK
266 : #define PF_ROUTE AF_ROUTE
267 : #define PF_LINK AF_LINK
268 : #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
269 : #define PF_COIP AF_COIP
270 : #define PF_CNT AF_CNT
271 : #define PF_IPX AF_IPX /* same format as AF_NS */
272 : #define PF_INET6 AF_INET6
273 : #define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
274 : #define PF_PIP pseudo_AF_PIP
275 : #define PF_ISDN AF_ISDN
276 : #define PF_NATM AF_NATM
277 : #define PF_ENCAP AF_ENCAP
278 : #define PF_SIP AF_SIP
279 : #define PF_KEY AF_KEY
280 : #define PF_BPF pseudo_AF_HDRCMPLT
281 : #define PF_BLUETOOTH AF_BLUETOOTH
282 : #define PF_MPLS AF_MPLS
283 : #define PF_PFLOW pseudo_AF_PFLOW
284 : #define PF_PIPEX pseudo_AF_PIPEX
285 : #define PF_MAX AF_MAX
286 :
287 : /*
288 : * These are the valid values for the "how" field used by shutdown(2).
289 : */
290 : #define SHUT_RD 0
291 : #define SHUT_WR 1
292 : #define SHUT_RDWR 2
293 :
294 : #if __BSD_VISIBLE
295 : #define SA_LEN(x) ((x)->sa_len)
296 :
297 : /* Read using getsockopt() with SOL_SOCKET, SO_PEERCRED */
298 : struct sockpeercred {
299 : uid_t uid; /* effective user id */
300 : gid_t gid; /* effective group id */
301 : pid_t pid;
302 : };
303 :
304 : /*
305 : * Definitions for network related sysctl, CTL_NET.
306 : *
307 : * Second level is protocol family.
308 : * Third level is protocol number.
309 : *
310 : * Further levels are defined by the individual families below.
311 : */
312 : #define NET_MAXID AF_MAX
313 :
314 : #define CTL_NET_NAMES { \
315 : { 0, 0 }, \
316 : { "unix", CTLTYPE_NODE }, \
317 : { "inet", CTLTYPE_NODE }, \
318 : { "implink", CTLTYPE_NODE }, \
319 : { "pup", CTLTYPE_NODE }, \
320 : { "chaos", CTLTYPE_NODE }, \
321 : { "xerox_ns", CTLTYPE_NODE }, \
322 : { "iso", CTLTYPE_NODE }, \
323 : { "emca", CTLTYPE_NODE }, \
324 : { "datakit", CTLTYPE_NODE }, \
325 : { "ccitt", CTLTYPE_NODE }, \
326 : { "ibm_sna", CTLTYPE_NODE }, \
327 : { "decnet", CTLTYPE_NODE }, \
328 : { "dec_dli", CTLTYPE_NODE }, \
329 : { "lat", CTLTYPE_NODE }, \
330 : { "hylink", CTLTYPE_NODE }, \
331 : { "appletalk", CTLTYPE_NODE }, \
332 : { "route", CTLTYPE_NODE }, \
333 : { "link_layer", CTLTYPE_NODE }, \
334 : { "xtp", CTLTYPE_NODE }, \
335 : { "coip", CTLTYPE_NODE }, \
336 : { "cnt", CTLTYPE_NODE }, \
337 : { "rtip", CTLTYPE_NODE }, \
338 : { "ipx", CTLTYPE_NODE }, \
339 : { "inet6", CTLTYPE_NODE }, \
340 : { "pip", CTLTYPE_NODE }, \
341 : { "isdn", CTLTYPE_NODE }, \
342 : { "natm", CTLTYPE_NODE }, \
343 : { "encap", CTLTYPE_NODE }, \
344 : { "sip", CTLTYPE_NODE }, \
345 : { "key", CTLTYPE_NODE }, \
346 : { "bpf", CTLTYPE_NODE }, \
347 : { "bluetooth", CTLTYPE_NODE }, \
348 : { "mpls", CTLTYPE_NODE }, \
349 : { "pflow", CTLTYPE_NODE }, \
350 : { "pipex", CTLTYPE_NODE }, \
351 : }
352 :
353 : /*
354 : * PF_ROUTE - Routing table
355 : *
356 : * Four additional levels are defined:
357 : * Fourth: address family, 0 is wildcard
358 : * Fifth: type of info, defined below
359 : * Sixth: flag(s) to mask with for NET_RT_FLAGS
360 : * Seventh: routing table to use (facultative, defaults to 0)
361 : * NET_RT_TABLE has the table id as sixth element.
362 : */
363 : #define NET_RT_DUMP 1 /* dump; may limit to a.f. */
364 : #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
365 : #define NET_RT_IFLIST 3 /* survey interface list */
366 : #define NET_RT_STATS 4 /* routing table statistics */
367 : #define NET_RT_TABLE 5
368 : #define NET_RT_IFNAMES 6
369 : #define NET_RT_MAXID 7
370 :
371 : #define CTL_NET_RT_NAMES { \
372 : { 0, 0 }, \
373 : { "dump", CTLTYPE_STRUCT }, \
374 : { "flags", CTLTYPE_STRUCT }, \
375 : { "iflist", CTLTYPE_STRUCT }, \
376 : { "stats", CTLTYPE_STRUCT }, \
377 : { "table", CTLTYPE_STRUCT }, \
378 : { "ifnames", CTLTYPE_STRUCT }, \
379 : }
380 :
381 : /*
382 : * PF_KEY - Key Management
383 : */
384 : #define NET_KEY_SADB_DUMP 1 /* return SADB */
385 : #define NET_KEY_SPD_DUMP 2 /* return SPD */
386 : #define NET_KEY_MAXID 3
387 :
388 : #define CTL_NET_KEY_NAMES { \
389 : { 0, 0 }, \
390 : { "sadb_dump", CTLTYPE_STRUCT }, \
391 : { "spd_dump", CTLTYPE_STRUCT }, \
392 : }
393 :
394 : /*
395 : * PF_BPF not really a family, but connected under CTL_NET
396 : */
397 : #define NET_BPF_BUFSIZE 1 /* default buffer size */
398 : #define NET_BPF_MAXBUFSIZE 2 /* maximum buffer size */
399 : #define NET_BPF_MAXID 3
400 :
401 : #define CTL_NET_BPF_NAMES { \
402 : { 0, 0 }, \
403 : { "bufsize", CTLTYPE_INT }, \
404 : { "maxbufsize", CTLTYPE_INT }, \
405 : }
406 :
407 : /*
408 : * PF_PFLOW not really a family, but connected under CTL_NET
409 : */
410 : #define NET_PFLOW_STATS 1 /* statistics */
411 : #define NET_PFLOW_MAXID 2
412 :
413 : #define CTL_NET_PFLOW_NAMES { \
414 : { 0, 0 }, \
415 : { "stats", CTLTYPE_STRUCT }, \
416 : }
417 : #endif /* __BSD_VISIBLE */
418 :
419 : /*
420 : * Maximum queue length specifiable by listen(2).
421 : */
422 : #define SOMAXCONN 128
423 :
424 : /*
425 : * Message header for recvmsg and sendmsg calls.
426 : * Used value-result for recvmsg, value only for sendmsg.
427 : */
428 : struct msghdr {
429 : void *msg_name; /* optional address */
430 : socklen_t msg_namelen; /* size of address */
431 : struct iovec *msg_iov; /* scatter/gather array */
432 : unsigned int msg_iovlen; /* # elements in msg_iov */
433 : void *msg_control; /* ancillary data, see below */
434 : socklen_t msg_controllen; /* ancillary data buffer len */
435 : int msg_flags; /* flags on received message */
436 : };
437 :
438 : #define MSG_OOB 0x1 /* process out-of-band data */
439 : #define MSG_PEEK 0x2 /* peek at incoming message */
440 : #define MSG_DONTROUTE 0x4 /* send without using routing tables */
441 : #define MSG_EOR 0x8 /* data completes record */
442 : #define MSG_TRUNC 0x10 /* data discarded before delivery */
443 : #define MSG_CTRUNC 0x20 /* control data lost before delivery */
444 : #define MSG_WAITALL 0x40 /* wait for full request or error */
445 : #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
446 : #define MSG_BCAST 0x100 /* this message rec'd as broadcast */
447 : #define MSG_MCAST 0x200 /* this message rec'd as multicast */
448 : #define MSG_NOSIGNAL 0x400 /* do not send SIGPIPE */
449 : #define MSG_CMSG_CLOEXEC 0x800 /* set FD_CLOEXEC on received fds */
450 :
451 : /*
452 : * Header for ancillary data objects in msg_control buffer.
453 : * Used for additional information with/about a datagram
454 : * not expressible by flags. The format is a sequence
455 : * of message elements headed by cmsghdr structures.
456 : */
457 : struct cmsghdr {
458 : socklen_t cmsg_len; /* data byte count, including hdr */
459 : int cmsg_level; /* originating protocol */
460 : int cmsg_type; /* protocol-specific type */
461 : /* followed by u_char cmsg_data[]; */
462 : };
463 :
464 : /* given pointer to struct cmsghdr, return pointer to data */
465 : #define CMSG_DATA(cmsg) \
466 : ((unsigned char *)(cmsg) + _ALIGN(sizeof(struct cmsghdr)))
467 :
468 : /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
469 : #define CMSG_NXTHDR(mhdr, cmsg) \
470 : (((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \
471 : _ALIGN(sizeof(struct cmsghdr)) > \
472 : ((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen) ? \
473 : (struct cmsghdr *)NULL : \
474 : (struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len)))
475 :
476 : /*
477 : * RFC 2292 requires to check msg_controllen, in case that the kernel returns
478 : * an empty list for some reasons.
479 : */
480 : #define CMSG_FIRSTHDR(mhdr) \
481 : ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
482 : (struct cmsghdr *)(mhdr)->msg_control : \
483 : (struct cmsghdr *)NULL)
484 :
485 : /* Round len up to next alignment boundary */
486 : #ifdef _KERNEL
487 : #define CMSG_ALIGN(n) _ALIGN(n)
488 : #endif
489 :
490 : /* Length of the contents of a control message of length len */
491 : #define CMSG_LEN(len) (_ALIGN(sizeof(struct cmsghdr)) + (len))
492 :
493 : /* Length of the space taken up by a padded control message of length len */
494 : #define CMSG_SPACE(len) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(len))
495 :
496 : /* "Socket"-level control message types: */
497 : #define SCM_RIGHTS 0x01 /* access rights (array of int) */
498 : #define SCM_TIMESTAMP 0x04 /* timestamp (struct timeval) */
499 :
500 : #ifndef _KERNEL
501 :
502 : __BEGIN_DECLS
503 : int accept(int, struct sockaddr *, socklen_t *);
504 : int bind(int, const struct sockaddr *, socklen_t);
505 : int connect(int, const struct sockaddr *, socklen_t);
506 : int getpeername(int, struct sockaddr *, socklen_t *);
507 : int getsockname(int, struct sockaddr *, socklen_t *);
508 : int getsockopt(int, int, int, void *, socklen_t *);
509 : int listen(int, int);
510 : ssize_t recv(int, void *, size_t, int);
511 : ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
512 : ssize_t recvmsg(int, struct msghdr *, int);
513 : ssize_t send(int, const void *, size_t, int);
514 : ssize_t sendto(int, const void *,
515 : size_t, int, const struct sockaddr *, socklen_t);
516 : ssize_t sendmsg(int, const struct msghdr *, int);
517 : int setsockopt(int, int, int, const void *, socklen_t);
518 : int shutdown(int, int);
519 : int sockatmark(int);
520 : int socket(int, int, int);
521 : int socketpair(int, int, int, int *);
522 :
523 : #if __BSD_VISIBLE
524 : int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
525 : #endif
526 :
527 : #if __BSD_VISIBLE
528 : int getpeereid(int, uid_t *, gid_t *);
529 : int getrtable(void);
530 : int setrtable(int);
531 : #endif /* __BSD_VISIBLE */
532 :
533 : __END_DECLS
534 :
535 : #else
536 :
537 : void pfctlinput(int, struct sockaddr *);
538 :
539 : static inline struct sockaddr *
540 0 : sstosa(struct sockaddr_storage *ss)
541 : {
542 0 : return ((struct sockaddr *)(ss));
543 : }
544 :
545 : #endif /* !_KERNEL */
546 :
547 : #endif /* !_SYS_SOCKET_H_ */
|