2
0

qemu_socket.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_nonblock(int fd);
  30. int send_all(int fd, const void *buf, int len1);
  31. /* New, ipv6-ready socket helper functions, see qemu-sockets.c */
  32. int inet_listen_opts(QemuOpts *opts, int port_offset);
  33. int inet_listen(const char *str, char *ostr, int olen,
  34. int socktype, int port_offset);
  35. int inet_connect_opts(QemuOpts *opts);
  36. int inet_connect(const char *str, int socktype);
  37. int inet_dgram_opts(QemuOpts *opts);
  38. const char *inet_strfamily(int family);
  39. int unix_listen_opts(QemuOpts *opts);
  40. int unix_listen(const char *path, char *ostr, int olen);
  41. int unix_connect_opts(QemuOpts *opts);
  42. int unix_connect(const char *path);
  43. /* Old, ipv4 only bits. Don't use for new code. */
  44. int parse_host_port(struct sockaddr_in *saddr, const char *str);
  45. int socket_init(void);
  46. #endif /* QEMU_SOCKET_H */