Andy Howell wrote:
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;
That assumes that an option will either be an "unsigned int" or a pointer.
I'd be inclined to have something more like
typedef struct {
bpf_u_int32 option;
bpf_u_int32 optlen;
} pcap_opthdr;
with the buffer being a sequence of pcap_opthdr structures followed by
option values. "option" is the code for the option type (with 0 being
the "end of option list" option), and "optlen" is the length of the
option value (so an application can skip options it doesn't understand).
"pcap_opthdr" is 64 bits long, so as long as the option buffer is
aligned on a {32-bit,64-bit} boundary, the options will be aligned on
that boundary as well (and if the option buffer is mallocated, it'll be
aligned on the strictest boundary required for C data types).
I'd also have pcap_open_live_ex() take a "pcap_opthdr *" as an argument
(for one thing, that means no whining from the compiler that we're
casting a "char *" to a type requiring stricter alignment).
We would probably want a
functions that returns the valid options for a device.
That's his "pcap_get_capabilities()" function.
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.