int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)

{

    const char *name;

    const char *type;

    int i;



    type = qemu_opt_get(opts, "type");

    if (!type) {

        qerror_report(QERR_MISSING_PARAMETER, "type");

        return -1;

    }



    if (is_netdev) {

        if (strcmp(type, "tap") != 0 &&

#ifdef CONFIG_SLIRP

            strcmp(type, "user") != 0 &&

#endif

#ifdef CONFIG_VDE

            strcmp(type, "vde") != 0 &&

#endif

            strcmp(type, "socket") != 0) {

            qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",

                          "a netdev backend type");

            return -1;

        }



        if (qemu_opt_get(opts, "vlan")) {

            qerror_report(QERR_INVALID_PARAMETER, "vlan");

            return -1;

        }

        if (qemu_opt_get(opts, "name")) {

            qerror_report(QERR_INVALID_PARAMETER, "name");

            return -1;

        }

        if (!qemu_opts_id(opts)) {

            qerror_report(QERR_MISSING_PARAMETER, "id");

            return -1;

        }

    }



    name = qemu_opts_id(opts);

    if (!name) {

        name = qemu_opt_get(opts, "name");

    }



    for (i = 0; i < NET_CLIENT_TYPE_MAX; i++) {

        if (net_client_types[i].type != NULL &&

            !strcmp(net_client_types[i].type, type)) {

            VLANState *vlan = NULL;

            int ret;



            if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -1) {

                return -1;

            }



            /* Do not add to a vlan if it's a -netdev or a nic with a

             * netdev= parameter. */

            if (!(is_netdev ||

                  (strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {

                vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);

            }



            ret = 0;

            if (net_client_types[i].init) {

                ret = net_client_types[i].init(opts, mon, name, vlan);

                if (ret < 0) {

                    /* TODO push error reporting into init() methods */

                    qerror_report(QERR_DEVICE_INIT_FAILED, type);

                    return -1;

                }

            }

            return ret;

        }

    }



    qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",

                  "a network client type");

    return -1;

}

int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)

