int net_init_slirp(const Netdev *netdev, const char *name,

                   NetClientState *peer, Error **errp)

{

    /* FIXME error_setg(errp, ...) on failure */

    struct slirp_config_str *config;

    char *vnet;

    int ret;

    const NetdevUserOptions *user;

    const char **dnssearch;

    bool ipv4 = true, ipv6 = true;



    assert(netdev->type == NET_CLIENT_DRIVER_USER);

    user = &netdev->u.user;



    if ((user->has_ipv6 && user->ipv6 && !user->has_ipv4) ||

        (user->has_ipv4 && !user->ipv4)) {

        ipv4 = 0;

    }

    if ((user->has_ipv4 && user->ipv4 && !user->has_ipv6) ||

        (user->has_ipv6 && !user->ipv6)) {

        ipv6 = 0;

    }



    vnet = user->has_net ? g_strdup(user->net) :

           user->has_ip  ? g_strdup_printf("%s/24", user->ip) :

           NULL;



    dnssearch = slirp_dnssearch(user->dnssearch);



    /* all optional fields are initialized to "all bits zero" */



    net_init_slirp_configs(user->hostfwd, SLIRP_CFG_HOSTFWD);

    net_init_slirp_configs(user->guestfwd, 0);



    ret = net_slirp_init(peer, "user", name, user->q_restrict,

                         ipv4, vnet, user->host,

                         ipv6, user->ipv6_prefix, user->ipv6_prefixlen,

                         user->ipv6_host, user->hostname, user->tftp,

                         user->bootfile, user->dhcpstart,

                         user->dns, user->ipv6_dns, user->smb,

                         user->smbserver, dnssearch);



    while (slirp_configs) {

        config = slirp_configs;

        slirp_configs = config->next;

        g_free(config);

    }



    g_free(vnet);

    g_free(dnssearch);



    return ret;

}

int net_init_slirp(const Netdev *netdev, const char *name,

                   NetClientState *peer, Error **errp)

{

    

    struct slirp_config_str *config;

    char *vnet;

    int ret;

    const NetdevUserOptions *user;

    const char **dnssearch;

    bool ipv4 = true, ipv6 = true;



    assert(netdev->type == NET_CLIENT_DRIVER_USER);

    user = &netdev->u.user;



    if ((user->has_ipv6 && user->ipv6 && !user->has_ipv4) ||

        (user->has_ipv4 && !user->ipv4)) {

        ipv4 = 0;

    }

    if ((user->has_ipv4 && user->ipv4 && !user->has_ipv6) ||

        (user->has_ipv6 && !user->ipv6)) {

        ipv6 = 0;

    }



    vnet = user->has_net ? g_strdup(user->net) :

           user->has_ip  ? g_strdup_printf("%s/24", user->ip) :

           NULL;



    dnssearch = slirp_dnssearch(user->dnssearch);



    



    net_init_slirp_configs(user->hostfwd, SLIRP_CFG_HOSTFWD);

    net_init_slirp_configs(user->guestfwd, 0);



    ret = net_slirp_init(peer, "user", name, user->q_restrict,

                         ipv4, vnet, user->host,

                         ipv6, user->ipv6_prefix, user->ipv6_prefixlen,

                         user->ipv6_host, user->hostname, user->tftp,

                         user->bootfile, user->dhcpstart,

                         user->dns, user->ipv6_dns, user->smb,

                         user->smbserver, dnssearch);



    while (slirp_configs) {

        config = slirp_configs;

        slirp_configs = config->next;

        g_free(config);

    }



    g_free(vnet);

    g_free(dnssearch);



    return ret;

}

                         user->smbserver, dnssearch);
int FUNC_0(const Netdev *VAR_0, const char *VAR_1,

                   NetClientState *VAR_2, Error **VAR_3)

{

    

    struct slirp_config_str *VAR_4;

    char *VAR_5;

    int VAR_6;

    const NetdevUserOptions *VAR_7;

    const char **VAR_8;

    bool ipv4 = true, ipv6 = true;



    assert(VAR_0->type == NET_CLIENT_DRIVER_USER);

    VAR_7 = &VAR_0->u.VAR_7;



    if ((VAR_7->has_ipv6 && VAR_7->ipv6 && !VAR_7->has_ipv4) ||

        (VAR_7->has_ipv4 && !VAR_7->ipv4)) {

        ipv4 = 0;

    }

    if ((VAR_7->has_ipv4 && VAR_7->ipv4 && !VAR_7->has_ipv6) ||

        (VAR_7->has_ipv6 && !VAR_7->ipv6)) {

        ipv6 = 0;

    }



    VAR_5 = VAR_7->has_net ? g_strdup(VAR_7->net) :

           VAR_7->has_ip  ? g_strdup_printf("%s/24", VAR_7->ip) :

           NULL;



    VAR_8 = slirp_dnssearch(VAR_7->VAR_8);



    



    net_init_slirp_configs(VAR_7->hostfwd, SLIRP_CFG_HOSTFWD);

    net_init_slirp_configs(VAR_7->guestfwd, 0);



    VAR_6 = net_slirp_init(VAR_2, "VAR_7", VAR_1, VAR_7->q_restrict,

                         ipv4, VAR_5, VAR_7->host,

                         ipv6, VAR_7->ipv6_prefix, VAR_7->ipv6_prefixlen,

                         VAR_7->ipv6_host, VAR_7->hostname, VAR_7->tftp,

                         VAR_7->bootfile, VAR_7->dhcpstart,

                         VAR_7->dns, VAR_7->ipv6_dns, VAR_7->smb,

                         VAR_7->smbserver, VAR_8);



    while (slirp_configs) {

        VAR_4 = slirp_configs;

        slirp_configs = VAR_4->next;

        g_free(VAR_4);

    }



    g_free(VAR_5);

    g_free(VAR_8);



    return VAR_6;

}

int FUNC_0(const Netdev *VAR_0, const char *VAR_1,
NetClientState *VAR_2, Error **VAR_3)
{ struct slirp_config_str *VAR_4; char *VAR_5; int VAR_6; const NetdevUserOptions *VAR_7; const char **VAR_8; bool ipv4 = true, ipv6 = true; assert(VAR_0->type == NET_CLIENT_DRIVER_USER); VAR_7 = &VAR_0->u.VAR_7; if ((VAR_7->has_ipv6 && VAR_7->ipv6 && !VAR_7->has_ipv4) ||
(VAR_7->has_ipv4 && !VAR_7->ipv4)) { ipv4 = 0; } if ((VAR_7->has_ipv4 && VAR_7->ipv4 && !VAR_7->has_ipv6) ||
(VAR_7->has_ipv6 && !VAR_7->ipv6)) { ipv6 = 0; } VAR_5 = VAR_7->has_net ? g_strdup(VAR_7->net) :
VAR_7->has_ip  ? g_strdup_printf("%s/24", VAR_7->ip) :
NULL; VAR_8 = slirp_dnssearch(VAR_7->VAR_8); net_init_slirp_configs(VAR_7->hostfwd, SLIRP_CFG_HOSTFWD); net_init_slirp_configs(VAR_7->guestfwd, 0); VAR_6 = net_slirp_init(VAR_2, "VAR_7", VAR_1, VAR_7->q_restrict,
ipv4, VAR_5, VAR_7->host,
ipv6, VAR_7->ipv6_prefix, VAR_7->ipv6_prefixlen,
VAR_7->ipv6_host, VAR_7->hostname, VAR_7->tftp,
VAR_7->bootfile, VAR_7->dhcpstart,
VAR_7->dns, VAR_7->ipv6_dns, VAR_7->smb,
VAR_7->smbserver, VAR_8); while (slirp_configs) { VAR_4 = slirp_configs; slirp_configs = VAR_4->next; g_free(VAR_4); } g_free(VAR_5); g_free(VAR_8); return VAR_6; }