aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-usb-linux.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2009-11-03 14:50:40 -0800
committerGuy Harris <guy@alum.mit.edu>2009-11-03 14:50:40 -0800
commit62b9af0706d54cd4e44f40f0da057e04d7b14ec5 (patch)
treecefa292282bdbf1d339f067b90bf33479227ef16 /pcap-usb-linux.c
parent6b414c082f0079664c0535963108ae4a648dba47 (diff)
From Márton Németh:
The usbmon text interface was moved from /sys/kernel/debug/usbmon to /sys/kernel/debug/usb/usbmon as of patch http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=f49ce96f11112a84c16ac217490ebd6f8d9a8977 . Please add this new directory also into the search list when finding USB devices. Get rid of older address for Gisle Vanem; convert Love's address to UTF-8 (as it is in the tcpdump CREDITS file).
Diffstat (limited to 'pcap-usb-linux.c')
-rw-r--r--pcap-usb-linux.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c
index bcbe45a..fea527f 100644
--- a/pcap-usb-linux.c
+++ b/pcap-usb-linux.c
@@ -65,7 +65,8 @@ static const char rcsid[] _U_ =
#endif
#define USB_IFACE "usbmon"
-#define USB_TEXT_DIR "/sys/kernel/debug/usbmon"
+#define USB_TEXT_DIR_OLD "/sys/kernel/debug/usbmon"
+#define USB_TEXT_DIR "/sys/kernel/debug/usb/usbmon"
#define SYS_USB_BUS_DIR "/sys/bus/usb/devices"
#define PROC_USB_BUS_DIR "/proc/bus/usb"
#define USB_LINE_LEN 4096
@@ -354,10 +355,21 @@ usb_activate(pcap_t* handle)
handle->fd = open(full_path, O_RDONLY, 0);
if (handle->fd < 0)
{
- /* no more fallback, give it up*/
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't open USB bus file %s: %s", full_path, strerror(errno));
- return PCAP_ERROR;
+ if (errno == ENOENT)
+ {
+ /*
+ * Not found at the new location; try
+ * the old location.
+ */
+ snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%dt", handle->md.ifindex);
+ handle->fd = open(full_path, O_RDONLY, 0);
+ }
+ if (handle->fd < 0) {
+ /* no more fallback, give it up*/
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "Can't open USB bus file %s: %s", full_path, strerror(errno));
+ return PCAP_ERROR;
+ }
}
if (handle->opt.rfmon) {
@@ -614,10 +626,21 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
fd = open(string, O_RDONLY, 0);
if (fd < 0)
{
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't open USB stats file %s: %s",
- string, strerror(errno));
- return -1;
+ if (errno == ENOENT)
+ {
+ /*
+ * Not found at the new location; try the old
+ * location.
+ */
+ snprintf(string, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%ds", handle->md.ifindex);
+ fd = open(string, O_RDONLY, 0);
+ }
+ if (fd < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "Can't open USB stats file %s: %s",
+ string, strerror(errno));
+ return -1;
+ }
}
/* read stats line */