1
2
3#ifndef QEMU_SOCKETS_H
4#define QEMU_SOCKETS_H
5
6#ifdef _WIN32
7
8int inet_aton(const char *cp, struct in_addr *ia);
9
10#endif
11
12#include "qapi-types.h"
13
14
15int qemu_socket(int domain, int type, int protocol);
16int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
17int socket_set_cork(int fd, int v);
18int socket_set_nodelay(int fd);
19void qemu_set_block(int fd);
20void qemu_set_nonblock(int fd);
21int socket_set_fast_reuse(int fd);
22
23#ifdef WIN32
24
25#define SHUT_RD 0
26#define SHUT_WR 1
27#define SHUT_RDWR 2
28#endif
29
30int inet_ai_family_from_address(InetSocketAddress *addr,
31 Error **errp);
32int inet_parse(InetSocketAddress *addr, const char *str, Error **errp);
33int inet_connect(const char *str, Error **errp);
34int inet_connect_saddr(InetSocketAddress *saddr, Error **errp);
35
36NetworkAddressFamily inet_netfamily(int family);
37
38int unix_listen(const char *path, char *ostr, int olen, Error **errp);
39int unix_connect(const char *path, Error **errp);
40
41SocketAddress *socket_parse(const char *str, Error **errp);
42int socket_connect(SocketAddress *addr, Error **errp);
43int socket_listen(SocketAddress *addr, Error **errp);
44void socket_listen_cleanup(int fd, Error **errp);
45int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp);
46
47
48int parse_host_port(struct sockaddr_in *saddr, const char *str,
49 Error **errp);
50int socket_init(void);
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66SocketAddress *
67socket_sockaddr_to_address(struct sockaddr_storage *sa,
68 socklen_t salen,
69 Error **errp);
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84SocketAddress *socket_local_address(int fd, Error **errp);
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99SocketAddress *socket_remote_address(int fd, Error **errp);
100
101
102
103
104
105
106
107
108
109
110SocketAddress *socket_address_flatten(SocketAddressLegacy *addr);
111
112#endif
113