title: Issue in pcap_set_buffer_size()
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;pcap.h&gt;
  
  #define BUFFER_SIZE 65535
  
  char errbuf[PCAP_ERRBUF_SIZE];
  
  int main(int argc, char **argv)
  {
      int d;
      pcap_if_t *alldevsp;
      pcap_t *pkt_handle;
  
      if((pcap_findalldevs(&amp;alldevsp,errbuf))==-1)
      {
          printf("findalldevices: %s\n",errbuf);
          exit(1);
      }
      printf("Availabel network devices are\n");
      pcap_if_t *temp = alldevsp;
      while((temp)!=NULL)
      {
          printf("%s: %s\n",(temp)-&gt;name,(temp)-&gt;description);
          (temp)=(temp)-&gt;next;
      }
      pcap_freealldevs(alldevsp);
  
      pkt_handle = pcap_create("wlan1",errbuf);
      if(pkt_handle==NULL)
      {
          printf("create: %s\n",errbuf);
          exit(1);
      }
  
  
      if((pcap_set_rfmon(pkt_handle, 1))!=0)
      {
          printf("Monitor mode could not be set\n");
          exit(1);
      }
  
      if((pcap_set_buffer_size(pkt_handle, BUFFER_SIZE))!=0)
          {
          printf("ERROR\n");
          exit(1);
      }
  
      if((d=(pcap_activate(pkt_handle)))!=0)
      {
          if(d==PCAP_ERROR_RFMON_NOTSUP)
              printf("%d : PCAP_ERROR_RFMON_NOTSUP\n",d);
          if(d==PCAP_WARNING)
              printf("%d : PCAP_WARNING\n",d);
          if(d==PCAP_ERROR)
              printf("%d : PCAP_ERROR\n",d);
          pcap_perror(pkt_handle,"Activate");
          exit(1);
      }
      printf("d=%d\n",d);
  
      while(1)
      {
          scanf("%d",&amp;d);
          if(d==-1)
              break;
      }
  
      pcap_close(pkt_handle);
      printf("Bye\n");
  
      return 0;
  }
  </code></pre>
  
  <p>When you run the above program using:</p>
  
  <pre><code>gcc -Wall -lpcap sample.c -o sample
  </code></pre>
  
  <p>I get the follwing error:</p>
  
  <pre><code>-1 : PCAP_ERROR
  Activate: can't mmap rx ring: Invalid argument
  </code></pre>
  
  <p>However, if I <strong>comment out the section of code containing <code>pcap_set_buffer_size()</code></strong> function call, the program works perfectly fine.</p>
  
  <p>So, what is this problem with <code>pcap_set_buffer_size()</code>?</p>
  
  <p>Why is it causing <code>pcap_activate()</code> to fail?</p>