equal
deleted
inserted
replaced
15 * along with this program; if not, write to the Free Software |
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 |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 */ |
17 */ |
18 |
18 |
19 #include "ns3/log.h" |
19 #include "ns3/log.h" |
|
20 #include "ns3/uinteger.h" |
20 |
21 |
21 #include "buffer.h" |
22 #include "buffer.h" |
22 #include "header.h" |
23 #include "header.h" |
23 #include "pcap-file-object.h" |
24 #include "pcap-file-object.h" |
24 |
25 |
32 PcapFileObject::GetTypeId (void) |
33 PcapFileObject::GetTypeId (void) |
33 { |
34 { |
34 static TypeId tid = TypeId ("ns3::PcapFileObject") |
35 static TypeId tid = TypeId ("ns3::PcapFileObject") |
35 .SetParent<Object> () |
36 .SetParent<Object> () |
36 .AddConstructor<PcapFileObject> () |
37 .AddConstructor<PcapFileObject> () |
|
38 .AddAttribute ("CaptureSize", |
|
39 "Maximum length of captured packets (cf. pcap snaplen)", |
|
40 UintegerValue (PcapFile::SNAPLEN_DEFAULT), |
|
41 MakeUintegerAccessor (&PcapFileObject::m_snapLen), |
|
42 MakeUintegerChecker<uint32_t> (0, PcapFile::SNAPLEN_DEFAULT)) |
37 ; |
43 ; |
38 return tid; |
44 return tid; |
39 } |
45 } |
40 |
46 |
41 |
47 |
61 } |
67 } |
62 |
68 |
63 bool |
69 bool |
64 PcapFileObject::Init (uint32_t dataLinkType, uint32_t snapLen, int32_t tzCorrection) |
70 PcapFileObject::Init (uint32_t dataLinkType, uint32_t snapLen, int32_t tzCorrection) |
65 { |
71 { |
66 return m_file.Init (dataLinkType, snapLen, tzCorrection); |
72 // |
|
73 // If the user doesn't provide a snaplen, the default value will come in. If |
|
74 // this happens, we use the "CaptureSize" Attribute. If the user does provide |
|
75 // a snaplen, we use the one provided. |
|
76 // |
|
77 if (snapLen != std::numeric_limits<uint32_t>::max ()) |
|
78 { |
|
79 return m_file.Init (dataLinkType, snapLen, tzCorrection); |
|
80 } |
|
81 else |
|
82 { |
|
83 return m_file.Init (dataLinkType, m_snapLen, tzCorrection); |
|
84 } |
|
85 |
|
86 // |
|
87 // Quiet the compiler |
|
88 // |
|
89 return true; |
67 } |
90 } |
68 |
91 |
69 bool |
92 bool |
70 PcapFileObject::Write (Time t, Ptr<const Packet> p) |
93 PcapFileObject::Write (Time t, Ptr<const Packet> p) |
71 { |
94 { |