98 socklen_t msg_namelen;
99 struct iovec *msg_iov;
102 socklen_t msg_controllen;
107#define MSG_TRUNC 0x0000
110#include <sys/featuretest.h>
122typedef __sa_family_t sa_family_t;
123#define sa_family_t __sa_family_t
127typedef __socklen_t socklen_t;
128#define socklen_t __socklen_t
131#include <machine/ansi.h>
134typedef _BSD_SIZE_T_ size_t;
139typedef _BSD_SSIZE_T_ ssize_t;
144#include <sys/sigtypes.h>
153#define SOCK_SEQPACKET 5
154#define SOCK_CONN_DGRAM 6
155#define SOCK_DCCP SOCK_CONN_DGRAM
157#define SOCK_CLOEXEC 0x10000000
158#define SOCK_NONBLOCK 0x20000000
159#define SOCK_NOSIGPIPE 0x40000000
160#define SOCK_FLAGS_MASK 0xf0000000
165#define SO_DEBUG 0x0001
166#define SO_ACCEPTCONN 0x0002
167#define SO_REUSEADDR 0x0004
168#define SO_KEEPALIVE 0x0008
169#define SO_DONTROUTE 0x0010
170#define SO_BROADCAST 0x0020
171#define SO_USELOOPBACK 0x0040
172#define SO_LINGER 0x0080
173#define SO_OOBINLINE 0x0100
174#define SO_REUSEPORT 0x0200
176#define SO_NOSIGPIPE 0x0800
177#define SO_ACCEPTFILTER 0x1000
178#define SO_TIMESTAMP 0x2000
179#define SO_RERROR 0x4000
182#define SO_DEFOPTS (SO_DEBUG|SO_REUSEADDR|SO_KEEPALIVE|SO_DONTROUTE| \
183 SO_BROADCAST|SO_USELOOPBACK|SO_LINGER|SO_OOBINLINE|SO_REUSEPORT| \
184 SO_NOSIGPIPE|SO_TIMESTAMP|SO_RERROR)
186#define __SO_OPTION_BITS \
200 "\15SO_ACCEPTFILTER" \
207#define SO_SNDBUF 0x1001
208#define SO_RCVBUF 0x1002
209#define SO_SNDLOWAT 0x1003
210#define SO_RCVLOWAT 0x1004
213#define SO_ERROR 0x1007
214#define SO_TYPE 0x1008
215#define SO_OVERFLOWED 0x1009
217#define SO_NOHEADER 0x100a
221#define SO_SNDTIMEO 0x100b
222#define SO_RCVTIMEO 0x100c
231struct accept_filter_arg {
239#define SOL_SOCKET 0xffff
246#define AF_UNIX AF_LOCAL
262#define AF_APPLETALK 16
265#if defined(_NETBSD_SOURCE)
266#define pseudo_AF_XTP 19
270#if defined(_NETBSD_SOURCE)
271#define pseudo_AF_RTIP 22
275#if defined(_NETBSD_SOURCE)
276#define pseudo_AF_PIP 25
279#define AF_E164 AF_ISDN
282#if defined(_NETBSD_SOURCE)
283#define pseudo_AF_KEY 29
284#define pseudo_AF_HDRCMPLT 30
287#define AF_BLUETOOTH 31
288#define AF_IEEE80211 32
301 sa_family_t sa_family;
320#define _SB_DATASIZE 254
325 sa_family_t sb_family;
326 char sb_data[_SB_DATASIZE];
337#define _SS_MAXSIZE 128
338#define _SS_ALIGNSIZE (sizeof(__int64_t))
339#define _SS_PAD1SIZE (_SS_ALIGNSIZE - 2)
340#define _SS_PAD2SIZE (_SS_MAXSIZE - 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE)
344 sa_family_t ss_family;
345 char __ss_pad1[_SS_PAD1SIZE];
346 __int64_t __ss_align;
347 char __ss_pad2[_SS_PAD2SIZE];
350#if defined(_NETBSD_SOURCE)
351#define sstosa(__ss) ((struct sockaddr *)(__ss))
352#define sstocsa(__ss) ((const struct sockaddr *)(__ss))
358#define PF_UNSPEC AF_UNSPEC
359#define PF_LOCAL AF_LOCAL
360#define PF_UNIX PF_LOCAL
361#define PF_INET AF_INET
362#define PF_IMPLINK AF_IMPLINK
364#define PF_CHAOS AF_CHAOS
368#define PF_ECMA AF_ECMA
369#define PF_DATAKIT AF_DATAKIT
370#define PF_CCITT AF_CCITT
372#define PF_DECnet AF_DECnet
375#define PF_HYLINK AF_HYLINK
376#define PF_APPLETALK AF_APPLETALK
377#define PF_OROUTE AF_OROUTE
378#define PF_LINK AF_LINK
379#if defined(_NETBSD_SOURCE)
380#define PF_XTP pseudo_AF_XTP
382#define PF_COIP AF_COIP
384#define PF_INET6 AF_INET6
386#if defined(_NETBSD_SOURCE)
387#define PF_RTIP pseudo_AF_RTIP
388#define PF_PIP pseudo_AF_PIP
390#define PF_ISDN AF_ISDN
391#define PF_E164 AF_E164
392#define PF_NATM AF_NATM
394#if defined(_NETBSD_SOURCE)
395#define PF_KEY pseudo_AF_KEY
397#define PF_BLUETOOTH AF_BLUETOOTH
398#define PF_MPLS AF_MPLS
399#define PF_ROUTE AF_ROUTE
401#define PF_ETHER AF_ETHER
405#if defined(_NETBSD_SOURCE)
408typedef __pid_t pid_t;
413typedef __gid_t gid_t;
418typedef __uid_t uid_t;
442#define SOCKCREDSIZE(ngrps) \
443 (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
447#if defined(_NETBSD_SOURCE)
450 __uint64_t ki_pcbaddr;
451 __uint64_t ki_ppcbaddr;
452 __uint64_t ki_sockaddr;
454 __uint32_t ki_family;
456 __uint32_t ki_protocol;
457 __uint32_t ki_pflags;
459 __uint32_t ki_sostate;
460 __uint32_t ki_prstate;
462 __uint32_t ki_tflags;
469 char _kis_pad[256 + 8];
473 char _kid_pad[256 + 8];
480 __uint64_t ki_nextref;
483#define ki_src ki_s._kis_src
484#define ki_dst ki_d._kid_dst
485#define ki_spad ki_s._kis_pad
486#define ki_dpad ki_d._kid_pad
493#if defined(_NETBSD_SOURCE)
503#define NET_RT_FLAGS 2
504#define NET_RT_OOOIFLIST 3
505#define NET_RT_OOIFLIST 4
506#define NET_RT_OIFLIST 5
507#define NET_RT_IFLIST 6
518#include <sys/cdefs.h>
526 socklen_t msg_namelen;
527 struct iovec *msg_iov;
530 socklen_t msg_controllen;
534#define MSG_OOB 0x0001
535#define MSG_PEEK 0x0002
536#define MSG_DONTROUTE 0x0004
537#define MSG_EOR 0x0008
538#define MSG_TRUNC 0x0010
539#define MSG_CTRUNC 0x0020
540#define MSG_WAITALL 0x0040
541#define MSG_DONTWAIT 0x0080
542#define MSG_BCAST 0x0100
543#define MSG_MCAST 0x0200
544#define MSG_NOSIGNAL 0x0400
545#if defined(_NETBSD_SOURCE)
546#define MSG_CMSG_CLOEXEC 0x0800
547#define MSG_NBIO 0x1000
548#define MSG_WAITFORONE 0x2000
549#define MSG_NOTIFICATION 0x4000
553 unsigned int msg_len;
558#define MSG_USERFLAGS 0x0ffffff
559#define MSG_NAMEMBUF 0x1000000
560#define MSG_CONTROLMBUF 0x2000000
561#define MSG_IOVUSRSPACE 0x4000000
562#define MSG_LENUSRSPACE 0x8000000
586#define __CMSG_ALIGN(n) (((n) + __ALIGNBYTES) & ~__ALIGNBYTES)
589#define CMSG_ALIGN(n) __CMSG_ALIGN(n)
592#define __CMSG_ASIZE __CMSG_ALIGN(sizeof(struct cmsghdr))
593#define __CMSG_MSGNEXT(cmsg) \
594 (__CASTV(char *, cmsg) + __CMSG_ALIGN((cmsg)->cmsg_len))
595#define __CMSG_MSGEND(mhdr) \
596 (__CASTV(char *, (mhdr)->msg_control) + (mhdr)->msg_controllen)
599#define CMSG_DATA(cmsg) (__CASTV(u_char *, cmsg) + __CMSG_ASIZE)
600#define CCMSG_DATA(cmsg) (__CASTCV(const u_char *, cmsg) + __CMSG_ASIZE)
603#define CMSG_NXTHDR(mhdr, cmsg) \
604 __CASTV(struct cmsghdr *, \
605 __CMSG_MSGNEXT(cmsg) + __CMSG_ASIZE > __CMSG_MSGEND(mhdr) ? 0 : \
606 __CMSG_MSGNEXT(cmsg))
612#define CMSG_FIRSTHDR(mhdr) \
613 __CASTV(struct cmsghdr *, \
614 (mhdr)->msg_controllen < sizeof(struct cmsghdr) ? 0 : \
617#define CMSG_SPACE(l) (__CMSG_ASIZE + __CMSG_ALIGN(l))
618#define CMSG_LEN(l) (__CMSG_ASIZE + (l))
621#define SCM_RIGHTS 0x01
622#if defined(_NETBSD_SOURCE)
625#define SCM_TIMESTAMP 0x08
626#define SCM_CREDS 0x10
637static __inline socklen_t
638sockaddr_getlen(
const struct sockaddr *sa)
644socklen_t sockaddr_getsize_by_family(sa_family_t);
649struct sockaddr *sockaddr_alloc(sa_family_t, socklen_t,
int);
650const void *sockaddr_const_addr(
const struct sockaddr *, socklen_t *);
651void *sockaddr_addr(
struct sockaddr *, socklen_t *);
653const struct sockaddr *sockaddr_any_by_family(sa_family_t);
654const void *sockaddr_anyaddr(
const struct sockaddr *, socklen_t *);
657int sockaddr_format(
const struct sockaddr *,
char *,
size_t);
658void sockaddr_free(
struct sockaddr *);
666int accept(
int,
struct sockaddr * __restrict, socklen_t * __restrict);
668int accept4(
int,
struct sockaddr * __restrict, socklen_t * __restrict,
int);
670int bind(
int,
const struct sockaddr *, socklen_t);
671int connect(
int,
const struct sockaddr *, socklen_t);
672int getpeername(
int,
struct sockaddr * __restrict, socklen_t * __restrict);
673int getsockname(
int,
struct sockaddr * __restrict, socklen_t * __restrict);
674int getsockopt(
int,
int,
int,
void *__restrict, socklen_t * __restrict);
676int getsockopt2(
int,
int,
int,
void *__restrict, socklen_t * __restrict);
680int paccept(
int,
struct sockaddr * __restrict, socklen_t * __restrict,
681 const sigset_t * __restrict,
int);
683ssize_t recv(
int,
void *,
size_t,
int);
684ssize_t recvfrom(
int,
void *__restrict,
size_t,
int,
685 struct sockaddr * __restrict, socklen_t * __restrict);
686ssize_t recvmsg(
int,
struct msghdr *,
int);
687ssize_t send(
int,
const void *,
size_t,
int);
688ssize_t sendto(
int,
const void *,
689 size_t,
int,
const struct sockaddr *, socklen_t);
690ssize_t sendmsg(
int,
const struct msghdr *,
int);
691int setsockopt(
int,
int,
int,
const void *, socklen_t);
692int shutdown(
int,
int);
696int socket(
int,
int,
int)
698#if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
704int socketpair(
int,
int,
int,
int *);
708#if defined(_NETBSD_SOURCE)
709int sendmmsg(
int,
struct mmsghdr *,
unsigned int,
unsigned int);
711int recvmmsg(
int,
struct mmsghdr *,
unsigned int,
unsigned int,
716int libcglue_ps2ip_setconfig(
t_ip_info *ip_info);
717int libcglue_ps2ip_getconfig(
char *netif_name,
t_ip_info *ip_info);
718void libcglue_dns_setserver(u8 numdns,
ip_addr_t *dnsserver);
719const ip_addr_t *libcglue_dns_getserver(u8 numdns);
723#ifndef LIBCGLUE_SYS_SOCKET_ALIASES
724#define LIBCGLUE_SYS_SOCKET_ALIASES 0
727#if LIBCGLUE_SYS_SOCKET_ALIASES
728#define closesocket(...) close(__VA_ARGS__)
729#define readsocket(...) read(__VA_ARGS__)
730#define writesocket(...) write(__VA_ARGS__)
731#define ioctlsocket(...) ioctl(__VA_ARGS__)
732#define fcntlsocket(...) fcntl(__VA_ARGS__)
733#define lwip_accept(...) accept(__VA_ARGS__)
734#define lwip_bind(...) bind(__VA_ARGS__)
735#define lwip_shutdown(...) shutdown(__VA_ARGS__)
736#define lwip_getpeername(...) getpeername(__VA_ARGS__)
737#define lwip_getsockname(...) getsockname(__VA_ARGS__)
738#define lwip_getsockopt(...) getsockopt(__VA_ARGS__)
739#define lwip_setsockopt(...) setsockopt(__VA_ARGS__)
740#define lwip_close(...) close(__VA_ARGS__)
741#define lwip_connect(...) connect(__VA_ARGS__)
742#define lwip_listen(...) listen(__VA_ARGS__)
743#define lwip_recv(...) recv(__VA_ARGS__)
744#define lwip_read(...) read(__VA_ARGS__)
745#define lwip_recvfrom(...) recvfrom(__VA_ARGS__)
746#define lwip_send(...) send(__VA_ARGS__)
747#define lwip_sendto(...) sendto(__VA_ARGS__)
748#define lwip_socket(...) socket(__VA_ARGS__)
749#define lwip_write(...) write(__VA_ARGS__)
750#define lwip_select(...) select(__VA_ARGS__)
751#define lwip_ioctl(...) ioctl(__VA_ARGS__)
752#define lwip_fcntl(...) fcntl(__VA_ARGS__)
753#define disconnect(...) close(__VA_ARGS__)
754#define ps2ip_setconfig(...) libcglue_ps2ip_setconfig(__VA_ARGS__)
755#define ps2ip_getconfig(...) libcglue_ps2ip_getconfig(__VA_ARGS__)
756#define dns_setserver(...) libcglue_dns_setserver(__VA_ARGS__)
757#define dns_getserver(...) libcglue_dns_getserver(__VA_ARGS__)