ClientCollectors/ARODataCollector/external/libpcap-1.1.1/pcap-common.c
void
swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
    int header_len_64_bytes)
{
	pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;

	/*
	 * The URB id is a totally opaque value; do we really need to 
	 * convert it to the reading host's byte order???
	 */
	if (hdr->caplen < 8)
		return;
	uhdr->id = SWAPLL(uhdr->id);
	if (hdr->caplen < 14)
		return;
	uhdr->bus_id = SWAPSHORT(uhdr->bus_id);
	if (hdr->caplen < 24)
		return;
	uhdr->ts_sec = SWAPLL(uhdr->ts_sec);
	if (hdr->caplen < 28)
		return;
	uhdr->ts_usec = SWAPLONG(uhdr->ts_usec);
	if (hdr->caplen < 32)
		return;
	uhdr->status = SWAPLONG(uhdr->status);
	if (hdr->caplen < 36)
		return;
	uhdr->urb_len = SWAPLONG(uhdr->urb_len);
	if (hdr->caplen < 40)
		return;
	uhdr->data_len = SWAPLONG(uhdr->data_len);

	if (header_len_64_bytes) {
		/*
		 * This is either the "version 1" header, with
		 * 16 bytes of additional fields at the end, or
		 * a "version 0" header from a memory-mapped
		 * capture, with 16 bytes of zeroed-out padding
		 * at the end.  Byte swap them as if this were
		 * a "version 1" header.
		 */
		if (hdr->caplen < 52)
			return;
		uhdr->interval = SWAPLONG(uhdr->interval);
		if (hdr->caplen < 56)
			return;
		uhdr->start_frame = SWAPLONG(uhdr->start_frame);
		if (hdr->caplen < 60)
			return;
		uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags);
		if (hdr->caplen < 64)
			return;
		uhdr->ndesc = SWAPLONG(uhdr->ndesc);
	}	
}
/*
 * The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
 * byte order when capturing (it's supplied directly from a
 * memory-mapped buffer shared by the kernel).
 *
 * When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file,
 * we need to convert it from the capturing host's byte order to
 * the reading host's byte order.
 */
The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
byte order when capturing (it's supplied directly from a
memory-mapped buffer shared by the kernel).

When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file,
we need to convert it from the capturing host's byte order to
the reading host's byte order.
The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host byte order when capturing ( it ' s supplied directly from a memory - mapped buffer shared by the kernel ) . When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED capture file we need to convert it from the capturing host ' s byte order to the reading host ' s byte order .
void
swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
    int header_len_64_bytes)
{
	pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;
	if (hdr->caplen < 8)
		return;
	uhdr->id = SWAPLL(uhdr->id);
	if (hdr->caplen < 14)
		return;
	uhdr->bus_id = SWAPSHORT(uhdr->bus_id);
	if (hdr->caplen < 24)
		return;
	uhdr->ts_sec = SWAPLL(uhdr->ts_sec);
	if (hdr->caplen < 28)
		return;
	uhdr->ts_usec = SWAPLONG(uhdr->ts_usec);
	if (hdr->caplen < 32)
		return;
	uhdr->status = SWAPLONG(uhdr->status);
	if (hdr->caplen < 36)
		return;
	uhdr->urb_len = SWAPLONG(uhdr->urb_len);
	if (hdr->caplen < 40)
		return;
	uhdr->data_len = SWAPLONG(uhdr->data_len);
	if (header_len_64_bytes) {
		if (hdr->caplen < 52)
			return;
		uhdr->interval = SWAPLONG(uhdr->interval);
		if (hdr->caplen < 56)
			return;
		uhdr->start_frame = SWAPLONG(uhdr->start_frame);
		if (hdr->caplen < 60)
			return;
		uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags);
		if (hdr->caplen < 64)
			return;
		uhdr->ndesc = SWAPLONG(uhdr->ndesc);
	}	
}
void swap_linux_usb_header ( const struct pcap_pkthdr * hdr , u_char * buf , int header_len_64_bytes ) { pcap_usb_header_mmapped * uhdr = ( pcap_usb_header_mmapped * ) buf ; if ( hdr -> caplen < 8 ) return ; uhdr -> id = SWAPLL ( uhdr -> id ) ; if ( hdr -> caplen < 14 ) return ; uhdr -> bus_id = SWAPSHORT ( uhdr -> bus_id ) ; if ( hdr -> caplen < 24 ) return ; uhdr -> ts_sec = SWAPLL ( uhdr -> ts_sec ) ; if ( hdr -> caplen < 28 ) return ; uhdr -> ts_usec = SWAPLONG ( uhdr -> ts_usec ) ; if ( hdr -> caplen < 32 ) return ; uhdr -> status = SWAPLONG ( uhdr -> status ) ; if ( hdr -> caplen < 36 ) return ; uhdr -> urb_len = SWAPLONG ( uhdr -> urb_len ) ; if ( hdr -> caplen < 40 ) return ; uhdr -> data_len = SWAPLONG ( uhdr -> data_len ) ; if ( header_len_64_bytes ) { if ( hdr -> caplen < 52 ) return ; uhdr -> interval = SWAPLONG ( uhdr -> interval ) ; if ( hdr -> caplen < 56 ) return ; uhdr -> start_frame = SWAPLONG ( uhdr -> start_frame ) ; if ( hdr -> caplen < 60 ) return ; uhdr -> xfer_flags = SWAPLONG ( uhdr -> xfer_flags ) ; if ( hdr -> caplen < 64 ) return ; uhdr -> ndesc = SWAPLONG ( uhdr -> ndesc ) ; } }
The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
 byte order when capturing (it's supplied directly from a
 memory-mapped buffer shared by the kernel).
The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host byte order when capturing ( it ' s supplied directly from a memory - mapped buffer shared by the kernel ) .
/*
	 * The URB id is a totally opaque value; do we really need to 
	 * convert it to the reading host's byte order???
	 */ /*
		 * This is either the "version 1" header, with
		 * 16 bytes of additional fields at the end, or
		 * a "version 0" header from a memory-mapped
		 * capture, with 16 bytes of zeroed-out padding
		 * at the end.  Byte swap them as if this were
		 * a "version 1" header.
		 */