aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/block/nbd.h3
-rw-r--r--include/io/channel-socket.h24
-rw-r--r--include/io/dns-resolver.h22
-rw-r--r--include/io/task.h10
-rw-r--r--include/qemu/sockets.h33
5 files changed, 53 insertions, 39 deletions
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 3e373f0498..0ed077502e 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -164,4 +164,7 @@ void nbd_client_new(NBDExport *exp,
void nbd_client_get(NBDClient *client);
void nbd_client_put(NBDClient *client);
+void nbd_server_start(SocketAddress *addr, const char *tls_creds,
+ Error **errp);
+
#endif
diff --git a/include/io/channel-socket.h b/include/io/channel-socket.h
index c1aaa72a5d..53801f6042 100644
--- a/include/io/channel-socket.h
+++ b/include/io/channel-socket.h
@@ -91,7 +91,7 @@ qio_channel_socket_new_fd(int fd,
* an error occurs.
*/
int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
- SocketAddressLegacy *addr,
+ SocketAddress *addr,
Error **errp);
/**
@@ -110,7 +110,7 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
* as this function returns without waiting for completion.
*/
void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
- SocketAddressLegacy *addr,
+ SocketAddress *addr,
QIOTaskFunc callback,
gpointer opaque,
GDestroyNotify destroy);
@@ -128,7 +128,7 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
* an error occurs.
*/
int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
- SocketAddressLegacy *addr,
+ SocketAddress *addr,
Error **errp);
/**
@@ -147,7 +147,7 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
* as this function returns without waiting for completion.
*/
void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
- SocketAddressLegacy *addr,
+ SocketAddress *addr,
QIOTaskFunc callback,
gpointer opaque,
GDestroyNotify destroy);
@@ -167,8 +167,8 @@ void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
* is established or an error occurs.
*/
int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
- SocketAddressLegacy *localAddr,
- SocketAddressLegacy *remoteAddr,
+ SocketAddress *localAddr,
+ SocketAddress *remoteAddr,
Error **errp);
/**
@@ -190,8 +190,8 @@ int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
* waiting for completion.
*/
void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
- SocketAddressLegacy *localAddr,
- SocketAddressLegacy *remoteAddr,
+ SocketAddress *localAddr,
+ SocketAddress *remoteAddr,
QIOTaskFunc callback,
gpointer opaque,
GDestroyNotify destroy);
@@ -205,12 +205,12 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
* 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: 0 on success, -1 on error
*/
-SocketAddressLegacy *
+SocketAddress *
qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
Error **errp);
@@ -222,12 +222,12 @@ qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
* 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 *
+SocketAddress *
qio_channel_socket_get_remote_address(QIOChannelSocket *ioc,
Error **errp);
diff --git a/include/io/dns-resolver.h b/include/io/dns-resolver.h
index aac46cadea..2f69c08c13 100644
--- a/include/io/dns-resolver.h
+++ b/include/io/dns-resolver.h
@@ -40,15 +40,15 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
* QIODNSResolver:
*
* The QIODNSResolver class provides a framework for doing
- * DNS resolution on SocketAddressLegacy objects, independently
+ * DNS resolution on SocketAddress objects, independently
* of socket creation.
*
* <example>
* <title>Resolving addresses synchronously</title>
* <programlisting>
- * int mylisten(SocketAddressLegacy *addr, Error **errp) {
+ * int mylisten(SocketAddress *addr, Error **errp) {
* QIODNSResolver *resolver = qio_dns_resolver_get_instance();
- * SocketAddressLegacy **rawaddrs = NULL;
+ * SocketAddress **rawaddrs = NULL;
* size_t nrawaddrs = 0;
* Error *err = NULL;
* QIOChannel **socks = NULL;
@@ -69,7 +69,7 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
* socks = g_renew(QIOChannelSocket *, socks, nsocks + 1);
* socks[nsocks++] = sock;
* }
- * qapi_free_SocketAddressLegacy(rawaddrs[i]);
+ * qapi_free_SocketAddress(rawaddrs[i]);
* }
* g_free(rawaddrs);
*
@@ -95,7 +95,7 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
* MyListenData *data = opaque;
* QIODNSResolver *resolver =
* QIO_DNS_RESOLVER(qio_task_get_source(task);
- * SocketAddressLegacy **rawaddrs = NULL;
+ * SocketAddress **rawaddrs = NULL;
* size_t nrawaddrs = 0;
* Error *err = NULL;
*
@@ -116,7 +116,7 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
* socks = g_renew(QIOChannelSocket *, socks, nsocks + 1);
* socks[nsocks++] = sock;
* }
- * qapi_free_SocketAddressLegacy(rawaddrs[i]);
+ * qapi_free_SocketAddress(rawaddrs[i]);
* }
* g_free(rawaddrs);
*
@@ -127,7 +127,7 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
* }
* }
*
- * void mylisten(SocketAddressLegacy *addr, MyListenData *data) {
+ * void mylisten(SocketAddress *addr, MyListenData *data) {
* QIODNSResolver *resolver = qio_dns_resolver_get_instance();
* qio_dns_resolver_lookup_async(dns, addr,
* mylistenresult, data, NULL);
@@ -177,9 +177,9 @@ QIODNSResolver *qio_dns_resolver_get_instance(void);
* Returns: 0 if resolution was successful, -1 on error
*/
int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
- SocketAddressLegacy *addr,
+ SocketAddress *addr,
size_t *naddrs,
- SocketAddressLegacy ***addrs,
+ SocketAddress ***addrs,
Error **errp);
/**
@@ -201,7 +201,7 @@ int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
* of the caller will not be blocked.
*/
void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
- SocketAddressLegacy *addr,
+ SocketAddress *addr,
QIOTaskFunc func,
gpointer opaque,
GDestroyNotify notify);
@@ -223,6 +223,6 @@ void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
void qio_dns_resolver_lookup_result(QIODNSResolver *resolver,
QIOTask *task,
size_t *naddrs,
- SocketAddressLegacy ***addrs);
+ SocketAddress ***addrs);
#endif /* QIO_DNS_RESOLVER_H */
diff --git a/include/io/task.h b/include/io/task.h
index f65ec7aca3..6021f51336 100644
--- a/include/io/task.h
+++ b/include/io/task.h
@@ -166,7 +166,7 @@ typedef void (*QIOTaskWorker)(QIOTask *task,
* gpointer opaque)
* {
* QMyObject obj = QMY_OBJECT(qio_task_get_source(task));
- * SocketAddressLegacy *addr = opaque;
+ * SocketAddress *addr = opaque;
* Error *err = NULL;
*
* obj->fd = socket_listen(addr, &err);
@@ -175,20 +175,20 @@ typedef void (*QIOTaskWorker)(QIOTask *task,
* }
*
* void myobject_listen_async(QMyObject *obj,
- * SocketAddressLegacy *addr,
+ * SocketAddress *addr,
* QIOTaskFunc *func,
* gpointer opaque,
* GDestroyNotify notify)
* {
* QIOTask *task;
- * SocketAddressLegacy *addrCopy;
+ * SocketAddress *addrCopy;
*
- * addrCopy = QAPI_CLONE(SocketAddressLegacy, addr);
+ * addrCopy = QAPI_CLONE(SocketAddress, addr);
* task = qio_task_new(OBJECT(obj), func, opaque, notify);
*
* qio_task_run_in_thread(task, myobject_listen_worker,
* addrCopy,
- * qapi_free_SocketAddressLegacy);
+ * qapi_free_SocketAddress);
* }
* </example>
*
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 */