Safe, efficient way to access unaligned data in a network packet from C
问题 I'm writing a program in C for Linux on an ARM9 processor. The program is to access network packets which include a sequence of tagged data like: <fieldID><length><data><fieldID><length><data> ... The fieldID and length fields are both uint16_t. The data can be 1 or more bytes (up to 64k if the full length was used, but it's not). As long as <data> has an even number of bytes, I don't see a problem. But if I have a 1- or 3- or 5-byte <data> section then the next 16-bit fieldID ends up not on