int net_init_socket(const NetClientOptions *opts, const char *name,

                    NetClientState *peer, Error **errp)

{

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

    Error *err = NULL;

    const NetdevSocketOptions *sock;



    assert(opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET);

    sock = opts->socket;



    if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast +

        sock->has_udp != 1) {

        error_report("exactly one of fd=, listen=, connect=, mcast= or udp="

                     " is required");

        return -1;

    }



    if (sock->has_localaddr && !sock->has_mcast && !sock->has_udp) {

        error_report("localaddr= is only valid with mcast= or udp=");

        return -1;

    }



    if (sock->has_fd) {

        int fd;



        fd = monitor_fd_param(cur_mon, sock->fd, &err);

        if (fd == -1) {

            error_report_err(err);

            return -1;

        }

        qemu_set_nonblock(fd);

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

            return -1;

        }

        return 0;

    }



    if (sock->has_listen) {

        if (net_socket_listen_init(peer, "socket", name, sock->listen) == -1) {

            return -1;

        }

        return 0;

    }



    if (sock->has_connect) {

        if (net_socket_connect_init(peer, "socket", name, sock->connect) ==

            -1) {

            return -1;

        }

        return 0;

    }



    if (sock->has_mcast) {

        /* if sock->localaddr is missing, it has been initialized to "all bits

         * zero" */

        if (net_socket_mcast_init(peer, "socket", name, sock->mcast,

            sock->localaddr) == -1) {

            return -1;

        }

        return 0;

    }



    assert(sock->has_udp);

    if (!sock->has_localaddr) {

        error_report("localaddr= is mandatory with udp=");

        return -1;

    }

    if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr) ==

        -1) {

        return -1;

    }

    return 0;

}

int net_init_socket(const NetClientOptions *opts, const char *name,

                    NetClientState *peer, Error **errp)

{

    

    Error *err = NULL;

    const NetdevSocketOptions *sock;



    assert(opts->kind == NET_CLIENT_OPTIONS_KIND_SOCKET);

    sock = opts->socket;



    if (sock->has_fd + sock->has_listen + sock->has_connect + sock->has_mcast +

        sock->has_udp != 1) {

        error_report("exactly one of fd=, listen=, connect=, mcast= or udp="

                     " is required");

        return -1;

    }



    if (sock->has_localaddr && !sock->has_mcast && !sock->has_udp) {

        error_report("localaddr= is only valid with mcast= or udp=");

        return -1;

    }



    if (sock->has_fd) {

        int fd;



        fd = monitor_fd_param(cur_mon, sock->fd, &err);

        if (fd == -1) {

            error_report_err(err);

            return -1;

        }

        qemu_set_nonblock(fd);

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

            return -1;

        }

        return 0;

    }



    if (sock->has_listen) {

        if (net_socket_listen_init(peer, "socket", name, sock->listen) == -1) {

            return -1;

        }

        return 0;

    }



    if (sock->has_connect) {

        if (net_socket_connect_init(peer, "socket", name, sock->connect) ==

            -1) {

            return -1;

        }

        return 0;

    }



    if (sock->has_mcast) {

        



        if (net_socket_mcast_init(peer, "socket", name, sock->mcast,

            sock->localaddr) == -1) {

            return -1;

        }

        return 0;

    }



    assert(sock->has_udp);

    if (!sock->has_localaddr) {

        error_report("localaddr= is mandatory with udp=");

        return -1;

    }

    if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr) ==

        -1) {

        return -1;

    }

    return 0;

}

int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1,

                    NetClientState *VAR_2, Error **VAR_3)

{

    

    Error *err = NULL;

    const NetdevSocketOptions *VAR_4;



    assert(VAR_0->kind == NET_CLIENT_OPTIONS_KIND_SOCKET);

    VAR_4 = VAR_0->socket;



    if (VAR_4->has_fd + VAR_4->has_listen + VAR_4->has_connect + VAR_4->has_mcast +

        VAR_4->has_udp != 1) {

        error_report("exactly one of VAR_5=, listen=, connect=, mcast= or udp="

                     " is required");

        return -1;

    }



    if (VAR_4->has_localaddr && !VAR_4->has_mcast && !VAR_4->has_udp) {

        error_report("localaddr= is only valid with mcast= or udp=");

        return -1;

    }



    if (VAR_4->has_fd) {

        int VAR_5;



        VAR_5 = monitor_fd_param(cur_mon, VAR_4->VAR_5, &err);

        if (VAR_5 == -1) {

            error_report_err(err);

            return -1;

        }

        qemu_set_nonblock(VAR_5);

        if (!net_socket_fd_init(VAR_2, "socket", VAR_1, VAR_5, 1)) {

            return -1;

        }

        return 0;

    }



    if (VAR_4->has_listen) {

        if (net_socket_listen_init(VAR_2, "socket", VAR_1, VAR_4->listen) == -1) {

            return -1;

        }

        return 0;

    }



    if (VAR_4->has_connect) {

        if (net_socket_connect_init(VAR_2, "socket", VAR_1, VAR_4->connect) ==

            -1) {

            return -1;

        }

        return 0;

    }



    if (VAR_4->has_mcast) {

        



        if (net_socket_mcast_init(VAR_2, "socket", VAR_1, VAR_4->mcast,

            VAR_4->localaddr) == -1) {

            return -1;

        }

        return 0;

    }



    assert(VAR_4->has_udp);

    if (!VAR_4->has_localaddr) {

        error_report("localaddr= is mandatory with udp=");

        return -1;

    }

    if (net_socket_udp_init(VAR_2, "socket", VAR_1, VAR_4->udp, VAR_4->localaddr) ==

        -1) {

        return -1;

    }

    return 0;

}

int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1,
NetClientState *VAR_2, Error **VAR_3)
{ Error *err = NULL; const NetdevSocketOptions *VAR_4; assert(VAR_0->kind == NET_CLIENT_OPTIONS_KIND_SOCKET); VAR_4 = VAR_0->socket; if (VAR_4->has_fd + VAR_4->has_listen + VAR_4->has_connect + VAR_4->has_mcast +
VAR_4->has_udp != 1) { error_report("exactly one of VAR_5=, listen=, connect=, mcast= or udp="
" is required"); return -1; } if (VAR_4->has_localaddr && !VAR_4->has_mcast && !VAR_4->has_udp) { error_report("localaddr= is only valid with mcast= or udp="); return -1; } if (VAR_4->has_fd) { int VAR_5; VAR_5 = monitor_fd_param(cur_mon, VAR_4->VAR_5, &err); if (VAR_5 == -1) { error_report_err(err); return -1; } qemu_set_nonblock(VAR_5); if (!net_socket_fd_init(VAR_2, "socket", VAR_1, VAR_5, 1)) { return -1; } return 0; } if (VAR_4->has_listen) { if (net_socket_listen_init(VAR_2, "socket", VAR_1, VAR_4->listen) == -1) { return -1; } return 0; } if (VAR_4->has_connect) { if (net_socket_connect_init(VAR_2, "socket", VAR_1, VAR_4->connect) ==
-1) { return -1; } return 0; } if (VAR_4->has_mcast) { if (net_socket_mcast_init(VAR_2, "socket", VAR_1, VAR_4->mcast,
VAR_4->localaddr) == -1) { return -1; } return 0; } assert(VAR_4->has_udp); if (!VAR_4->has_localaddr) { error_report("localaddr= is mandatory with udp="); return -1; } if (net_socket_udp_init(VAR_2, "socket", VAR_1, VAR_4->udp, VAR_4->localaddr) ==
-1) { return -1; } return 0; }