[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t)
From: |
Stephane Lesage |
Subject: |
[lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t) |
Date: |
Fri, 05 Feb 2010 14:00:12 +0000 |
User-agent: |
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) |
Follow-up Comment #31, bug #27352 (project lwip):
>At least struct etharp_hdr contains an unaligned IP address (sipaddr).
>This is currently the reason we have the struct ip_addr2. >However, if
that's the only problem we can just add an u16_t array there
>since we only access this field using SMEMCPY, anyway.
By "word" aligned I mean "2-bytes" = even addresses.
etharp_hdr->sipaddr is indeed word aligned.
>Only some structs would still require packing (netbios and ip_reass_helper
mainly).
no I think netbios_name_hdr fields are also word aligned.
Of course, as other structures, IP payload can be aligned at 2 or 4, when
using padding.
Compiling with #pragma pack(2) works for me.
>> - define IP4_ADDR() and ip4_addrX() macros directly according to
endianness
>On big endian platforms, the ntohX/htonX functions should be defined to
nothing,
>so that should improved away by the compiler.
the problem is little endian...
what about this ?
#if BYTE_ORDER == BIG_ENDIAN
#define IP4_ADDR(ipaddr, a,b,c,d)
(ipaddr)->addr = (((u32_t)((a) & 0xff) << 24) |
((u32_t)((b) & 0xff) << 16) |
((u32_t)((c) & 0xff) << 8) |
(u32_t)((d) & 0xff))
#else
#define IP4_ADDR(ipaddr, a,b,c,d)
(ipaddr)->addr = (((u32_t)((d) & 0xff) << 24) |
((u32_t)((c) & 0xff) << 16) |
((u32_t)((b) & 0xff) << 8) |
(u32_t)((a) & 0xff))
#endif
#if BYTE_ORDER == BIG_ENDIAN
#define ip4_addr1(ipaddr) (((u8_t*)&((ipaddr)->addr))[0])
#define ip4_addr2(ipaddr) (((u8_t*)&((ipaddr)->addr))[1])
#define ip4_addr3(ipaddr) (((u8_t*)&((ipaddr)->addr))[2])
#define ip4_addr4(ipaddr) (((u8_t*)&((ipaddr)->addr))[3])
#else
#define ip4_addr1(ipaddr) (((u8_t*)&((ipaddr)->addr))[3])
#define ip4_addr2(ipaddr) (((u8_t*)&((ipaddr)->addr))[2])
#define ip4_addr3(ipaddr) (((u8_t*)&((ipaddr)->addr))[1])
#define ip4_addr4(ipaddr) (((u8_t*)&((ipaddr)->addr))[0])
#endif
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/bugs/?27352>
_______________________________________________
Message posté via/par Savannah
http://savannah.nongnu.org/
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), (continued)
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Simon Goldschmidt, 2010/02/01
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Bill Auerbach, 2010/02/01
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Simon Goldschmidt, 2010/02/02
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Bill Auerbach, 2010/02/02
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Bill Auerbach, 2010/02/02
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Simon Goldschmidt, 2010/02/02
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Simon Goldschmidt, 2010/02/04
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Stephane Lesage, 2010/02/04
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Stephane Lesage, 2010/02/05
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Simon Goldschmidt, 2010/02/05
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t),
Stephane Lesage <=
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Simon Goldschmidt, 2010/02/05
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Bill Auerbach, 2010/02/05
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Stephane Lesage, 2010/02/06
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Stephane Lesage, 2010/02/06
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Stephane Lesage, 2010/02/07
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Simon Goldschmidt, 2010/02/08
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Simon Goldschmidt, 2010/02/08
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Kieran Mansley, 2010/02/08
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Stephane Lesage, 2010/02/08
- [lwip-devel] [bug #27352] Change ip_addr from struct to typedef (u32_t), Stephane Lesage, 2010/02/13