On May 13, 2010, at 12:57 PM, Edgar, Thomas wrote:
> I have updated libpcap to capture traffic from serial COM ports. However, in
> order to do this I needed to configure the serial port settings before
> starting the capture. The method I have working is to add the port settings
> variables to the pcap structure. However, this required a change to the
> libpcap API by not calling the activate function during the pcap_open_live
> function if it is a serial port interface and adding a second
> pcap_configure_serial function that accepts the serial port settings as
> arguments and then calls the activate function.
>
> Is there a better way to do this so that I can avoid changing the main API?
Not without...
> I prefer keeping it within the API and not a config file or something
...having it get the configuration information from somewhere that doesn't
involve the API, such as a configuration file (ugly) or an environment variable
(arguably uglier).
My inclination would be to
1) encourage anybody who wants to capture on a serial device to use
pcap_create() and pcap_activate() (they're not going to be able to do it on
versions of libpcap without your changes, and unless you backport them to a
pre-1.0 version, that means they're not going to be able to do it on a version
of libpcap without pcap_create() and pcap_activate()), and have a
pcap_set_serial_port_params() routine that's called between pcap_create() and
pcap_activate();
2) either set the serial port parameters to "not set yet" values in
pcap_create() and have the serial port activate routine fail if they're not
set, in which case pcap_open_live() will fail on serial ports (as indicated,
that's no big loss), or set them to default values, in which case
pcap_open_live() will use the default values - I'd vote for the first of those
alternatives.
If you want to use the monitor mode support, or to set the buffer size, in
libpcap, you have to use pcap_create() and pcap_activate(); I think it's no
loss to require that you use them to capture on serial ports.-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.