我已经在原始套接字开始一个冒险,我发现一个IP报头,我不明白,我的疑问是叶结构参数C
- hdrlen:4
这两分四点用于什么?
- 属性((填充));
什么是这个属性?
struct iphdr {
uint8_t hdrlen:4;
uint8_t version:4;
uint8_t ecn:2; // Explicit Congestion Notification - RFC 3168
uint8_t dscp:6; // DiffServ Code Point
uint16_t length;
uint16_t ident;
uint16_t fragoff:13;
uint16_t flags:3;
uint8_t ttl;
uint8_t protocol;
uint16_t checksum;
uint32_t srcip;
uint32_t dstip;
uint32_t options[ ]; // Present if hdrlen > 5
} __attribute__((__packed__));
可能的重复[什么是C++结构语法“a:b”的意思](http://stackoverflow.com/questions/824295/what-does-c-struct-syntax-ab-mean) –
http:///stackoverflow.com/questions/1604968/what-does-a-colon-in-a-struct-declaration-mean-such-as-1-7-16-or-32/1604972#1604972 – thelaws
http:// stackoverflow .com/questions/8568432/is-gccs-attribute-packed-pragma-pack-unsafe – thelaws