2
0

qemu_socket.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* headers to use the BSD sockets */
  2. #ifndef QEMU_SOCKET_H
  3. #define QEMU_SOCKET_H
  4. #ifdef _WIN32
  5. #include <windows.h>
  6. #include <winsock2.h>
  7. #include <ws2tcpip.h>
  8. #define socket_error() WSAGetLastError()
  9. #undef EINTR
  10. #define EWOULDBLOCK WSAEWOULDBLOCK
  11. #define EINTR WSAEINTR
  12. #define EINPROGRESS WSAEINPROGRESS
  13. int inet_aton(const char *cp, struct in_addr *ia);
  14. #else
  15. #include <sys/types.h>
  16. #include <sys/socket.h>
  17. #include <netinet/in.h>
  18. #include <netinet/tcp.h>
  19. #include <arpa/inet.h>
  20. #include <netdb.h>
  21. #include <sys/un.h>
  22. #define socket_error() errno
  23. #define closesocket(s) close(s)
  24. #endif /* !_WIN32 */
  25. #include "qemu-option.h"
  26. /* misc helpers */
  27. int qemu_socket(int domain, int type, int protocol);
  28. int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
  29. void socket_set_block(int fd);
  30. void socket_set_nonblock(int fd);
  31. int send_all(int fd, const void *buf, int len1);
  32. /* New, ipv6-ready socket helper functions, see qemu-sockets.c */
  33. int inet_listen_opts(QemuOpts *opts, int port_offset);
  34. int inet_listen(const char *str, char *ostr, int olen,
  35. int socktype, int port_offset);
  36. int inet_connect_opts(QemuOpts *opts);
  37. int inet_connect(const char *str, int socktype);
  38. int inet_dgram_opts(QemuOpts *opts);
  39. const char *inet_strfamily(int family);
  40. int unix_listen_opts(QemuOpts *opts);
  41. int unix_listen(const char *path, char *ostr, int olen);
  42. int unix_connect_opts(QemuOpts *opts);
  43. int unix_connect(const char *path);
  44. /* Old, ipv4 only bits. Don't use for new code. */
  45. int parse_host_port(struct sockaddr_in *saddr, const char *str);
  46. int socket_init(void);
  47. #endif /* QEMU_SOCKET_H */