fork download
  1. #include <pcap.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <string.h>
  6.  
  7. void intranet_packages(u_char *user, const struct pcap_pkthdr *header, const u_char *packet);
  8.  
  9. int main() {
  10.  
  11. char errbuf[PCAP_ERRBUF_SIZE];
  12. char *dev = pcap_lookupdev(errbuf);
  13. pcap_t *handle = pcap_open_live(dev, 1600, 1, -1, errbuf);
  14. const unsigned char *packet;
  15.  
  16. if (handle == NULL) {
  17. printf("1 fasfas %s\n", errbuf);
  18. return -1;
  19. }
  20.  
  21. char filter[] = "";
  22. struct bpf_program fp;
  23. memset((void*)&fp, 0, sizeof(struct bpf_program));
  24.  
  25. int result = pcap_compile(handle, &fp, filter, 0, 0);
  26. if (result < 0) {
  27. printf("2 fasfas\n");
  28. return -1;
  29. }
  30.  
  31. result = pcap_setfilter(handle, &fp);
  32. if (result < 0) {
  33. printf("3 fasfas\n");
  34. return -1;
  35. }
  36.  
  37. struct pcap_pkthdr header;
  38. int i;
  39. while (1) {
  40.  
  41. packet = pcap_next(handle, &header);
  42. printf("%d ", header.len);
  43. if (result < 0) {
  44. return -1;
  45. }
  46. }
  47.  
  48. pcap_close(handle);
  49. }
  50.  
  51.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:18: fatal error: pcap.h: No such file or directory
compilation terminated.
stdout
Standard output is empty