/* 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 sbcopy(struct sbuf *sb, int off, int len, char *to)
/* 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 sbcopy(struct sbuf *sb, int off, int len, char *to)
{
	char *from;
	from = sb->sb_rptr + off;
	if (from >= sb->sb_data + sb->sb_datalen)
		from -= sb->sb_datalen;
	if (from < sb->sb_wptr) {
		if (len > sb->sb_cc) len = sb->sb_cc;
		memcpy(to,from,len);
	} else {
		off = (sb->sb_data + sb->sb_datalen) - from;
		if (off > len) off = len;
		memcpy(to,from,off);
		len -= off;
		if (len)
		   memcpy(to+off,sb->sb_data,len);
	}
}