tcpdump mailing list archives

Re: capturing on both interfaces simultaneously


From: abhinav narain <abhinavnarain10 () gmail com>
Date: Sat, 10 Dec 2011 19:12:24 -0500

Two threads are too large on this.

I was unable to find how to set the set of interfaces to be restricted to 2
(the ones i want) and call the same callback on return from dispatch.

This code is not right, but I am clueless to proceed

Any direction will be good.
<code>
  fd_set rfds;
  char * device="phy0";
  char * device1="phy1";
  handle1 = pcap_open_live(device, BUFSIZ, 1, 0, errbuf);
  handle2 = pcap_open_live(device1, BUFSIZ, 1, 0, errbuf);

  fd = pcap_get_selectable_fd(handle1);
  pcap_compile(handle1, &fcode, "type mgt subtype beacon", 1, 0);
  pcap_setfilter(handle1, &fcode);

  /*


  fd = pcap_get_selectable_fd(handle2);


  pcap_compile(handle2, &fcode, "type mgt subtype beacon", 1, 0);


  pcap_setfilter(handle2, &fcode);


  */

  while (retval == 0) {
    FD_ZERO(&rfds);
    FD_SET(fd, &rfds);
    tv.tv_sec = 1; /* timeout 1 sec */
    tv.tv_usec = 0;
    retval = select(fd + 1, &rfds, NULL, NULL, &tv);

    if(pcap_dispatch(handle1,-1,callback1,(u_char *)NULL) < 0 ){
      printf("error");
    }
    if(pcap_dispatch(handle2, -1,callback1,(u_char *)NULL) < 0 ){
      printf("error");
    }

  }

</code>
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: