wut  v1.7.0
Wii U Toolchain
socket.h
Go to the documentation of this file.
1 #pragma once
2 #include <stdint.h>
3 #include <sys/time.h>
4 
5 #define SOL_SOCKET -1
6 
7 #define PF_UNSPEC 0
8 #define PF_INET 2
9 
10 #define AF_UNSPEC PF_UNSPEC
11 #define AF_INET PF_INET
12 
13 #define SOCK_STREAM 1
14 #define SOCK_DGRAM 2
15 
16 #define MSG_OOB 0x0001
17 #define MSG_PEEK 0x0002
18 #define MSG_DONTROUTE 0x0004
19 #define MSG_DONTWAIT 0x0020
20 
21 #define SHUT_RD 0
22 #define SHUT_WR 1
23 #define SHUT_RDWR 2
24 
25 /*
26  * SOL_SOCKET options
27  */
28 #define SO_REUSEADDR 0x0004 // reuse address
29 #define SO_KEEPALIVE 0x0008 // keep connections alive
30 #define SO_DONTROUTE 0x0010 // route locally only
31 #define SO_BROADCAST 0x0020 // broadcast
32 #define SO_LINGER 0x0080 // linger (no effect?)
33 #define SO_OOBINLINE 0x0100 // out-of-band data inline (no effect?)
34 #define SO_TCPSACK 0x0200 // set tcp selective acknowledgment
35 #define SO_WINSCALE 0x0400 // set tcp window scaling
36 #define SO_SNDBUF 0x1001 // send buffer size
37 #define SO_RCVBUF 0x1002 // receive buffer size
38 #define SO_SNDLOWAT 0x1003 // send low-water mark (no effect?)
39 #define SO_RCVLOWAT 0x1004 // receive low-water mark
40 #define SO_ERROR 0x1007 // get socket error
41 #define SO_TYPE 0x1008 // get socket type
42 #define SO_HOPCNT 0x1009 // get hop count
43 #define SO_MAXMSG 0x1010 // same as TCP_MAXSEG
44 #define SO_RXDATA 0x1011 // get count of bytes in sb_rcv
45 #define SO_TXDATA 0x1012 // get count of bytes in sb_snd
46 #define SO_MYADDR 0x1013 // get IP address
47 #define SO_NBIO 0x1014 // set socket to NON-blocking mode
48 #define SO_BIO 0x1015 // set socket to blocking mode
49 #define SO_NONBLOCK 0x1016 // set/get blocking mode via optval param
50 #define SO_UNKNOWN1019 0x1019 // tcp related
51 #define SO_UNKNOWN101A 0x101A // tcp related
52 #define SO_UNKNOWN101B 0x101B // tcp related
53 #define SO_NOSLOWSTART 0x4000 // disable slowstart
54 #define SO_RUSRBUF 0x10000 // enable somemopt provided memory for receive buffer
55 
56 typedef uint32_t socklen_t;
57 typedef uint16_t sa_family_t;
58 
59 struct sockaddr
60 {
62  char sa_data[];
63 };
64 
66 {
68  char ss_padding[14];
69 };
70 
71 struct linger
72 {
73  int l_onoff;
74  int l_linger;
75 };
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
81 int
82 accept(int sockfd,
83  struct sockaddr *addr,
84  socklen_t *addrlen);
85 
86 int
87 bind(int sockfd,
88  const struct sockaddr *addr,
89  socklen_t addrlen);
90 
91 int
92 connect(int sockfd,
93  const struct sockaddr *addr,
94  socklen_t addrlen);
95 
96 int
97 getpeername(int sockfd,
98  struct sockaddr *addr,
99  socklen_t *addrlen);
100 
101 int
102 getsockname(int sockfd,
103  struct sockaddr *addr,
104  socklen_t *addrlen);
105 
106 int
107 getsockopt(int sockfd,
108  int level,
109  int optname,
110  void *optval,
111  socklen_t *optlen);
112 
113 int
114 listen(int sockfd,
115  int backlog);
116 
117 ssize_t
118 recv(int sockfd,
119  void *buf,
120  size_t len,
121  int flags);
122 
123 ssize_t
124 recvfrom(int sockfd,
125  void *buf,
126  size_t len,
127  int flags,
128  struct sockaddr *src_addr,
129  socklen_t *addrlen);
130 
131 ssize_t
132 send(int sockfd,
133  const void *buf,
134  size_t len,
135  int flags);
136 
137 ssize_t
138 sendto(int sockfd,
139  const void *buf,
140  size_t len,
141  int flags,
142  const struct sockaddr *dest_addr,
143  socklen_t addrlen);
144 
145 int
146 setsockopt(int sockfd,
147  int level,
148  int optname,
149  const void *optval,
150  socklen_t optlen);
151 
152 int
153 shutdown(int sockfd,
154  int how);
155 
156 int
157 socket(int domain,
158  int type,
159  int protocol);
160 
161 int
162 sockatmark(int sockfd);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
char ss_padding[14]
Definition: socket.h:68
uint16_t sa_family_t
Definition: socket.h:57
sa_family_t sa_family
Definition: socket.h:61
uint32_t socklen_t
Definition: socket.h:56
int shutdown(int sockfd, int how)
ssize_t recv(int sockfd, void *buf, size_t len, int flags)
int l_onoff
Definition: socket.h:73
int listen(int sockfd, int backlog)
int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
int sockatmark(int sockfd)
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
int l_linger
Definition: socket.h:74
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen)
int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen)
char sa_data[]
Definition: socket.h:62
ssize_t send(int sockfd, const void *buf, size_t len, int flags)
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)
int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
sa_family_t ss_family
Definition: socket.h:67
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
int socket(int domain, int type, int protocol)
Definition: socket.h:72