]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-usb.c
CMake: Fix the comment about versions. [skip ci]
[tcpdump] / print-usb.c
index 56e6dd4674b9d4ac186b0f6552ad3c95050830cf..98bd91b20fb3f633d6f5e437067683c6c8a16738 100644 (file)
 
 /* \summary: USB printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "extract.h"
 
@@ -147,8 +146,7 @@ get_direction(int transfer_type, int event_type)
        case URB_BULK:
        case URB_CONTROL:
        case URB_ISOCHRONOUS:
-               switch(event_type)
-               {
+               switch(event_type) {
                case URB_SUBMIT:
                        direction = 2;
                        break;
@@ -161,8 +159,7 @@ get_direction(int transfer_type, int event_type)
                }
                break;
        case URB_INTERRUPT:
-               switch(event_type)
-               {
+               switch(event_type) {
                case URB_SUBMIT:
                        direction = 1;
                        break;
@@ -187,9 +184,15 @@ usb_header_print(netdissect_options *ndo, const pcap_usb_header *uh)
        int direction;
        uint8_t transfer_type, event_type;
 
-       transfer_type = EXTRACT_U_1(uh->transfer_type);
-       switch(transfer_type)
-       {
+       ndo->ndo_protocol = "usb";
+
+       nd_print_protocol_caps(ndo);
+       if (ndo->ndo_qflag)
+               return;
+
+       ND_PRINT(" ");
+       transfer_type = GET_U_1(uh->transfer_type);
+       switch(transfer_type) {
                case URB_ISOCHRONOUS:
                        ND_PRINT("ISOCHRONOUS");
                        break;
@@ -206,9 +209,8 @@ usb_header_print(netdissect_options *ndo, const pcap_usb_header *uh)
                        ND_PRINT(" ?");
        }
 
-       event_type = EXTRACT_U_1(uh->event_type);
-       switch(event_type)
-       {
+       event_type = GET_U_1(uh->event_type);
+       switch(event_type) {
                case URB_SUBMIT:
                        ND_PRINT(" SUBMIT");
                        break;
@@ -227,7 +229,9 @@ usb_header_print(netdissect_options *ndo, const pcap_usb_header *uh)
                ND_PRINT(" from");
        else if(direction == 2)
                ND_PRINT(" to");
-       ND_PRINT(" %u:%u:%u", EXTRACT_HE_U_2(uh->bus_id), EXTRACT_U_1(uh->device_address), EXTRACT_U_1(uh->endpoint_number) & 0x7f);
+       ND_PRINT(" %u:%u:%u", GET_HE_U_2(uh->bus_id),
+                GET_U_1(uh->device_address),
+                GET_U_1(uh->endpoint_number) & 0x7f);
 }
 
 /*
@@ -238,19 +242,15 @@ usb_header_print(netdissect_options *ndo, const pcap_usb_header *uh)
  * '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_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
-                           const u_char *p)
+void
+usb_linux_48_byte_if_print(netdissect_options *ndo,
+                           const struct pcap_pkthdr *h _U_, const u_char *p)
 {
-       ndo->ndo_protocol = "usb_linux_48_byte_if";
-       if (h->caplen < sizeof(pcap_usb_header)) {
-               nd_print_trunc(ndo);
-               return(sizeof(pcap_usb_header));
-       }
+       ndo->ndo_protocol = "usb_linux_48_byte";
+       ND_TCHECK_LEN(p, sizeof(pcap_usb_header));
+       ndo->ndo_ll_hdr_len += sizeof (pcap_usb_header);
 
        usb_header_print(ndo, (const pcap_usb_header *) p);
-
-       return(sizeof(pcap_usb_header));
 }
 
 #ifdef DLT_USB_LINUX_MMAPPED
@@ -262,19 +262,15 @@ usb_linux_48_byte_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
  * '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_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
-                           const u_char *p)
+void
+usb_linux_64_byte_if_print(netdissect_options *ndo,
+                           const struct pcap_pkthdr *h _U_, const u_char *p)
 {
-       ndo->ndo_protocol = "usb_linux_64_byte_if";
-       if (h->caplen < sizeof(pcap_usb_header_mmapped)) {
-               nd_print_trunc(ndo);
-               return(sizeof(pcap_usb_header_mmapped));
-       }
+       ndo->ndo_protocol = "usb_linux_64_byte";
+       ND_TCHECK_LEN(p, sizeof(pcap_usb_header_mmapped));
+       ndo->ndo_ll_hdr_len += sizeof (pcap_usb_header_mmapped);
 
        usb_header_print(ndo, (const pcap_usb_header *) p);
-
-       return(sizeof(pcap_usb_header_mmapped));
 }
 #endif /* DLT_USB_LINUX_MMAPPED */