int net_init_socket(QemuOpts *opts,

                    Monitor *mon,

                    const char *name,

                    VLANState *vlan)

{

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

        int fd;



        if (qemu_opt_get(opts, "listen") ||

            qemu_opt_get(opts, "connect") ||

            qemu_opt_get(opts, "mcast")) {

            qemu_error("listen=, connect= and mcast= is invalid with fd=\n");

            return -1;

        }



        fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));

        if (fd == -1) {

            return -1;

        }



        if (!net_socket_fd_init(vlan, "socket", name, fd, 1)) {

            close(fd);

            return -1;

        }

    } else if (qemu_opt_get(opts, "listen")) {

        const char *listen;



        if (qemu_opt_get(opts, "fd") ||

            qemu_opt_get(opts, "connect") ||

            qemu_opt_get(opts, "mcast")) {

            qemu_error("fd=, connect= and mcast= is invalid with listen=\n");

            return -1;

        }



        listen = qemu_opt_get(opts, "listen");



        if (net_socket_listen_init(vlan, "socket", name, listen) == -1) {

            return -1;

        }

    } else if (qemu_opt_get(opts, "connect")) {

        const char *connect;



        if (qemu_opt_get(opts, "fd") ||

            qemu_opt_get(opts, "listen") ||

            qemu_opt_get(opts, "mcast")) {

            qemu_error("fd=, listen= and mcast= is invalid with connect=\n");

            return -1;

        }



        connect = qemu_opt_get(opts, "connect");



        if (net_socket_connect_init(vlan, "socket", name, connect) == -1) {

            return -1;

        }

    } else if (qemu_opt_get(opts, "mcast")) {

        const char *mcast;



        if (qemu_opt_get(opts, "fd") ||

            qemu_opt_get(opts, "connect") ||

            qemu_opt_get(opts, "listen")) {

            qemu_error("fd=, connect= and listen= is invalid with mcast=\n");

            return -1;

        }



        mcast = qemu_opt_get(opts, "mcast");



        if (net_socket_mcast_init(vlan, "socket", name, mcast) == -1) {

            return -1;

        }

    } else {

        qemu_error("-socket requires fd=, listen=, connect= or mcast=\n");

        return -1;

    }



    if (vlan) {

        vlan->nb_host_devs++;

    }



    return 0;

}

int net_init_socket(QemuOpts *opts,

                    Monitor *mon,

                    const char *name,

                    VLANState *vlan)

{

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

        int fd;



        if (qemu_opt_get(opts, "listen") ||

            qemu_opt_get(opts, "connect") ||

            qemu_opt_get(opts, "mcast")) {

            qemu_error("listen=, connect= and mcast= is invalid with fd=\n");

            return -1;

        }



        fd = net_handle_fd_param(mon, qemu_opt_get(opts, "fd"));

        if (fd == -1) {

            return -1;

        }



        if (!net_socket_fd_init(vlan, "socket", name, fd, 1)) {

            close(fd);

            return -1;

        }

    } else if (qemu_opt_get(opts, "listen")) {

        const char *listen;



        if (qemu_opt_get(opts, "fd") ||

            qemu_opt_get(opts, "connect") ||

            qemu_opt_get(opts, "mcast")) {

            qemu_error("fd=, connect= and mcast= is invalid with listen=\n");

            return -1;

        }



        listen = qemu_opt_get(opts, "listen");



        if (net_socket_listen_init(vlan, "socket", name, listen) == -1) {

            return -1;

        }

    } else if (qemu_opt_get(opts, "connect")) {

        const char *connect;



        if (qemu_opt_get(opts, "fd") ||

            qemu_opt_get(opts, "listen") ||

            qemu_opt_get(opts, "mcast")) {

            qemu_error("fd=, listen= and mcast= is invalid with connect=\n");

            return -1;

        }



        connect = qemu_opt_get(opts, "connect");



        if (net_socket_connect_init(vlan, "socket", name, connect) == -1) {

            return -1;

        }

    } else if (qemu_opt_get(opts, "mcast")) {

        const char *mcast;



        if (qemu_opt_get(opts, "fd") ||

            qemu_opt_get(opts, "connect") ||

            qemu_opt_get(opts, "listen")) {

            qemu_error("fd=, connect= and listen= is invalid with mcast=\n");

            return -1;

        }



        mcast = qemu_opt_get(opts, "mcast");



        if (net_socket_mcast_init(vlan, "socket", name, mcast) == -1) {

            return -1;

        }

    } else {

        qemu_error("-socket requires fd=, listen=, connect= or mcast=\n");

        return -1;

    }



    if (vlan) {

        vlan->nb_host_devs++;

    }



    return 0;

}

int FUNC_0(QemuOpts *VAR_0,

                    Monitor *VAR_1,

                    const char *VAR_2,

                    VLANState *VAR_3)

