title: How to access IP_DF and IP_MF from iph->frag_offset when using netfilter
body: <p>I am trying to write a netfilter module and want to access the fields of the IPHeader that denotes the DF and MF fields. I can access most other fields as desired but I think I have to extract the DF and MF fields from the ipheader in the struct and manipulate them say for example I want to set or unset the DF bit depending on the type of packet I receive.</p>
  
  <p>The below structure has 'frag_off' how do I access/rewrite IP_DF and IP_MF from this?</p>
  
  <pre><code>struct iphdr {
      #if defined(__LITTLE_ENDIAN_BITFIELD)
          __u8    ihl:4,
                  version:4;
      #elif defined (__BIG_ENDIAN_BITFIELD)
          __u8    version:4,
                  ihl:4;
      #else
          #error  "Please fix &lt;asm/byteorder.h&gt;"
      #endif
           __u8   tos;
           __u16  tot_len;
           __u16  id;
           __u16  frag_off;
           __u8   ttl;
           __u8   protocol;
           __u16  check;
           __u32  saddr;
           __u32  daddr;
           /*The options start here. */
  };
  
  #define IP_MF 0x2000 /* Flag: "More Fragments" */
  #define IP_OFFSET 0x1FFF /* "Fragment Offset" part */
  #define IP_DF 0x4000 /* dont fragment flag */
        printk(KERN_INFO "IP_FRAG_OFF : %d", (iph-&gt;frag_off &amp; IP_OFFSET));
        printk(KERN_INFO "MF: %d", (iph-&gt;frag_off &amp; IP_MF));
  </code></pre>