]> git.proxmox.com Git - qemu.git/blame - qemu_socket.h
sockets: add inet_connect_opts
[qemu.git] / qemu_socket.h
CommitLineData
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
16int inet_aton(const char *cp, struct in_addr *ia);
17
6ca957f0
FB
18#else
19
20#include <sys/socket.h>
21#include <netinet/in.h>
22#include <netinet/tcp.h>
03ff3ca3
AL
23#include <arpa/inet.h>
24#include <netdb.h>
ffd843bc 25#include <sys/un.h>
6ca957f0
FB
26
27#define socket_error() errno
28#define closesocket(s) close(s)
29
30#endif /* !_WIN32 */
31
2af2bf67
GH
32#include "qemu-option.h"
33
d247d25f 34/* misc helpers */
6ca957f0 35void socket_set_nonblock(int fd);
d247d25f
AL
36int send_all(int fd, const void *buf, int len1);
37
38/* New, ipv6-ready socket helper functions, see qemu-sockets.c */
39int inet_listen(const char *str, char *ostr, int olen,
40 int socktype, int port_offset);
f4c94c7c 41int inet_connect_opts(QemuOpts *opts);
d247d25f
AL
42int inet_connect(const char *str, int socktype);
43
62b6adfb 44int unix_listen_opts(QemuOpts *opts);
d247d25f 45int unix_listen(const char *path, char *ostr, int olen);
2af2bf67 46int unix_connect_opts(QemuOpts *opts);
d247d25f
AL
47int unix_connect(const char *path);
48
49/* Old, ipv4 only bits. Don't use for new code. */
5bb7910a 50int parse_host_port(struct sockaddr_in *saddr, const char *str);
0e82f34d
AL
51int parse_host_src_port(struct sockaddr_in *haddr,
52 struct sockaddr_in *saddr,
53 const char *str);
6ca957f0
FB
54
55#endif /* QEMU_SOCKET_H */