I got it to work.
Thanks for replying on the thread

Abhinav

On Sat, Dec 10, 2011 at 8:15 PM, abhinav narain
<[email protected]>wrote:

> Actually, I did better now ... but I don't know what should be done to
> call the corresponding dispatch
> If someone can give me a hint
>
>
>   char  *device0="phy0";
>   char  *device1="phy1";
>   pcap0 = pcap_open_live(device0, BUFSIZ, 1, -1, errbuf);
>   pcap1 = pcap_open_live(device1, BUFSIZ, 1, -1, errbuf);
>
> for(;;)
>    {
>
>    /* If you include STDIN_FILENO, be sure to read from it when you get
>       traffic from it, or select will return every time it is called,
>       since there will still be traffic waiting there.
>    */
>
>    FD_ZERO(&fd_wait);
>    //FD_SET(STDIN_FILENO, &fd_wait);
>    FD_SET(pcap_fileno(pcap0), &fd_wait);
>    FD_SET(pcap_fileno(pcap1), &fd_wait);
>
>    st.tv_sec  = 1;
>    st.tv_usec = 0;   /* 1000 = 1 second */
>
>    t=select(FD_SETSIZE, &fd_wait, NULL, NULL, &st);
>    printf("t is %d\n",t);
>    switch(t)
>      {
>      case -1:      /* Something went really wrong */
>        printf("Argh!\n\n");
>        exit(1);
>
>      case  0:      /* We timed out, no trafffic */
>        printf( " Time out ! \n");
>        break;
>
>      default:      /* We got traffic */
>        pcap_dispatch(pcap0,-1, (void *) packet_callback, NULL);
>        pcap_dispatch(pcap1,-1, (void *) packet_callback2, NULL);
>      }
>    // Put your service routine here.. is called when select times out or
> when a packet is processed
>    }
>
>
>
>
>
> On Sat, Dec 10, 2011 at 7:12 PM, abhinav narain <[email protected]
> > wrote:
>
>> 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.

Reply via email to