udp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr,

           u_int lport, int flags)

{

	struct sockaddr_in addr;

	struct socket *so;

	socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1;



	so = socreate(slirp);

	if (!so) {

	    return NULL;

	}

	so->s = socket(AF_INET,SOCK_DGRAM,0);

	so->so_expire = curtime + SO_EXPIRE;

	insque(so, &slirp->udb);



	addr.sin_family = AF_INET;

	addr.sin_addr.s_addr = haddr;

	addr.sin_port = hport;



	if (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) {

		udp_detach(so);

		return NULL;

	}

	setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));



	getsockname(so->s,(struct sockaddr *)&addr,&addrlen);

	so->so_fport = addr.sin_port;

	if (addr.sin_addr.s_addr == 0 ||

	    addr.sin_addr.s_addr == loopback_addr.s_addr) {

	   so->so_faddr = slirp->vhost_addr;

	} else {

	   so->so_faddr = addr.sin_addr;

	}

	so->so_lport = lport;

	so->so_laddr.s_addr = laddr;

	if (flags != SS_FACCEPTONCE)

	   so->so_expire = 0;



	so->so_state &= SS_PERSISTENT_MASK;

	so->so_state |= SS_ISFCONNECTED | flags;



	return so;

}

udp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr,

           u_int lport, int flags)

{

	struct sockaddr_in addr;

	struct socket *so;

	socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1;



	so = socreate(slirp);

	if (!so) {

	    return NULL;

	}

	so->s = socket(AF_INET,SOCK_DGRAM,0);

	so->so_expire = curtime + SO_EXPIRE;

	insque(so, &slirp->udb);



	addr.sin_family = AF_INET;

	addr.sin_addr.s_addr = haddr;

	addr.sin_port = hport;



	if (bind(so->s,(struct sockaddr *)&addr, addrlen) < 0) {

		udp_detach(so);

		return NULL;

	}

	setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));



	getsockname(so->s,(struct sockaddr *)&addr,&addrlen);

	so->so_fport = addr.sin_port;

	if (addr.sin_addr.s_addr == 0 ||

	    addr.sin_addr.s_addr == loopback_addr.s_addr) {

	   so->so_faddr = slirp->vhost_addr;

	} else {

	   so->so_faddr = addr.sin_addr;

	}

	so->so_lport = lport;

	so->so_laddr.s_addr = laddr;

	if (flags != SS_FACCEPTONCE)

	   so->so_expire = 0;



	so->so_state &= SS_PERSISTENT_MASK;

	so->so_state |= SS_ISFCONNECTED | flags;



	return so;

}

	so->s = socket(AF_INET,SOCK_DGRAM,0);
FUNC_0(Slirp *VAR_0, u_int32_t VAR_1, u_int VAR_2, u_int32_t VAR_3,

           u_int VAR_4, int VAR_5)

{

	struct sockaddr_in VAR_6;

	struct socket *VAR_7;

	socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1;



	VAR_7 = socreate(VAR_0);

	if (!VAR_7) {

	    return NULL;

	}

	VAR_7->s = socket(AF_INET,SOCK_DGRAM,0);

	VAR_7->so_expire = curtime + SO_EXPIRE;

	insque(VAR_7, &VAR_0->udb);



	VAR_6.sin_family = AF_INET;

	VAR_6.sin_addr.s_addr = VAR_1;

	VAR_6.sin_port = VAR_2;



	if (bind(VAR_7->s,(struct sockaddr *)&VAR_6, addrlen) < 0) {

		udp_detach(VAR_7);

		return NULL;

	}

	setsockopt(VAR_7->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));



	getsockname(VAR_7->s,(struct sockaddr *)&VAR_6,&addrlen);

	VAR_7->so_fport = VAR_6.sin_port;

	if (VAR_6.sin_addr.s_addr == 0 ||

	    VAR_6.sin_addr.s_addr == loopback_addr.s_addr) {

	   VAR_7->so_faddr = VAR_0->vhost_addr;

	} else {

	   VAR_7->so_faddr = VAR_6.sin_addr;

	}

	VAR_7->so_lport = VAR_4;

	VAR_7->so_laddr.s_addr = VAR_3;

	if (VAR_5 != SS_FACCEPTONCE)

	   VAR_7->so_expire = 0;



	VAR_7->so_state &= SS_PERSISTENT_MASK;

	VAR_7->so_state |= SS_ISFCONNECTED | VAR_5;



	return VAR_7;

}

FUNC_0(Slirp *VAR_0, u_int32_t VAR_1, u_int VAR_2, u_int32_t VAR_3,
u_int VAR_4, int VAR_5)
{ struct sockaddr_in VAR_6; struct socket *VAR_7; socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1; VAR_7 = socreate(VAR_0); if (!VAR_7) { return NULL; } VAR_7->s = socket(AF_INET,SOCK_DGRAM,0); VAR_7->so_expire = curtime + SO_EXPIRE; insque(VAR_7, &VAR_0->udb); VAR_6.sin_family = AF_INET; VAR_6.sin_addr.s_addr = VAR_1; VAR_6.sin_port = VAR_2; if (bind(VAR_7->s,(struct sockaddr *)&VAR_6, addrlen) < 0) { udp_detach(VAR_7); return NULL; } setsockopt(VAR_7->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); getsockname(VAR_7->s,(struct sockaddr *)&VAR_6,&addrlen); VAR_7->so_fport = VAR_6.sin_port; if (VAR_6.sin_addr.s_addr == 0 ||
VAR_6.sin_addr.s_addr == loopback_addr.s_addr) { VAR_7->so_faddr = VAR_0->vhost_addr; } else { VAR_7->so_faddr = VAR_6.sin_addr; } VAR_7->so_lport = VAR_4; VAR_7->so_laddr.s_addr = VAR_3; if (VAR_5 != SS_FACCEPTONCE)
VAR_7->so_expire = 0; VAR_7->so_state &= SS_PERSISTENT_MASK; VAR_7->so_state |= SS_ISFCONNECTED | VAR_5; return VAR_7; }