static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,

                                             SocketAddress *addr,

                                             size_t *naddrs,

                                             SocketAddress ***addrs,

                                             Error **errp)

{

    struct addrinfo ai, *res, *e;

    InetSocketAddress *iaddr = addr->u.inet.data;

    char port[33];

    char uaddr[INET6_ADDRSTRLEN + 1];

    char uport[33];

    int rc;

    Error *err = NULL;

    size_t i;



    *naddrs = 0;

    *addrs = NULL;



    memset(&ai, 0, sizeof(ai));

    ai.ai_flags = AI_PASSIVE;

    if (iaddr->has_numeric && iaddr->numeric) {

        ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;

    }

    ai.ai_family = inet_ai_family_from_address(iaddr, &err);

    ai.ai_socktype = SOCK_STREAM;



    if (err) {

        error_propagate(errp, err);

        return -1;

    }



    if (iaddr->host == NULL) {

        error_setg(errp, "host not specified");

        return -1;

    }

    if (iaddr->port != NULL) {

        pstrcpy(port, sizeof(port), iaddr->port);

    } else {

        port[0] = '\0';

    }



    rc = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL,

                     strlen(port) ? port : NULL, &ai, &res);

    if (rc != 0) {

        error_setg(errp, "address resolution failed for %s:%s: %s",

                   iaddr->host, port, gai_strerror(rc));

        return -1;

    }



    for (e = res; e != NULL; e = e->ai_next) {

        (*naddrs)++;

    }



    *addrs = g_new0(SocketAddress *, *naddrs);



    /* 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;



        getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen,

                    uaddr, INET6_ADDRSTRLEN, uport, 32,

                    NI_NUMERICHOST | NI_NUMERICSERV);



        *newiaddr = (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,

        };



        (*addrs)[i] = newaddr;

    }

    freeaddrinfo(res);

    return 0;

}

static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,

                                             SocketAddress *addr,

                                             size_t *naddrs,

                                             SocketAddress ***addrs,

                                             Error **errp)

{

    struct addrinfo ai, *res, *e;

    InetSocketAddress *iaddr = addr->u.inet.data;

    char port[33];

    char uaddr[INET6_ADDRSTRLEN + 1];

    char uport[33];

    int rc;

    Error *err = NULL;

    size_t i;



    *naddrs = 0;

    *addrs = NULL;



    memset(&ai, 0, sizeof(ai));

    ai.ai_flags = AI_PASSIVE;

    if (iaddr->has_numeric && iaddr->numeric) {

        ai.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;

    }

    ai.ai_family = inet_ai_family_from_address(iaddr, &err);

    ai.ai_socktype = SOCK_STREAM;



    if (err) {

        error_propagate(errp, err);

        return -1;

    }



    if (iaddr->host == NULL) {

        error_setg(errp, "host not specified");

        return -1;

    }

    if (iaddr->port != NULL) {

        pstrcpy(port, sizeof(port), iaddr->port);

    } else {

        port[0] = '\0';

    }



    rc = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL,

                     strlen(port) ? port : NULL, &ai, &res);

    if (rc != 0) {

        error_setg(errp, "address resolution failed for %s:%s: %s",

                   iaddr->host, port, gai_strerror(rc));

        return -1;

    }



    for (e = res; e != NULL; e = e->ai_next) {

        (*naddrs)++;

    }



    *addrs = g_new0(SocketAddress *, *naddrs);



    

    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;



        getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen,

                    uaddr, INET6_ADDRSTRLEN, uport, 32,

                    NI_NUMERICHOST | NI_NUMERICSERV);



        *newiaddr = (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,

        };



        (*addrs)[i] = newaddr;

    }

    freeaddrinfo(res);

    return 0;

}

static int FUNC_0(QIODNSResolver *VAR_0,

                                             SocketAddress *VAR_1,

                                             size_t *VAR_2,

                                             SocketAddress ***VAR_3,

                                             Error **VAR_4)

{

    struct addrinfo VAR_5, *VAR_6, *VAR_7;

    InetSocketAddress *iaddr = VAR_1->u.inet.data;

    char VAR_8[33];

    char VAR_9[INET6_ADDRSTRLEN + 1];

    char VAR_10[33];

    int VAR_11;

    Error *err = NULL;

    size_t i;



    *VAR_2 = 0;

    *VAR_3 = NULL;



    memset(&VAR_5, 0, sizeof(VAR_5));

    VAR_5.ai_flags = AI_PASSIVE;

    if (iaddr->has_numeric && iaddr->numeric) {

        VAR_5.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV;

    }

    VAR_5.ai_family = inet_ai_family_from_address(iaddr, &err);

    VAR_5.ai_socktype = SOCK_STREAM;



    if (err) {

        error_propagate(VAR_4, err);

        return -1;

    }



    if (iaddr->host == NULL) {

        error_setg(VAR_4, "host not specified");

        return -1;

    }

    if (iaddr->VAR_8 != NULL) {

        pstrcpy(VAR_8, sizeof(VAR_8), iaddr->VAR_8);

    } else {

        VAR_8[0] = '\0';

    }



    VAR_11 = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL,

                     strlen(VAR_8) ? VAR_8 : NULL, &VAR_5, &VAR_6);

    if (VAR_11 != 0) {

        error_setg(VAR_4, "address resolution failed for %s:%s: %s",

                   iaddr->host, VAR_8, gai_strerror(VAR_11));

        return -1;

    }



    for (VAR_7 = VAR_6; VAR_7 != NULL; VAR_7 = VAR_7->ai_next) {

        (*VAR_2)++;

    }



    *VAR_3 = g_new0(SocketAddress *, *VAR_2);



    

    for (i = 0, VAR_7 = VAR_6; VAR_7 != NULL; i++, VAR_7 = VAR_7->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;



        getnameinfo((struct sockaddr *)VAR_7->ai_addr, VAR_7->ai_addrlen,

                    VAR_9, INET6_ADDRSTRLEN, VAR_10, 32,

                    NI_NUMERICHOST | NI_NUMERICSERV);



        *newiaddr = (InetSocketAddress){

            .host = g_strdup(VAR_9),

            .VAR_8 = g_strdup(VAR_10),

            .has_numeric = true,

            .numeric = true,

            .has_to = iaddr->has_to,

            .to = iaddr->to,

            .has_ipv4 = false,

            .has_ipv6 = false,

        };



        (*VAR_3)[i] = newaddr;

    }

    freeaddrinfo(VAR_6);

    return 0;

}

static int FUNC_0(QIODNSResolver *VAR_0,
SocketAddress *VAR_1,
size_t *VAR_2,
SocketAddress ***VAR_3,
Error **VAR_4)
{ struct addrinfo VAR_5, *VAR_6, *VAR_7; InetSocketAddress *iaddr = VAR_1->u.inet.data; char VAR_8[33]; char VAR_9[INET6_ADDRSTRLEN + 1]; char VAR_10[33]; int VAR_11; Error *err = NULL; size_t i; *VAR_2 = 0; *VAR_3 = NULL; memset(&VAR_5, 0, sizeof(VAR_5)); VAR_5.ai_flags = AI_PASSIVE; if (iaddr->has_numeric && iaddr->numeric) { VAR_5.ai_flags |= AI_NUMERICHOST | AI_NUMERICSERV; } VAR_5.ai_family = inet_ai_family_from_address(iaddr, &err); VAR_5.ai_socktype = SOCK_STREAM; if (err) { error_propagate(VAR_4, err); return -1; } if (iaddr->host == NULL) { error_setg(VAR_4, "host not specified"); return -1; } if (iaddr->VAR_8 != NULL) { pstrcpy(VAR_8, sizeof(VAR_8), iaddr->VAR_8); } else { VAR_8[0] = '\0'; } VAR_11 = getaddrinfo(strlen(iaddr->host) ? iaddr->host : NULL,
strlen(VAR_8) ? VAR_8 : NULL, &VAR_5, &VAR_6); if (VAR_11 != 0) { error_setg(VAR_4, "address resolution failed for %s:%s: %s",
iaddr->host, VAR_8, gai_strerror(VAR_11)); return -1; } for (VAR_7 = VAR_6; VAR_7 != NULL; VAR_7 = VAR_7->ai_next) { (*VAR_2)++; } *VAR_3 = g_new0(SocketAddress *, *VAR_2); for (i = 0, VAR_7 = VAR_6; VAR_7 != NULL; i++, VAR_7 = VAR_7->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; getnameinfo((struct sockaddr *)VAR_7->ai_addr, VAR_7->ai_addrlen,
VAR_9, INET6_ADDRSTRLEN, VAR_10, 32,
NI_NUMERICHOST | NI_NUMERICSERV); *newiaddr = (InetSocketAddress){ .host = g_strdup(VAR_9),
.VAR_8 = g_strdup(VAR_10),
.has_numeric = true,
.numeric = true,
.has_to = iaddr->has_to,
.to = iaddr->to,
.has_ipv4 = false,
.has_ipv6 = false,
}; (*VAR_3)[i] = newaddr; } freeaddrinfo(VAR_6); return 0; }