tcpdump mailing list archives
Re: How to set my device name with pcap_platform_finddevs()
From: Guy Harris <guy () alum mit edu>
Date: Tue, 25 Sep 2007 13:40:05 -0700
On Sep 25, 2007, at 4:33 AM, Varuna De Silva wrote:
1. How should I work around so that pcap_findalldevs() will add my device inthe list?
If you're doing this on Windows, you will have to: modify pcap_findalldevs() in fad-win32.c to, right before it does if (ret == -1) { /* * We had an error; free the list we've been constructing. */ if (devlist != NULL) { pcap_freealldevs(devlist); devlist = NULL; } } do if (ret != -1) { /* * We haven't had any errors yet; do any platform-specific * operations to add devices. */ if (pcap_platform_finddevs(&devlist, errbuf) < 0) ret = -1; }Then add a routine to your pcap-xxx.c that, similarly to septel_platform_finddevs(), adds your device to the list of devices, and then add a routine to pcap-win32.c called "pcap_platform_finddevs()" that calls your routine, similarly to the Linux pcap_platform_finddevs() in pcap-linux.c.
If you're doing this on some form of UN*X, e.g. Linux, just add the routine to your pcap-xxx.c and find the appropriate pcap-yyy.c and modify its pcap_platform_finddevs() to call your routine.
2. What is the relationship between pcap_platform_finddevs() and pcap_findalldevs() function in this regard ?
pcap_findalldevs() is the routine that finds "standard" network adapters (i.e., the ones that the OS's mechanism for enumerating network adapters finds); pcap_platform_finddevs() is the routine that finds other adapters for a particular platform.
3. How should I modify "pcap_platform_finddevs()" so that I get my deviceadded?
See septel_platform_finddevs() for an example.
do I need to do this?
Yes.
4. Where are these two functions written, (pcap_findalldevs() I found onlyin fad32! Sorry for this foolish question, But I was not able to figure it out)
They're in libpcap, but not in the current version of WinPcap, because pcap-win32.c and fad-win32.c didn't have them. I've just checked changes to pcap-win32.c and fad-win32.c into the main branch of libpcap to add those routines; hopefully they'll appear in a future version of WinPcap.
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- How to set my device name with pcap_platform_finddevs() Varuna De Silva (Sep 25)
- Re: How to set my device name with pcap_platform_finddevs() Guy Harris (Sep 25)
- Announce: tcpdump 3.9.8 and libpcap 0.9.8 released Ken Bantoft (Sep 25)
- Re: Announce: tcpdump 3.9.8 and libpcap 0.9.8 released Max Laier (Sep 29)
- Re: How to set my device name with pcap_platform_finddevs() Varuna De Silva (Sep 27)
- Re: How to set my device name with Guy Harris (Sep 27)
- Announce: tcpdump 3.9.8 and libpcap 0.9.8 released Ken Bantoft (Sep 25)
- Re: How to set my device name with pcap_platform_finddevs() Guy Harris (Sep 25)