title: Parse dns header in C
body: <p>I would like to have a dns-parser. I have found this code:</p>
  
  <p><a href="https://github.com/uvic-sdo/DNS-Packet-Parser" rel="nofollow">https://github.com/uvic-sdo/DNS-Packet-Parser</a></p>
  
  <p>Which is quite useful and understandable. It prints DNS answer (Resource Records) using RR structure:</p>
  
  <pre><code>typedef struct {
      uint16_t type;
      uint16_t clas;
      uint32_t ttl;
      uint16_t rdlength;
  } static_RR;
  </code></pre>
  
  <p>The answer is than derived from packet:</p>
  
  <pre><code>static_RR* RRd = (static_RR*) ((void*) pd-&gt;data + sizeofUrl(pd-&gt;data));
  </code></pre>
  
  <p>I have two questions:</p>
  
  <p>1) How to get a name of the dns answer?</p>
  
  <p>2) How can I derive a dns query. By creating a separate structure, perhaps?</p>