]>
Commit | Line | Data |
---|---|---|
6ca957f0 FB |
1 | /* headers to use the BSD sockets */ |
2 | #ifndef QEMU_SOCKET_H | |
3 | #define QEMU_SOCKET_H | |
4 | ||
5 | #ifdef _WIN32 | |
6ca957f0 FB |
6 | #include <windows.h> |
7 | #include <winsock2.h> | |
8 | #include <ws2tcpip.h> | |
9 | ||
10 | #define socket_error() WSAGetLastError() | |
11 | #undef EINTR | |
12 | #define EWOULDBLOCK WSAEWOULDBLOCK | |
13 | #define EINTR WSAEINTR | |
14 | #define EINPROGRESS WSAEINPROGRESS | |
15 | ||
03ff3ca3 AL |
16 | int inet_aton(const char *cp, struct in_addr *ia); |
17 | ||
6ca957f0 FB |
18 | #else |
19 | ||
80bb8cba | 20 | #include <sys/types.h> |
6ca957f0 FB |
21 | #include <sys/socket.h> |
22 | #include <netinet/in.h> | |
23 | #include <netinet/tcp.h> | |
03ff3ca3 AL |
24 | #include <arpa/inet.h> |
25 | #include <netdb.h> | |
ffd843bc | 26 | #include <sys/un.h> |
6ca957f0 FB |
27 | |
28 | #define socket_error() errno | |
29 | #define closesocket(s) close(s) | |
30 | ||
31 | #endif /* !_WIN32 */ | |
32 | ||
2af2bf67 GH |
33 | #include "qemu-option.h" |
34 | ||
d247d25f | 35 | /* misc helpers */ |
40ff6d7e KW |
36 | int qemu_socket(int domain, int type, int protocol); |
37 | int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); | |
154b9a0c | 38 | void socket_set_block(int fd); |
6ca957f0 | 39 | void socket_set_nonblock(int fd); |
d247d25f AL |
40 | int send_all(int fd, const void *buf, int len1); |
41 | ||
42 | /* New, ipv6-ready socket helper functions, see qemu-sockets.c */ | |
e5bc776f | 43 | int inet_listen_opts(QemuOpts *opts, int port_offset); |
d247d25f AL |
44 | int inet_listen(const char *str, char *ostr, int olen, |
45 | int socktype, int port_offset); | |
f4c94c7c | 46 | int inet_connect_opts(QemuOpts *opts); |
d247d25f | 47 | int inet_connect(const char *str, int socktype); |
7e1b35b4 | 48 | int inet_dgram_opts(QemuOpts *opts); |
c9c4b34e | 49 | const char *inet_strfamily(int family); |
d247d25f | 50 | |
62b6adfb | 51 | int unix_listen_opts(QemuOpts *opts); |
d247d25f | 52 | int unix_listen(const char *path, char *ostr, int olen); |
2af2bf67 | 53 | int unix_connect_opts(QemuOpts *opts); |
d247d25f AL |
54 | int unix_connect(const char *path); |
55 | ||
56 | /* Old, ipv4 only bits. Don't use for new code. */ | |
5bb7910a | 57 | int parse_host_port(struct sockaddr_in *saddr, const char *str); |
0706a4dc | 58 | int socket_init(void); |
6ca957f0 FB |
59 | |
60 | #endif /* QEMU_SOCKET_H */ |