static int net_client_init(const char *str)

{

    const char *p;

    char *q;

    char device[64];

    char buf[1024];

    int vlan_id, ret;

    VLANState *vlan;



    p = str;

    q = device;

    while (*p != '\0' && *p != ',') {

        if ((q - device) < sizeof(device) - 1)

            *q++ = *p;

        p++;

    }

    *q = '\0';

    if (*p == ',')

        p++;

    vlan_id = 0;

    if (get_param_value(buf, sizeof(buf), "vlan", p)) {

        vlan_id = strtol(buf, NULL, 0);

    }

    vlan = qemu_find_vlan(vlan_id);

    if (!vlan) {

        fprintf(stderr, "Could not create vlan %d\n", vlan_id);

        return -1;

    }

    if (!strcmp(device, "nic")) {

        NICInfo *nd;

        uint8_t *macaddr;



        if (nb_nics >= MAX_NICS) {

            fprintf(stderr, "Too Many NICs\n");

            return -1;

        }

        nd = &nd_table[nb_nics];

        macaddr = nd->macaddr;

        macaddr[0] = 0x52;

        macaddr[1] = 0x54;

        macaddr[2] = 0x00;

        macaddr[3] = 0x12;

        macaddr[4] = 0x34;

        macaddr[5] = 0x56 + nb_nics;



        if (get_param_value(buf, sizeof(buf), "macaddr", p)) {

            if (parse_macaddr(macaddr, buf) < 0) {

                fprintf(stderr, "invalid syntax for ethernet address\n");

                return -1;

            }

        }

        if (get_param_value(buf, sizeof(buf), "model", p)) {

            nd->model = strdup(buf);

        }

        nd->vlan = vlan;

        nb_nics++;

        vlan->nb_guest_devs++;

        ret = 0;

    } else

    if (!strcmp(device, "none")) {

        /* does nothing. It is needed to signal that no network cards

           are wanted */

        ret = 0;

    } else

#ifdef CONFIG_SLIRP

    if (!strcmp(device, "user")) {

        if (get_param_value(buf, sizeof(buf), "hostname", p)) {

            pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf);

        }


        ret = net_slirp_init(vlan);

    } else

#endif

#ifdef _WIN32

    if (!strcmp(device, "tap")) {

        char ifname[64];

        if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {

            fprintf(stderr, "tap: no interface name\n");

            return -1;

        }


        ret = tap_win32_init(vlan, ifname);

    } else

#else

    if (!strcmp(device, "tap")) {

        char ifname[64];

        char setup_script[1024];

        int fd;

        if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {

            fd = strtol(buf, NULL, 0);

            ret = -1;

            if (net_tap_fd_init(vlan, fd))

                ret = 0;

        } else {

            if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {

                ifname[0] = '\0';

            }

            if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) {

                pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT);

            }


            ret = net_tap_init(vlan, ifname, setup_script);

        }

    } else

#endif

    if (!strcmp(device, "socket")) {

        if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {

            int fd;

            fd = strtol(buf, NULL, 0);

            ret = -1;

            if (net_socket_fd_init(vlan, fd, 1))

                ret = 0;

        } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) {

            ret = net_socket_listen_init(vlan, buf);

        } else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) {

            ret = net_socket_connect_init(vlan, buf);

        } else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) {

            ret = net_socket_mcast_init(vlan, buf);

        } else {

            fprintf(stderr, "Unknown socket options: %s\n", p);

            return -1;

        }


    } else

    {

        fprintf(stderr, "Unknown network device: %s\n", device);

        return -1;

    }

    if (ret < 0) {

        fprintf(stderr, "Could not initialize device '%s'\n", device);

    }

    

    return ret;

}
static int net_client_init(const char *str)

