Blame pcap/usb.h

Packit 209cc3
/*
Packit 209cc3
 * Copyright (c) 2006 Paolo Abeni (Italy)
Packit 209cc3
 * All rights reserved.
Packit 209cc3
 *
Packit 209cc3
 * Redistribution and use in source and binary forms, with or without
Packit 209cc3
 * modification, are permitted provided that the following conditions
Packit 209cc3
 * are met:
Packit 209cc3
 *
Packit 209cc3
 * 1. Redistributions of source code must retain the above copyright
Packit 209cc3
 * notice, this list of conditions and the following disclaimer.
Packit 209cc3
 * 2. Redistributions in binary form must reproduce the above copyright
Packit 209cc3
 * notice, this list of conditions and the following disclaimer in the
Packit 209cc3
 * documentation and/or other materials provided with the distribution.
Packit 209cc3
 * 3. The name of the author may not be used to endorse or promote
Packit 209cc3
 * products derived from this software without specific prior written
Packit 209cc3
 * permission.
Packit 209cc3
 *
Packit 209cc3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 209cc3
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 209cc3
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 209cc3
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 209cc3
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 209cc3
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 209cc3
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 209cc3
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 209cc3
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 209cc3
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 209cc3
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 209cc3
 *
Packit 209cc3
 * Basic USB data struct
Packit 209cc3
 * By Paolo Abeni <paolo.abeni@email.it>
Packit 209cc3
 */
Packit 209cc3
Packit 209cc3
#ifndef lib_pcap_usb_h
Packit 209cc3
#define lib_pcap_usb_h
Packit 209cc3
Packit 209cc3
#include <pcap/pcap-inttypes.h>
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * possible transfer mode
Packit 209cc3
 */
Packit 209cc3
#define URB_TRANSFER_IN   0x80
Packit 209cc3
#define URB_ISOCHRONOUS   0x0
Packit 209cc3
#define URB_INTERRUPT     0x1
Packit 209cc3
#define URB_CONTROL       0x2
Packit 209cc3
#define URB_BULK          0x3
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * possible event type
Packit 209cc3
 */
Packit 209cc3
#define URB_SUBMIT        'S'
Packit 209cc3
#define URB_COMPLETE      'C'
Packit 209cc3
#define URB_ERROR         'E'
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * USB setup header as defined in USB specification.
Packit 209cc3
 * Appears at the front of each Control S-type packet in DLT_USB captures.
Packit 209cc3
 */
Packit 209cc3
typedef struct _usb_setup {
Packit 209cc3
	uint8_t bmRequestType;
Packit 209cc3
	uint8_t bRequest;
Packit 209cc3
	uint16_t wValue;
Packit 209cc3
	uint16_t wIndex;
Packit 209cc3
	uint16_t wLength;
Packit 209cc3
} pcap_usb_setup;
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * Information from the URB for Isochronous transfers.
Packit 209cc3
 */
Packit 209cc3
typedef struct _iso_rec {
Packit 209cc3
	int32_t	error_count;
Packit 209cc3
	int32_t	numdesc;
Packit 209cc3
} iso_rec;
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * Header prepended by linux kernel to each event.
Packit 209cc3
 * Appears at the front of each packet in DLT_USB_LINUX captures.
Packit 209cc3
 */
Packit 209cc3
typedef struct _usb_header {
Packit 209cc3
	uint64_t id;
Packit 209cc3
	uint8_t event_type;
Packit 209cc3
	uint8_t transfer_type;
Packit 209cc3
	uint8_t endpoint_number;
Packit 209cc3
	uint8_t device_address;
Packit 209cc3
	uint16_t bus_id;
Packit 209cc3
	char setup_flag;/*if !=0 the urb setup header is not present*/
Packit 209cc3
	char data_flag; /*if !=0 no urb data is present*/
Packit 209cc3
	int64_t ts_sec;
Packit 209cc3
	int32_t ts_usec;
Packit 209cc3
	int32_t status;
Packit 209cc3
	uint32_t urb_len;
Packit 209cc3
	uint32_t data_len; /* amount of urb data really present in this event*/
Packit 209cc3
	pcap_usb_setup setup;
Packit 209cc3
} pcap_usb_header;
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * Header prepended by linux kernel to each event for the 2.6.31
Packit 209cc3
 * and later kernels; for the 2.6.21 through 2.6.30 kernels, the
Packit 209cc3
 * "iso_rec" information, and the fields starting with "interval"
Packit 209cc3
 * are zeroed-out padding fields.
Packit 209cc3
 *
Packit 209cc3
 * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures.
Packit 209cc3
 */
Packit 209cc3
typedef struct _usb_header_mmapped {
Packit 209cc3
	uint64_t id;
Packit 209cc3
	uint8_t event_type;
Packit 209cc3
	uint8_t transfer_type;
Packit 209cc3
	uint8_t endpoint_number;
Packit 209cc3
	uint8_t device_address;
Packit 209cc3
	uint16_t bus_id;
Packit 209cc3
	char setup_flag;/*if !=0 the urb setup header is not present*/
Packit 209cc3
	char data_flag; /*if !=0 no urb data is present*/
Packit 209cc3
	int64_t ts_sec;
Packit 209cc3
	int32_t ts_usec;
Packit 209cc3
	int32_t status;
Packit 209cc3
	uint32_t urb_len;
Packit 209cc3
	uint32_t data_len; /* amount of urb data really present in this event*/
Packit 209cc3
	union {
Packit 209cc3
		pcap_usb_setup setup;
Packit 209cc3
		iso_rec iso;
Packit 209cc3
	} s;
Packit 209cc3
	int32_t	interval;	/* for Interrupt and Isochronous events */
Packit 209cc3
	int32_t start_frame;	/* for Isochronous events */
Packit 209cc3
	uint32_t xfer_flags;	/* copy of URB's transfer flags */
Packit 209cc3
	uint32_t ndesc;	/* number of isochronous descriptors */
Packit 209cc3
} pcap_usb_header_mmapped;
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * Isochronous descriptors; for isochronous transfers there might be
Packit 209cc3
 * one or more of these at the beginning of the packet data.  The
Packit 209cc3
 * number of descriptors is given by the "ndesc" field in the header;
Packit 209cc3
 * as indicated, in older kernels that don't put the descriptors at
Packit 209cc3
 * the beginning of the packet, that field is zeroed out, so that field
Packit 209cc3
 * can be trusted even in captures from older kernels.
Packit 209cc3
 */
Packit 209cc3
typedef struct _usb_isodesc {
Packit 209cc3
	int32_t		status;
Packit 209cc3
	uint32_t	offset;
Packit 209cc3
	uint32_t	len;
Packit 209cc3
	uint8_t	pad[4];
Packit 209cc3
} usb_isodesc;
Packit 209cc3
Packit 209cc3
#endif