LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 University of Washington | 3 * Copyright (c) 2009 University of Washington |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 void | 118 void |
119 PcapFileWrapper::Write (Time t, Ptr<const Packet> p) | 119 PcapFileWrapper::Write (Time t, Ptr<const Packet> p) |
120 { | 120 { |
121 NS_LOG_FUNCTION (this << t << p); | 121 NS_LOG_FUNCTION (this << t << p); |
122 if (m_file.IsNanoSecMode()) | 122 if (m_file.IsNanoSecMode()) |
123 { | 123 { |
124 uint64_t current = t.GetNanoSeconds (); | 124 uint64_t current = t.GetNanoSeconds (); |
125 uint64_t s = current / 1000000000; | 125 uint64_t s = current / 1000000000; |
126 uint64_t ns = current % 1000000000; | 126 uint64_t ns = current % 1000000000; |
127 m_file.Write (static_cast<uint32_t>(s), static_cast<uint32_t>(ns), p); | 127 m_file.Write (static_cast<uint32_t> (s), static_cast<uint32_t> (ns), p); |
128 } | 128 } |
129 else | 129 else |
130 { | 130 { |
131 uint64_t current = t.GetMicroSeconds (); | 131 uint64_t current = t.GetMicroSeconds (); |
132 uint64_t s = current / 1000000; | 132 uint64_t s = current / 1000000; |
133 uint64_t us = current % 1000000; | 133 uint64_t us = current % 1000000; |
134 m_file.Write (static_cast<uint32_t>(s), static_cast<uint32_t>(us), p); | 134 m_file.Write (static_cast<uint32_t> (s), static_cast<uint32_t> (us), p); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 void | 138 void |
139 PcapFileWrapper::Write (Time t, const Header &header, Ptr<const Packet> p) | 139 PcapFileWrapper::Write (Time t, const Header &header, Ptr<const Packet> p) |
140 { | 140 { |
141 NS_LOG_FUNCTION (this << t << &header << p); | 141 NS_LOG_FUNCTION (this << t << &header << p); |
142 if (m_file.IsNanoSecMode()) | 142 if (m_file.IsNanoSecMode()) |
143 { | 143 { |
144 uint64_t current = t.GetNanoSeconds (); | 144 uint64_t current = t.GetNanoSeconds (); |
145 uint64_t s = current / 1000000000; | 145 uint64_t s = current / 1000000000; |
146 uint64_t ns = current % 1000000000; | 146 uint64_t ns = current % 1000000000; |
147 m_file.Write (static_cast<uint32_t>(s), static_cast<uint32_t>(ns), header,
p); | 147 m_file.Write (static_cast<uint32_t> (s), static_cast<uint32_t> (ns), heade
r, p); |
148 } | 148 } |
149 else | 149 else |
150 { | 150 { |
151 uint64_t current = t.GetMicroSeconds (); | 151 uint64_t current = t.GetMicroSeconds (); |
152 uint64_t s = current / 1000000; | 152 uint64_t s = current / 1000000; |
153 uint64_t us = current % 1000000; | 153 uint64_t us = current % 1000000; |
154 m_file.Write (static_cast<uint32_t>(s), static_cast<uint32_t>(us), header,
p); | 154 m_file.Write (static_cast<uint32_t> (s), static_cast<uint32_t> (us), heade
r, p); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 void | 158 void |
159 PcapFileWrapper::Write (Time t, uint8_t const *buffer, uint32_t length) | 159 PcapFileWrapper::Write (Time t, uint8_t const *buffer, uint32_t length) |
160 { | 160 { |
161 NS_LOG_FUNCTION (this << t << &buffer << length); | 161 NS_LOG_FUNCTION (this << t << &buffer << length); |
162 if (m_file.IsNanoSecMode()) | 162 if (m_file.IsNanoSecMode()) |
163 { | 163 { |
164 uint64_t current = t.GetNanoSeconds (); | 164 uint64_t current = t.GetNanoSeconds (); |
165 uint64_t s = current / 1000000000; | 165 uint64_t s = current / 1000000000; |
166 uint64_t ns = current % 1000000000; | 166 uint64_t ns = current % 1000000000; |
167 m_file.Write (static_cast<uint32_t>(s), static_cast<uint32_t>(ns), buffer,
length); | 167 m_file.Write (static_cast<uint32_t> (s), static_cast<uint32_t> (ns), buffe
r, length); |
168 } | 168 } |
169 else | 169 else |
170 { | 170 { |
171 uint64_t current = t.GetMicroSeconds (); | 171 uint64_t current = t.GetMicroSeconds (); |
172 uint64_t s = current / 1000000; | 172 uint64_t s = current / 1000000; |
173 uint64_t us = current % 1000000; | 173 uint64_t us = current % 1000000; |
174 m_file.Write (static_cast<uint32_t>(s), static_cast<uint32_t>(us), buffer,
length); | 174 m_file.Write (static_cast<uint32_t> (s), static_cast<uint32_t> (us), buffe
r, length); |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 Ptr<Packet>· | 178 Ptr<Packet>· |
179 PcapFileWrapper::Read (Time &t) | 179 PcapFileWrapper::Read (Time &t) |
180 { | 180 { |
181 uint32_t tsSec; | 181 uint32_t tsSec; |
182 uint32_t tsUsec; | 182 uint32_t tsUsec; |
183 uint32_t inclLen; | 183 uint32_t inclLen; |
184 uint32_t origLen; | 184 uint32_t origLen; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 251 } |
252 | 252 |
253 uint32_t | 253 uint32_t |
254 PcapFileWrapper::GetDataLinkType (void) | 254 PcapFileWrapper::GetDataLinkType (void) |
255 { | 255 { |
256 NS_LOG_FUNCTION (this); | 256 NS_LOG_FUNCTION (this); |
257 return m_file.GetDataLinkType (); | 257 return m_file.GetDataLinkType (); |
258 } | 258 } |
259 | 259 |
260 } // namespace ns3 | 260 } // namespace ns3 |
LEFT | RIGHT |