Blame pcap-common.h

Packit 209cc3
/*
Packit 209cc3
 * Copyright (c) 1993, 1994, 1995, 1996, 1997
Packit 209cc3
 *	The Regents of the University of California.  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: (1) source code distributions
Packit 209cc3
 * retain the above copyright notice and this paragraph in its entirety, (2)
Packit 209cc3
 * distributions including binary code include the above copyright notice and
Packit 209cc3
 * this paragraph in its entirety in the documentation or other materials
Packit 209cc3
 * provided with the distribution, and (3) all advertising materials mentioning
Packit 209cc3
 * features or use of this software display the following acknowledgement:
Packit 209cc3
 * ``This product includes software developed by the University of California,
Packit 209cc3
 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
Packit 209cc3
 * the University nor the names of its contributors may be used to endorse
Packit 209cc3
 * or promote products derived from this software without specific prior
Packit 209cc3
 * written permission.
Packit 209cc3
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
Packit 209cc3
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
Packit 209cc3
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Packit 209cc3
 *
Packit 209cc3
 * pcap-common.h - common code for pcap and pcapng files
Packit 209cc3
 */
Packit 209cc3
Packit 209cc3
/*
Packit 209cc3
 * We use the "receiver-makes-right" approach to byte order,
Packit 209cc3
 * because time is at a premium when we are writing the file.
Packit 209cc3
 * In other words, the pcap_file_header and pcap_pkthdr,
Packit 209cc3
 * records are written in host byte order.
Packit 209cc3
 * Note that the bytes of packet data are written out in the order in
Packit 209cc3
 * which they were received, so multi-byte fields in packets are not
Packit 209cc3
 * written in host byte order, they're written in whatever order the
Packit 209cc3
 * sending machine put them in.
Packit 209cc3
 *
Packit 209cc3
 * ntoh[ls] aren't sufficient because we might need to swap on a big-endian
Packit 209cc3
 * machine (if the file was written in little-end order).
Packit 209cc3
 */
Packit 209cc3
#define	SWAPLONG(y) \
Packit 209cc3
    (((((u_int)(y))&0xff)<<24) | \
Packit 209cc3
     ((((u_int)(y))&0xff00)<<8) | \
Packit 209cc3
     ((((u_int)(y))&0xff0000)>>8) | \
Packit 209cc3
     ((((u_int)(y))>>24)&0xff))
Packit 209cc3
#define	SWAPSHORT(y) \
Packit 209cc3
     ((u_short)(((((u_int)(y))&0xff)<<8) | \
Packit 209cc3
                ((((u_int)(y))&0xff00)>>8)))
Packit 209cc3
Packit 209cc3
extern int dlt_to_linktype(int dlt);
Packit 209cc3
Packit 209cc3
extern int linktype_to_dlt(int linktype);
Packit 209cc3
Packit 209cc3
extern void swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr,
Packit 209cc3
    u_char *data);
Packit 209cc3
Packit 209cc3
extern u_int max_snaplen_for_dlt(int dlt);