8 #define OFP_PCAP_VERSION_MAJOR 2
9 #define OFP_PCAP_VERSION_MINOR 4
11 #define TCPDUMP_MAGIC 0xa1b2c3d4
13 #define OFP_LINKTYPE_ETHERNET 1
15 #define OFP_PCAP_ERRBUF_SIZE 256
17 /* Swap the byte order regardless of the architecture */
19 ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))
20 #define SWAPSHORT(x) \
21 ((((x)&0xff)<<8) | (((x)&0xff00)>>8))
24 FILE *fp; /* File pointer to currently processed file */
25 int swapped; /* Indicate whether endian-ness needs to change */
26 char *buf; /* Buffer to hold packet data */
27 size_t bufsize; /* Size of buffer */
28 char *errbuf; /* Pointer to buffer to hold error message */
31 struct pcap_file_header {
32 uint32_t magic; /* Magic number */
33 uint16_t version_major; /* Version number major */
34 uint16_t version_minor; /* Version number minor */
35 int32_t thiszone; /* Gmt to local correction */
36 uint32_t sigfigs; /* Accuracy of timestamps */
37 uint32_t snaplen; /* Max length saved portion of each pkt */
38 uint32_t linktype; /* Data link type (LINKTYPE_*) */
42 * This is a timeval as stored in disk in a dumpfile.
43 * It has to use the same types everywhere, independent of the actual
47 int32_t tv_sec; /* Seconds */
48 int32_t tv_usec; /* Microseconds */
52 * How a `pcap_pkthdr' is actually stored in the dumpfile.
55 struct pcap_timeval ts; /* Time stamp */
56 uint32_t caplen; /* Length of portion present */
57 uint32_t len; /* Length this packet (off wire) */
60 int ofp_pcap_open(struct ofp_pcap *p, const char *fname, char *errbuf);
61 char *ofp_pcap_next(struct ofp_pcap *p, struct pcap_pkthdr *hdr);
62 void ofp_pcap_close(struct ofp_pcap *p);
64 #endif /* ofp_pcap.h */