static int net_socket_udp_init(NetClientState *peer,

                                 const char *model,

                                 const char *name,

                                 const char *rhost,

                                 const char *lhost)

{

    NetSocketState *s;

    int fd, ret;

    struct sockaddr_in laddr, raddr;



    if (parse_host_port(&laddr, lhost) < 0) {

        return -1;

    }



    if (parse_host_port(&raddr, rhost) < 0) {

        return -1;

    }



    fd = qemu_socket(PF_INET, SOCK_DGRAM, 0);

    if (fd < 0) {

        perror("socket(PF_INET, SOCK_DGRAM)");

        return -1;

    }



    ret = socket_set_fast_reuse(fd);

    if (ret < 0) {

        closesocket(fd);

        return -1;

    }

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

    if (ret < 0) {

        perror("bind");

        closesocket(fd);

        return -1;

    }

    qemu_set_nonblock(fd);



    s = net_socket_fd_init(peer, model, name, fd, 0);

    if (!s) {

        return -1;

    }



    s->dgram_dst = raddr;



    snprintf(s->nc.info_str, sizeof(s->nc.info_str),

             "socket: udp=%s:%d",

             inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port));

    return 0;

}

static int net_socket_udp_init(NetClientState *peer,

                                 const char *model,

                                 const char *name,

                                 const char *rhost,

                                 const char *lhost)

{

    NetSocketState *s;

    int fd, ret;

    struct sockaddr_in laddr, raddr;



    if (parse_host_port(&laddr, lhost) < 0) {

        return -1;

    }



    if (parse_host_port(&raddr, rhost) < 0) {

        return -1;

    }



    fd = qemu_socket(PF_INET, SOCK_DGRAM, 0);

    if (fd < 0) {

        perror("socket(PF_INET, SOCK_DGRAM)");

        return -1;

    }



    ret = socket_set_fast_reuse(fd);

    if (ret < 0) {

        closesocket(fd);

        return -1;

    }

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

    if (ret < 0) {

        perror("bind");

        closesocket(fd);

        return -1;

    }

    qemu_set_nonblock(fd);



    s = net_socket_fd_init(peer, model, name, fd, 0);

    if (!s) {

        return -1;

    }



    s->dgram_dst = raddr;



    snprintf(s->nc.info_str, sizeof(s->nc.info_str),

             "socket: udp=%s:%d",

             inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port));

    return 0;

}

    s = net_socket_fd_init(peer, model, name, fd, 0);     s = net_socket_fd_init(peer, model, name, fd, 0);
static int FUNC_0(NetClientState *VAR_0,

                                 const char *VAR_1,

                                 const char *VAR_2,

                                 const char *VAR_3,

                                 const char *VAR_4)

{

    NetSocketState *s;

    int VAR_5, VAR_6;

    struct sockaddr_in VAR_7, VAR_8;



    if (parse_host_port(&VAR_7, VAR_4) < 0) {

        return -1;

    }



    if (parse_host_port(&VAR_8, VAR_3) < 0) {

        return -1;

    }



    VAR_5 = qemu_socket(PF_INET, SOCK_DGRAM, 0);

    if (VAR_5 < 0) {

        perror("socket(PF_INET, SOCK_DGRAM)");

        return -1;

    }



    VAR_6 = socket_set_fast_reuse(VAR_5);

    if (VAR_6 < 0) {

        closesocket(VAR_5);

        return -1;

    }

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

    if (VAR_6 < 0) {

        perror("bind");

        closesocket(VAR_5);

        return -1;

    }

    qemu_set_nonblock(VAR_5);



    s = net_socket_fd_init(VAR_0, VAR_1, VAR_2, VAR_5, 0);

    if (!s) {

        return -1;

    }



    s->dgram_dst = VAR_8;



    snprintf(s->nc.info_str, sizeof(s->nc.info_str),

             "socket: udp=%s:%d",

             inet_ntoa(VAR_8.sin_addr), ntohs(VAR_8.sin_port));

    return 0;

}

static int FUNC_0(NetClientState *VAR_0,
const char *VAR_1,
const char *VAR_2,
const char *VAR_3,
const char *VAR_4)
{ NetSocketState *s; int VAR_5, VAR_6; struct sockaddr_in VAR_7, VAR_8; if (parse_host_port(&VAR_7, VAR_4) < 0) { return -1; } if (parse_host_port(&VAR_8, VAR_3) < 0) { return -1; } VAR_5 = qemu_socket(PF_INET, SOCK_DGRAM, 0); if (VAR_5 < 0) { perror("socket(PF_INET, SOCK_DGRAM)"); return -1; } VAR_6 = socket_set_fast_reuse(VAR_5); if (VAR_6 < 0) { closesocket(VAR_5); return -1; } VAR_6 = bind(VAR_5, (struct sockaddr *)&VAR_7, sizeof(VAR_7)); if (VAR_6 < 0) { perror("bind"); closesocket(VAR_5); return -1; } qemu_set_nonblock(VAR_5); s = net_socket_fd_init(VAR_0, VAR_1, VAR_2, VAR_5, 0); if (!s) { return -1; } s->dgram_dst = VAR_8; snprintf(s->nc.info_str, sizeof(s->nc.info_str),
"socket: udp=%s:%d",
inet_ntoa(VAR_8.sin_addr), ntohs(VAR_8.sin_port)); return 0; }