lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] Question about a specific error handling in "lwip_sendt


From: Benjamin Schelte
Subject: RE: [lwip-users] Question about a specific error handling in "lwip_sendto" (1.4.0.rc1)
Date: Wed, 20 Oct 2010 16:54:30 +0200

Thank you for your answer. That sounds reasonable.
But if you say that "sizeof(sockaddr)" should be equal to "sizeof(sockaddr_in)" 
then there might be a problem inside "sockets.h".

/* members are in network byte order */
struct sockaddr_in {
  u8_t sin_len;
  u8_t sin_family;
  u16_t sin_port;
  struct in_addr sin_addr;
  char sin_zero[8];
};
Memory usage on my system: 16 bytes

struct sockaddr {
  u8_t sa_len;
  u8_t sa_family;
  u16_t sa_data[14];
};
Memory usage on my system: 30 bytes

That seems to be the reason, where my problem was coming from.
If it is problematic someone of the developers might fix it before 1.4.0 is 
finally released.

Best regards,
Benjamin



> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden On
> Behalf Of Simon Goldschmidt
> Sent: Wednesday, October 20, 2010 4:24 PM
> To: Mailing list for lwIP users
> Subject: Re: [lwip-users] Question about a specific error handling in
> "lwip_sendto" (1.4.0.rc1)
> 
> "Benjamin Schelte" <address@hidden> wrote:
> > So LWIP_ERROR will throw an error here, because (sizeof(struct
> sockaddr))
> > !=
> > (sizeof(struct sockaddr_in)).
> 
> That seems like a bug in our "struct sockaddr" definition. I though the
> two structs have the same size...?
> 
> > Is this intended behavior?
> 
> Yes: 'struct sockaddr' is like an "abstract base-class" struct: it is
> not really useful on its own, only the derived structs are used.
> However, this was the way the creators of the BSD socket API wanted to
> create functions that don't change for future addresses. As the lwIP
> socket API only supports IPv4 addresses, you have to pass a
> sockaddr_in. Passing a sockaddr is *not* correct! You have to pass a
> struct sockaddr_in casted to a "struct sockaddr*", but the size has to
> be "sizeof(struct sockaddr_in)".
> 
> > Or is either the LWIP_ERROR condition or the parameter list of
> lwIP_sendto incorrect?
> 
> See above. After all, since the two sizes should be the same, you
> wouldn't have noticed that your code is wrong ;-) It might work, but
> it's not how it is intended.
> 
> Simon
> --
> GRATIS! Movie-FLAT mit über 300 Videos.
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
> 
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users




reply via email to

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