1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef POTD_SOCKET_H
#define POTD_SOCKET_H 1
#include <netdb.h>
#include <net/if.h>
#define POTD_BACKLOG 1
typedef struct psocket {
int fd;
socklen_t addr_len;
struct sockaddr addr;
int family;
int socktype;
int protocol;
} psocket;
int socket_nonblock(const psocket *psock);
int socket_init_in(const char *addr,
const char *port, struct addrinfo **results);
int socket_bind_in(psocket *psock, struct addrinfo **results);
int socket_listen_in(psocket *psock);
int socket_accept_in(const psocket *psock, psocket *client_psock);
int socket_connect_in(psocket *psock, struct addrinfo **results);
int socket_connectaddr_in(psocket *psock, struct addrinfo **results,
char host_buf[NI_MAXHOST],
char service_buf[NI_MAXSERV]);
int socket_addrtostr_in(const psocket *psock,
char hbuf[NI_MAXHOST], char sbuf[NI_MAXSERV]);
int socket_reconnect_in(psocket *psock);
int socket_close(psocket *psock);
void socket_clone(const psocket *src, psocket *dst);
ssize_t socket_get_ifnames(const psocket *test_sock, char name[][IFNAMSIZ],
size_t siz, int loopback_only);
int socket_set_ifaddr(const psocket *test_sock,
const char *ifname, const char *addr, const char *mask);
#endif
|