lwip-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-members] BUG: UDP recv callback returns network byte order


From: Jani Monoses
Subject: Re: [lwip-members] BUG: UDP recv callback returns network byte order
Date: Fri, 31 Jan 2003 17:46:18 +0200

Trying to remember what was in my mind back then :
BSD socket calls assume network byte order.

In recv_udp which is the udp recv hook in netconn and implicitely in socket API
there are two lines like
      buf->fromaddr = addr;
      buf->fromport = port;
    }

which fill the netbuf IP/port  from what is passed up from UDP layer.

Seeing that addr is already in net byte order in udp_input i.e. taken directly
from the header I thought it would be consistent to pass the port up in the 
same way.

> > >       pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), udphdr->src);

Either byte order we keep port and IP at various levels they at least should be 
the same
for both.

So we'll have to decide on a fix for this.As it was before I changed the 
sockaddr returned from
an udp recv was in host byte order which is not the way it should be.Another 
way of fixing
would be 

buf->fromaddr = addr;
 buf->fromport = ntohs(port);

at the netconn level .It looks inconsistent and we do 2 ntohs on the way 
UDP->SOCK when we could do 0.

Thoughts?







reply via email to

[Prev in Thread] Current Thread [Next in Thread]