]> git.proxmox.com Git - mirror_qemu.git/blobdiff - io/dns-resolver.c
target/loongarch: Implement vexth
[mirror_qemu.git] / io / dns-resolver.c
index 759d1b40d77b9896ca8e03168a35f767af96e85f..53b0e8407a97ea8154fed19e9533ead7c3d7d93e 100644 (file)
@@ -6,7 +6,7 @@
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include "qemu/osdep.h"
 #include "io/dns-resolver.h"
 #include "qapi/clone-visitor.h"
+#include "qapi/qapi-visit-sockets.h"
 #include "qemu/sockets.h"
 #include "qapi/error.h"
 #include "qemu/cutils.h"
+#include "qemu/module.h"
 
 #ifndef AI_NUMERICSERV
 # define AI_NUMERICSERV 0
@@ -51,7 +53,7 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
                                              Error **errp)
 {
     struct addrinfo ai, *res, *e;
-    InetSocketAddress *iaddr = addr->u.inet.data;
+    InetSocketAddress *iaddr = &addr->u.inet;
     char port[33];
     char uaddr[INET6_ADDRSTRLEN + 1];
     char uport[33];
@@ -102,23 +104,28 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
     /* create socket + bind */
     for (i = 0, e = res; e != NULL; i++, e = e->ai_next) {
         SocketAddress *newaddr = g_new0(SocketAddress, 1);
-        InetSocketAddress *newiaddr = g_new0(InetSocketAddress, 1);
-        newaddr->u.inet.data = newiaddr;
-        newaddr->type = SOCKET_ADDRESS_KIND_INET;
+
+        newaddr->type = SOCKET_ADDRESS_TYPE_INET;
 
         getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen,
                     uaddr, INET6_ADDRSTRLEN, uport, 32,
                     NI_NUMERICHOST | NI_NUMERICSERV);
 
-        *newiaddr = (InetSocketAddress){
+        newaddr->u.inet = (InetSocketAddress){
             .host = g_strdup(uaddr),
             .port = g_strdup(uport),
             .has_numeric = true,
             .numeric = true,
             .has_to = iaddr->has_to,
             .to = iaddr->to,
-            .has_ipv4 = false,
-            .has_ipv6 = false,
+            .has_ipv4 = iaddr->has_ipv4,
+            .ipv4 = iaddr->ipv4,
+            .has_ipv6 = iaddr->has_ipv6,
+            .ipv6 = iaddr->ipv6,
+#ifdef HAVE_IPPROTO_MPTCP
+            .has_mptcp = iaddr->has_mptcp,
+            .mptcp = iaddr->mptcp,
+#endif
         };
 
         (*addrs)[i] = newaddr;
@@ -149,16 +156,16 @@ int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
                                  Error **errp)
 {
     switch (addr->type) {
-    case SOCKET_ADDRESS_KIND_INET:
+    case SOCKET_ADDRESS_TYPE_INET:
         return qio_dns_resolver_lookup_sync_inet(resolver,
                                                  addr,
                                                  naddrs,
                                                  addrs,
                                                  errp);
 
-    case SOCKET_ADDRESS_KIND_UNIX:
-    case SOCKET_ADDRESS_KIND_VSOCK:
-    case SOCKET_ADDRESS_KIND_FD:
+    case SOCKET_ADDRESS_TYPE_UNIX:
+    case SOCKET_ADDRESS_TYPE_VSOCK:
+    case SOCKET_ADDRESS_TYPE_FD:
         return qio_dns_resolver_lookup_sync_nop(resolver,
                                                 addr,
                                                 naddrs,
@@ -232,7 +239,8 @@ void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
     qio_task_run_in_thread(task,
                            qio_dns_resolver_lookup_worker,
                            data,
-                           qio_dns_resolver_lookup_data_free);
+                           qio_dns_resolver_lookup_data_free,
+                           NULL);
 }
 
 
@@ -263,7 +271,6 @@ static const TypeInfo qio_dns_resolver_info = {
     .parent = TYPE_OBJECT,
     .name = TYPE_QIO_DNS_RESOLVER,
     .instance_size = sizeof(QIODNSResolver),
-    .class_size = sizeof(QIODNSResolverClass),
 };