diff options
| author | Markus Armbruster <armbru@redhat.com> | 2017-04-26 09:36:41 +0200 |
|---|---|---|
| committer | Markus Armbruster <armbru@redhat.com> | 2017-05-09 09:14:40 +0200 |
| commit | bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884 (patch) | |
| tree | 82ef0cd9da0812afc7021d5690c14f72e8e13177 /include/qemu/sockets.h | |
| parent | 62cf396b5d397948c5ac4d04d09596ca14f6c173 (diff) | |
| download | focaccia-qemu-bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884.tar.gz focaccia-qemu-bd269ebc82fbaa5fe7ce5bc7c1770ac8acecd884.zip | |
sockets: Limit SocketAddressLegacy to external interfaces
SocketAddressLegacy is a simple union, and simple unions are awkward: they have their variant members wrapped in a "data" object on the wire, and require additional indirections in C. SocketAddress is the equivalent flat union. Convert all users of SocketAddressLegacy to SocketAddress, except for existing external interfaces. See also commit fce5d53..9445673 and 85a82e8..c5f1ae3. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1493192202-3184-7-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Minor editing accident fixed, commit message and a comment tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'include/qemu/sockets.h')
| -rw-r--r-- | include/qemu/sockets.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 82b7460ea4..a0b5cae03b 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -45,12 +45,12 @@ NetworkAddressFamily inet_netfamily(int family); int unix_listen(const char *path, char *ostr, int olen, Error **errp); int unix_connect(const char *path, Error **errp); -SocketAddressLegacy *socket_parse(const char *str, Error **errp); -int socket_connect(SocketAddressLegacy *addr, NonBlockingConnectHandler *callback, +SocketAddress *socket_parse(const char *str, Error **errp); +int socket_connect(SocketAddress *addr, NonBlockingConnectHandler *callback, void *opaque, Error **errp); -int socket_listen(SocketAddressLegacy *addr, Error **errp); +int socket_listen(SocketAddress *addr, Error **errp); void socket_listen_cleanup(int fd, Error **errp); -int socket_dgram(SocketAddressLegacy *remote, SocketAddressLegacy *local, Error **errp); +int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp); /* Old, ipv4 only bits. Don't use for new code. */ int parse_host_port(struct sockaddr_in *saddr, const char *str); @@ -65,12 +65,12 @@ int socket_init(void); * Get the string representation of the socket * address. A pointer to the allocated address information * struct will be returned, which the caller is required to - * release with a call qapi_free_SocketAddressLegacy() when no + * release with a call qapi_free_SocketAddress() when no * longer required. * * Returns: the socket address struct, or NULL on error */ -SocketAddressLegacy * +SocketAddress * socket_sockaddr_to_address(struct sockaddr_storage *sa, socklen_t salen, Error **errp); @@ -83,12 +83,12 @@ socket_sockaddr_to_address(struct sockaddr_storage *sa, * Get the string representation of the local socket * address. A pointer to the allocated address information * struct will be returned, which the caller is required to - * release with a call qapi_free_SocketAddressLegacy() when no + * release with a call qapi_free_SocketAddress() when no * longer required. * * Returns: the socket address struct, or NULL on error */ -SocketAddressLegacy *socket_local_address(int fd, Error **errp); +SocketAddress *socket_local_address(int fd, Error **errp); /** * socket_remote_address: @@ -98,12 +98,12 @@ SocketAddressLegacy *socket_local_address(int fd, Error **errp); * Get the string representation of the remote socket * address. A pointer to the allocated address information * struct will be returned, which the caller is required to - * release with a call qapi_free_SocketAddressLegacy() when no + * release with a call qapi_free_SocketAddress() when no * longer required. * * Returns: the socket address struct, or NULL on error */ -SocketAddressLegacy *socket_remote_address(int fd, Error **errp); +SocketAddress *socket_remote_address(int fd, Error **errp); /** * socket_address_to_string: @@ -118,7 +118,7 @@ SocketAddressLegacy *socket_remote_address(int fd, Error **errp); * * Returns: the socket address in string format, or NULL on error */ -char *socket_address_to_string(struct SocketAddressLegacy *addr, Error **errp); +char *socket_address_to_string(struct SocketAddress *addr, Error **errp); /** * socket_address_crumple: @@ -131,4 +131,15 @@ char *socket_address_to_string(struct SocketAddressLegacy *addr, Error **errp); */ SocketAddressLegacy *socket_address_crumple(SocketAddress *addr); +/** + * socket_address_flatten: + * @addr: the socket address to flatten + * + * Convert SocketAddressLegacy to SocketAddress. Caller is responsible + * for freeing with qapi_free_SocketAddress(). + * + * Returns: the argument converted to SocketAddress. + */ +SocketAddress *socket_address_flatten(SocketAddressLegacy *addr); + #endif /* QEMU_SOCKETS_H */ |