aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-usb-linux.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@steve.local>2009-07-04 15:04:59 -0700
committerGuy Harris <gharris@steve.local>2009-07-04 15:04:59 -0700
commitbbd8be8360053578da1a829b529204ae42c68ef1 (patch)
treec3f717d3e93e5005adadf15a7245905309e9441d /pcap-usb-linux.c
parent8844f5bad80968a16bedae8e9f0b47bfe1a2778d (diff)
Older Linux kernels have different member names for "struct
usbdevfs_ctrltransfer"; check for that and handle it. Don't declare variables in the middle of a block; some versions of GCC appear to warn about that.
Diffstat (limited to 'pcap-usb-linux.c')
-rw-r--r--pcap-usb-linux.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c
index 358865c..3d7cb2c 100644
--- a/pcap-usb-linux.c
+++ b/pcap-usb-linux.c
@@ -247,11 +247,23 @@ probe_devices(int bus)
if (fd == -1)
continue;
+ /*
+ * Sigh. Different kernels have different member names
+ * for this structure.
+ */
+#ifdef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE
ctrl.bRequestType = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
ctrl.wValue = USB_DT_DEVICE << 8;
ctrl.wIndex = 0;
ctrl.wLength = sizeof(buf);
+#else
+ ctrl.requesttype = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
+ ctrl.request = USB_REQ_GET_DESCRIPTOR;
+ ctrl.value = USB_DT_DEVICE << 8;
+ ctrl.index = 0;
+ ctrl.length = sizeof(buf);
+#endif
ctrl.data = buf;
ctrl.timeout = CTRL_TIMEOUT;
@@ -593,9 +605,10 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
char string[USB_LINE_LEN];
char token[USB_LINE_LEN];
char * ptr = string;
- snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handle->md.ifindex);
+ int fd;
- int fd = open(string, O_RDONLY, 0);
+ snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handle->md.ifindex);
+ fd = open(string, O_RDONLY, 0);
if (fd < 0)
{
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
@@ -626,8 +639,10 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
* of execution" but the Corrigendum seems to contradict this.
* Do not make any assumptions on the effect of %n conversions
* on the return value and explicitly check for cnt assignmet*/
+ int ntok;
+
cnt = -1;
- int ntok = sscanf(ptr, "%s%n", token, &cnt);
+ ntok = sscanf(ptr, "%s%n", token, &cnt);
if ((ntok < 1) || (cnt < 0))
break;
consumed += cnt;