+#ifdef DLT_USB_LINUX
+/*
+ * possible transfer mode
+ */
+#define URB_TRANSFER_IN 0x80
+#define URB_ISOCHRONOUS 0x0
+#define URB_INTERRUPT 0x1
+#define URB_CONTROL 0x2
+#define URB_BULK 0x3
+
+/*
+ * possible event type
+ */
+#define URB_SUBMIT 'S'
+#define URB_COMPLETE 'C'
+#define URB_ERROR 'E'
+
+/*
+ * USB setup header as defined in USB specification.
+ * Appears at the front of each Control S-type packet in DLT_USB captures.
+ */
+typedef struct _usb_setup {
+ nd_uint8_t bmRequestType;
+ nd_uint8_t bRequest;
+ nd_uint16_t wValue;
+ nd_uint16_t wIndex;
+ nd_uint16_t wLength;
+} pcap_usb_setup;
+
+/*
+ * Information from the URB for Isochronous transfers.
+ */
+typedef struct _iso_rec {
+ nd_int32_t error_count;
+ nd_int32_t numdesc;
+} iso_rec;
+
+/*
+ * Header prepended by linux kernel to each event.
+ * Appears at the front of each packet in DLT_USB_LINUX captures.
+ */
+typedef struct _usb_header {
+ nd_uint64_t id;
+ nd_uint8_t event_type;
+ nd_uint8_t transfer_type;
+ nd_uint8_t endpoint_number;
+ nd_uint8_t device_address;
+ nd_uint16_t bus_id;
+ nd_uint8_t setup_flag;/*if !=0 the urb setup header is not present*/
+ nd_uint8_t data_flag; /*if !=0 no urb data is present*/
+ nd_int64_t ts_sec;
+ nd_int32_t ts_usec;
+ nd_int32_t status;
+ nd_uint32_t urb_len;
+ nd_uint32_t data_len; /* amount of urb data really present in this event*/
+ pcap_usb_setup setup;
+} pcap_usb_header;
+
+/*
+ * Header prepended by linux kernel to each event for the 2.6.31
+ * and later kernels; for the 2.6.21 through 2.6.30 kernels, the
+ * "iso_rec" information, and the fields starting with "interval"
+ * are zeroed-out padding fields.
+ *
+ * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures.
+ */
+typedef struct _usb_header_mmapped {
+ nd_uint64_t id;
+ nd_uint8_t event_type;
+ nd_uint8_t transfer_type;
+ nd_uint8_t endpoint_number;
+ nd_uint8_t device_address;
+ nd_uint16_t bus_id;
+ nd_uint8_t setup_flag;/*if !=0 the urb setup header is not present*/
+ nd_uint8_t data_flag; /*if !=0 no urb data is present*/
+ nd_int64_t ts_sec;
+ nd_int32_t ts_usec;
+ nd_int32_t status;
+ nd_uint32_t urb_len;
+ nd_uint32_t data_len; /* amount of urb data really present in this event*/
+ union {
+ pcap_usb_setup setup;
+ iso_rec iso;
+ } s;
+ nd_int32_t interval; /* for Interrupt and Isochronous events */
+ nd_int32_t start_frame; /* for Isochronous events */
+ nd_uint32_t xfer_flags; /* copy of URB's transfer flags */
+ nd_uint32_t ndesc; /* number of isochronous descriptors */
+} pcap_usb_header_mmapped;