{

    if (qemu_opt_get(VAR_0, "VAR_4")) {

        int VAR_4;



        if (qemu_opt_get(VAR_0, "VAR_5") ||

            qemu_opt_get(VAR_0, "VAR_6") ||

            qemu_opt_get(VAR_0, "VAR_7")) {

            qemu_error("VAR_5=, VAR_6= and VAR_7= is invalid with VAR_4=\n");

            return -1;

        }



        VAR_4 = net_handle_fd_param(VAR_1, qemu_opt_get(VAR_0, "VAR_4"));

        if (VAR_4 == -1) {

            return -1;

        }



        if (!net_socket_fd_init(VAR_3, "socket", VAR_2, VAR_4, 1)) {

            close(VAR_4);

            return -1;

        }

    } else if (qemu_opt_get(VAR_0, "VAR_5")) {

        const char *VAR_5;



        if (qemu_opt_get(VAR_0, "VAR_4") ||

            qemu_opt_get(VAR_0, "VAR_6") ||

            qemu_opt_get(VAR_0, "VAR_7")) {

            qemu_error("VAR_4=, VAR_6= and VAR_7= is invalid with VAR_5=\n");

            return -1;

        }



        VAR_5 = qemu_opt_get(VAR_0, "VAR_5");



        if (net_socket_listen_init(VAR_3, "socket", VAR_2, VAR_5) == -1) {

            return -1;

        }

    } else if (qemu_opt_get(VAR_0, "VAR_6")) {

        const char *VAR_6;



        if (qemu_opt_get(VAR_0, "VAR_4") ||

            qemu_opt_get(VAR_0, "VAR_5") ||

            qemu_opt_get(VAR_0, "VAR_7")) {

            qemu_error("VAR_4=, VAR_5= and VAR_7= is invalid with VAR_6=\n");

            return -1;

        }



        VAR_6 = qemu_opt_get(VAR_0, "VAR_6");



        if (net_socket_connect_init(VAR_3, "socket", VAR_2, VAR_6) == -1) {

            return -1;

        }

    } else if (qemu_opt_get(VAR_0, "VAR_7")) {

        const char *VAR_7;



        if (qemu_opt_get(VAR_0, "VAR_4") ||

            qemu_opt_get(VAR_0, "VAR_6") ||

            qemu_opt_get(VAR_0, "VAR_5")) {

            qemu_error("VAR_4=, VAR_6= and VAR_5= is invalid with VAR_7=\n");

            return -1;

        }



        VAR_7 = qemu_opt_get(VAR_0, "VAR_7");



        if (net_socket_mcast_init(VAR_3, "socket", VAR_2, VAR_7) == -1) {

            return -1;

        }

    } else {

        qemu_error("-socket requires VAR_4=, VAR_5=, VAR_6= or VAR_7=\n");

        return -1;

    }



    if (VAR_3) {

        VAR_3->nb_host_devs++;

    }



    return 0;

}

int FUNC_0(QemuOpts *VAR_0,
Monitor *VAR_1,
const char *VAR_2,
VLANState *VAR_3)
{ if (qemu_opt_get(VAR_0, "VAR_4")) { int VAR_4; if (qemu_opt_get(VAR_0, "VAR_5") ||
qemu_opt_get(VAR_0, "VAR_6") ||
qemu_opt_get(VAR_0, "VAR_7")) { qemu_error("VAR_5=, VAR_6= and VAR_7= is invalid with VAR_4=\n"); return -1; } VAR_4 = net_handle_fd_param(VAR_1, qemu_opt_get(VAR_0, "VAR_4")); if (VAR_4 == -1) { return -1; } if (!net_socket_fd_init(VAR_3, "socket", VAR_2, VAR_4, 1)) { close(VAR_4); return -1; } } else if (qemu_opt_get(VAR_0, "VAR_5")) { const char *VAR_5; if (qemu_opt_get(VAR_0, "VAR_4") ||
qemu_opt_get(VAR_0, "VAR_6") ||
qemu_opt_get(VAR_0, "VAR_7")) { qemu_error("VAR_4=, VAR_6= and VAR_7= is invalid with VAR_5=\n"); return -1; } VAR_5 = qemu_opt_get(VAR_0, "VAR_5"); if (net_socket_listen_init(VAR_3, "socket", VAR_2, VAR_5) == -1) { return -1; } } else if (qemu_opt_get(VAR_0, "VAR_6")) { const char *VAR_6; if (qemu_opt_get(VAR_0, "VAR_4") ||
qemu_opt_get(VAR_0, "VAR_5") ||
qemu_opt_get(VAR_0, "VAR_7")) { qemu_error("VAR_4=, VAR_5= and VAR_7= is invalid with VAR_6=\n"); return -1; } VAR_6 = qemu_opt_get(VAR_0, "VAR_6"); if (net_socket_connect_init(VAR_3, "socket", VAR_2, VAR_6) == -1) { return -1; } } else if (qemu_opt_get(VAR_0, "VAR_7")) { const char *VAR_7; if (qemu_opt_get(VAR_0, "VAR_4") ||
qemu_opt_get(VAR_0, "VAR_6") ||
qemu_opt_get(VAR_0, "VAR_5")) { qemu_error("VAR_4=, VAR_6= and VAR_5= is invalid with VAR_7=\n"); return -1; } VAR_7 = qemu_opt_get(VAR_0, "VAR_7"); if (net_socket_mcast_init(VAR_3, "socket", VAR_2, VAR_7) == -1) { return -1; } } else { qemu_error("-socket requires VAR_4=, VAR_5=, VAR_6= or VAR_7=\n"); return -1; } if (VAR_3) { VAR_3->nb_host_devs++; } return 0; }