tcpdump mailing list archives

Re: supporting extend 'open live capture' parametes


From: Michael Richardson <mcr () sandelman ottawa on ca>
Date: Sun, 13 Jan 2008 18:33:55 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


"Guy" == Guy Harris <guy () alum mit edu> writes:
    >> What problem is the ultra-open parameter list supposed to solve?

    Guy> 1) allow open options to be added without having to change the
    Guy> signature of the open-live routine, so that we don't have to
    Guy> anticipate all the options that might ever want to be added.

  It seems to me that the problem isn't that we need to add new options
to the open-live call, but that we have the problem that the open-live
call is a one-shot.

  I.e. we should instead have a new pcap_open() call, and then we should
have a serious of calls that set various options or ask for various
things based upon that handle. 
  Thus:

pcap_t pcap_open_live(char *device, int snaplen, int promisc, int to_me,
                      char *ebuf)
{
        pcap_t pt = pcap_create();

        pcap_set_mechanism(pt, PCAP_BPF);
        pcap_set_device(pt, device);
        pcap_set_snaplen(pt, snaplen);
        pcap_set_promisc(pt, promisc)
        pcap_set_tome(pt, to_me);
        pcap_set_errbuf(pt, ebuf);
        if(pcap_activate(pt)) {
                return pt;
        } else {
                return NULL;
        }
}

or, you can make pcap_set_int() call with an enum type that can be
extended for new parameters.

That would also remove the pcap_open_live() call from all the pcap-*.c
and make the interface to a lower-level kernel driver more hidden than
it is now.

    Guy> 2) allow a application to inquire which particular options are
    Guy> available for a particular device, so it could, for example,
    Guy> not present UI for turning on 802.11 monitor mode if it's not

Right, so maybe you have to have pcap_get_prop() on the pt too.
Adding functions that act on a handle is a very nice way to extend an
interface. 
  
- -- 
]           Bear: "Me, I'm just the shape of a bear."          |  firewalls  [
]  Michael Richardson,    Xelerance Corporation, Ottawa, ON    |net architect[
]mcr () xelerance com      http://www.sandelman.ottawa.on.ca/mcr/ |device driver[
]panic("Just another Debian GNU/Linux using, kernel hacking, security guy"); [


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Finger me for keys

iQEVAwUBR4qf4oCLcPvd0N1lAQJrewf/eGpAFdWxScyVG1XO7rIo+PQaKsRyR+QC
8vDdLltxjqJqE4HZXMlckad4UuNMAFxH67ZEG6ff6yrbKPnsqkzNgwfAq/pV1FYC
hjQ0y7nRXleuft0aJO5Bs4/88GQvbUdBO76kMccNE8VnNrcLOawvsJQ10mD4PctO
LXWlMIz/AJ1YigcrxOHqpjh3/YCR+ctnzq4bS7ASXZ+8ZLhNdPzig6/YeKNFY6UQ
vwptqoNG5S5AhU9FOwKaKvSJHrq1dk0App4jAEnaRubWWKmhPjDTA8rNradBxJZr
rsjofRhLHTTfhGn/PkdE4GG5230FTpNWiNF+hsC8Y9/uhkmzzrX6Hw==
=PHIe
-----END PGP SIGNATURE-----
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: