Skip to content

Commit c1822f6

Browse files
author
Damir Zainullin
committed
++
1 parent fcae478 commit c1822f6

File tree

11 files changed

+89
-44
lines changed

11 files changed

+89
-44
lines changed
-896 KB
Binary file not shown.

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <optional>
66
#include <readers/rangeReader/rangeReader.hpp>
77
#include <readers/rangeReader/generator.hpp>
8+
#include <readers/rangeReader/functionTraits.hpp>
89

910
#include "dnsRecord.hpp"
1011

@@ -19,14 +20,14 @@ struct DNSSectionReaderFactory
1920
std::size_t itemCount,
2021
std::span<const std::byte> fullDNSPayload,
2122
std::span<const std::byte> section,
22-
ParsingState* parsingState
23+
ParsingState& parsingState
2324
) noexcept
2425
{
2526
return Generator::generate([section, itemCount, fullDNSPayload, parsingState]() mutable
2627
-> std::optional<DNSRecord> {
2728
auto res = std::make_optional<DNSRecord>();
2829
if (itemCount == 0) {
29-
parsingState->state = ParsingState::State::SUCCESS;
30+
parsingState.state = ParsingState::State::SUCCESS;
3031
return std::nullopt;
3132
}
3233
itemCount--;
@@ -84,9 +85,11 @@ class DNSSectionReader : public RangeReader<DNSSectionReaderFactory> {
8485
: RangeReader(section, DNSSectionReaderFactory{this, itemCount, fullDNSPayload.data()}) {}
8586
};*/
8687

88+
using Ret = FunctionTraits<decltype(
89+
&DNSSectionReaderFactory::makeReader)>::ReturnType;
90+
8791
class DNSSectionReader :
88-
public RangeReader<decltype(
89-
DNSSectionReaderFactory::makeReader({}, {}, {}, {}))> {
92+
public RangeReader<Ret> {
9093

9194
public:
9295
DNSSectionReader(
@@ -95,7 +98,7 @@ class DNSSectionReader :
9598
std::span<const std::byte> section)
9699
: RangeReader(
97100
DNSSectionReaderFactory::makeReader(
98-
itemCount, fullDNSPayload, section, &m_state))
101+
itemCount, fullDNSPayload, section, m_state))
99102
{
100103
}
101104

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
namespace ipxp
4+
{
5+
6+
template<typename Function>
7+
struct FunctionTraits;
8+
9+
template<typename R, typename... Args>
10+
struct FunctionTraits<R(*)(Args...)> {
11+
using ReturnType = R;
12+
};
13+
14+
} // namespace ipxp

process-plugin-api/process/common/readers/rangeReader/generator.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
#include <ranges>
44

5-
namespace ipxp::Generator
5+
namespace ipxp
66
{
77

88
// no std::ranges::generate in c++20(from c++23)
9+
10+
template<typename GeneratorCallback>
11+
class Generator {
12+
public:
13+
914
constexpr static
1015
auto generate(auto generator) noexcept
1116
{
@@ -15,4 +20,6 @@ auto generate(auto generator) noexcept
1520
});
1621
}
1722

23+
};
24+
1825
} // namespace ipxp

process-plugin-api/process/common/tlsParser/extensionReaders/extensionReader.hpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11

22
#include <span>
3-
#include <views>
3+
#include <ranges>
44
#include <optional>
5-
#include <rangeReader/rangeReader.hpp>
6-
#include <rangeReader/generator.hpp>
5+
#include <readers/rangeReader/rangeReader.hpp>
6+
#include <readers/rangeReader/generator.hpp>
77

8-
#include "../tlsExtensionType.hpp"
8+
#include "../tlsExtension.hpp"
99

1010
namespace ipxp
1111
{
1212

13-
struct Extension {
14-
ExtensionType type;
15-
std::span<const std::byte> payload;
16-
};
13+
1714

1815
class ExtensionReader;
1916

2017
struct ExtensionReaderFactory {
21-
ExtensionReader* self;
2218

23-
auto operator()(std::span<const std::byte> payload) const {
19+
static auto operator()(
20+
std::span<const std::byte> payload
21+
) noexcept {
2422
return Generator::generate([payload, self = self](int) mutable -> std::optional<Extension> {
2523
if (payload.empty()) {
2624
self->setSuccess();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
#include <span>
5+
6+
#include "tlsExtensionType.hpp"
7+
8+
namespace ipxp
9+
{
10+
11+
struct TLSExtension {
12+
TLSExtensionType type;
13+
std::span<const std::byte> payload;
14+
};
15+
16+
} // namespace ipxp

process-plugin-api/process/common/tlsParser/tlsExtensionType.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ enum class TLSExtensionType : uint16_t
1616
QUIC_TRANSPORT_PARAMETERS = 0xffa5,
1717
QUIC_TRANSPORT_PARAMETERS_V1 = 0x39,
1818
QUIC_TRANSPORT_PARAMETERS_V2 = 0x26
19-
}
19+
};
2020

21-
} // namespace ipxp::tls
21+
} // namespace ipxp

process-plugin-api/process/common/tlsParser/tlsHandshakeHeader.hpp renamed to process-plugin-api/process/common/tlsParser/tlsHandshake.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct TLSHandshake {
1616
Type type;
1717
uint8_t length1; // length field is 3 bytes long...
1818
uint16_t length2;
19-
Version version;
19+
TLSVersion version;
2020

2121
/* Handshake data... */
2222
} __attribute__((packed));

process-plugin-api/process/common/tlsParser/tlsHeader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct TLSHeader {
1111
};
1212

1313
Type type;
14-
Version version;
14+
TLSVersion version;
1515
uint16_t length;
1616
/* Record data... */
1717

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
#include <utils/spanUtils.hpp>
2121

22-
#include "tlsCipherSuite.hpp"
22+
//#include "tlsCipherSuite.hpp"
2323
#include "tlsHeader.hpp"
24-
#include "tlsHandshakeHeader.hpp"
24+
#include "tlsHandshake.hpp"
2525
#include "extensionReaders/extensionReader.hpp"
2626

2727

0 commit comments

Comments
 (0)