Guy Harris <[EMAIL PROTECTED]> writes:
> > First, since we have loopback devices sorted to the end, we don't have
> > to loop; we can just return the first one unless it is_loopback.
> >
> > Second, we should probably call pcap_freealldevs here.
>
> ...or perhaps have a static routine that finds all interface addresses,
> calling a supplied callback routine for each address, and have
> "pcap_findalldevs()" and "pcap_lookupdev()" call that routine, with
> different callbacks.
>
> That might let us avoid allocating anything in "pcap_lookupdev()", and
> also avoid (at least on platforms lacking "getifaddrs()") bothering to
> spend CPU cycles getting addresses that aren't supplied by SIOCGIFCONF.
I've been playing with this and thinking about it for a week or so,
and it seems like it adds complexity without saving much. For the
callback routine, we still have to get all of the interfaces at once
to sort them, and since we're not sure how much space each interface
will take up, we have to allocate and free that. Even with a callback
routine we'll still be allocating and freeing nearly the same amount
of memory, and it will probably be more fragmented if we do it a
little bit at a time rather than all at once when they get entire
interface list.
I think we should just free the memory and incorporate the patches,
and see if we find any problems that would warrant a more flexible
interface.
-----ScottG.
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe