sbuf.c revision 56ddefc0b36ad1ad21a595bf75c4ac460085c24b
/*
* Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/
#include <slirp.h>
/* Done as a macro in socket.h */
/* int
* sbspace(struct sockbuff *sb)
* {
* return SB_DATALEN - sb->sb_cc;
* }
*/
void
{
}
void
{
/*
* We can only drop how much we have
* This should never succeed
*/
}
void
{
{
/* Already alloced, realloc if necessary */
{
else
sb->sb_datalen = 0;
}
}
else
{
else
sb->sb_datalen = 0;
}
}
/*
* Try and write() to the socket, whatever doesn't get written
* append to the buffer... for a host with a fast net connection,
* this prevents an unnecessary copy of the data
* (the socket is non-blocking, so we won't hang)
*/
void
{
int ret = 0;
DEBUG_CALL("sbappend");
DEBUG_ARG("m = %lx", (long)m);
/* Shouldn't happen, but... e.g. foreign host closes connection */
if (m->m_len <= 0)
{
return;
}
/*
* If there is urgent data, call sosendoob
* if not all was sent, sowrite will take care of the rest
* (The rest of this function is just an optimisation)
*/
{
return;
}
/*
* We only write if there's nothing in the buffer,
* ottherwise it'll arrive out of order, and hence corrupt
*/
if (ret <= 0)
{
/*
* Nothing was written
* It's possible that the socket has closed, but
* we don't need to check because if it has closed,
* it will be detected in the normal way by soread()
*/
}
{
/*
* Something was written, but not everything..
* sbappendsb the rest
*/
} /* else */
/* Whatever happened, we free the mbuf */
}
/*
* Copy the data from m into sb
* The caller is responsible to make sure there's enough room
*/
void
{
{
if (n > len)
n = len;
}
else
{
/* Do the right edge first */
if (n > len)
n = len;
len -= n;
if (len)
{
/* Now the left edge */
n += nn;
}
}
}
/*
* Copy data from sbuf to a normal, straight buffer
* Don't update the sbuf rptr, this will be
* done in sbdrop when the data is acked
*/
void
{
char *from;
{
}
else
{
/* re-use off */
if (len)
}
}