]>
The Tcpdump Group git mirrors - tcpdump/blob - print-usb.c
2 * Copyright 2009 Bert Vermeulen <bert@biot.com>
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that: (1) source code distributions
6 * retain the above copyright notice and this paragraph in its entirety, (2)
7 * distributions including binary code include the above copyright notice and
8 * this paragraph in its entirety in the documentation or other materials
9 * provided with the distribution, and (3) all advertising materials mentioning
10 * features or use of this software display the following acknowledgement:
11 * ``This product includes software developed by Paolo Abeni.''
12 * The name of author may not be used to endorse or promote products derived
13 * from this software without specific prior written permission.
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 * Support for USB packets
26 #include <tcpdump-stdinc.h>
32 #include "interface.h"
35 #if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX)
38 /* returns direction: 1=inbound 2=outbound -1=invalid */
39 static int get_direction(int transfer_type
, int event_type
)
44 switch(transfer_type
){
83 * This is the top level routine of the printer. 'p' points
84 * to the ether header of the packet, 'h->ts' is the timestamp,
85 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
86 * is the number of bytes actually captured.
88 u_int
usb_linux_print(const struct pcap_pkthdr
*h
, register const u_char
*p
)
90 const pcap_usb_header
*uh
;
93 if (h
->caplen
< sizeof(pcap_usb_header
)) {
95 return(sizeof(pcap_usb_header
));
98 uh
= (const pcap_usb_header
*) p
;
99 switch(uh
->transfer_type
)
101 case URB_ISOCHRONOUS
:
102 printf("ISOCHRONOUS");
117 switch(uh
->event_type
)
132 direction
= get_direction(uh
->transfer_type
, uh
->event_type
);
135 else if(direction
== 2)
137 printf(" %d:%d:%d", uh
->bus_id
, uh
->device_address
, uh
->endpoint_number
& 0x7f);
139 return(sizeof(pcap_usb_header
));