PageRenderTime 51ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/bsd/sys/sys/socket.h

https://gitlab.com/jforge/osv
C Header | 587 lines | 407 code | 49 blank | 131 comment | 1 complexity | 1768299a4a48a5ae79c7cbed9a132547 MD5 | raw file
Possible License(s): BSD-3-Clause, 0BSD, MPL-2.0-no-copyleft-exception
  1. /*-
  2. * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
  3. * The Regents of the University of California. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 4. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * @(#)socket.h 8.4 (Berkeley) 2/21/94
  30. * $FreeBSD$
  31. */
  32. #ifndef _SYS_SOCKET_H_
  33. #define _SYS_SOCKET_H_
  34. #define __NEED___pid_t
  35. #define __NEED___gid_t
  36. #define __NEED___off_t
  37. #define __NEED_gid_t
  38. #define __NEED_pid_t
  39. #define __NEED_off_t
  40. #define __NEED_uid_t
  41. #define __NEED_socklen_t
  42. #define __NEED_ssize_t
  43. #define __NEED_uint32_t
  44. #include <bits/alltypes.h>
  45. #include <osv/uio.h>
  46. #include <sys/cdefs.h>
  47. #include <machine/_align.h>
  48. /*
  49. * Definitions related to sockets: types, address families, options.
  50. */
  51. /*
  52. * Types
  53. */
  54. #define SOCK_STREAM 1 /* stream socket */
  55. #define SOCK_DGRAM 2 /* datagram socket */
  56. #define SOCK_RAW 3 /* raw-protocol interface */
  57. #if __BSD_VISIBLE
  58. #define SOCK_RDM 4 /* reliably-delivered message */
  59. #endif
  60. #define SOCK_SEQPACKET 5 /* sequenced packet stream */
  61. /* accept4 flags */
  62. #define SOCK_CLOEXEC 02000000
  63. #define SOCK_NONBLOCK 00004000
  64. /*
  65. * Option flags per-socket.
  66. */
  67. #define SO_DEBUG 0x0001 /* turn on debugging info recording */
  68. #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
  69. #define SO_REUSEADDR 0x0004 /* allow local address reuse */
  70. #define SO_KEEPALIVE 0x0008 /* keep connections alive */
  71. #define SO_DONTROUTE 0x0010 /* just use interface addresses */
  72. #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
  73. #if __BSD_VISIBLE
  74. #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
  75. #endif
  76. #define SO_LINGER 0x0080 /* linger on close if data present */
  77. #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
  78. #if __BSD_VISIBLE
  79. #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
  80. #define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */
  81. #define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */
  82. #define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */
  83. #define SO_BINTIME 0x2000 /* timestamp received dgram traffic */
  84. #endif
  85. #define SO_NO_OFFLOAD 0x4000 /* socket cannot be offloaded */
  86. #define SO_NO_DDP 0x8000 /* disable direct data placement */
  87. /*
  88. * Additional options, not kept in so_options.
  89. */
  90. #define SO_SNDBUF 0x1001 /* send buffer size */
  91. #define SO_RCVBUF 0x1002 /* receive buffer size */
  92. #define SO_SNDLOWAT 0x1003 /* send low-water mark */
  93. #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
  94. #define SO_SNDTIMEO 0x1005 /* send timeout */
  95. #define SO_RCVTIMEO 0x1006 /* receive timeout */
  96. #define SO_ERROR 0x1007 /* get error status and clear */
  97. #define SO_TYPE 0x1008 /* get socket type */
  98. #if __BSD_VISIBLE
  99. #define SO_LABEL 0x1009 /* socket's MAC label */
  100. #define SO_PEERLABEL 0x1010 /* socket's peer's MAC label */
  101. #define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */
  102. #define SO_LISTENQLEN 0x1012 /* socket's complete queue length */
  103. #define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */
  104. #define SO_SETFIB 0x1014 /* use this FIB to route */
  105. #define SO_USER_COOKIE 0x1015 /* user cookie (dummynet etc.) */
  106. #define SO_PROTOCOL 0x1016 /* get socket protocol (Linux name) */
  107. #define SO_PROTOTYPE SO_PROTOCOL /* alias for SO_PROTOCOL (SunOS name) */
  108. #endif
  109. #if __BSD_VISIBLE
  110. struct accept_filter_arg {
  111. char af_name[16];
  112. char af_arg[256-16];
  113. };
  114. #endif
  115. /*
  116. * Address families.
  117. */
  118. #define AF_UNSPEC 0 /* unspecified */
  119. #if __BSD_VISIBLE
  120. #define AF_LOCAL AF_UNIX /* local to host (pipes, portals) */
  121. #endif
  122. #define AF_UNIX 1 /* standardized name for AF_LOCAL */
  123. #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
  124. #if __BSD_VISIBLE
  125. #define AF_IMPLINK 3 /* arpanet imp addresses */
  126. #define AF_PUP 4 /* pup protocols: e.g. BSP */
  127. #define AF_CHAOS 5 /* mit CHAOS protocols */
  128. #define AF_NETBIOS 6 /* SMB protocols */
  129. #define AF_ISO 7 /* ISO protocols */
  130. #define AF_OSI AF_ISO
  131. #define AF_ECMA 8 /* European computer manufacturers */
  132. #define AF_DATAKIT 9 /* datakit protocols */
  133. #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
  134. #define AF_SNA 11 /* IBM SNA */
  135. #define AF_DECnet 12 /* DECnet */
  136. #define AF_DLI 13 /* DEC Direct data link interface */
  137. #define AF_LAT 14 /* LAT */
  138. #define AF_HYLINK 15 /* NSC Hyperchannel */
  139. #define AF_APPLETALK 16 /* Apple Talk */
  140. #define AF_ROUTE 17 /* Internal Routing Protocol */
  141. #define AF_LINK 18 /* Link layer interface */
  142. #define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
  143. #define AF_COIP 20 /* connection-oriented IP, aka ST II */
  144. #define AF_CNT 21 /* Computer Network Technology */
  145. #define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
  146. #define AF_IPX 23 /* Novell Internet Protocol */
  147. #define AF_SIP 24 /* Simple Internet Protocol */
  148. #define pseudo_AF_PIP 25 /* Help Identify PIP packets */
  149. #define AF_ISDN 26 /* Integrated Services Digital Network*/
  150. #define AF_E164 AF_ISDN /* CCITT E.164 recommendation */
  151. #define pseudo_AF_KEY 27 /* Internal key-management function */
  152. #endif
  153. #define AF_INET6 28 /* IPv6 */
  154. #if __BSD_VISIBLE
  155. #define AF_NATM 29 /* native ATM access */
  156. #define AF_ATM 30 /* ATM */
  157. #define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers
  158. * in interface output routine
  159. */
  160. #define AF_NETGRAPH 32 /* Netgraph sockets */
  161. #define AF_SLOW 33 /* 802.3ad slow protocol */
  162. #define AF_SCLUSTER 34 /* Sitara cluster protocol */
  163. #define AF_ARP 35
  164. #define AF_BLUETOOTH 36 /* Bluetooth sockets */
  165. #define AF_IEEE80211 37 /* IEEE 802.11 protocol */
  166. #define AF_MAX 38
  167. /*
  168. * When allocating a new AF_ constant, please only allocate
  169. * even numbered constants for FreeBSD until 134 as odd numbered AF_
  170. * constants 39-133 are now reserved for vendors.
  171. */
  172. #define AF_VENDOR00 39
  173. #define AF_VENDOR01 41
  174. #define AF_VENDOR02 43
  175. #define AF_VENDOR03 45
  176. #define AF_VENDOR04 47
  177. #define AF_VENDOR05 49
  178. #define AF_VENDOR06 51
  179. #define AF_VENDOR07 53
  180. #define AF_VENDOR08 55
  181. #define AF_VENDOR09 57
  182. #define AF_VENDOR10 59
  183. #define AF_VENDOR11 61
  184. #define AF_VENDOR12 63
  185. #define AF_VENDOR13 65
  186. #define AF_VENDOR14 67
  187. #define AF_VENDOR15 69
  188. #define AF_VENDOR16 71
  189. #define AF_VENDOR17 73
  190. #define AF_VENDOR18 75
  191. #define AF_VENDOR19 77
  192. #define AF_VENDOR20 79
  193. #define AF_VENDOR21 81
  194. #define AF_VENDOR22 83
  195. #define AF_VENDOR23 85
  196. #define AF_VENDOR24 87
  197. #define AF_VENDOR25 89
  198. #define AF_VENDOR26 91
  199. #define AF_VENDOR27 93
  200. #define AF_VENDOR28 95
  201. #define AF_VENDOR29 97
  202. #define AF_VENDOR30 99
  203. #define AF_VENDOR31 101
  204. #define AF_VENDOR32 103
  205. #define AF_VENDOR33 105
  206. #define AF_VENDOR34 107
  207. #define AF_VENDOR35 109
  208. #define AF_VENDOR36 111
  209. #define AF_VENDOR37 113
  210. #define AF_VENDOR38 115
  211. #define AF_VENDOR39 117
  212. #define AF_VENDOR40 119
  213. #define AF_VENDOR41 121
  214. #define AF_VENDOR42 123
  215. #define AF_VENDOR43 125
  216. #define AF_VENDOR44 127
  217. #define AF_VENDOR45 129
  218. #define AF_VENDOR46 131
  219. #define AF_VENDOR47 133
  220. #endif
  221. /*
  222. * Structure used by kernel to store most
  223. * addresses.
  224. */
  225. struct bsd_sockaddr {
  226. unsigned char sa_len; /* total length */
  227. bsd_sa_family_t sa_family; /* address family */
  228. char sa_data[14]; /* actually longer; address value */
  229. };
  230. #if __BSD_VISIBLE
  231. #define SOCK_MAXADDRLEN 255 /* longest possible addresses */
  232. /*
  233. * Structure used by kernel to pass protocol
  234. * information in raw sockets.
  235. */
  236. struct sockproto {
  237. unsigned short sp_family; /* address family */
  238. unsigned short sp_protocol; /* protocol */
  239. };
  240. #endif
  241. #include <bsd/sys/sys/_sockaddr_storage.h>
  242. #if __BSD_VISIBLE
  243. /*
  244. * Protocol families, same as address families for now.
  245. */
  246. #define PF_UNSPEC AF_UNSPEC
  247. #define PF_LOCAL AF_LOCAL
  248. #define PF_UNIX PF_LOCAL /* backward compatibility */
  249. #define PF_INET AF_INET
  250. #define PF_IMPLINK AF_IMPLINK
  251. #define PF_PUP AF_PUP
  252. #define PF_CHAOS AF_CHAOS
  253. #define PF_NETBIOS AF_NETBIOS
  254. #define PF_ISO AF_ISO
  255. #define PF_OSI AF_ISO
  256. #define PF_ECMA AF_ECMA
  257. #define PF_DATAKIT AF_DATAKIT
  258. #define PF_CCITT AF_CCITT
  259. #define PF_SNA AF_SNA
  260. #define PF_DECnet AF_DECnet
  261. #define PF_DLI AF_DLI
  262. #define PF_LAT AF_LAT
  263. #define PF_HYLINK AF_HYLINK
  264. #define PF_APPLETALK AF_APPLETALK
  265. #define PF_ROUTE AF_ROUTE
  266. #define PF_LINK AF_LINK
  267. #define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
  268. #define PF_COIP AF_COIP
  269. #define PF_CNT AF_CNT
  270. #define PF_SIP AF_SIP
  271. #define PF_IPX AF_IPX
  272. #define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */
  273. #define PF_PIP pseudo_AF_PIP
  274. #define PF_ISDN AF_ISDN
  275. #define PF_KEY pseudo_AF_KEY
  276. #define PF_INET6 AF_INET6
  277. #define PF_NATM AF_NATM
  278. #define PF_ATM AF_ATM
  279. #define PF_NETGRAPH AF_NETGRAPH
  280. #define PF_SLOW AF_SLOW
  281. #define PF_SCLUSTER AF_SCLUSTER
  282. #define PF_ARP AF_ARP
  283. #define PF_BLUETOOTH AF_BLUETOOTH
  284. #define PF_MAX AF_MAX
  285. /*
  286. * Definitions for network related sysctl, CTL_NET.
  287. *
  288. * Second level is protocol family.
  289. * Third level is protocol number.
  290. *
  291. * Further levels are defined by the individual families below.
  292. */
  293. #define NET_MAXID AF_MAX
  294. #define CTL_NET_NAMES { \
  295. { 0, 0 }, \
  296. { "unix", CTLTYPE_NODE }, \
  297. { "inet", CTLTYPE_NODE }, \
  298. { "implink", CTLTYPE_NODE }, \
  299. { "pup", CTLTYPE_NODE }, \
  300. { "chaos", CTLTYPE_NODE }, \
  301. { "xerox_ns", CTLTYPE_NODE }, \
  302. { "iso", CTLTYPE_NODE }, \
  303. { "emca", CTLTYPE_NODE }, \
  304. { "datakit", CTLTYPE_NODE }, \
  305. { "ccitt", CTLTYPE_NODE }, \
  306. { "ibm_sna", CTLTYPE_NODE }, \
  307. { "decnet", CTLTYPE_NODE }, \
  308. { "dec_dli", CTLTYPE_NODE }, \
  309. { "lat", CTLTYPE_NODE }, \
  310. { "hylink", CTLTYPE_NODE }, \
  311. { "appletalk", CTLTYPE_NODE }, \
  312. { "route", CTLTYPE_NODE }, \
  313. { "link_layer", CTLTYPE_NODE }, \
  314. { "xtp", CTLTYPE_NODE }, \
  315. { "coip", CTLTYPE_NODE }, \
  316. { "cnt", CTLTYPE_NODE }, \
  317. { "rtip", CTLTYPE_NODE }, \
  318. { "ipx", CTLTYPE_NODE }, \
  319. { "sip", CTLTYPE_NODE }, \
  320. { "pip", CTLTYPE_NODE }, \
  321. { "isdn", CTLTYPE_NODE }, \
  322. { "key", CTLTYPE_NODE }, \
  323. { "inet6", CTLTYPE_NODE }, \
  324. { "natm", CTLTYPE_NODE }, \
  325. { "atm", CTLTYPE_NODE }, \
  326. { "hdrcomplete", CTLTYPE_NODE }, \
  327. { "netgraph", CTLTYPE_NODE }, \
  328. { "snp", CTLTYPE_NODE }, \
  329. { "scp", CTLTYPE_NODE }, \
  330. }
  331. /*
  332. * PF_ROUTE - Routing table
  333. *
  334. * Three additional levels are defined:
  335. * Fourth: address family, 0 is wildcard
  336. * Fifth: type of info, defined below
  337. * Sixth: flag(s) to mask with for NET_RT_FLAGS
  338. */
  339. #define NET_RT_DUMP 1 /* dump; may limit to a.f. */
  340. #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
  341. #define NET_RT_IFLIST 3 /* survey interface list */
  342. #define NET_RT_IFMALIST 4 /* return multicast address list */
  343. #define NET_RT_IFLISTL 5 /* Survey interface list, using 'l'en
  344. * versions of msghdr structs. */
  345. #define NET_RT_MAXID 6
  346. #define CTL_NET_RT_NAMES { \
  347. { 0, 0 }, \
  348. { "dump", CTLTYPE_STRUCT }, \
  349. { "flags", CTLTYPE_STRUCT }, \
  350. { "iflist", CTLTYPE_STRUCT }, \
  351. { "ifmalist", CTLTYPE_STRUCT }, \
  352. { "iflistl", CTLTYPE_STRUCT }, \
  353. }
  354. #endif /* __BSD_VISIBLE */
  355. /*
  356. * Maximum queue length specifiable by listen.
  357. */
  358. #define SOMAXCONN 128
  359. /*
  360. * Message header for recvmsg and sendmsg calls.
  361. * Used value-result for recvmsg, value only for sendmsg.
  362. */
  363. #include <api/sys/__socket.h>
  364. #define MSG_OOB 0x1 /* process out-of-band data */
  365. #define MSG_PEEK 0x2 /* peek at incoming message */
  366. #define MSG_DONTROUTE 0x4 /* send without using routing tables */
  367. #define MSG_EOR 0x8 /* data completes record */
  368. #define MSG_TRUNC 0x10 /* data discarded before delivery */
  369. #define MSG_CTRUNC 0x20 /* control data lost before delivery */
  370. #define MSG_WAITALL 0x40 /* wait for full request or error */
  371. #define MSG_NOTIFICATION 0x2000 /* SCTP notification */
  372. #if __BSD_VISIBLE
  373. #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
  374. #define MSG_EOF 0x100 /* data completes connection */
  375. #define MSG_NBIO 0x4000 /* FIONBIO mode, used by fifofs */
  376. #define MSG_COMPAT 0x8000 /* used in sendit() */
  377. #endif
  378. #ifdef _KERNEL
  379. #define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */
  380. #endif
  381. #if __BSD_VISIBLE
  382. #define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */
  383. #endif
  384. #if __BSD_VISIBLE
  385. /*
  386. * While we may have more groups than this, the cmsgcred struct must
  387. * be able to fit in an mbuf and we have historically supported a
  388. * maximum of 16 groups.
  389. */
  390. #define CMGROUP_MAX 16
  391. /*
  392. * Credentials structure, used to verify the identity of a peer
  393. * process that has sent us a message. This is allocated by the
  394. * peer process but filled in by the kernel. This prevents the
  395. * peer from lying about its identity. (Note that cmcred_groups[0]
  396. * is the effective GID.)
  397. */
  398. struct cmsgcred {
  399. pid_t cmcred_pid; /* PID of sending process */
  400. uid_t cmcred_uid; /* real UID of sending process */
  401. uid_t cmcred_euid; /* effective UID of sending process */
  402. gid_t cmcred_gid; /* real GID of sending process */
  403. short cmcred_ngroups; /* number or groups */
  404. gid_t cmcred_groups[CMGROUP_MAX]; /* groups */
  405. };
  406. /*
  407. * Socket credentials.
  408. */
  409. struct sockcred {
  410. uid_t sc_uid; /* real user id */
  411. uid_t sc_euid; /* effective user id */
  412. gid_t sc_gid; /* real group id */
  413. gid_t sc_egid; /* effective group id */
  414. int sc_ngroups; /* number of supplemental groups */
  415. gid_t sc_groups[1]; /* variable length */
  416. };
  417. /*
  418. * Compute size of a sockcred structure with groups.
  419. */
  420. #define SOCKCREDSIZE(ngrps) \
  421. (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
  422. #endif /* __BSD_VISIBLE */
  423. /* given pointer to struct cmsghdr, return pointer to data */
  424. #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
  425. _ALIGN(sizeof(struct cmsghdr)))
  426. /* given pointer to struct cmsghdr, return pointer to next cmsghdr */
  427. #define CMSG_NXTHDR(mhdr, cmsg) \
  428. ((char *)(cmsg) == NULL ? CMSG_FIRSTHDR(mhdr) : \
  429. ((char *)(cmsg) + _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len) + \
  430. _ALIGN(sizeof(struct cmsghdr)) > \
  431. (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
  432. (struct cmsghdr *)0 : \
  433. (struct cmsghdr *)(void *)((char *)(cmsg) + \
  434. _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len)))
  435. /*
  436. * RFC 2292 requires to check msg_controllen, in case that the kernel returns
  437. * an empty list for some reasons.
  438. */
  439. #define CMSG_FIRSTHDR(mhdr) \
  440. ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
  441. (struct cmsghdr *)(mhdr)->msg_control : \
  442. (struct cmsghdr *)NULL)
  443. #if __BSD_VISIBLE
  444. /* RFC 2292 additions */
  445. #define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
  446. #define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l))
  447. #endif
  448. #ifdef _KERNEL
  449. #define CMSG_ALIGN(n) _ALIGN(n)
  450. #endif
  451. /* "Socket"-level control message types: */
  452. #define SCM_RIGHTS 0x01 /* access rights (array of int) */
  453. #if __BSD_VISIBLE
  454. #define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */
  455. #define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */
  456. #define SCM_BINTIME 0x04 /* timestamp (struct bintime) */
  457. #endif
  458. #if __BSD_VISIBLE
  459. /*
  460. * 4.3 compat bsd_sockaddr, move to compat file later
  461. */
  462. struct bsd_osockaddr {
  463. unsigned short sa_family; /* address family */
  464. char sa_data[14]; /* up to 14 bytes of direct address */
  465. };
  466. /*
  467. * 4.3-compat message header (move to compat file later).
  468. */
  469. struct omsghdr {
  470. char *msg_name; /* optional address */
  471. int msg_namelen; /* size of address */
  472. struct iovec *msg_iov; /* scatter/gather array */
  473. int msg_iovlen; /* # elements in msg_iov */
  474. char *msg_accrights; /* access rights sent/received */
  475. int msg_accrightslen;
  476. };
  477. #endif
  478. /*
  479. * howto arguments for shutdown(2), specified by Posix.1g.
  480. */
  481. #define SHUT_RD 0 /* shut down the reading side */
  482. #define SHUT_WR 1 /* shut down the writing side */
  483. #define SHUT_RDWR 2 /* shut down both sides */
  484. /* we cheat and use the SHUT_XX defines for these */
  485. #define PRU_FLUSH_RD SHUT_RD
  486. #define PRU_FLUSH_WR SHUT_WR
  487. #define PRU_FLUSH_RDWR SHUT_RDWR
  488. #if __BSD_VISIBLE
  489. /*
  490. * sendfile(2) header/trailer struct
  491. */
  492. struct sf_hdtr {
  493. struct iovec *headers; /* pointer to an array of header struct iovec's */
  494. int hdr_cnt; /* number of header iovec's */
  495. struct iovec *trailers; /* pointer to an array of trailer struct iovec's */
  496. int trl_cnt; /* number of trailer iovec's */
  497. };
  498. /*
  499. * Sendfile-specific flag(s)
  500. */
  501. #define SF_NODISKIO 0x00000001
  502. #define SF_MNOWAIT 0x00000002
  503. #define SF_SYNC 0x00000004
  504. #endif
  505. #ifndef _KERNEL
  506. #include <sys/cdefs.h>
  507. __BEGIN_DECLS
  508. int bsd_accept(int, struct bsd_sockaddr * __restrict, socklen_t * __restrict);
  509. int bsd_bind(int, const struct bsd_sockaddr *, socklen_t);
  510. int bsd_connect(int, const struct bsd_sockaddr *, socklen_t);
  511. int bsd_getpeername(int, struct bsd_sockaddr * __restrict, socklen_t * __restrict);
  512. int bsd_getsockname(int, struct bsd_sockaddr * __restrict, socklen_t * __restrict);
  513. int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
  514. int listen(int, int);
  515. ssize_t recv(int, void *, size_t, int);
  516. ssize_t bsd_recvfrom(int, void *, size_t, int, struct bsd_sockaddr * __restrict, socklen_t * __restrict);
  517. ssize_t recvmsg(int, struct msghdr *, int);
  518. ssize_t send(int, const void *, size_t, int);
  519. ssize_t bsd_sendto(int, const void *,
  520. size_t, int, const struct bsd_sockaddr *, socklen_t);
  521. ssize_t sendmsg(int, const struct msghdr *, int);
  522. #if __BSD_VISIBLE
  523. int sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int);
  524. int setfib(int);
  525. #endif
  526. int setsockopt(int, int, int, const void *, socklen_t);
  527. int shutdown(int, int);
  528. int sockatmark(int);
  529. int socket(int, int, int);
  530. int socketpair(int, int, int, int *);
  531. __END_DECLS
  532. #endif /* !_KERNEL */
  533. #ifdef _KERNEL
  534. struct socket;
  535. struct tcpcb *so_sototcpcb(struct socket *so);
  536. struct inpcb *so_sotoinpcb(struct socket *so);
  537. #endif
  538. #endif /* !_SYS_SOCKET_H_ */