hw/arm/aspeed: Unlock SCU when running kernel
[qemu.git] / include / qemu / sockets.h
blob4f7311b52ae49dcc00dfd503bdf6d1c79586d21b
1 /* headers to use the BSD sockets */
3 #ifndef QEMU_SOCKETS_H
4 #define QEMU_SOCKETS_H
6 #ifdef _WIN32
8 int inet_aton(const char *cp, struct in_addr *ia);
10 #endif /* !_WIN32 */
12 #include "qapi-types.h"
14 /* misc helpers */
15 int qemu_socket(int domain, int type, int protocol);
16 int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
17 int socket_set_cork(int fd, int v);
18 int socket_set_nodelay(int fd);
19 void qemu_set_block(int fd);
20 void qemu_set_nonblock(int fd);
21 int socket_set_fast_reuse(int fd);
23 #ifdef WIN32
24 /* Windows has different names for the same constants with the same values */
25 #define SHUT_RD 0
26 #define SHUT_WR 1
27 #define SHUT_RDWR 2
28 #endif
30 int inet_ai_family_from_address(InetSocketAddress *addr,
31 Error **errp);
32 int inet_parse(InetSocketAddress *addr, const char *str, Error **errp);
33 int inet_connect(const char *str, Error **errp);
34 int inet_connect_saddr(InetSocketAddress *saddr, Error **errp);
36 NetworkAddressFamily inet_netfamily(int family);
38 int unix_listen(const char *path, char *ostr, int olen, Error **errp);
39 int unix_connect(const char *path, Error **errp);
41 SocketAddress *socket_parse(const char *str, Error **errp);
42 int socket_connect(SocketAddress *addr, Error **errp);
43 int socket_listen(SocketAddress *addr, Error **errp);
44 void socket_listen_cleanup(int fd, Error **errp);
45 int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp);
47 /* Old, ipv4 only bits. Don't use for new code. */
48 int parse_host_port(struct sockaddr_in *saddr, const char *str,
49 Error **errp);
50 int socket_init(void);
52 /**
53 * socket_sockaddr_to_address:
54 * @sa: socket address struct
55 * @salen: size of @sa struct
56 * @errp: pointer to uninitialized error object
58 * Get the string representation of the socket
59 * address. A pointer to the allocated address information
60 * struct will be returned, which the caller is required to
61 * release with a call qapi_free_SocketAddress() when no
62 * longer required.
64 * Returns: the socket address struct, or NULL on error
66 SocketAddress *
67 socket_sockaddr_to_address(struct sockaddr_storage *sa,
68 socklen_t salen,
69 Error **errp);
71 /**
72 * socket_local_address:
73 * @fd: the socket file handle
74 * @errp: pointer to uninitialized error object
76 * Get the string representation of the local socket
77 * address. A pointer to the allocated address information
78 * struct will be returned, which the caller is required to
79 * release with a call qapi_free_SocketAddress() when no
80 * longer required.
82 * Returns: the socket address struct, or NULL on error
84 SocketAddress *socket_local_address(int fd, Error **errp);
86 /**
87 * socket_remote_address:
88 * @fd: the socket file handle
89 * @errp: pointer to uninitialized error object
91 * Get the string representation of the remote socket
92 * address. A pointer to the allocated address information
93 * struct will be returned, which the caller is required to
94 * release with a call qapi_free_SocketAddress() when no
95 * longer required.
97 * Returns: the socket address struct, or NULL on error
99 SocketAddress *socket_remote_address(int fd, Error **errp);
102 * socket_address_flatten:
103 * @addr: the socket address to flatten
105 * Convert SocketAddressLegacy to SocketAddress. Caller is responsible
106 * for freeing with qapi_free_SocketAddress().
108 * Returns: the argument converted to SocketAddress.
110 SocketAddress *socket_address_flatten(SocketAddressLegacy *addr);
112 #endif /* QEMU_SOCKETS_H */