title: Why is the third parameter to pcap_next_ex an incompatible pointer type?
body: <p>Disclaimer: This is for a homework assignment, but the question is not regarding the assignment, just about general syntax weirdness.</p>
  
  <p>I'm trying to use libpcap in the context of a much larger program, but when I try to get the packet header and data for each packet gcc complains that the third parameter to pcap_next_ex is of an incompatible pointer type. Here's some sample code to see what I'm talking about:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;pcap.h&gt;
  
  int main()
  {
      pcap_t *pcap;
      char pcapErr[PCAP_ERRBUF_SIZE];
      struct pcap_pkthdr *pktHeader;
      u_char *pktData;
  
      pcap = pcap_open_offline("somefile.pcap", pcapErr);
      if (pcap == NULL)
      {
          fprintf(stderr, "pcap_open_offline failed: %s\n", pcapErr);
          exit(EXIT_FAILURE);
      }
  
      while (pcap_next_ex(pcap, &amp;pktHeader, &amp;pktData) == 1)
      {
          // do things here
      }
  
      pcap_close(pcap);
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>The man pages indicated that the prototype for pcap_next_ex() is:</p>
  
  <pre><code>int pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, const u_char **pkt_data)
  </code></pre>
  
  <p>How exactly is what I'm passing an incompatible pointer type? Thanks.</p>