Merge remote-tracking branch 'stefanha/trivial-patches' into staging
[qemu/opensuse.git] / qemu_socket.h
blob51ad210a7f9f4acfb363b445f094551965571d27
1 /* headers to use the BSD sockets */
2 #ifndef QEMU_SOCKET_H
3 #define QEMU_SOCKET_H
5 #ifdef _WIN32
6 #include <windows.h>
7 #include <winsock2.h>
8 #include <ws2tcpip.h>
10 #define socket_error() WSAGetLastError()
11 #undef EWOULDBLOCK
12 #undef EINTR
13 #undef EINPROGRESS
14 #define EWOULDBLOCK WSAEWOULDBLOCK
15 #define EINTR WSAEINTR
16 #define EINPROGRESS WSAEINPROGRESS
18 int inet_aton(const char *cp, struct in_addr *ia);
20 #else
22 #include <sys/types.h>
23 #include <sys/socket.h>
24 #include <netinet/in.h>
25 #include <netinet/tcp.h>
26 #include <arpa/inet.h>
27 #include <netdb.h>
28 #include <sys/un.h>
30 #define socket_error() errno
31 #define closesocket(s) close(s)
33 #endif /* !_WIN32 */
35 #include "qemu-option.h"
37 /* misc helpers */
38 int qemu_socket(int domain, int type, int protocol);
39 int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
40 int socket_set_cork(int fd, int v);
41 void socket_set_block(int fd);
42 void socket_set_nonblock(int fd);
43 int send_all(int fd, const void *buf, int len1);
45 /* New, ipv6-ready socket helper functions, see qemu-sockets.c */
46 int inet_listen_opts(QemuOpts *opts, int port_offset);
47 int inet_listen(const char *str, char *ostr, int olen,
48 int socktype, int port_offset);
49 int inet_connect_opts(QemuOpts *opts);
50 int inet_connect(const char *str, int socktype);
51 int inet_dgram_opts(QemuOpts *opts);
52 const char *inet_strfamily(int family);
54 int unix_listen_opts(QemuOpts *opts);
55 int unix_listen(const char *path, char *ostr, int olen);
56 int unix_connect_opts(QemuOpts *opts);
57 int unix_connect(const char *path);
59 /* Old, ipv4 only bits. Don't use for new code. */
60 int parse_host_port(struct sockaddr_in *saddr, const char *str);
61 int socket_init(void);
63 #endif /* QEMU_SOCKET_H */