title: packet socket not receiving data
body: <p>I have the following C code that is supposed to await <strong>any</strong> packet on ethernet device <code>eth0</code>, including <code>IPv6</code> multicast messages.</p>
  <p>I am using a <code>packet(7)</code> socket here, as my underlying code is handling the layers. Hence, I want to receive all packets on that socket.</p>
  <p>The communication to the other host is established via two <code>IPv6</code> multicast messages back and forth and a subsequent <code>TCP</code>-based communication.</p>
  <pre class="lang-c prettyprint-override"><code>#include &lt;sys/socket.h&gt;
  #include &lt;linux/if_packet.h&gt;
  #include &lt;netinet/if_ether.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main(void) {
      int fd = socket(AF_PACKET, SOCK_RAW, 0);
      if (fd &lt; 0)
      {
          perror(&quot;cannot open socket&quot;);
      }
  
      struct sockaddr_ll sll;
      memset(&amp;sll, 0, sizeof(sll));
      sll.sll_family   = AF_PACKET;
      sll.sll_ifindex  = if_nametoindex(&quot;eth0&quot;);
      sll.sll_protocol = ETH_P_ALL;
  
      if (bind(fd, (struct sockaddr*)&amp;sll, sizeof(sll)) &lt; 0)
      {
          perror(&quot;cannot bind socket to device&quot;);
          return 1;
      }
  
      while(1) {
          char *recvBuf[1518];
          struct sockaddr_ll saddr;
          socklen_t saddr_size = sizeof(saddr);
  
          size_t len = recvfrom(fd, recvBuf, 1518, 0, (struct sockaddr*)&amp;saddr, &amp;saddr_size);
  
          // PRINTOUT HERE
      }
  
      close(fd);
  
      return 0;
  }
  
  </code></pre>
  <p>I compile on my debian machine like that:</p>
  <pre class="lang-sh prettyprint-override"><code>gcc my_sniffer.c -o test.bin
  setcap 'cap_net_admin,cap_net_raw+ep' ./test.bin
  ./test.bin
  </code></pre>
  <p>The binary starts up. However, no packet is received.</p>
  <p>Running <code>tcpdump -i eth0 -w test.pcap</code>, yields in a received <code>IPv6</code> multicast message.</p>
  <p>What am I missing here? Is the code off? Wrong socket in use?</p>