{

    const char *p;

    char *q;

    char device[64];

    char buf[1024];

    int vlan_id, ret;

    VLANState *vlan;



    p = str;

    q = device;

    while (*p != '\0' && *p != ',') {

        if ((q - device) < sizeof(device) - 1)

            *q++ = *p;

        p++;

    }

    *q = '\0';

    if (*p == ',')

        p++;

    vlan_id = 0;

    if (get_param_value(buf, sizeof(buf), "vlan", p)) {

        vlan_id = strtol(buf, NULL, 0);

    }

    vlan = qemu_find_vlan(vlan_id);

    if (!vlan) {

        fprintf(stderr, "Could not create vlan %d\n", vlan_id);

        return -1;

    }

    if (!strcmp(device, "nic")) {

        NICInfo *nd;

        uint8_t *macaddr;



        if (nb_nics >= MAX_NICS) {

            fprintf(stderr, "Too Many NICs\n");

            return -1;

        }

        nd = &nd_table[nb_nics];

        macaddr = nd->macaddr;

        macaddr[0] = 0x52;

        macaddr[1] = 0x54;

        macaddr[2] = 0x00;

        macaddr[3] = 0x12;

        macaddr[4] = 0x34;

        macaddr[5] = 0x56 + nb_nics;



        if (get_param_value(buf, sizeof(buf), "macaddr", p)) {

            if (parse_macaddr(macaddr, buf) < 0) {

                fprintf(stderr, "invalid syntax for ethernet address\n");

                return -1;

            }

        }

        if (get_param_value(buf, sizeof(buf), "model", p)) {

            nd->model = strdup(buf);

        }

        nd->vlan = vlan;

        nb_nics++;

        vlan->nb_guest_devs++;

        ret = 0;

    } else

    if (!strcmp(device, "none")) {

        



        ret = 0;

    } else

#ifdef CONFIG_SLIRP

    if (!strcmp(device, "user")) {

        if (get_param_value(buf, sizeof(buf), "hostname", p)) {

            pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf);

        }


        ret = net_slirp_init(vlan);

    } else

#endif

#ifdef _WIN32

    if (!strcmp(device, "tap")) {

        char ifname[64];

        if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {

            fprintf(stderr, "tap: no interface name\n");

            return -1;

        }


        ret = tap_win32_init(vlan, ifname);

    } else

#else

    if (!strcmp(device, "tap")) {

        char ifname[64];

        char setup_script[1024];

        int fd;

        if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {

            fd = strtol(buf, NULL, 0);

            ret = -1;

            if (net_tap_fd_init(vlan, fd))

                ret = 0;

        } else {

            if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) {

                ifname[0] = '\0';

            }

            if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) {

                pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT);

            }


            ret = net_tap_init(vlan, ifname, setup_script);

        }

    } else

#endif

    if (!strcmp(device, "socket")) {

        if (get_param_value(buf, sizeof(buf), "fd", p) > 0) {

            int fd;

            fd = strtol(buf, NULL, 0);

            ret = -1;

            if (net_socket_fd_init(vlan, fd, 1))

                ret = 0;

        } else if (get_param_value(buf, sizeof(buf), "listen", p) > 0) {

            ret = net_socket_listen_init(vlan, buf);

        } else if (get_param_value(buf, sizeof(buf), "connect", p) > 0) {

            ret = net_socket_connect_init(vlan, buf);

        } else if (get_param_value(buf, sizeof(buf), "mcast", p) > 0) {

            ret = net_socket_mcast_init(vlan, buf);

        } else {

            fprintf(stderr, "Unknown socket options: %s\n", p);

            return -1;

        }


    } else

    {

        fprintf(stderr, "Unknown network device: %s\n", device);

        return -1;

    }

    if (ret < 0) {

        fprintf(stderr, "Could not initialize device '%s'\n", device);

    }

    

    return ret;

}
static int FUNC_0(const char *VAR_0)

