sosendto(struct socket *so, struct mbuf *m)

{

	Slirp *slirp = so->slirp;

	int ret;

	struct sockaddr_in addr;



	DEBUG_CALL("sosendto");

	DEBUG_ARG("so = %p", so);

	DEBUG_ARG("m = %p", m);



        addr.sin_family = AF_INET;

	if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==

	    slirp->vnetwork_addr.s_addr) {

	  /* It's an alias */

	  if (so->so_faddr.s_addr == slirp->vnameserver_addr.s_addr) {

	    if (get_dns_addr(&addr.sin_addr) < 0)

	      addr.sin_addr = loopback_addr;

	  } else {

	    addr.sin_addr = loopback_addr;

	  }

	} else

	  addr.sin_addr = so->so_faddr;

	addr.sin_port = so->so_fport;



	DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n", ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));



	/* Don't care what port we get */

	ret = sendto(so->s, m->m_data, m->m_len, 0,

		     (struct sockaddr *)&addr, sizeof (struct sockaddr));

	if (ret < 0)

		return -1;



	/*

	 * Kill the socket if there's no reply in 4 minutes,

	 * but only if it's an expirable socket

	 */

	if (so->so_expire)

		so->so_expire = curtime + SO_EXPIRE;

	so->so_state &= SS_PERSISTENT_MASK;

	so->so_state |= SS_ISFCONNECTED; /* So that it gets select()ed */

	return 0;

}

sosendto(struct socket *so, struct mbuf *m)

{

	Slirp *slirp = so->slirp;

	int ret;

	struct sockaddr_in addr;



	DEBUG_CALL("sosendto");

	DEBUG_ARG("so = %p", so);

	DEBUG_ARG("m = %p", m);



        addr.sin_family = AF_INET;

	if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==

	    slirp->vnetwork_addr.s_addr) {

	  

	  if (so->so_faddr.s_addr == slirp->vnameserver_addr.s_addr) {

	    if (get_dns_addr(&addr.sin_addr) < 0)

	      addr.sin_addr = loopback_addr;

	  } else {

	    addr.sin_addr = loopback_addr;

	  }

	} else

	  addr.sin_addr = so->so_faddr;

	addr.sin_port = so->so_fport;



	DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n", ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));



	

	ret = sendto(so->s, m->m_data, m->m_len, 0,

		     (struct sockaddr *)&addr, sizeof (struct sockaddr));

	if (ret < 0)

		return -1;



	







	if (so->so_expire)

		so->so_expire = curtime + SO_EXPIRE;

	so->so_state &= SS_PERSISTENT_MASK;

	so->so_state |= SS_ISFCONNECTED; 

	return 0;

}

FUNC_0(struct socket *VAR_0, struct mbuf *VAR_1)

{

	Slirp *slirp = VAR_0->slirp;

	int VAR_2;

	struct sockaddr_in VAR_3;



	DEBUG_CALL("FUNC_0");

	DEBUG_ARG("VAR_0 = %p", VAR_0);

	DEBUG_ARG("VAR_1 = %p", VAR_1);



        VAR_3.sin_family = AF_INET;

	if ((VAR_0->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==

	    slirp->vnetwork_addr.s_addr) {

	  

	  if (VAR_0->so_faddr.s_addr == slirp->vnameserver_addr.s_addr) {

	    if (get_dns_addr(&VAR_3.sin_addr) < 0)

	      VAR_3.sin_addr = loopback_addr;

	  } else {

	    VAR_3.sin_addr = loopback_addr;

	  }

	} else

	  VAR_3.sin_addr = VAR_0->so_faddr;

	VAR_3.sin_port = VAR_0->so_fport;



	DEBUG_MISC((dfd, " sendto()ing, VAR_3.sin_port=%d, VAR_3.sin_addr.s_addr=%.16s\n", ntohs(VAR_3.sin_port), inet_ntoa(VAR_3.sin_addr)));



	

	VAR_2 = sendto(VAR_0->s, VAR_1->m_data, VAR_1->m_len, 0,

		     (struct sockaddr *)&VAR_3, sizeof (struct sockaddr));

	if (VAR_2 < 0)

		return -1;



	







	if (VAR_0->so_expire)

		VAR_0->so_expire = curtime + SO_EXPIRE;

	VAR_0->so_state &= SS_PERSISTENT_MASK;

	VAR_0->so_state |= SS_ISFCONNECTED; 

	return 0;

}

FUNC_0(struct socket *VAR_0, struct mbuf *VAR_1)
{ Slirp *slirp = VAR_0->slirp; int VAR_2; struct sockaddr_in VAR_3; DEBUG_CALL("FUNC_0"); DEBUG_ARG("VAR_0 = %p", VAR_0); DEBUG_ARG("VAR_1 = %p", VAR_1); VAR_3.sin_family = AF_INET; if ((VAR_0->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==
slirp->vnetwork_addr.s_addr) { if (VAR_0->so_faddr.s_addr == slirp->vnameserver_addr.s_addr) { if (get_dns_addr(&VAR_3.sin_addr) < 0)
VAR_3.sin_addr = loopback_addr; } else { VAR_3.sin_addr = loopback_addr; } } else VAR_3.sin_addr = VAR_0->so_faddr; VAR_3.sin_port = VAR_0->so_fport; DEBUG_MISC((dfd, " sendto()ing, VAR_3.sin_port=%d, VAR_3.sin_addr.s_addr=%.16s\n", ntohs(VAR_3.sin_port), inet_ntoa(VAR_3.sin_addr))); VAR_2 = sendto(VAR_0->s, VAR_1->m_data, VAR_1->m_len, 0,
(struct sockaddr *)&VAR_3, sizeof (struct sockaddr)); if (VAR_2 < 0)
return -1; if (VAR_0->so_expire)
VAR_0->so_expire = curtime + SO_EXPIRE; VAR_0->so_state &= SS_PERSISTENT_MASK; VAR_0->so_state |= SS_ISFCONNECTED; return 0; }