socket.h 17 KB

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