Move qemu_irq typedef out of qemu-common.h
[qemu.git] / qemu_socket.h
blob02490ad06c3a7592b50cba3bad1502c4a94c35e2
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()
12 int inet_aton(const char *cp, struct in_addr *ia);
14 #else
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <netinet/tcp.h>
20 #include <arpa/inet.h>
21 #include <netdb.h>
22 #include <sys/un.h>
24 #define socket_error() errno
25 #define closesocket(s) close(s)
27 #endif /* !_WIN32 */
29 #include "qemu-option.h"
30 #include "error.h"
31 #include "qerror.h"
33 /* misc helpers */
34 int qemu_socket(int domain, int type, int protocol);
35 int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
36 int socket_set_cork(int fd, int v);
37 void socket_set_block(int fd);
38 void socket_set_nonblock(int fd);
39 int send_all(int fd, const void *buf, int len1);
41 /* callback function for nonblocking connect
42 * valid fd on success, negative error code on failure
44 typedef void NonBlockingConnectHandler(int fd, void *opaque);
46 int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp);
47 int inet_listen(const char *str, char *ostr, int olen,
48 int socktype, int port_offset, Error **errp);
49 int inet_connect_opts(QemuOpts *opts, Error **errp,
50 NonBlockingConnectHandler *callback, void *opaque);
51 int inet_connect(const char *str, Error **errp);
52 int inet_nonblocking_connect(const char *str,
53 NonBlockingConnectHandler *callback,
54 void *opaque, Error **errp);
56 int inet_dgram_opts(QemuOpts *opts, Error **errp);
57 const char *inet_strfamily(int family);
59 int unix_listen_opts(QemuOpts *opts, Error **errp);
60 int unix_listen(const char *path, char *ostr, int olen, Error **errp);
61 int unix_connect_opts(QemuOpts *opts, Error **errp,
62 NonBlockingConnectHandler *callback, void *opaque);
63 int unix_connect(const char *path, Error **errp);
64 int unix_nonblocking_connect(const char *str,
65 NonBlockingConnectHandler *callback,
66 void *opaque, Error **errp);
68 SocketAddress *socket_parse(const char *str, Error **errp);
69 int socket_connect(SocketAddress *addr, Error **errp,
70 NonBlockingConnectHandler *callback, void *opaque);
71 int socket_listen(SocketAddress *addr, Error **errp);
73 /* Old, ipv4 only bits. Don't use for new code. */
74 int parse_host_port(struct sockaddr_in *saddr, const char *str);
75 int socket_init(void);
77 #endif /* QEMU_SOCKET_H */