title: recvfrom read wrong ethernet address from raw socket
body: <p>I tried to use libpcap for sniff packets,
  but sometimes it give me a wrong ethernet header.</p>
  
  <p>then i tried to use a simpler program to debug this issue, the behaviour is the same.</p>
  
  <p>then i moved the libpcap into my program, performing the same syscall as libpcap were do on my target platform ( android arm linux ), and the result is unchanged.</p>
  
  <p>i tried to retrieve the interface index using another socket rather then the main one.
  this time things get a little better, wrong packets were drastically reduced. but sometimes them still appear.</p>
  
  <p>program source: <a href="http://pastebin.com/K0JZgtiK" rel="nofollow">http://pastebin.com/K0JZgtiK</a></p>
  
  <p>sample output: <a href="http://pastebin.com/zsg0MZZF" rel="nofollow">http://pastebin.com/zsg0MZZF</a></p>
  
  <p>i've also opened an <a href="https://code.google.com/p/android/issues/detail?id=81370" rel="nofollow">issue</a> on the android bug tracker.</p>
  
  <p>i've also tried to fork instead of using threads, but nothing changes.</p>
  
  <p><s>but having two distinct programs, one that send and one that sniff, works correctly.</s></p>
  
  <p>thanks in advance for any help, this problem is driving me mad.</p>
  
  <h3>UPDATE</h3>
  
  <p>two different programs, one that send and one that receive, have the same problem.
  i didn't figured it out before because the sender was too slow.
  probably this issue happens if a packets is sent while recvfrom is reading a previous one.</p>
  
  <p>here the relevant part of nbns.h :</p>
  
  <pre><code>#define NBNS_NBSTATREQ_LEN 50
  extern uint8_t nbns_nbstat_request[NBNS_NBSTATREQ_LEN];
  </code></pre>
  
  <p>and nbns.c :</p>
  
  <pre><code>/**
   * @brief static NetBIOS NBSTAT request.
   * 
   * RFC 1002, Paragraph 4.2.17
   */
  uint8_t nbns_nbstat_request[NBNS_NBSTATREQ_LEN] = {
      0x82, 0x28, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x20, 0x43, 0x4B, 0x41, 0x41, 0x41, 0x41, 0x41,
      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
      0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41,
      0x41, 0x41, 0x41, 0x41, 0x41, 0x00, 0x00, 0x21, 0x00, 0x01
  };
  </code></pre>