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