#include #include #include #define __sso_be __attribute__((scalar_storage_order("big-endian"))) struct __sso_be ipv6hdr { uint32_t version:4, tos:8, flow_lbl:20; }; int main() { struct ipv6hdr hdr; memcpy(&hdr, "\x60\x01\x23\x45", 4); printf("size: %ld\n\n", sizeof(hdr)); printf("version: %x\n", hdr.version); printf("tos: %x\n", hdr.tos); printf("flow_lbl: %x\n\n", hdr.flow_lbl); return 0; }