{

    const char *VAR_1;

    char *VAR_2;

    char VAR_3[64];

    char VAR_4[1024];

    int VAR_5, VAR_6;

    VLANState *vlan;



    VAR_1 = VAR_0;

    VAR_2 = VAR_3;

    while (*VAR_1 != '\0' && *VAR_1 != ',') {

        if ((VAR_2 - VAR_3) < sizeof(VAR_3) - 1)

            *VAR_2++ = *VAR_1;

        VAR_1++;

    }

    *VAR_2 = '\0';

    if (*VAR_1 == ',')

        VAR_1++;

    VAR_5 = 0;

    if (get_param_value(VAR_4, sizeof(VAR_4), "vlan", VAR_1)) {

        VAR_5 = strtol(VAR_4, NULL, 0);

    }

    vlan = qemu_find_vlan(VAR_5);

    if (!vlan) {

        fprintf(stderr, "Could not create vlan %d\n", VAR_5);

        return -1;

    }

    if (!strcmp(VAR_3, "nic")) {

        NICInfo *nd;

        uint8_t *macaddr;



        if (nb_nics >= MAX_NICS) {

            fprintf(stderr, "Too Many NICs\n");

            return -1;

        }

        nd = &nd_table[nb_nics];

        macaddr = nd->macaddr;

        macaddr[0] = 0x52;

        macaddr[1] = 0x54;

        macaddr[2] = 0x00;

        macaddr[3] = 0x12;

        macaddr[4] = 0x34;

        macaddr[5] = 0x56 + nb_nics;



        if (get_param_value(VAR_4, sizeof(VAR_4), "macaddr", VAR_1)) {

            if (parse_macaddr(macaddr, VAR_4) < 0) {

                fprintf(stderr, "invalid syntax for ethernet address\n");

                return -1;

            }

        }

        if (get_param_value(VAR_4, sizeof(VAR_4), "model", VAR_1)) {

            nd->model = strdup(VAR_4);

        }

        nd->vlan = vlan;

        nb_nics++;

        vlan->nb_guest_devs++;

        VAR_6 = 0;

    } else

    if (!strcmp(VAR_3, "none")) {

        



        VAR_6 = 0;

    } else

#ifdef CONFIG_SLIRP

    if (!strcmp(VAR_3, "user")) {

        if (get_param_value(VAR_4, sizeof(VAR_4), "hostname", VAR_1)) {

            pstrcpy(slirp_hostname, sizeof(slirp_hostname), VAR_4);

        }


        VAR_6 = net_slirp_init(vlan);

    } else

#endif

#ifdef _WIN32

    if (!strcmp(VAR_3, "tap")) {

        char VAR_7[64];

        if (get_param_value(VAR_7, sizeof(VAR_7), "VAR_7", VAR_1) <= 0) {

            fprintf(stderr, "tap: no interface name\n");

            return -1;

        }


        VAR_6 = tap_win32_init(vlan, VAR_7);

    } else

#else

    if (!strcmp(VAR_3, "tap")) {

        char VAR_7[64];

        char VAR_8[1024];

        int VAR_10;

        if (get_param_value(VAR_4, sizeof(VAR_4), "VAR_10", VAR_1) > 0) {

            VAR_10 = strtol(VAR_4, NULL, 0);

            VAR_6 = -1;

            if (net_tap_fd_init(vlan, VAR_10))

                VAR_6 = 0;

        } else {

            if (get_param_value(VAR_7, sizeof(VAR_7), "VAR_7", VAR_1) <= 0) {

                VAR_7[0] = '\0';

            }

            if (get_param_value(VAR_8, sizeof(VAR_8), "script", VAR_1) == 0) {

                pstrcpy(VAR_8, sizeof(VAR_8), DEFAULT_NETWORK_SCRIPT);

            }


            VAR_6 = net_tap_init(vlan, VAR_7, VAR_8);

        }

    } else

#endif

    if (!strcmp(VAR_3, "socket")) {

        if (get_param_value(VAR_4, sizeof(VAR_4), "VAR_10", VAR_1) > 0) {

            int VAR_10;

            VAR_10 = strtol(VAR_4, NULL, 0);

            VAR_6 = -1;

            if (net_socket_fd_init(vlan, VAR_10, 1))

                VAR_6 = 0;

        } else if (get_param_value(VAR_4, sizeof(VAR_4), "listen", VAR_1) > 0) {

            VAR_6 = net_socket_listen_init(vlan, VAR_4);

        } else if (get_param_value(VAR_4, sizeof(VAR_4), "connect", VAR_1) > 0) {

            VAR_6 = net_socket_connect_init(vlan, VAR_4);

        } else if (get_param_value(VAR_4, sizeof(VAR_4), "mcast", VAR_1) > 0) {

            VAR_6 = net_socket_mcast_init(vlan, VAR_4);

        } else {

            fprintf(stderr, "Unknown socket options: %s\n", VAR_1);

            return -1;

        }


    } else

    {

        fprintf(stderr, "Unknown network VAR_3: %s\n", VAR_3);

        return -1;

    }

    if (VAR_6 < 0) {

        fprintf(stderr, "Could not initialize VAR_3 '%s'\n", VAR_3);

    }

    

    return VAR_6;

}
static int FUNC_0(const char *VAR_0)
{ const char *VAR_1; char *VAR_2; char VAR_3[64]; char VAR_4[1024]; int VAR_5, VAR_6; VLANState *vlan; VAR_1 = VAR_0; VAR_2 = VAR_3; while (*VAR_1 != '\0' && *VAR_1 != ',') { if ((VAR_2 - VAR_3) < sizeof(VAR_3) - 1)
*VAR_2++ = *VAR_1; VAR_1++; } *VAR_2 = '\0'; if (*VAR_1 == ',')
VAR_1++; VAR_5 = 0; if (get_param_value(VAR_4, sizeof(VAR_4), "vlan", VAR_1)) { VAR_5 = strtol(VAR_4, NULL, 0); } vlan = qemu_find_vlan(VAR_5); if (!vlan) { fprintf(stderr, "Could not create vlan %d\n", VAR_5); return -1; } if (!strcmp(VAR_3, "nic")) { NICInfo *nd; uint8_t *macaddr; if (nb_nics >= MAX_NICS) { fprintf(stderr, "Too Many NICs\n"); return -1; } nd = &nd_table[nb_nics]; macaddr = nd->macaddr; macaddr[0] = 0x52; macaddr[1] = 0x54; macaddr[2] = 0x00; macaddr[3] = 0x12; macaddr[4] = 0x34; macaddr[5] = 0x56 + nb_nics; if (get_param_value(VAR_4, sizeof(VAR_4), "macaddr", VAR_1)) { if (parse_macaddr(macaddr, VAR_4) < 0) { fprintf(stderr, "invalid syntax for ethernet address\n"); return -1; } } if (get_param_value(VAR_4, sizeof(VAR_4), "model", VAR_1)) { nd->model = strdup(VAR_4); } nd->vlan = vlan; nb_nics++; vlan->nb_guest_devs++; VAR_6 = 0; } else if (!strcmp(VAR_3, "none")) { VAR_6 = 0; } else #ifdef CONFIG_SLIRP
if (!strcmp(VAR_3, "user")) { if (get_param_value(VAR_4, sizeof(VAR_4), "hostname", VAR_1)) { pstrcpy(slirp_hostname, sizeof(slirp_hostname), VAR_4); } VAR_6 = net_slirp_init(vlan); } else #endif
#ifdef _WIN32
if (!strcmp(VAR_3, "tap")) { char VAR_7[64]; if (get_param_value(VAR_7, sizeof(VAR_7), "VAR_7", VAR_1) <= 0) { fprintf(stderr, "tap: no interface name\n"); return -1; } VAR_6 = tap_win32_init(vlan, VAR_7); } else #else
if (!strcmp(VAR_3, "tap")) { char VAR_7[64]; char VAR_8[1024]; int VAR_10; if (get_param_value(VAR_4, sizeof(VAR_4), "VAR_10", VAR_1) > 0) { VAR_10 = strtol(VAR_4, NULL, 0); VAR_6 = -1; if (net_tap_fd_init(vlan, VAR_10))
VAR_6 = 0; } else { if (get_param_value(VAR_7, sizeof(VAR_7), "VAR_7", VAR_1) <= 0) { VAR_7[0] = '\0'; } if (get_param_value(VAR_8, sizeof(VAR_8), "script", VAR_1) == 0) { pstrcpy(VAR_8, sizeof(VAR_8), DEFAULT_NETWORK_SCRIPT); } VAR_6 = net_tap_init(vlan, VAR_7, VAR_8); } } else #endif
if (!strcmp(VAR_3, "socket")) { if (get_param_value(VAR_4, sizeof(VAR_4), "VAR_10", VAR_1) > 0) { int VAR_10; VAR_10 = strtol(VAR_4, NULL, 0); VAR_6 = -1; if (net_socket_fd_init(vlan, VAR_10, 1))
VAR_6 = 0; } else if (get_param_value(VAR_4, sizeof(VAR_4), "listen", VAR_1) > 0) { VAR_6 = net_socket_listen_init(vlan, VAR_4); } else if (get_param_value(VAR_4, sizeof(VAR_4), "connect", VAR_1) > 0) { VAR_6 = net_socket_connect_init(vlan, VAR_4); } else if (get_param_value(VAR_4, sizeof(VAR_4), "mcast", VAR_1) > 0) { VAR_6 = net_socket_mcast_init(vlan, VAR_4); } else { fprintf(stderr, "Unknown socket options: %s\n", VAR_1); return -1; } } else { fprintf(stderr, "Unknown network VAR_3: %s\n", VAR_3); return -1; } if (VAR_6 < 0) { fprintf(stderr, "Could not initialize VAR_3 '%s'\n", VAR_3); } return VAR_6; }