1 2/* 3 * We use the "receiver-makes-right" approach to byte order, 4 * because time is at a premium when we are writing the file. 5 * In other words, the pcap_file_header and pcap_pkthdr, 6 * records are written in host byte order. 7 * Note that the bytes of packet data are written out in the order in 8 * which they were received, so multi-byte fields in packets are not 9 * written in host byte order, they're written in whatever order the 10 * sending machine put them in. 11 * 12 * ntoh[ls] aren't sufficient because we might need to swap on a big-endian 13 * machine (if the file was written in little-end order). 14 */ 15#define SWAPLONG(y) \ 16((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff)) 17#define SWAPSHORT(y) \ 18 ( (((y)&0xff)<<8) | ((u_short)((y)&0xff00)>>8) ) 19#define SWAPLONGLONG(y) \ 20 (((unsigned long long)SWAPLONG((unsigned long)(y)) << 32) | (SWAPLONG((unsigned long)((y) >> 32)))) 21 22extern int dlt_to_linktype(int dlt); 23 24extern int linktype_to_dlt(int linktype); 25 26extern void swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf, 27 int header_len_64_bytes); 28