c - raw socket. ip header when to use hton -
i new raw socket, , playing around ip header. noticed ip->ip_hl = sizeof(struct ip) >> 2 //works fine;
ip->ip_hl = hton(sizeof(struct ip) >> 2) //will not work;
what dont understand why not convert numbers network order instead of host order in case? what's general rule judge when use network order/host order?
thanks
htons
16-bit values. htonl
32-bit values. hton
(no suffix), i'm not sure exists.
the header length occupies 1 byte (actually part of 1 byte). don't need flip bytes right form. accordingly, there no macro htons
or htonl
8-bit values.
Comments
Post a Comment