IP报头格式

来源:互联网 发布:mysql语句面试题及答案 编辑:程序博客网 时间:2024/06/05 11:35




/* * Structure of an internet header, naked of options. */struct ip{#if __BYTE_ORDER == __LITTLE_ENDIANunsigned int ip_hl:4;/* header length */unsigned int ip_v:4;/* version */#endif#if __BYTE_ORDER == __BIG_ENDIANunsigned int ip_v:4;/* version */unsigned int ip_hl:4;/* header length */#endifu_int8_tip_tos;/* type of service */u_shortip_len;/* total length */u_shortip_id;/* identification */u_shortip_off;/* fragment offset field */#defineIP_RF 0x8000/* reserved fragment flag */#defineIP_DF 0x4000/* dont fragment flag */#defineIP_MF 0x2000/* more fragments flag */#defineIP_OFFMASK 0x1fff/* mask for fragmenting bits */u_int8_tip_ttl;/* time to live */u_int8_tip_p;/* protocol */u_shortip_sum;/* checksum */struct in_addr ip_src, ip_dst;/* source and dest address */};