{

    const char *name;

    const char *type;

    int i;



    type = qemu_opt_get(opts, "type");

    if (!type) {

        qerror_report(QERR_MISSING_PARAMETER, "type");

        return -1;

    }



    if (is_netdev) {

        if (strcmp(type, "tap") != 0 &&

#ifdef CONFIG_SLIRP

            strcmp(type, "user") != 0 &&

#endif

#ifdef CONFIG_VDE

            strcmp(type, "vde") != 0 &&

#endif

            strcmp(type, "socket") != 0) {

            qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",

                          "a netdev backend type");

            return -1;

        }



        if (qemu_opt_get(opts, "vlan")) {

            qerror_report(QERR_INVALID_PARAMETER, "vlan");

            return -1;

        }

        if (qemu_opt_get(opts, "name")) {

            qerror_report(QERR_INVALID_PARAMETER, "name");

            return -1;

        }

        if (!qemu_opts_id(opts)) {

            qerror_report(QERR_MISSING_PARAMETER, "id");

            return -1;

        }

    }



    name = qemu_opts_id(opts);

    if (!name) {

        name = qemu_opt_get(opts, "name");

    }



    for (i = 0; i < NET_CLIENT_TYPE_MAX; i++) {

        if (net_client_types[i].type != NULL &&

            !strcmp(net_client_types[i].type, type)) {

            VLANState *vlan = NULL;

            int ret;



            if (qemu_opts_validate(opts, &net_client_types[i].desc[0]) == -1) {

                return -1;

            }



            



            if (!(is_netdev ||

                  (strcmp(type, "nic") == 0 && qemu_opt_get(opts, "netdev")))) {

                vlan = qemu_find_vlan(qemu_opt_get_number(opts, "vlan", 0), 1);

            }



            ret = 0;

            if (net_client_types[i].init) {

                ret = net_client_types[i].init(opts, mon, name, vlan);

                if (ret < 0) {

                    

                    qerror_report(QERR_DEVICE_INIT_FAILED, type);

                    return -1;

                }

            }

            return ret;

        }

    }



    qerror_report(QERR_INVALID_PARAMETER_VALUE, "type",

                  "a network client type");

    return -1;

}

            strcmp(type, "socket") != 0) {
int FUNC_0(Monitor *VAR_0, QemuOpts *VAR_1, int VAR_2)

{

    const char *VAR_3;

    const char *VAR_4;

    int VAR_5;



    VAR_4 = qemu_opt_get(VAR_1, "VAR_4");

    if (!VAR_4) {

        qerror_report(QERR_MISSING_PARAMETER, "VAR_4");

        return -1;

    }



    if (VAR_2) {

        if (strcmp(VAR_4, "tap") != 0 &&

#ifdef CONFIG_SLIRP

            strcmp(VAR_4, "user") != 0 &&

#endif

#ifdef CONFIG_VDE

            strcmp(VAR_4, "vde") != 0 &&

#endif

            strcmp(VAR_4, "socket") != 0) {

            qerror_report(QERR_INVALID_PARAMETER_VALUE, "VAR_4",

                          "a netdev backend VAR_4");

            return -1;

        }



        if (qemu_opt_get(VAR_1, "vlan")) {

            qerror_report(QERR_INVALID_PARAMETER, "vlan");

            return -1;

        }

        if (qemu_opt_get(VAR_1, "VAR_3")) {

            qerror_report(QERR_INVALID_PARAMETER, "VAR_3");

            return -1;

        }

        if (!qemu_opts_id(VAR_1)) {

            qerror_report(QERR_MISSING_PARAMETER, "id");

            return -1;

        }

    }



    VAR_3 = qemu_opts_id(VAR_1);

    if (!VAR_3) {

        VAR_3 = qemu_opt_get(VAR_1, "VAR_3");

    }



    for (VAR_5 = 0; VAR_5 < NET_CLIENT_TYPE_MAX; VAR_5++) {

        if (net_client_types[VAR_5].VAR_4 != NULL &&

            !strcmp(net_client_types[VAR_5].VAR_4, VAR_4)) {

            VLANState *vlan = NULL;

            int ret;



            if (qemu_opts_validate(VAR_1, &net_client_types[VAR_5].desc[0]) == -1) {

                return -1;

            }



            



            if (!(VAR_2 ||

                  (strcmp(VAR_4, "nic") == 0 && qemu_opt_get(VAR_1, "netdev")))) {

                vlan = qemu_find_vlan(qemu_opt_get_number(VAR_1, "vlan", 0), 1);

            }



            ret = 0;

            if (net_client_types[VAR_5].init) {

                ret = net_client_types[VAR_5].init(VAR_1, VAR_0, VAR_3, vlan);

                if (ret < 0) {

                    

                    qerror_report(QERR_DEVICE_INIT_FAILED, VAR_4);

                    return -1;

                }

            }

            return ret;

        }

    }



    qerror_report(QERR_INVALID_PARAMETER_VALUE, "VAR_4",

                  "a network client VAR_4");

    return -1;

}

int FUNC_0(Monitor *VAR_0, QemuOpts *VAR_1, int VAR_2)
{ const char *VAR_3; const char *VAR_4; int VAR_5; VAR_4 = qemu_opt_get(VAR_1, "VAR_4"); if (!VAR_4) { qerror_report(QERR_MISSING_PARAMETER, "VAR_4"); return -1; } if (VAR_2) { if (strcmp(VAR_4, "tap") != 0 &&
#ifdef CONFIG_SLIRP
strcmp(VAR_4, "user") != 0 &&
#endif
#ifdef CONFIG_VDE
strcmp(VAR_4, "vde") != 0 &&
#endif
strcmp(VAR_4, "socket") != 0) { qerror_report(QERR_INVALID_PARAMETER_VALUE, "VAR_4",
"a netdev backend VAR_4"); return -1; } if (qemu_opt_get(VAR_1, "vlan")) { qerror_report(QERR_INVALID_PARAMETER, "vlan"); return -1; } if (qemu_opt_get(VAR_1, "VAR_3")) { qerror_report(QERR_INVALID_PARAMETER, "VAR_3"); return -1; } if (!qemu_opts_id(VAR_1)) { qerror_report(QERR_MISSING_PARAMETER, "id"); return -1; } } VAR_3 = qemu_opts_id(VAR_1); if (!VAR_3) { VAR_3 = qemu_opt_get(VAR_1, "VAR_3"); } for (VAR_5 = 0; VAR_5 < NET_CLIENT_TYPE_MAX; VAR_5++) { if (net_client_types[VAR_5].VAR_4 != NULL &&
!strcmp(net_client_types[VAR_5].VAR_4, VAR_4)) { VLANState *vlan = NULL; int ret; if (qemu_opts_validate(VAR_1, &net_client_types[VAR_5].desc[0]) == -1) { return -1; } if (!(VAR_2 ||
(strcmp(VAR_4, "nic") == 0 && qemu_opt_get(VAR_1, "netdev")))) { vlan = qemu_find_vlan(qemu_opt_get_number(VAR_1, "vlan", 0), 1); } ret = 0; if (net_client_types[VAR_5].init) { ret = net_client_types[VAR_5].init(VAR_1, VAR_0, VAR_3, vlan); if (ret < 0) { qerror_report(QERR_DEVICE_INIT_FAILED, VAR_4); return -1; } } return ret; } } qerror_report(QERR_INVALID_PARAMETER_VALUE, "VAR_4",
"a network client VAR_4"); return -1; }