static int net_socket_listen_init(VLANState *vlan,

                                  const char *model,

                                  const char *name,

                                  const char *host_str)

{

    NetSocketListenState *s;

    int fd, val, ret;

    struct sockaddr_in saddr;



    if (parse_host_port(&saddr, host_str) < 0)

        return -1;



    s = g_malloc0(sizeof(NetSocketListenState));



    fd = qemu_socket(PF_INET, SOCK_STREAM, 0);

    if (fd < 0) {

        perror("socket");

        g_free(s);

        return -1;

    }

    socket_set_nonblock(fd);



    /* allow fast reuse */

    val = 1;

    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));



    ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));

    if (ret < 0) {

        perror("bind");

        g_free(s);


        return -1;

    }

    ret = listen(fd, 0);

    if (ret < 0) {

        perror("listen");

        g_free(s);


        return -1;

    }

    s->vlan = vlan;

    s->model = g_strdup(model);

    s->name = name ? g_strdup(name) : NULL;

    s->fd = fd;

    qemu_set_fd_handler(fd, net_socket_accept, NULL, s);

    return 0;

}
static int net_socket_listen_init(VLANState *vlan,

                                  const char *model,

                                  const char *name,

                                  const char *host_str)

{

    NetSocketListenState *s;

    int fd, val, ret;

    struct sockaddr_in saddr;



    if (parse_host_port(&saddr, host_str) < 0)

        return -1;



    s = g_malloc0(sizeof(NetSocketListenState));



    fd = qemu_socket(PF_INET, SOCK_STREAM, 0);

    if (fd < 0) {

        perror("socket");

        g_free(s);

        return -1;

    }

    socket_set_nonblock(fd);



    

    val = 1;

    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));



    ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));

    if (ret < 0) {

        perror("bind");

        g_free(s);


        return -1;

    }

    ret = listen(fd, 0);

    if (ret < 0) {

        perror("listen");

        g_free(s);


        return -1;

    }

    s->vlan = vlan;

    s->model = g_strdup(model);

    s->name = name ? g_strdup(name) : NULL;

    s->fd = fd;

    qemu_set_fd_handler(fd, net_socket_accept, NULL, s);

    return 0;

}
static int FUNC_0(VLANState *VAR_0,

                                  const char *VAR_1,

                                  const char *VAR_2,

                                  const char *VAR_3)

{

    NetSocketListenState *s;

    int VAR_4, VAR_5, VAR_6;

    struct sockaddr_in VAR_7;



    if (parse_host_port(&VAR_7, VAR_3) < 0)

        return -1;



    s = g_malloc0(sizeof(NetSocketListenState));



    VAR_4 = qemu_socket(PF_INET, SOCK_STREAM, 0);

    if (VAR_4 < 0) {

        perror("socket");

        g_free(s);

        return -1;

    }

    socket_set_nonblock(VAR_4);



    

    VAR_5 = 1;

    setsockopt(VAR_4, SOL_SOCKET, SO_REUSEADDR, (const char *)&VAR_5, sizeof(VAR_5));



    VAR_6 = bind(VAR_4, (struct sockaddr *)&VAR_7, sizeof(VAR_7));

    if (VAR_6 < 0) {

        perror("bind");

        g_free(s);


        return -1;

    }

    VAR_6 = listen(VAR_4, 0);

    if (VAR_6 < 0) {

        perror("listen");

        g_free(s);


        return -1;

    }

    s->VAR_0 = VAR_0;

    s->VAR_1 = g_strdup(VAR_1);

    s->VAR_2 = VAR_2 ? g_strdup(VAR_2) : NULL;

    s->VAR_4 = VAR_4;

    qemu_set_fd_handler(VAR_4, net_socket_accept, NULL, s);

    return 0;

}
static int FUNC_0(VLANState *VAR_0,
const char *VAR_1,
const char *VAR_2,
const char *VAR_3)
{ NetSocketListenState *s; int VAR_4, VAR_5, VAR_6; struct sockaddr_in VAR_7; if (parse_host_port(&VAR_7, VAR_3) < 0)
return -1; s = g_malloc0(sizeof(NetSocketListenState)); VAR_4 = qemu_socket(PF_INET, SOCK_STREAM, 0); if (VAR_4 < 0) { perror("socket"); g_free(s); return -1; } socket_set_nonblock(VAR_4); VAR_5 = 1; setsockopt(VAR_4, SOL_SOCKET, SO_REUSEADDR, (const char *)&VAR_5, sizeof(VAR_5)); VAR_6 = bind(VAR_4, (struct sockaddr *)&VAR_7, sizeof(VAR_7)); if (VAR_6 < 0) { perror("bind"); g_free(s); return -1; } VAR_6 = listen(VAR_4, 0); if (VAR_6 < 0) { perror("listen"); g_free(s); return -1; } s->VAR_0 = VAR_0; s->VAR_1 = g_strdup(VAR_1); s->VAR_2 = VAR_2 ? g_strdup(VAR_2) : NULL; s->VAR_4 = VAR_4; qemu_set_fd_handler(VAR_4, net_socket_accept, NULL, s); return 0; }