A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
pcap-file-wrapper.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#ifndef PCAP_FILE_WRAPPER_H
20
#define PCAP_FILE_WRAPPER_H
21
22
#include <cstring>
23
#include <limits>
24
#include <fstream>
25
#include "ns3/ptr.h"
26
#include "ns3/packet.h"
27
#include "ns3/object.h"
28
#include "ns3/nstime.h"
29
#include "
pcap-file.h
"
30
31
namespace
ns3 {
32
33
/*
34
* A class that wraps a PcapFile as an ns3::Object and provides a higher-layer
35
* ns-3 interface to the low-level public methods of PcapFile. Users are
36
* encouraged to use this object instead of class ns3::PcapFile in ns-3
37
* public APIs.
38
*/
39
class
PcapFileWrapper
:
public
Object
40
{
41
public
:
42
static
TypeId
GetTypeId
(
void
);
43
44
PcapFileWrapper
();
45
~PcapFileWrapper
();
46
47
51
bool
Fail
(
void
)
const
;
55
bool
Eof
(
void
)
const
;
59
void
Clear
(
void
);
60
74
void
Open
(std::string
const
&filename, std::ios::openmode mode);
75
79
void
Close
(
void
);
80
104
void
Init
(uint32_t dataLinkType,
105
uint32_t snapLen = std::numeric_limits<uint32_t>::max (),
106
int32_t tzCorrection =
PcapFile::ZONE_DEFAULT
);
107
115
void
Write
(
Time
t,
Ptr<const Packet>
p);
116
129
void
Write
(
Time
t,
Header
&header,
Ptr<const Packet>
p);
130
139
void
Write
(
Time
t, uint8_t
const
*buffer, uint32_t length);
140
141
/*
142
* \brief Returns the magic number of the pcap file as defined by the magic_number
143
* field in the pcap global header.
144
*
145
* See http://wiki.wireshark.org/Development/LibpcapFileFormat
146
*/
147
uint32_t
GetMagic
(
void
);
148
149
/*
150
* \brief Returns the major version of the pcap file as defined by the version_major
151
* field in the pcap global header.
152
*
153
* See http://wiki.wireshark.org/Development/LibpcapFileFormat
154
*/
155
uint16_t
GetVersionMajor
(
void
);
156
157
/*
158
* \brief Returns the minor version of the pcap file as defined by the version_minor
159
* field in the pcap global header.
160
*
161
* See http://wiki.wireshark.org/Development/LibpcapFileFormat
162
*/
163
uint16_t
GetVersionMinor
(
void
);
164
165
/*
166
* \brief Returns the time zone offset of the pcap file as defined by the thiszone
167
* field in the pcap global header.
168
*
169
* See http://wiki.wireshark.org/Development/LibpcapFileFormat
170
*/
171
int32_t
GetTimeZoneOffset
(
void
);
172
173
/*
174
* \brief Returns the accuracy of timestamps field of the pcap file as defined
175
* by the sigfigs field in the pcap global header.
176
*
177
* See http://wiki.wireshark.org/Development/LibpcapFileFormat
178
*/
179
uint32_t
GetSigFigs
(
void
);
180
181
/*
182
* \brief Returns the max length of saved packets field of the pcap file as
183
* defined by the snaplen field in the pcap global header.
184
*
185
* See http://wiki.wireshark.org/Development/LibpcapFileFormat
186
*/
187
uint32_t
GetSnapLen
(
void
);
188
189
/*
190
* \brief Returns the data link type field of the pcap file as defined by the
191
* network field in the pcap global header.
192
*
193
* See http://wiki.wireshark.org/Development/LibpcapFileFormat
194
*/
195
uint32_t
GetDataLinkType
(
void
);
196
197
private
:
198
PcapFile
m_file
;
199
uint32_t
m_snapLen
;
200
};
201
202
}
// namespace ns3
203
204
#endif
/* PCAP_FILE_WRAPPER_H */
src
network
utils
pcap-file-wrapper.h
Generated on Tue May 14 2013 11:08:31 for ns-3 by
1.8.1.2