socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,

                                socklen_t salen,

                                Error **errp)

{

    char host[NI_MAXHOST];

    char serv[NI_MAXSERV];

    SocketAddressLegacy *addr;

    InetSocketAddress *inet;

    int ret;



    ret = getnameinfo((struct sockaddr *)sa, salen,

                      host, sizeof(host),

                      serv, sizeof(serv),

                      NI_NUMERICHOST | NI_NUMERICSERV);

    if (ret != 0) {

        error_setg(errp, "Cannot format numeric socket address: %s",

                   gai_strerror(ret));

        return NULL;

    }



    addr = g_new0(SocketAddressLegacy, 1);

    addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;

    inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);

    inet->host = g_strdup(host);

    inet->port = g_strdup(serv);

    if (sa->ss_family == AF_INET) {

        inet->has_ipv4 = inet->ipv4 = true;

    } else {

        inet->has_ipv6 = inet->ipv6 = true;

    }



    return addr;

}

socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,

                                socklen_t salen,

                                Error **errp)

{

    char host[NI_MAXHOST];

    char serv[NI_MAXSERV];

    SocketAddressLegacy *addr;

    InetSocketAddress *inet;

    int ret;



    ret = getnameinfo((struct sockaddr *)sa, salen,

                      host, sizeof(host),

                      serv, sizeof(serv),

                      NI_NUMERICHOST | NI_NUMERICSERV);

    if (ret != 0) {

        error_setg(errp, "Cannot format numeric socket address: %s",

                   gai_strerror(ret));

        return NULL;

    }



    addr = g_new0(SocketAddressLegacy, 1);

    addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;

    inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);

    inet->host = g_strdup(host);

    inet->port = g_strdup(serv);

    if (sa->ss_family == AF_INET) {

        inet->has_ipv4 = inet->ipv4 = true;

    } else {

        inet->has_ipv6 = inet->ipv6 = true;

    }



    return addr;

}

FUNC_0(struct sockaddr_storage *VAR_0,

                                socklen_t VAR_1,

                                Error **VAR_2)

{

    char VAR_3[NI_MAXHOST];

    char VAR_4[NI_MAXSERV];

    SocketAddressLegacy *addr;

    InetSocketAddress *inet;

    int VAR_5;



    VAR_5 = getnameinfo((struct sockaddr *)VAR_0, VAR_1,

                      VAR_3, sizeof(VAR_3),

                      VAR_4, sizeof(VAR_4),

                      NI_NUMERICHOST | NI_NUMERICSERV);

    if (VAR_5 != 0) {

        error_setg(VAR_2, "Cannot format numeric socket address: %s",

                   gai_strerror(VAR_5));

        return NULL;

    }



    addr = g_new0(SocketAddressLegacy, 1);

    addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;

    inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);

    inet->VAR_3 = g_strdup(VAR_3);

    inet->port = g_strdup(VAR_4);

    if (VAR_0->ss_family == AF_INET) {

        inet->has_ipv4 = inet->ipv4 = true;

    } else {

        inet->has_ipv6 = inet->ipv6 = true;

    }



    return addr;

}

FUNC_0(struct sockaddr_storage *VAR_0,
socklen_t VAR_1,
Error **VAR_2)
{ char VAR_3[NI_MAXHOST]; char VAR_4[NI_MAXSERV]; SocketAddressLegacy *addr; InetSocketAddress *inet; int VAR_5; VAR_5 = getnameinfo((struct sockaddr *)VAR_0, VAR_1,
VAR_3, sizeof(VAR_3),
VAR_4, sizeof(VAR_4),
NI_NUMERICHOST | NI_NUMERICSERV); if (VAR_5 != 0) { error_setg(VAR_2, "Cannot format numeric socket address: %s",
gai_strerror(VAR_5)); return NULL; } addr = g_new0(SocketAddressLegacy, 1); addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET; inet = addr->u.inet.data = g_new0(InetSocketAddress, 1); inet->VAR_3 = g_strdup(VAR_3); inet->port = g_strdup(VAR_4); if (VAR_0->ss_family == AF_INET) { inet->has_ipv4 = inet->ipv4 = true; } else { inet->has_ipv6 = inet->ipv6 = true; } return addr; }