root / qemu_socket.h @ a8a358bf
History | View | Annotate | Download (1.3 kB)
1 | 6ca957f0 | bellard | /* headers to use the BSD sockets */
|
---|---|---|---|
2 | 6ca957f0 | bellard | #ifndef QEMU_SOCKET_H
|
3 | 6ca957f0 | bellard | #define QEMU_SOCKET_H
|
4 | 6ca957f0 | bellard | |
5 | 6ca957f0 | bellard | #ifdef _WIN32
|
6 | 6ca957f0 | bellard | #include <windows.h> |
7 | 6ca957f0 | bellard | #include <winsock2.h> |
8 | 6ca957f0 | bellard | #include <ws2tcpip.h> |
9 | 6ca957f0 | bellard | |
10 | 6ca957f0 | bellard | #define socket_error() WSAGetLastError()
|
11 | 6ca957f0 | bellard | #undef EINTR
|
12 | 6ca957f0 | bellard | #define EWOULDBLOCK WSAEWOULDBLOCK
|
13 | 6ca957f0 | bellard | #define EINTR WSAEINTR
|
14 | 6ca957f0 | bellard | #define EINPROGRESS WSAEINPROGRESS
|
15 | 6ca957f0 | bellard | |
16 | 03ff3ca3 | aliguori | int inet_aton(const char *cp, struct in_addr *ia); |
17 | 03ff3ca3 | aliguori | |
18 | 6ca957f0 | bellard | #else
|
19 | 6ca957f0 | bellard | |
20 | 6ca957f0 | bellard | #include <sys/socket.h> |
21 | 6ca957f0 | bellard | #include <netinet/in.h> |
22 | 6ca957f0 | bellard | #include <netinet/tcp.h> |
23 | 03ff3ca3 | aliguori | #include <arpa/inet.h> |
24 | 03ff3ca3 | aliguori | #include <netdb.h> |
25 | ffd843bc | ths | #include <sys/un.h> |
26 | 6ca957f0 | bellard | |
27 | 6ca957f0 | bellard | #define socket_error() errno
|
28 | 6ca957f0 | bellard | #define closesocket(s) close(s)
|
29 | 6ca957f0 | bellard | |
30 | 6ca957f0 | bellard | #endif /* !_WIN32 */ |
31 | 6ca957f0 | bellard | |
32 | d247d25f | aliguori | /* misc helpers */
|
33 | 6ca957f0 | bellard | void socket_set_nonblock(int fd); |
34 | d247d25f | aliguori | int send_all(int fd, const void *buf, int len1); |
35 | d247d25f | aliguori | |
36 | d247d25f | aliguori | /* New, ipv6-ready socket helper functions, see qemu-sockets.c */
|
37 | d247d25f | aliguori | int inet_listen(const char *str, char *ostr, int olen, |
38 | d247d25f | aliguori | int socktype, int port_offset); |
39 | d247d25f | aliguori | int inet_connect(const char *str, int socktype); |
40 | d247d25f | aliguori | |
41 | d247d25f | aliguori | int unix_listen(const char *path, char *ostr, int olen); |
42 | d247d25f | aliguori | int unix_connect(const char *path); |
43 | d247d25f | aliguori | |
44 | d247d25f | aliguori | /* Old, ipv4 only bits. Don't use for new code. */
|
45 | 5bb7910a | aliguori | int parse_host_port(struct sockaddr_in *saddr, const char *str); |
46 | 0e82f34d | aliguori | int parse_host_src_port(struct sockaddr_in *haddr, |
47 | 0e82f34d | aliguori | struct sockaddr_in *saddr,
|
48 | 0e82f34d | aliguori | const char *str); |
49 | 6ca957f0 | bellard | |
50 | 6ca957f0 | bellard | #endif /* QEMU_SOCKET_H */ |