title: can't read arp packets in c
body: <p>i have the following simple code to capture all the arp packet sent to my device but it doesn't print anything</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  
  #include &lt;sys/socket.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;arpa/inet.h&gt;
  #include &lt;net/ethernet.h&gt;
  
  int main(){
          int sock;
          char recvbuf[2048];
          if((sock=socket(PF_PACKET,SOCK_DGRAM,htons(ETH_P_ARP)))==-1){
                  perror(&quot;socket error&quot;);
                  return -1;
          }
          for(;;){
                  if(recvfrom(sock,recvbuf,sizeof(recvbuf),0,NULL,NULL)==-1){
                          perror(&quot;recvfrom error&quot;);
                  }
                  struct ether_header *e;
                  e=(struct ether_header *)recvbuf;
                  printf(&quot;arp from :%s\n&quot;,e-&gt;ether_shost);
          }
  }
  </code></pre>
  <p>the output is like:</p>
  <pre><code>arp from :
  arp from :
  arp from :
  arp from :
  arp from :
  </code></pre>