Reputation: 163
I have following code in packet sniffer:
struct ip_header {
unsigned char ip_ver:4;
...
};
...
printf("Version: %i\n", (int)ip_hdr->ip_ver)
The output of ths is "Version: 5". I think version can onl be 4 or 6, right?
Upvotes: 1
Views: 72
Reputation: 163
I got it it is just the Header length first 4 bits and version is second 4bits, so it should be
struct ip_header {
unsigned char ip_hl:4;
unsigned char ip_ver:4;
...
};
Upvotes: 1