lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: [lwip] netif alignment


From: Jani Monoses
Subject: [lwip-users] Re: [lwip] netif alignment
Date: Wed, 08 Jan 2003 23:37:03 -0000

What does correctly as you have assumed mean ?
The netif structure does not have strict packing or alignment requirements
If you compile lwip and your app with the same compiler options it should work..
What target and version of gcc?
But yes the netif struct could use a bit of restructuring even if only for
better readability.

> Hello,
> 
> When compiling and linking the lwIP stack to our application, the compiler
> (gcc) apparently did not align the stucture netif correctly as I had
> assumed. At runtime, the netif structure was allocated in an aligned manner,
> 24 bytes, the first few entries could be dereferenced, but not the input and
> output functions. This could be solved by a slightly different struct
> definition:
> 
> struct netif {
>   struct netif *next;
>   struct ip_addr ip_addr;
>   struct ip_addr netmask;  /* netmask in network byte order */
>   struct ip_addr gw;
>   unsigned char hwaddr[6];
>   char name[2];
> 
>   /* This function is called by the network device driver
>      when it wants to pass a packet to the TCP/IP stack. */
>   err_t (* input)(struct pbuf *p, struct netif *inp);
> 
>   /* The following two fields should be filled in by the
>      initialization function for the device driver. */
> 
>   /* This function is called by the IP module when it wants
>      to send a packet on the interface. */
>   err_t (* output)(struct netif *netif, struct pbuf *p,
>                  struct ip_addr *ipaddr);
>   err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
> 
>   /* This field can be set bu the device driver and could point
>      to state information for the device. */
>   void *state;
>   u8_t num;
>   u8_t dummy[MEM_ALIGNMENT-1];
> };
> 
> peter
> 
> 
> Peter Wurmsdober
> Eurotherm Drives Ltd.
> Littlehampton, BN17 7RZ, UK
> TEL: +44 19 03 73 73 58
> FAX: +44 19 03 73 71 07
> [This message was sent through the lwip discussion list.]
[This message was sent through the lwip discussion list.]




reply via email to

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