coova / coova-chilli

CoovaChilli is an open-source software access controller for captive portal hotspots.
Other
512 stars 258 forks source link

fix for getting fragment offset in ip header #575

Closed kkrime closed 7 months ago

kkrime commented 11 months ago

In an IP header, If the first 3 bits from the 7th byte are flags not related to the fragment offset, then they should be blocked out (using bitwise &) and the rest should remain, hence:

ntohs((((p)->opt_off_high & 0x1f) << 8)|(p)->off_low)

In the original:

ntohs((((p)->opt_off_high & 0x13) << 8)|(p)->off_low)

I'm really having trouble understanding why we & with 0x13, won't this unset some of the fragmentation offset bits?

Maybe this is something I don't understand (I'm new to low level network programming), if so, please let me know why it's done this way.

Thanks