Skip to content

Commit 3711775

Browse files
author
Damir Zainullin
committed
++
1 parent 82c89d0 commit 3711775

File tree

99 files changed

+1324
-1048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1324
-1048
lines changed

process-plugin-api/directionalField.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ template<typename T>
88
struct DirectionalField {
99
T values[2]{};
1010

11-
T& operator[](Direction d) { return values[static_cast<std::size_t>(d)]; }
12-
const T& operator[](Direction d) const { return values[static_cast<std::size_t>(d)]; }
11+
constexpr T& operator[](Direction d) { return values[static_cast<std::size_t>(d)]; }
12+
constexpr const T& operator[](Direction d) const { return values[static_cast<std::size_t>(d)]; }
1313
};

process-plugin-api/ipAddress.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ union IPAddress {
2828
u32[2] = u32[3] = std::numeric_limits<uint32_t>::max();
2929
}
3030

31-
constexpr IPAddress(const std::array<uint8_t, 16>& ipv6) noexcept
31+
constexpr IPAddress(const std::span<const std::byte, 16>& ipv6) noexcept
3232
{
33-
u8 = ipv6;
33+
std::copy(
34+
ipv6.begin(), ipv6.end(), reinterpret_cast<std::byte*>(u8.data()));
3435
}
3536

3637
constexpr bool isIPv4() const noexcept

process-plugin-api/main.o

5.68 KB
Binary file not shown.
4.13 MB
Binary file not shown.
4.32 MB
Binary file not shown.

process-plugin-api/process/common/dnsParser/dnsParser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ parseSection(
4848
std::size_t sectionSize{0};
4949
const auto sectionBegin = payload.begin();
5050

51-
DNSSectionReader reader(recordCount, payload, fullDNSPayload);
51+
DNSSectionReader reader;
5252

53-
std::ranges::for_each(reader,
53+
std::ranges::for_each(
54+
reader.getRange(recordCount, payload, fullDNSPayload),
5455
[&, needToCallCallback = true]
5556
(const DNSRecord& record) mutable {
5657
sectionSize = static_cast<std::size_t>(
879 KB
Binary file not shown.

process-plugin-api/process/common/dnsParser/dnsSection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ DNSSection::parseSection(
1919
const std::size_t recordsCount) noexcept
2020
{
2121
auto res = std::make_optional<DNSSection>();
22-
DNSSectionReader reader(recordsCount, section, fullDNSPayload);
23-
std::ranges::copy(reader |
22+
DNSSectionReader reader;
23+
std::ranges::copy(reader.getRange(recordsCount, section, fullDNSPayload) |
2424
std::views::take(res->records.capacity()),
2525
std::back_inserter(res->records));
2626

-7.3 KB
Binary file not shown.

process-plugin-api/process/common/dnsParser/dnsSectionReader.hpp

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@
1414
namespace ipxp
1515
{
1616

17-
class DNSSectionReader;
18-
19-
struct DNSSectionReaderFactory
17+
class DNSSectionReader : public RangeReader
2018
{
21-
static auto makeReader(
19+
public:
20+
21+
auto getRange(
2222
std::size_t itemCount,
2323
std::span<const std::byte> fullDNSPayload,
24-
std::span<const std::byte> section,
25-
ParsingState& parsingState
24+
std::span<const std::byte> section
2625
) noexcept
2726
{
28-
return Generator::generate([section, itemCount, fullDNSPayload, parsingState]() mutable
27+
return Generator::generate([this, section, itemCount, fullDNSPayload]() mutable
2928
-> std::optional<DNSRecord> {
3029
auto res = std::make_optional<DNSRecord>();
3130
if (itemCount == 0) {
32-
parsingState.state = ParsingState::State::SUCCESS;
31+
setSuccess();
3332
return std::nullopt;
3433
}
3534
itemCount--;
@@ -76,7 +75,6 @@ struct DNSSectionReaderFactory
7675
return *v;
7776
});
7877
}
79-
8078
};
8179

8280
/*
@@ -87,27 +85,22 @@ class DNSSectionReader : public RangeReader<DNSSectionReaderFactory> {
8785
: RangeReader(section, DNSSectionReaderFactory{this, itemCount, fullDNSPayload.data()}) {}
8886
};*/
8987

90-
using Args = FunctionTraits<decltype(
91-
&DNSSectionReaderFactory::makeReader
92-
)>::ArgumentTypes;
93-
94-
using Ret =
95-
ReturnType<DNSSectionReaderFactory::makeReader, Args>::Type;
96-
97-
class DNSSectionReader :
98-
public RangeReader<Ret> {
88+
/*
89+
class DNSSectionReaderX : public RangeReader {
9990
10091
public:
10192
DNSSectionReader(
10293
const std::size_t itemCount,
10394
std::span<const std::byte> fullDNSPayload,
10495
std::span<const std::byte> section)
105-
: RangeReader(
106-
DNSSectionReaderFactory::makeReader(
107-
itemCount, fullDNSPayload, section, m_state))
96+
: m_callback(DNSSectionReaderFactory::makeReader(
97+
itemCount, fullDNSPayload, section))
10898
{
10999
}
100+
101+
auto m_callback{DNSSectionReaderFactory::makeReader({}, {}, {})};
110102
103+
};*/
111104
/*public:
112105
113106
DNSSectionReader(
@@ -124,7 +117,6 @@ class DNSSectionReader :
124117
std::span<const std::byte> m_fullDNSPayload;
125118
std::span<const std::byte> section;
126119
CallbackType m_callback;*/
127-
};
128120

129121

130122

0 commit comments

Comments
 (0)