[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] uIP: writev() and tap
From: |
Adam Dunkels |
Subject: |
[lwip-users] Re: [lwip] uIP: writev() and tap |
Date: |
Wed, 08 Jan 2003 22:34:04 -0000 |
Hi Felipe!
Yes, the Linux code for uIP 0.6 was taken from lwIP without even looking at
it :-)
On Tuesday 19 February 2002 01.06, you wrote:
> it seems that the tap device under Linux gets a packet per write. So the
> writev in tapdev_send breaks one packet in 2. Well, I replaced the writev
> with
>
> ret = write(fd,uip_buf,uip_len);
>
> Even thinking "well, there must be a reason to use writev instead of
> write"... I suppose it's because sometimes there's a "hole" between the
> headers and the data.
The writev will gather the two pieces of data in a single write() since the
headers and data can be from different places in memory. There is a bug in
Linux < 2.4.18 that makes writev() on a tapdev misbehave. Eddie C. Dost
reported this uIP bug a few days ago and also sent in a bug report to Linus
so that upcoming Linux versions will work better with writev() and the tap
device.
The simplest workaround is just to copy the data into a new buffer and do a
write() on that buffer:
#ifdef linux
{
char tmpbuf[UIP_BUFSIZE];
int i;
for(i = 0; i < 40 + UIP_LLH_LEN; i++) {
tmpbuf[i] = uip_buf[i];
}
for(; i < uip_len; i++) {
tmpbuf[i] = uip_appdata[i - 40 - UIP_LLH_LEN];
}
ret = write(fd, tmpbuf, uip_len);
}
#else
/adam
--
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]
- [lwip-users] Re: [lwip] uIP: writev() and tap,
Adam Dunkels <=