tcpdump mailing list archives
Re: supporting extend 'open live capture' parametes
From: Andy Howell <AndyHowell () raitechnology com>
Date: Thu, 10 Jan 2008 14:08:59 -0600
Abeni Paolo wrote:
hello, I assume that the my initial suggestion is going to be dismissed, right ?!? on Thu 1/10/2008 10:47 AM Guy Harris wrote:There'd also be an API to ask which parameters a particular adapter supports (and possibly which values it supports for those parameters, e.g. if one of the parameters is a DLT_ type or an 802.11 channel).I think that a complete solution can be pretty complicated; such information could be provided with a buffer filled with TLV items, much like the 'extened open live capture' call. Supported values for each parameter could be inserted in the corresponding 'value' part of each item, putting all the supported values in the same item. A possible API could be: int pcap_get_capabilities(const char* device_name, char* optbuf, unsigned size); /* fill optbuf up to size bytes with TLVs and returns error code or the number of bytes used */ There is an issue: optbuf can be not large enough to handle all supported parameters/values; we can enforce a reasonable upper bound for the TLVs buffer or we can use a TLV entry to specify the required buffer len. To completed the picture, in extended open live capture the timeout parameter could be provided via the TLV buffer, since is not supported by all platform: int pcap_open_live_ex(const char *device, int snaplen, int promisc, const char * optbuf, char *errbuf); What do you think?
Paolo, How about having a generic list of options? Something like: typedef enum { END_OF_OPTS, PARAM_1, PARAM_2, } pcap_opts; typedef union { void *p; unsigned int u; } pcap_opt_value; typedef struct { pcap_opts option; pcap_opt_value value; } pcap_opt_item; int pcap_open_live_ex(const char *device, int snaplen, int promisc, pcap_opt_item *options, char *errbuf); main() { char *strOpt="blah"; char errbuf[ PCAP_ERRBUF_SIZE ]; pcap_opt_item my_opts[] = { { PARAM_1, .value.u = 1 }, { PARAM_2, .value.p = strOpt }, { END_OF_OPTS }, }; pcap_open_live_ex( "eth0", 0, 0, my_opts, errbuf ); }The list of options could easily be extended. We would probably want a functions that returns the valid options for a device.
Regards, Andy - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- setting the initial ring size Abeni Paolo (Jan 07)
- Re: setting the initial ring size Andy Howell (Jan 07)
- Re: setting the initial ring size Guy Harris (Jan 09)
- Re: setting the initial ring size Abeni Paolo (Jan 10)
- Re: setting the initial ring size Guy Harris (Jan 10)
- Re: supporting extend 'open live capture' parametes [was: setting the initial ring size] Abeni Paolo (Jan 10)
- Re: supporting extend 'open live capture' parametes Guy Harris (Jan 10)
- Re: supporting extend 'open live capture' parametes Andy Howell (Jan 10)
- Re: supporting extend 'open live capture' parametes Guy Harris (Jan 10)
- Re: supporting extend 'open live capture' parametes Andy Howell (Jan 11)
- Re: supporting extend 'open live capture' parametes Michael Richardson (Jan 13)
- Re: supporting extend 'open live capture' parametes Guy Harris (Jan 13)
- Re: supporting extend 'open live capture' parametes Michael Richardson (Jan 13)
- Re: supporting extend 'open live capture' parametes Guy Harris (Jan 15)
- Re: setting the initial ring size Guy Harris (Jan 09)
- Re: setting the initial ring size Andy Howell (Jan 07)