Skip to content

Commit 6e0b3ef

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce process common
1 parent 047988c commit 6e0b3ef

File tree

6 files changed

+47
-1
lines changed

6 files changed

+47
-1
lines changed

src/plugins/process/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
add_subdirectory(common)
12
add_subdirectory(basicplus)
23
add_subdirectory(bstats)
34
add_subdirectory(icmp)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
add_library(ipfixprobe-process-tls-parser STATIC
2+
tlsParser/tls_parser.hpp
3+
tlsParser/tls_parser.cpp
4+
)
5+
6+
target_include_directories(ipfixprobe-process-tls-parser PUBLIC
7+
${CMAKE_SOURCE_DIR}/include
8+
)
9+
10+
set_property(TARGET ipfixprobe-process-tls-parser
11+
PROPERTY POSITION_INDEPENDENT_CODE ON
12+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929
#ifndef IPXP_PROCESS_COMMON_HPP
3030
#define IPXP_PROCESS_COMMON_HPP
3131

32+
#include <cstddef>
33+
#include <cstdint>
3234
#include <cstring>
3335

36+
#include <sys/types.h>
37+
#include <unistd.h>
38+
3439
namespace ipxp {
3540

3641
static inline bool check_payload_len(size_t payload_len, size_t required_len) noexcept
@@ -69,6 +74,34 @@ static inline const char* strnstr(const char* str1, const char* str2, size_t len
6974
return ((char*) str1);
7075
}
7176

77+
/**
78+
* \brief Copy string and append \0 character.
79+
* NOTE: function removes any CR chars at the end of string.
80+
* \param [in] dst Destination buffer.
81+
* \param [in] size Size of destination buffer.
82+
* \param [in] begin Ptr to begin of source string.
83+
* \param [in] end Ptr to end of source string.
84+
*/
85+
static inline void copy_str(char* dst, ssize_t size, const char* begin, const char* end)
86+
{
87+
ssize_t len = end - begin;
88+
if (len >= size) {
89+
len = size - 1;
90+
}
91+
92+
memcpy(dst, begin, len);
93+
94+
if (len >= 1 && dst[len - 1] == '\n') {
95+
len--;
96+
}
97+
98+
if (len >= 1 && dst[len - 1] == '\r') {
99+
len--;
100+
}
101+
102+
dst[len] = 0;
103+
}
104+
72105
} // namespace ipxp
73106

74107
#endif /* IPXP_PROCESS_COMMON_HPP */
File renamed without changes.

src/plugins/process/tls_parser.hpp renamed to src/plugins/process/common/tlsParser/tls_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <string_view>
1818
#include <vector>
1919

20-
#include <ipfixprobe/process.hpp>
20+
#include <ipfixprobe/processPlugin.hpp>
2121

2222
#define TLS_HANDSHAKE_CLIENT_HELLO 1
2323
#define TLS_HANDSHAKE_SERVER_HELLO 2

0 commit comments

Comments
 (0)