7 void main(int argc
, char **argv
)
10 char errbuf
[PCAP_ERRBUF_SIZE
];
14 /* Check the validity of the command line */
17 printf("usage: %s interface (e.g. 'rpcap://eth0')", argv
[0]);
21 /* Open the output device */
22 if ( (fp
= pcap_open(argv
[1], // name of the device
23 100, // portion of the packet to capture (only the first 100 bytes)
24 PCAP_OPENFLAG_PROMISCUOUS
, // promiscuous mode
26 NULL
, // authentication on the remote machine
27 errbuf
// error buffer
30 fprintf(stderr
,"\nUnable to open the adapter. %s is not supported by WinPcap\n", argv
[1]);
34 /* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */
42 /* set mac source to 2:2:2:2:2:2 */
50 /* Fill the rest of the packet */
56 /* Send down the packet */
57 if (pcap_sendpacket(fp
, packet
, 100 /* size */) != 0)
59 fprintf(stderr
,"\nError sending the packet: \n", pcap_geterr(fp
));