diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2015-05-01 17:36:20 +0100 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2015-10-20 14:15:42 +0100 |
commit | 17c55decec2a516cf7f290ec8a5f4f207531e8b4 (patch) | |
tree | 07420add184d3d8e2de3ce8395c248c6626d9b0b /include | |
parent | c14e42d7a4495ecbad7bf8b3d603272e3a8992a1 (diff) | |
download | qemu-17c55decec2a516cf7f290ec8a5f4f207531e8b4.zip qemu-17c55decec2a516cf7f290ec8a5f4f207531e8b4.tar.gz qemu-17c55decec2a516cf7f290ec8a5f4f207531e8b4.tar.bz2 |
sockets: add helpers for creating SocketAddress from a socket
Add two helper methods that, given a socket file descriptor,
can return a populated SocketAddress struct containing either
the local or remote address information.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/sockets.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index c174b5c..3ea7cc9 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -88,4 +88,34 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp); int parse_host_port(struct sockaddr_in *saddr, const char *str); int socket_init(void); +/** + * socket_local_address: + * @fd: the socket file handle + * @errp: pointer to uninitialized error object + * + * 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_SocketAddress when no + * longer required. + * + * Returns: the socket address struct, or NULL on error + */ +SocketAddress *socket_local_address(int fd, Error **errp); + +/** + * socket_remote_address: + * @fd: the socket file handle + * @errp: pointer to uninitialized error object + * + * 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_SocketAddress when no + * longer required. + * + * Returns: the socket address struct, or NULL on error + */ +SocketAddress *socket_remote_address(int fd, Error **errp); + #endif /* QEMU_SOCKET_H */ |