1
2#ifndef QEMU_SOCKET_H
3#define QEMU_SOCKET_H
4
5#ifdef _WIN32
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
16int inet_aton(const char *cp, struct in_addr *ia);
17
18#else
19
20#include <sys/types.h>
21#include <sys/socket.h>
22#include <netinet/in.h>
23#include <netinet/tcp.h>
24#include <arpa/inet.h>
25#include <netdb.h>
26#include <sys/un.h>
27
28#define socket_error() errno
29#define closesocket(s) close(s)
30
31#endif
32
33#include "qemu-option.h"
34
35
36int qemu_socket(int domain, int type, int protocol);
37int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
38void socket_set_block(int fd);
39void socket_set_nonblock(int fd);
40int send_all(int fd, const void *buf, int len1);
41
42
43int inet_listen_opts(QemuOpts *opts, int port_offset);
44int inet_listen(const char *str, char *ostr, int olen,
45 int socktype, int port_offset);
46int inet_connect_opts(QemuOpts *opts);
47int inet_connect(const char *str, int socktype);
48int inet_dgram_opts(QemuOpts *opts);
49const char *inet_strfamily(int family);
50
51int unix_listen_opts(QemuOpts *opts);
52int unix_listen(const char *path, char *ostr, int olen);
53int unix_connect_opts(QemuOpts *opts);
54int unix_connect(const char *path);
55
56
57int parse_host_port(struct sockaddr_in *saddr, const char *str);
58int socket_init(void);
59
60#endif
61