Home | History | Annotate | Download | only in libpcap
      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 
     20 extern int dlt_to_linktype(int dlt);
     21 
     22 extern int linktype_to_dlt(int linktype);
     23 
     24 extern void swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr,
     25     u_char *data);
     26