#include <stdio.h>
#include <stdlib.h>
#include <pcap.h>

void proccess_packet(u_char *args, const struct pcap_pkthdr *pkthdr, const u_char *packet) {
 printf("packet %d\n", rand());
}

int main (int argc, char *argv[]) {
 char errbuf[PCAP_ERRBUF_SIZE];
 pcap_t *idescr;

 if (2 != argc) {
  fprintf (stderr, "invalid arguments: %s if\n", argv[0]);
  return EXIT_FAILURE;
 }
 
 idescr = pcap_open_live (argv[1], BUFSIZ, 1, 1, errbuf);  

 if (NULL == idescr) {
  fprintf (stderr, "error: %s\n", errbuf);
  return EXIT_FAILURE;
 }
 
 pcap_loop (idescr, -1, proccess_packet, NULL);
 
 pcap_close (idescr);
 
 return EXIT_SUCCESS;
}
