title: How to Send/Inject Packet with WinPcap
body: <p>I'm working on <code>Windows 10 64-bit</code> and compiling with <code>MinGW-w64</code>, also using <code>WinPcap</code>.</p>
  
  <p>Trying to send/inject packets like this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;pcap.h&gt;
  
  int main(int argc, char **argv)
  {
      char errbuf[PCAP_ERRBUF_SIZE];
  
      pcap_t *cap = pcap_open(argv[1], 65535, 0, 1000, 0, errbuf);
      printf("interface capture: %s\n", cap == 0 ? "failed" : "success");
  
      unsigned char packet[100];
  
      // Dst MAC
      packet[0] = 0x74;
      packet[1] = 0xc6;
      packet[2] = 0x3b;
      packet[3] = 0x00;
      packet[0] = 0x06;
      packet[5] = 0xb5;
  
      // Src MAC
      packet[6] = 0x74;
      packet[7] = 0xc6;
      packet[8] = 0x3b;
      packet[9] = 0x00;
      packet[10] = 0x06;
      packet[11] = 0xb5;
  
      // others
      for (unsigned char i = 12; i &lt; 100; i++)
      {
          packet[i] = i;
      }
  
      printf("inject packet: %s\n", pcap_sendpacket(cap, packet, 100) == 0 ? "success" : "failed");
      return 0;
  }
  </code></pre>
  
  <p>Everything looks fine and getting success on send/inject program.</p>
  
  <p>However I'm not able to capture any packet, checked with <code>Wireshark</code>, still no luck.</p>
  
  <p>I'm running program as administrator with CMD, also tried to send raw UDP packet.</p>
  
  <p>Am I missing something or is this the proper way to send/inject packets into network interface?</p>