bellard | 6ca957f | 2006-04-30 22:53:25 +0000 | [diff] [blame] | 1 | /* headers to use the BSD sockets */ |
| 2 | #ifndef QEMU_SOCKET_H |
| 3 | #define QEMU_SOCKET_H |
| 4 | |
| 5 | #ifdef _WIN32 |
bellard | 6ca957f | 2006-04-30 22:53:25 +0000 | [diff] [blame] | 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 | |
aliguori | 03ff3ca | 2008-09-15 15:51:35 +0000 | [diff] [blame] | 16 | int inet_aton(const char *cp, struct in_addr *ia); |
| 17 | |
bellard | 6ca957f | 2006-04-30 22:53:25 +0000 | [diff] [blame] | 18 | #else |
| 19 | |
Blue Swirl | 80bb8cb | 2010-09-22 19:51:33 +0300 | [diff] [blame] | 20 | #include <sys/types.h> |
bellard | 6ca957f | 2006-04-30 22:53:25 +0000 | [diff] [blame] | 21 | #include <sys/socket.h> |
| 22 | #include <netinet/in.h> |
| 23 | #include <netinet/tcp.h> |
aliguori | 03ff3ca | 2008-09-15 15:51:35 +0000 | [diff] [blame] | 24 | #include <arpa/inet.h> |
| 25 | #include <netdb.h> |
ths | ffd843b | 2006-12-21 19:46:43 +0000 | [diff] [blame] | 26 | #include <sys/un.h> |
bellard | 6ca957f | 2006-04-30 22:53:25 +0000 | [diff] [blame] | 27 | |
| 28 | #define socket_error() errno |
| 29 | #define closesocket(s) close(s) |
| 30 | |
| 31 | #endif /* !_WIN32 */ |
| 32 | |
Gerd Hoffmann | 2af2bf6 | 2009-09-10 10:58:37 +0200 | [diff] [blame] | 33 | #include "qemu-option.h" |
| 34 | |
aliguori | d247d25 | 2008-11-11 20:46:40 +0000 | [diff] [blame] | 35 | /* misc helpers */ |
Kevin Wolf | 40ff6d7 | 2009-12-02 12:24:42 +0100 | [diff] [blame] | 36 | int qemu_socket(int domain, int type, int protocol); |
| 37 | int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); |
bellard | 6ca957f | 2006-04-30 22:53:25 +0000 | [diff] [blame] | 38 | void socket_set_nonblock(int fd); |
aliguori | d247d25 | 2008-11-11 20:46:40 +0000 | [diff] [blame] | 39 | int send_all(int fd, const void *buf, int len1); |
| 40 | |
| 41 | /* New, ipv6-ready socket helper functions, see qemu-sockets.c */ |
Gerd Hoffmann | e5bc776 | 2009-09-10 10:58:41 +0200 | [diff] [blame] | 42 | int inet_listen_opts(QemuOpts *opts, int port_offset); |
aliguori | d247d25 | 2008-11-11 20:46:40 +0000 | [diff] [blame] | 43 | int inet_listen(const char *str, char *ostr, int olen, |
| 44 | int socktype, int port_offset); |
Gerd Hoffmann | f4c94c7 | 2009-09-10 10:58:40 +0200 | [diff] [blame] | 45 | int inet_connect_opts(QemuOpts *opts); |
aliguori | d247d25 | 2008-11-11 20:46:40 +0000 | [diff] [blame] | 46 | int inet_connect(const char *str, int socktype); |
Gerd Hoffmann | 7e1b35b | 2009-09-10 10:58:51 +0200 | [diff] [blame] | 47 | int inet_dgram_opts(QemuOpts *opts); |
Luiz Capitulino | c9c4b34 | 2010-01-20 11:42:38 -0200 | [diff] [blame] | 48 | const char *inet_strfamily(int family); |
aliguori | d247d25 | 2008-11-11 20:46:40 +0000 | [diff] [blame] | 49 | |
Gerd Hoffmann | 62b6adf | 2009-09-10 10:58:38 +0200 | [diff] [blame] | 50 | int unix_listen_opts(QemuOpts *opts); |
aliguori | d247d25 | 2008-11-11 20:46:40 +0000 | [diff] [blame] | 51 | int unix_listen(const char *path, char *ostr, int olen); |
Gerd Hoffmann | 2af2bf6 | 2009-09-10 10:58:37 +0200 | [diff] [blame] | 52 | int unix_connect_opts(QemuOpts *opts); |
aliguori | d247d25 | 2008-11-11 20:46:40 +0000 | [diff] [blame] | 53 | int unix_connect(const char *path); |
| 54 | |
| 55 | /* Old, ipv4 only bits. Don't use for new code. */ |
aliguori | 5bb7910 | 2008-10-13 03:12:02 +0000 | [diff] [blame] | 56 | int parse_host_port(struct sockaddr_in *saddr, const char *str); |
Paolo Bonzini | 0706a4d | 2010-04-01 19:57:08 +0200 | [diff] [blame] | 57 | int socket_init(void); |
bellard | 6ca957f | 2006-04-30 22:53:25 +0000 | [diff] [blame] | 58 | |
| 59 | #endif /* QEMU_SOCKET_H */ |