I considered solving the problem by changing the ip_addr struct from:
struct ip_addr {
u32_t addr;
}
To something like:
struct ip_addr {
u8_t addr0;
u8_t addr1;
u8_t addr2;
u8_t addr3;
}
But I found that this struct is used in tons of places.
That's alot of code to
rewrite..
Have anyone solved this problem without introducing padding?
Yes, I had to use a similar approach to what you suggested:
struct ip_addr {
u8_t addrb[4];
}
I changed the name to ensure the compiler would catch all occurrences.
I then used macros to access the address. When copying, I used structure copy, i.e. instead of
"p->addr = x->y.addr;" I did "*p = x->y;". I defined htonlb() and ntohlb()
functions too.
A lot of the required changes are actually in LWIP_DEBUGF statements.
The next thing I found was that similar changes were needed for the seqno and
ackno in the TCP header, which are also unaligned, and so need redefinition as
u8_t arrays. It is then necessary to be careful about byte order. Instead of
rewriting the header in the received buffer, I left the seqno and ackno in
network byte order in the header, but transformed to native order when copying
to local variables.
I have hesitated to submit my changes yet, because there are still a few
kludges and also I haven't yet ensured portability back to CPUs and compilers
that don't need all this trickery. Also because I've been doing it as paid work.
Cheers,
Tony
***********************************************************************************
This email, its content and any attachments is PRIVATE AND
CONFIDENTIAL to TANDBERG Television. If received in error please
notify the sender and destroy the original message and attachments.
www.tandbergtv.com
***********************************************************************************
_______________________________________________
lwip-users mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/lwip-users