How to Learn the Structure of Linux Wireless Drivers (Mac80211)

configure network device with wireless extensions

the struct iwreq is found in linux/wireless.h you can simply include it and use the 'iwreq' struct.

misaligned address access crash on linux wifi drivers on arc platform

Simple. Just do the right thing. In general case, one would use memcpy:

t_u32 value = wlan_cpu_to_le32((t_u32)ul_temp);
memcpy(psnmp_mib->value, &value, sizeof (t_u32));

As pointed out by 0andriy, the put_unaligned could be used here:

put_unaligned(wlan_cpu_to_le32((t_u32)ul_temp), (t_u32*)psnmp_mib->value);

However this is very worrisome because the C standard does state that the behaviour is undefined when:

Conversion between two pointer types produces a result that is incorrectly aligned (6.3.2.3).

Thus even the mere presence of the cast (t_u32*) can lead to the compiler to "realize" that the pointer psnmp_mib->value is aligned to the alignment requirement of t_u32 anyway.


Unaligned access - or even casting pointers to unaligned structures - has undefined behaviour even on platforms that "supposedly" allow unaligned access "everywhere".



Related Topics



Leave a reply



Submit