]>
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() | |
6ca957f0 | 11 | |
03ff3ca3 AL |
12 | int inet_aton(const char *cp, struct in_addr *ia); |
13 | ||
6ca957f0 FB |
14 | #else |
15 | ||
80bb8cba | 16 | #include <sys/types.h> |
6ca957f0 FB |
17 | #include <sys/socket.h> |
18 | #include <netinet/in.h> | |
19 | #include <netinet/tcp.h> | |
03ff3ca3 AL |
20 | #include <arpa/inet.h> |
21 | #include <netdb.h> | |
ffd843bc | 22 | #include <sys/un.h> |
6ca957f0 FB |
23 | |
24 | #define socket_error() errno | |
25 | #define closesocket(s) close(s) | |
26 | ||
27 | #endif /* !_WIN32 */ | |
28 | ||
2af2bf67 | 29 | #include "qemu-option.h" |
a6ba35b3 AK |
30 | #include "error.h" |
31 | #include "qerror.h" | |
2af2bf67 | 32 | |
d247d25f | 33 | /* misc helpers */ |
40ff6d7e KW |
34 | int qemu_socket(int domain, int type, int protocol); |
35 | int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); | |
128aa589 | 36 | int socket_set_cork(int fd, int v); |
154b9a0c | 37 | void socket_set_block(int fd); |
6ca957f0 | 38 | void socket_set_nonblock(int fd); |
d247d25f AL |
39 | int send_all(int fd, const void *buf, int len1); |
40 | ||
41 | /* New, ipv6-ready socket helper functions, see qemu-sockets.c */ | |
029409e5 | 42 | int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp); |
d247d25f | 43 | int inet_listen(const char *str, char *ostr, int olen, |
029409e5 | 44 | int socktype, int port_offset, Error **errp); |
a6ba35b3 AK |
45 | int inet_connect_opts(QemuOpts *opts, Error **errp); |
46 | int inet_connect(const char *str, bool block, Error **errp); | |
7e1b35b4 | 47 | int inet_dgram_opts(QemuOpts *opts); |
c9c4b34e | 48 | const char *inet_strfamily(int family); |
d247d25f | 49 | |
62b6adfb | 50 | int unix_listen_opts(QemuOpts *opts); |
d247d25f | 51 | int unix_listen(const char *path, char *ostr, int olen); |
2af2bf67 | 52 | int unix_connect_opts(QemuOpts *opts); |
d247d25f AL |
53 | int unix_connect(const char *path); |
54 | ||
55 | /* Old, ipv4 only bits. Don't use for new code. */ | |
5bb7910a | 56 | int parse_host_port(struct sockaddr_in *saddr, const char *str); |
0706a4dc | 57 | int socket_init(void); |
6ca957f0 FB |
58 | |
59 | #endif /* QEMU_SOCKET_H */ |