qemu_socket.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* headers to use the BSD sockets */
  2. #ifndef QEMU_SOCKET_H
  3. #define QEMU_SOCKET_H
  4. #ifdef _WIN32
  5. #define WIN32_LEAN_AND_MEAN
  6. #define WINVER 0x0501 /* needed for ipv6 bits */
  7. #include <windows.h>
  8. #include <winsock2.h>
  9. #include <ws2tcpip.h>
  10. #define socket_error() WSAGetLastError()
  11. #undef EINTR
  12. #define EWOULDBLOCK WSAEWOULDBLOCK
  13. #define EINTR WSAEINTR
  14. #define EINPROGRESS WSAEINPROGRESS
  15. int inet_aton(const char *cp, struct in_addr *ia);
  16. #else
  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>
  23. #define socket_error() errno
  24. #define closesocket(s) close(s)
  25. #endif /* !_WIN32 */
  26. /* misc helpers */
  27. void socket_set_nonblock(int fd);
  28. int send_all(int fd, const void *buf, int len1);
  29. /* New, ipv6-ready socket helper functions, see qemu-sockets.c */
  30. int inet_listen(const char *str, char *ostr, int olen,
  31. int socktype, int port_offset);
  32. int inet_connect(const char *str, int socktype);
  33. int unix_listen(const char *path, char *ostr, int olen);
  34. int unix_connect(const char *path);
  35. /* Old, ipv4 only bits. Don't use for new code. */
  36. int parse_host_port(struct sockaddr_in *saddr, const char *str);
  37. int parse_host_src_port(struct sockaddr_in *haddr,
  38. struct sockaddr_in *saddr,
  39. const char *str);
  40. #endif /* QEMU_SOCKET_H */