static NetSocketState *net_socket_fd_init(VLANState *vlan,

                                          const char *model, const char *name,

                                          int fd, int is_connected)

{

    int so_type=-1, optlen=sizeof(so_type);



    if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,

        (socklen_t *)&optlen)< 0) {

	fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n", fd);

	return NULL;

    }

    switch(so_type) {

    case SOCK_DGRAM:

        return net_socket_fd_init_dgram(vlan, model, name, fd, is_connected);

    case SOCK_STREAM:

        return net_socket_fd_init_stream(vlan, model, name, fd, is_connected);

    default:

        /* who knows ... this could be a eg. a pty, do warn and continue as stream */

        fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);

        return net_socket_fd_init_stream(vlan, model, name, fd, is_connected);

    }

    return NULL;

}

static NetSocketState *net_socket_fd_init(VLANState *vlan,

                                          const char *model, const char *name,

                                          int fd, int is_connected)

{

    int so_type=-1, optlen=sizeof(so_type);



    if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type,

        (socklen_t *)&optlen)< 0) {

	fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n", fd);

	return NULL;

    }

    switch(so_type) {

    case SOCK_DGRAM:

        return net_socket_fd_init_dgram(vlan, model, name, fd, is_connected);

    case SOCK_STREAM:

        return net_socket_fd_init_stream(vlan, model, name, fd, is_connected);

    default:

        

        fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);

        return net_socket_fd_init_stream(vlan, model, name, fd, is_connected);

    }

    return NULL;

}

static NetSocketState *FUNC_0(VLANState *vlan,

                                          const char *model, const char *name,

                                          int fd, int is_connected)

{

    int VAR_0=-1, VAR_1=sizeof(VAR_0);



    if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&VAR_0,

        (socklen_t *)&VAR_1)< 0) {

	fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n", fd);

	return NULL;

    }

    switch(VAR_0) {

    case SOCK_DGRAM:

        return net_socket_fd_init_dgram(vlan, model, name, fd, is_connected);

    case SOCK_STREAM:

        return net_socket_fd_init_stream(vlan, model, name, fd, is_connected);

    default:

        

        fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", VAR_0, fd);

        return net_socket_fd_init_stream(vlan, model, name, fd, is_connected);

    }

    return NULL;

}

static NetSocketState *FUNC_0(VLANState *vlan,
const char *model, const char *name,
int fd, int is_connected)
{ int VAR_0=-1, VAR_1=sizeof(VAR_0); if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&VAR_0,
(socklen_t *)&VAR_1)< 0) { fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n", fd); return NULL; } switch(VAR_0) { case SOCK_DGRAM:
return net_socket_fd_init_dgram(vlan, model, name, fd, is_connected); case SOCK_STREAM:
return net_socket_fd_init_stream(vlan, model, name, fd, is_connected); default:
fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", VAR_0, fd); return net_socket_fd_init_stream(vlan, model, name, fd, is_connected); } return NULL; }