-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlength_extractors.h
34 lines (31 loc) · 1.03 KB
/
length_extractors.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include "splitter.h"
#include "network_headers.h"
#include "simba_headers.h"
class EthernetIpLengthExtractor : public LengthExtractor {
public:
std::optional<size_t> GetDatagramLength(const std::span<char>& buffer) override {
throw;
return 0;
}
};
#include <iostream>
class PcapLengthExtractor : public LengthExtractor {
public:
std::optional<size_t> GetDatagramLength(const std::span<char>& buffer) override {
if (buffer.size() < sizeof(PcapRecHdr)) return std::nullopt;
const auto* pcap_rec_hdr = reinterpret_cast<const PcapRecHdr*>(buffer.data());
return pcap_rec_hdr->incl_len + sizeof(PcapRecHdr);
}
};
class MdpLengthExtractor : public LengthExtractor {
public:
std::optional<size_t> GetDatagramLength(const std::span<char>& buffer) override {
if (buffer.size() < sizeof(MdpHdr)) {
return std::nullopt;
}
const auto* mdp_hdr = reinterpret_cast<const MdpHdr*>(buffer.data());
return mdp_hdr->msg_size;
}
int ctr = 0;
};