author | Josh Pelkey <jpelkey@gatech.edu> |
Tue, 23 Feb 2010 12:54:13 -0500 | |
changeset 6008 | aa1c297a0de2 |
parent 5883 | c55a30dfe65e |
child 6054 | 8b1b404f4335 |
permissions | -rw-r--r-- |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2009 University of Washington |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
5465
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
17 |
* |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
18 |
* Author: Craig Dowell (craigdo@ee.washington.edu) |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
*/ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
#ifndef PCAP_FILE_H |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
#define PCAP_FILE_H |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
#include <string> |
4774
066f73df2229
fc11 is pretty picky about headers
Craig Dowell <craigdo@ee.washington.edu>
parents:
4772
diff
changeset
|
25 |
#include <stdint.h> |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
namespace ns3 { |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
/* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
* A class representing a pcap file. This allows easy creation, writing and |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
* reading of files composed of stored packets; which may be viewed using |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
* standard tools. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
*/ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
class PcapFile |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
{ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
public: |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
static const int32_t ZONE_DEFAULT = 0; /**< Time zone offset for current location */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
static const uint32_t SNAPLEN_DEFAULT = 65535; /**< Default value for maximum octets to save per packet */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
public: |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
PcapFile (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
~PcapFile (); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
/** |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
* Create a new pcap file or open an existing pcap file. Semantics are |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
* similar to the C standard library function \c fopen, but differ in that |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
* positions in the file are based on packets not characters. For example |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
* if the file is opened for reading, the file position indicator (seek |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
* position) points to the beginning of the first packet in the file, not |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
* zero (which would point to the start of the pcap header). |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
* Possible modes are: |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
* \verbatim |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
* "r": Open a file for reading. The file must exist. The pcap header |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
* is assumed to exist in the file and will be read and checked. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
* The file seek position indicator is set to point to the first |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
* packet on exit. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
* "w": Create an empty file for writing. If a file with the same name |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
* already exists its content is erased and the file is treated as a |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
* new empty pcap file. The file is assumed not to have a pcap |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
* header and the caller is responsible for calling Init before saving |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
* any packet data. The file seek position indicator is set to point |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
* to the beginning of the file on exit since there will be no pcap |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
* header. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
* "a": Append to an existing file. This mode allows for adding packet data |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
* to the end of an existing pcap file. The file must exist and have a |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
* valid pcap header written (N.B. this is different from standard fopen |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
* semantics). The file seek position indicator is set to point |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
* to the end of the file on exit. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
75 |
* "r+": Open a file for update -- both reading and writing. The file must |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
76 |
* exist. The pcap header is assumed to have been written to the |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
* file and will be read and checked. The file seek position indicator |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
* is set to point to the first packet on exit. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
* "w+": Create an empty file for both reading and writing. If a file with |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
* the same name already exists, its content is erased and the file is |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
* treated as a new empty pcap file. Since this new file will not have |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
* a pcap header, the caller is responsible for calling Init before |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
* saving any packet data. On exit, the file seek position indicator is |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
85 |
* set to point to the beginning of the file. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
* "a+" Open a file for reading and appending. The file must exist and have a |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
* valid pcap header written (N.B. this is different from standard fopen |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
89 |
* semantics). The file seek position indicator is set to point |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
* to the end of the file on exit. Existing content is preserved. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
91 |
* \endverbatim |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
92 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
* Since a pcap file is always a binary file, the file type is automatically |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
94 |
* selected as a binary file. For example, providing a mode string "a+" |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
* results in the underlying OS file being opened in "a+b" mode. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
96 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
* \param filename String containing the name of the file. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
* \param mode String containing the access mode for the file. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
101 |
* \returns Error indication that should be interpreted as, "did an error |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
102 |
* happen"? That is, the method returns false if the open succeeds, true |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
103 |
* otherwise. The errno variable will be set by the OS to to provide a |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
* more descriptive failure indication. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
*/ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
bool Open (std::string const &filename, std::string const &mode); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
void Close (void); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
/** |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
* Initialize the pcap file associated with this object. This file must have |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
* been previously opened with write permissions. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
* \param dataLinkType A data link type as defined in the pcap library. If |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
115 |
* you want to make resulting pcap files visible in existing tools, the |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
* data link type must match existing definitions, such as PCAP_ETHERNET, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
* PCAP_PPP, PCAP_80211, etc. If you are storing different kinds of packet |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
* data, such as naked TCP headers, you are at liberty to locally define your |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
* own data link types. According to the pcap-linktype man page, "well-known" |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
* pcap linktypes range from 0 to 177. If you use a large random number for |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
* your type, chances are small for a collision. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
* \param snapLen An optional maximum size for packets written to the file. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
* Defaults to 65535. If packets exceed this length they are truncated. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
* \param timeZoneCorrection An integer describing the offset of your local |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
* time zone from UTC/GMT. For example, Pacific Standard Time in the US is |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
* GMT-8, so one would enter -8 for that correction. Defaults to 0 (UTC). |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
* |
6008
aa1c297a0de2
Fix non-undocumented warnings in doxygen, also update doxygen.conf
Josh Pelkey <jpelkey@gatech.edu>
parents:
5883
diff
changeset
|
130 |
* \param swapMode Flag indicating a difference in endianness of the |
aa1c297a0de2
Fix non-undocumented warnings in doxygen, also update doxygen.conf
Josh Pelkey <jpelkey@gatech.edu>
parents:
5883
diff
changeset
|
131 |
* writing system. Defaults to false. |
aa1c297a0de2
Fix non-undocumented warnings in doxygen, also update doxygen.conf
Josh Pelkey <jpelkey@gatech.edu>
parents:
5883
diff
changeset
|
132 |
* |
5465
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
133 |
* \return false if the open succeeds, true otherwise. |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
* |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
* \warning Calling this method on an existing file will result in the loss |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
* any existing data. |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
*/ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
bool Init (uint32_t dataLinkType, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
uint32_t snapLen = SNAPLEN_DEFAULT, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
int32_t timeZoneCorrection = ZONE_DEFAULT, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
bool swapMode = false); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
|
5465
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
143 |
/** |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
144 |
* \brief Write next packet to file |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
145 |
* |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
146 |
* \param tsSec Packet timestamp, seconds |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
147 |
* \param tsUsec Packet timestamp, microseconds |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
148 |
* \param data Data buffer |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
149 |
* \param totalLen Total packet length |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
150 |
* |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
151 |
* \return true on error, false otherwise |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
152 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
153 |
bool Write (uint32_t tsSec, uint32_t tsUsec, uint8_t const * const data, uint32_t totalLen); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
154 |
|
5465
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
155 |
/** |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
156 |
* \brief Read next packet from file |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
157 |
* |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
158 |
* \param data [out] Data buffer |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
159 |
* \param maxBytes Allocated data buffer size |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
160 |
* \param tsSec [out] Packet timestamp, seconds |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
161 |
* \param tsUsec [out] Packet timestamp, microseconds |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
162 |
* \param inclLen [out] Included length |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
163 |
* \param origLen [out] Original length |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
164 |
* \param readLen [out] Number of bytes read |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
165 |
* |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
166 |
* \return true if read failed, false otherwise |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
167 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
168 |
bool Read (uint8_t * const data, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
169 |
uint32_t maxBytes, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
170 |
uint32_t &tsSec, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
uint32_t &tsUsec, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
uint32_t &inclLen, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
173 |
uint32_t &origLen, |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
174 |
uint32_t &readLen); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
175 |
|
5883
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
176 |
/** |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
177 |
* \brief Get the swap mode of the file. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
178 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
179 |
* Pcap files use a magic number that is overloaded to identify both the |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
180 |
* format of the file itself and the byte ordering of the file. The magic |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
181 |
* number (and all data) is written into the file according to the native |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
182 |
* byte ordering of the writing system. If a reading application reads |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
183 |
* the magic number identically (for example 0xa1b2c3d4) then no byte |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
184 |
* swapping is required to correctly interpret the file data. If the reading |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
185 |
* application sees the magic number is byte swapped (for example 0xd4c3b2a1) |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
186 |
* then it knows that it needs to byteswap appropriate fields in the format. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
187 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
188 |
* GetSWapMode returns a value indicating whether or not the fields are being |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
189 |
* byteswapped. Used primarily for testing the class itself, but may be |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
190 |
* useful as a flag indicating a difference in endianness of the writing |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
191 |
* system. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
192 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
193 |
bool GetSwapMode (void); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
194 |
|
5883
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
195 |
/* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
196 |
* \brief Returns the magic number of the pcap file as defined by the magic_number |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
197 |
* field in the pcap global header. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
198 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
199 |
* See http://wiki.wireshark.org/Development/LibpcapFileFormat |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
200 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
201 |
uint32_t GetMagic (void); |
5883
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
202 |
|
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
203 |
/* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
204 |
* \brief Returns the major version of the pcap file as defined by the version_major |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
205 |
* field in the pcap global header. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
206 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
207 |
* See http://wiki.wireshark.org/Development/LibpcapFileFormat |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
208 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
209 |
uint16_t GetVersionMajor (void); |
5883
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
210 |
|
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
211 |
/* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
212 |
* \brief Returns the minor version of the pcap file as defined by the version_minor |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
213 |
* field in the pcap global header. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
214 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
215 |
* See http://wiki.wireshark.org/Development/LibpcapFileFormat |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
216 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
217 |
uint16_t GetVersionMinor (void); |
5883
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
218 |
|
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
219 |
/* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
220 |
* \brief Returns the time zone offset of the pcap file as defined by the thiszone |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
221 |
* field in the pcap global header. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
222 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
223 |
* See http://wiki.wireshark.org/Development/LibpcapFileFormat |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
224 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
225 |
int32_t GetTimeZoneOffset (void); |
5883
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
226 |
|
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
227 |
/* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
228 |
* \brief Returns the accuracy of timestamps field of the pcap file as defined |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
229 |
* by the sigfigs field in the pcap global header. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
230 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
231 |
* See http://wiki.wireshark.org/Development/LibpcapFileFormat |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
232 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
233 |
uint32_t GetSigFigs (void); |
5883
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
234 |
|
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
235 |
/* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
236 |
* \brief Returns the max length of saved packets field of the pcap file as |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
237 |
* defined by the snaplen field in the pcap global header. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
238 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
239 |
* See http://wiki.wireshark.org/Development/LibpcapFileFormat |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
240 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
241 |
uint32_t GetSnapLen (void); |
5883
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
242 |
|
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
243 |
/* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
244 |
* \brief Returns the data link type field of the pcap file as defined by the |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
245 |
* network field in the pcap global header. |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
246 |
* |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
247 |
* See http://wiki.wireshark.org/Development/LibpcapFileFormat |
c55a30dfe65e
doxygen for missing methods in pcap-file.h
craigdo@ns-test.ee.washington.edu
parents:
5465
diff
changeset
|
248 |
*/ |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
249 |
uint32_t GetDataLinkType (void); |
5465
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
250 |
|
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
251 |
/** |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
252 |
* \brief Compare two PCAP files packet-by-packet |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
253 |
* |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
254 |
* \return true if files are different, false otherwise |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
255 |
* |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
256 |
* \param f1 First PCAP file name |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
257 |
* \param f2 Second PCAP file name |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
258 |
* \param sec [out] Time stamp of first different packet, seconds. Undefined if files doesn't differ. |
6008
aa1c297a0de2
Fix non-undocumented warnings in doxygen, also update doxygen.conf
Josh Pelkey <jpelkey@gatech.edu>
parents:
5883
diff
changeset
|
259 |
* \param usec [out] Time stamp of first different packet, microseconds. Undefined if files doesn't differ. |
5465
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
260 |
* \param snapLen Snap length (if used) |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
261 |
*/ |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
262 |
static bool Diff (std::string const & f1, std::string const & f2, |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
263 |
uint32_t & sec, uint32_t & usec, |
917f7367691e
Pcap::Diff() method added to compare PCAP traces packet-by-packet
Pavel Boyko <boyko@iitp.ru>
parents:
4774
diff
changeset
|
264 |
uint32_t snapLen = SNAPLEN_DEFAULT); |
4772
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
265 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
266 |
private: |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
267 |
typedef struct { |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
268 |
uint32_t m_magicNumber; /**< Magic number identifying this as a pcap file */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
269 |
uint16_t m_versionMajor; /**< Major version identifying the version of pcap used in this file */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
270 |
uint16_t m_versionMinor; /**< Minor version identifying the version of pcap used in this file */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
271 |
int32_t m_zone; /**< Time zone correction to be applied to timestamps of packets */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
272 |
uint32_t m_sigFigs; /**< Unused by pretty much everybody */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
273 |
uint32_t m_snapLen; /**< Maximum length of packet data stored in records */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
274 |
uint32_t m_type; /**< Data link type of packet data */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
275 |
} PcapFileHeader; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
276 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
277 |
typedef struct { |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
278 |
uint32_t m_tsSec; /**< seconds part of timestamp */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
279 |
uint32_t m_tsUsec; /**< microseconds part of timestamp (nsecs for PCAP_NSEC_MAGIC) */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
280 |
uint32_t m_inclLen; /**< number of octets of packet saved in file */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
281 |
uint32_t m_origLen; /**< actual length of original packet */ |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
282 |
} PcapRecordHeader; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
283 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
284 |
uint8_t Swap (uint8_t val); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
285 |
uint16_t Swap (uint16_t val); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
286 |
uint32_t Swap (uint32_t val); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
287 |
void Swap (PcapFileHeader *from, PcapFileHeader *to); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
288 |
void Swap (PcapRecordHeader *from, PcapRecordHeader *to); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
289 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
290 |
bool WriteFileHeader (void); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
291 |
bool ReadAndVerifyFileHeader (void); |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
292 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
293 |
std::string m_filename; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
294 |
FILE *m_filePtr; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
295 |
PcapFileHeader m_fileHeader; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
296 |
bool m_haveFileHeader; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
297 |
bool m_swapMode; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
298 |
}; |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
299 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
300 |
}//namespace ns3 |
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
301 |
|
7b6ae6bf0055
add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
302 |
#endif /* PCAP_FILE_H */ |