Skip to content

Commit d9858ce

Browse files
committed
utils - introduce memcpy_le32toh function
1 parent b775de3 commit d9858ce

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/ipfixprobe/utils.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ std::string vec2str(const std::vector<T> &vec) {
171171
return ss.str();
172172
}
173173

174+
/**
175+
* @brief Copy uint32 in little endian byte order to destination in host byte order
176+
*/
177+
void memcpy_le32toh(uint32_t* dest, const uint32_t* src);
178+
174179
}
175180

176181
#endif /* IPXP_UTILS_HPP */

utils.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <arpa/inet.h>
3131
#include <cstring>
32+
#include <endian.h>
3233
#include <string>
3334
#include <utility>
3435

@@ -138,4 +139,9 @@ uint64_t timeval2usec(const struct timeval& tv)
138139
return tv.tv_sec * usec_in_sec + tv.tv_usec;
139140
}
140141

142+
void memcpy_le32toh(uint32_t* dest, const uint32_t* src)
143+
{
144+
*dest = le32toh(*src);
145+
}
146+
141147
} // namespace ipxp

0 commit comments

Comments
 (0)