c - How to find whether the MORE FRAGMENTS field is set or no? -


given header , how find if more fragments field set or not..

struct sniff_ip {         u_char  ip_vhl;                 /* version << 4 | header length >> 2 */         u_char  ip_tos;                 /* type of service */         u_short ip_len;                 /* total length */         u_short ip_id;                  /* identification */         u_short ip_off;                 /* fragment offset field */         #define ip_rf 0x8000            /* reserved fragment flag */         #define ip_df 0x4000            /* dont fragment flag */         #define ip_mf 0x2000            /* more fragments flag */         #define ip_offmask 0x1fff       /* mask fragmenting bits */         u_char  ip_ttl;                 /* time live */         u_char  ip_p;                   /* protocol */         u_short ip_sum;                 /* checksum */         struct  in_addr ip_src,ip_dst;  /* source , dest address */ }; 

struct sniff_ip ip_hdr;  ... if(ip_hdr.ip_off & ip_mf) {   //more fragments bit set. } 

Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -