title: How to check if flag in TCP struct is set?
body: <p>I'm using the pcap C library to read packets. Currently, I use the following to check and see whether a flag in the <code>struct tcphdr</code> (this struct is defined in the <code>netinet/tcp.h</code> library) is set:</p>
  
  <pre><code>struct tcphdr *tcp = ....
  
  if(tcp-&gt;th_flags &amp; TH_SYN) {
          //SYN FLAG IS SET?
      }
  </code></pre>
  
  <p>Will this always work for checking if a particular flag is set in the struct? Or is there a better way? Would greatly appreciate any advice/tips :)</p>