]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Handle the 48-byte and 64-byte Linux USB headers differently; for now,
authorGuy Harris <[email protected]>
Mon, 25 Jan 2010 23:25:33 +0000 (15:25 -0800)
committerGuy Harris <[email protected]>
Mon, 25 Jan 2010 23:25:33 +0000 (15:25 -0800)
the difference isn't major, but it might be more important later.

interface.h
print-usb.c
tcpdump.c

index 2507168a73984d149ccb91625184200ad5f30e70..3638ddf71284f7775ab2e271405ac9078c1411fd 100644 (file)
@@ -318,7 +318,8 @@ extern void bfd_print(const u_char *, u_int, u_int);
 extern void sip_print(const u_char *, u_int);
 extern void syslog_print(const u_char *, u_int);
 extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_print(const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
+extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
 
 #ifdef INET6
 extern void ip6_print(const u_char *, u_int);
index 1195133fd0bc9d4a846fd527663cfbb0eb5de109..8e15e7bf39d1eb93c0e7960aed9ad4a699866f96 100644 (file)
@@ -36,7 +36,8 @@
 #include <pcap/usb.h>
 
 /* returns direction: 1=inbound 2=outbound -1=invalid */
-static int get_direction(int transfer_type, int event_type)
+static int
+get_direction(int transfer_type, int event_type)
 {
        int direction;
 
@@ -79,23 +80,11 @@ static int get_direction(int transfer_type, int event_type)
        return direction;
 }
 
-/*
- * This is the top level routine of the printer.  'p' points
- * to the ether header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
- * is the number of bytes actually captured.
- */
-u_int usb_linux_print(const struct pcap_pkthdr *h, register const u_char *p)
+static void
+usb_header_print(const pcap_usb_header *uh)
 {
-       const pcap_usb_header *uh;
        int direction;
 
-       if (h->caplen < sizeof(pcap_usb_header)) {
-               printf("[|usb]");
-               return(sizeof(pcap_usb_header));
-       }
-
-       uh = (const pcap_usb_header *) p;
        switch(uh->transfer_type)
        {
                case URB_ISOCHRONOUS:
@@ -135,9 +124,51 @@ u_int usb_linux_print(const struct pcap_pkthdr *h, register const u_char *p)
        else if(direction == 2)
                printf(" to");
        printf(" %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f);
+}
+
+/*
+ * This is the top level routine of the printer for captures with a
+ * 48-byte header.
+ *
+ * 'p' points to the header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+{
+       if (h->caplen < sizeof(pcap_usb_header)) {
+               printf("[|usb]");
+               return(sizeof(pcap_usb_header));
+       }
+
+       usb_header_print((const pcap_usb_header *) p);
 
        return(sizeof(pcap_usb_header));
 }
 
-#endif
+#ifdef DLT_USB_LINUX_MMAPPED
+/*
+ * This is the top level routine of the printer for captures with a
+ * 64-byte header.
+ *
+ * 'p' points to the header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+usb_linux_64_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+{
+       if (h->caplen < sizeof(pcap_usb_header_mmapped)) {
+               printf("[|usb]");
+               return(sizeof(pcap_usb_header_mmapped));
+       }
+
+       usb_header_print((const pcap_usb_header *) p);
+
+       return(sizeof(pcap_usb_header_mmapped));
+}
+#endif /* DLT_USB_LINUX_MMAPPED */
+
+#endif /* defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX) */
 
index cc25014377f5b2f5864e545de61f774cc7ffe188..87005e57aa1070692b4b0c518750aa7b7e4c5116 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -285,12 +285,14 @@ static struct printer printers[] = {
 #if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
        { bt_if_print,          DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
 #endif
-#if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX)
-       { usb_linux_print,      DLT_USB_LINUX},
-#endif
-#if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX_MMAPPED)
-       { usb_linux_print,      DLT_USB_LINUX_MMAPPED},
-#endif
+#ifdef HAVE_PCAP_USB_H
+#ifdef DLT_USB_LINUX
+       { usb_linux_48_byte_print, DLT_USB_LINUX},
+#endif /* DLT_USB_LINUX */
+#ifdef DLT_USB_LINUX_MMAPPED
+       { usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
+#endif /* DLT_USB_LINUX_MMAPPED */
+#endif /* HAVE_PCAP_USB_H */
 #ifdef DLT_IPV4
        { raw_if_print,         DLT_IPV4 },
 #endif