sosendoob(struct socket *so)

{

	struct sbuf *sb = &so->so_rcv;

	char buff[2048]; /* XXX Shouldn't be sending more oob data than this */



	int n, len;



	DEBUG_CALL("sosendoob");

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

	DEBUG_ARG("sb->sb_cc = %d", sb->sb_cc);



	if (so->so_urgc > 2048)

	   so->so_urgc = 2048; /* XXXX */



	if (sb->sb_rptr < sb->sb_wptr) {

		/* We can send it directly */

		n = slirp_send(so, sb->sb_rptr, so->so_urgc, (MSG_OOB)); /* |MSG_DONTWAIT)); */

		so->so_urgc -= n;



		DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));

	} else {

		/*

		 * Since there's no sendv or sendtov like writev,

		 * we must copy all data to a linear buffer then

		 * send it all

		 */

		len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;

		if (len > so->so_urgc) len = so->so_urgc;

		memcpy(buff, sb->sb_rptr, len);

		so->so_urgc -= len;

		if (so->so_urgc) {

			n = sb->sb_wptr - sb->sb_data;

			if (n > so->so_urgc) n = so->so_urgc;

			memcpy((buff + len), sb->sb_data, n);

			so->so_urgc -= n;

			len += n;

		}

		n = slirp_send(so, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */

#ifdef DEBUG

		if (n != len)

		   DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));

#endif

		DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));

	}



	sb->sb_cc -= n;

	sb->sb_rptr += n;

	if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen))

		sb->sb_rptr -= sb->sb_datalen;



	return n;

}

sosendoob(struct socket *so)

{

	struct sbuf *sb = &so->so_rcv;

	char buff[2048]; 



	int n, len;



	DEBUG_CALL("sosendoob");

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

	DEBUG_ARG("sb->sb_cc = %d", sb->sb_cc);



	if (so->so_urgc > 2048)

	   so->so_urgc = 2048; 



	if (sb->sb_rptr < sb->sb_wptr) {

		

		n = slirp_send(so, sb->sb_rptr, so->so_urgc, (MSG_OOB)); 

		so->so_urgc -= n;



		DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));

	} else {

		









		len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;

		if (len > so->so_urgc) len = so->so_urgc;

		memcpy(buff, sb->sb_rptr, len);

		so->so_urgc -= len;

		if (so->so_urgc) {

			n = sb->sb_wptr - sb->sb_data;

			if (n > so->so_urgc) n = so->so_urgc;

			memcpy((buff + len), sb->sb_data, n);

			so->so_urgc -= n;

			len += n;

		}

		n = slirp_send(so, buff, len, (MSG_OOB)); 

#ifdef DEBUG

		if (n != len)

		   DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));

#endif

		DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));

	}



	sb->sb_cc -= n;

	sb->sb_rptr += n;

	if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen))

		sb->sb_rptr -= sb->sb_datalen;



	return n;

}

FUNC_0(struct socket *VAR_0)

{

	struct sbuf *VAR_1 = &VAR_0->so_rcv;

	char VAR_2[2048]; 



	int VAR_3, VAR_4;



	DEBUG_CALL("FUNC_0");

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

	DEBUG_ARG("VAR_1->sb_cc = %d", VAR_1->sb_cc);



	if (VAR_0->so_urgc > 2048)

	   VAR_0->so_urgc = 2048; 



	if (VAR_1->sb_rptr < VAR_1->sb_wptr) {

		

		VAR_3 = slirp_send(VAR_0, VAR_1->sb_rptr, VAR_0->so_urgc, (MSG_OOB)); 

		VAR_0->so_urgc -= VAR_3;



		DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\VAR_3", VAR_3, VAR_0->so_urgc));

	} else {

		









		VAR_4 = (VAR_1->sb_data + VAR_1->sb_datalen) - VAR_1->sb_rptr;

		if (VAR_4 > VAR_0->so_urgc) VAR_4 = VAR_0->so_urgc;

		memcpy(VAR_2, VAR_1->sb_rptr, VAR_4);

		VAR_0->so_urgc -= VAR_4;

		if (VAR_0->so_urgc) {

			VAR_3 = VAR_1->sb_wptr - VAR_1->sb_data;

			if (VAR_3 > VAR_0->so_urgc) VAR_3 = VAR_0->so_urgc;

			memcpy((VAR_2 + VAR_4), VAR_1->sb_data, VAR_3);

			VAR_0->so_urgc -= VAR_3;

			VAR_4 += VAR_3;

		}

		VAR_3 = slirp_send(VAR_0, VAR_2, VAR_4, (MSG_OOB)); 

#ifdef DEBUG

		if (VAR_3 != VAR_4)

		   DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\VAR_3"));

#endif

		DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\VAR_3", VAR_3, VAR_0->so_urgc));

	}



	VAR_1->sb_cc -= VAR_3;

	VAR_1->sb_rptr += VAR_3;

	if (VAR_1->sb_rptr >= (VAR_1->sb_data + VAR_1->sb_datalen))

		VAR_1->sb_rptr -= VAR_1->sb_datalen;



	return VAR_3;

}

FUNC_0(struct socket *VAR_0)
{ struct sbuf *VAR_1 = &VAR_0->so_rcv; char VAR_2[2048]; int VAR_3, VAR_4; DEBUG_CALL("FUNC_0"); DEBUG_ARG("VAR_0 = %p", VAR_0); DEBUG_ARG("VAR_1->sb_cc = %d", VAR_1->sb_cc); if (VAR_0->so_urgc > 2048)
VAR_0->so_urgc = 2048; if (VAR_1->sb_rptr < VAR_1->sb_wptr) { VAR_3 = slirp_send(VAR_0, VAR_1->sb_rptr, VAR_0->so_urgc, (MSG_OOB)); VAR_0->so_urgc -= VAR_3; DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\VAR_3", VAR_3, VAR_0->so_urgc)); } else { VAR_4 = (VAR_1->sb_data + VAR_1->sb_datalen) - VAR_1->sb_rptr; if (VAR_4 > VAR_0->so_urgc) VAR_4 = VAR_0->so_urgc; memcpy(VAR_2, VAR_1->sb_rptr, VAR_4); VAR_0->so_urgc -= VAR_4; if (VAR_0->so_urgc) { VAR_3 = VAR_1->sb_wptr - VAR_1->sb_data; if (VAR_3 > VAR_0->so_urgc) VAR_3 = VAR_0->so_urgc; memcpy((VAR_2 + VAR_4), VAR_1->sb_data, VAR_3); VAR_0->so_urgc -= VAR_3; VAR_4 += VAR_3; } VAR_3 = slirp_send(VAR_0, VAR_2, VAR_4, (MSG_OOB)); #ifdef DEBUG
if (VAR_3 != VAR_4)
DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\VAR_3")); #endif
DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\VAR_3", VAR_3, VAR_0->so_urgc)); } VAR_1->sb_cc -= VAR_3; VAR_1->sb_rptr += VAR_3; if (VAR_1->sb_rptr >= (VAR_1->sb_data + VAR_1->sb_datalen))
VAR_1->sb_rptr -= VAR_1->sb_datalen; return VAR_3; }