File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,54 @@ std::string vec2str(const std::vector<T>& vec)
179179 */
180180void memcpy_le32toh (uint32_t * dest, const uint32_t * src);
181181
182+ constexpr static inline
183+ timeval operator +(const timeval& a, const timeval& b) noexcept
184+ {
185+ constexpr time_t USEC_IN_SEC = 1'000'000 ;
186+
187+ timeval result{};
188+ result.tv_sec = a.tv_sec + b.tv_sec ;
189+ result.tv_usec = a.tv_usec + b.tv_usec ;
190+ if (result.tv_usec >= USEC_IN_SEC) {
191+ result.tv_sec ++;
192+ result.tv_usec -= USEC_IN_SEC;
193+ }
194+ return result;
195+ }
196+
197+ constexpr static inline
198+ timeval operator -(const timeval& a) noexcept
199+ {
200+ timeval result{};
201+ result.tv_sec = -a.tv_sec ;
202+ result.tv_usec = -a.tv_usec ;
203+ return result;
204+ }
205+
206+ constexpr static inline
207+ timeval operator -(const timeval& a, const timeval& b) noexcept
208+ {
209+ return a + (-b);
210+ }
211+
212+ constexpr static inline
213+ bool operator >(const timeval& a, const timeval& b) noexcept
214+ {
215+ return std::tie (a.tv_sec , a.tv_usec ) > std::tie (b.tv_sec , b.tv_usec );
216+ }
217+
218+ constexpr static inline
219+ bool operator <(const timeval& a, const timeval& b) noexcept
220+ {
221+ return std::tie (a.tv_sec , a.tv_usec ) < std::tie (b.tv_sec , b.tv_usec );
222+ }
223+
224+ constexpr static inline
225+ bool operator ==(const timeval& a, const timeval& b) noexcept
226+ {
227+ return not (a < b) and not (b < a);
228+ }
229+
182230} // namespace ipxp
183231
184232#endif /* IPXP_UTILS_HPP */
Original file line number Diff line number Diff line change 11#pragma once
22
33#include < cstdint>
4+ #include < sys/time.h>
5+
46#include " directionalField.hpp"
57#include " tcpFlags.hpp"
68
79namespace ipxp
810{
911
1012struct Packet {
13+ timeval timestamp;
1114 uint8_t ipTtl;
1215 uint8_t ipFlags;
1316 uint16_t ipLength;
1417 uint16_t tcpWindow;
1518 uint64_t tcpOptions;
1619 uint32_t tcpMss;
1720 TcpFlags tcpFlags;
21+
22+ uint32_t actualLength;
23+ uint32_t receivedLength;
24+
1825};
1926
2027} // namespace ipxp
You can’t perform that action at this time.
0 commit comments