add inet_pton (and inet_ntop) functional tests
[libc-test] / src / api / sys_socket.c
1 #include <sys/socket.h>
2 #define T(t) (t*)0;
3 #define F(t,n) {t *y = &x.n;}
4 #define C(n) switch(n){case n:;}
5 static void f()
6 {
7 T(size_t)
8 T(ssize_t)
9 T(socklen_t)
10 T(sa_family_t)
11 {
12 struct sockaddr x;
13 F(sa_family_t,sa_family)
14 F(char, sa_data[0])
15 }
16 {
17 struct sockaddr_storage x;
18 F(sa_family_t, ss_family)
19 }
20 {
21 struct msghdr x;
22 F(void*,msg_name)
23 F(socklen_t,msg_namelen)
24 F(struct iovec*,msg_iov)
25 F(int,msg_iovlen)
26 F(void*,msg_control)
27 F(socklen_t,msg_controllen)
28 F(int,msg_flags)
29 }
30 {
31 struct cmsghdr x;
32 F(socklen_t,cmsg_len)
33 F(int,cmsg_level)
34 F(int,cmsg_type)
35 }
36 C(SCM_RIGHTS)
37 #ifndef CMSG_DATA
38 #error no CMSG_DATA
39 #endif
40 #ifndef CMSG_NXTHDR
41 #error no CMSG_NXTHDR
42 #endif
43 #ifndef CMSG_FIRSTHDR
44 #error CMSG_FIRSTTHDR
45 #endif
46 {
47 struct linger x;
48 F(int,l_onoff)
49 F(int,l_linger)
50 }
51 C(SOCK_DGRAM)
52 C(SOCK_RAW)
53 C(SOCK_SEQPACKET)
54 C(SOCK_STREAM)
55 C(SOL_SOCKET)
56 C(SO_ACCEPTCONN)
57 C(SO_BROADCAST)
58 C(SO_DEBUG)
59 C(SO_DONTROUTE)
60 C(SO_ERROR)
61 C(SO_KEEPALIVE)
62 C(SO_LINGER)
63 C(SO_OOBINLINE)
64 C(SO_RCVBUF)
65 C(SO_RCVLOWAT)
66 C(SO_RCVTIMEO)
67 C(SO_REUSEADDR)
68 C(SO_SNDBUF)
69 C(SO_SNDLOWAT)
70 C(SO_SNDTIMEO)
71 C(SO_TYPE)
72 C(SOMAXCONN)
73 C(MSG_CTRUNC)
74 C(MSG_DONTROUTE)
75 C(MSG_EOR)
76 C(MSG_OOB)
77 C(MSG_NOSIGNAL)
78 C(MSG_PEEK)
79 C(MSG_TRUNC)
80 C(MSG_WAITALL)
81 C(AF_INET)
82 C(AF_INET6)
83 C(AF_UNIX)
84 C(AF_UNSPEC)
85 C(SHUT_RD)
86 C(SHUT_RDWR)
87 C(SHUT_WR)
88 {int(*p)(int,struct sockaddr*restrict,socklen_t*restrict) = accept;}
89 {int(*p)(int,const struct sockaddr*,socklen_t) = bind;}
90 {int(*p)(int,const struct sockaddr*,socklen_t) = connect;}
91 {int(*p)(int,struct sockaddr*restrict,socklen_t*restrict) = getpeername;}
92 {int(*p)(int,struct sockaddr*restrict,socklen_t*restrict) = getsockname;}
93 {int(*p)(int,int,int,void*restrict,socklen_t*restrict) = getsockopt;}
94 {int(*p)(int,int) = listen;}
95 {ssize_t(*p)(int,void*,size_t,int) = recv;}
96 {ssize_t(*p)(int,void*restrict,size_t,int,struct sockaddr*restrict,socklen_t*restrict) = recvfrom;}
97 {ssize_t(*p)(int,struct msghdr*,int) = recvmsg;}
98 {ssize_t(*p)(int,const void*,size_t,int) = send;}
99 {ssize_t(*p)(int,const struct msghdr*,int) = sendmsg;}
100 {ssize_t(*p)(int,const void*,size_t,int,const struct sockaddr*,socklen_t) = sendto;}
101 {int(*p)(int,int,int,const void*,socklen_t) = setsockopt;}
102 {int(*p)(int,int) = shutdown;}
103 {int(*p)(int) = sockatmark;}
104 {int(*p)(int,int,int) = socket;}
105 {int(*p)(int,int,int,int[]) = socketpair;}
106 }