title: Determining if a packet is ipv4 or ipv6 from sk_buff's network header
body: <p>I have the SKB of type 'struct sk_buff' and I was trying to determine if the packet is of type IPv4 or IPv6. Basically I need the source IP address, but dont know, for sure how to check the 'version' field inside iph or ipv6h, or dont know if it is a reliable approach to check 'version' value. </p>
  
  <p>Network header inside the sk_buff implementation on my machine is:</p>
  
  <pre><code>union {
          struct iphdr    *iph;
          struct ipv6hdr  *ipv6h;
          struct arphdr   *arph;
          unsigned char   *raw;
  } nh;
  </code></pre>
  
  <p>And the iphdr and ipv6hdr have usual definitions.</p>
  
  <p>How to determine the IP version from the IP network header in sk_buff?</p>