Skip to content

Commit

Permalink
refactor sds parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
marenz2569 committed Jul 1, 2024
1 parent e28228f commit 0149af2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 42 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ add_executable(tetra-decoder
src/l2/upper_mac_packet.cpp
src/l2/upper_mac_packet_builder.cpp
src/l2/upper_mac_packet_formatter.cpp
src/l3/short_data_service.cpp
src/utils/address.cpp
src/utils/bit_vector.cpp
src/utils/viter_bi_codec.cpp)
Expand Down
4 changes: 2 additions & 2 deletions include/l3/circuit_mode_control_entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class CircuitModeControlEntityParser : public PacketParser<MobileLinkEntityPacke
auto forward(const CircuitModeControlEntityPacket& packet)
-> std::unique_ptr<CircuitModeControlEntityPacket> override {
if (packet.sds_data_) {
return sds_.process(packet);
return sds_.parse(packet);
}

return std::make_unique<CircuitModeControlEntityPacket>(packet);
};

ShortDataService sds_;
ShortDataServiceParser sds_;
};
28 changes: 13 additions & 15 deletions include/l3/short_data_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

#include "l3/circuit_mode_control_entity_packet.hpp"
#include "l3/short_data_service_packet.hpp"
#include "utils/packet_counter_metrics.hpp"
#include <array>
#include <string>
#include "utils/packet_parser.hpp"

class ShortDataService {
class ShortDataServiceParser : public PacketParser<CircuitModeControlEntityPacket, ShortDataServicePacket> {
public:
ShortDataService() = delete;
ShortDataService(const std::shared_ptr<PrometheusExporter>& prometheus_exporter) {
ShortDataServiceParser() = delete;
explicit ShortDataServiceParser(const std::shared_ptr<PrometheusExporter>& prometheus_exporter)
: PacketParser(prometheus_exporter, "short_data_service") {
sds_pdu_description_[0] = "Reserved 0";
sds_pdu_description_[1] = "OTAK (Over The Air re-Keying for end to end encryption)";
sds_pdu_description_[2] = "Simple Text Messaging";
Expand Down Expand Up @@ -61,17 +60,16 @@ class ShortDataService {
sds_pdu_description_[i] = "Available for user application definition " + std::to_string(i);
}
sds_pdu_description_[255] = "Reserved for extension";

if (prometheus_exporter) {
metrics_ = std::make_unique<PacketCounterMetrics>(prometheus_exporter, "short_data_service");
}
};
~ShortDataService() noexcept = default;

auto process(const CircuitModeControlEntityPacket& packet) -> std::unique_ptr<ShortDataServicePacket>;

private:
std::array<std::string, 256> sds_pdu_description_;
auto packet_name(const ShortDataServicePacket& packet) -> std::string override {
return sds_pdu_description_.at(packet.protocol_identifier_);
}

std::unique_ptr<PacketCounterMetrics> metrics_;
auto forward(const ShortDataServicePacket& packet) -> std::unique_ptr<ShortDataServicePacket> override {
return std::make_unique<ShortDataServicePacket>(packet);
};

std::array<std::string, 256> sds_pdu_description_;
};
24 changes: 0 additions & 24 deletions src/l3/short_data_service.cpp

This file was deleted.

0 comments on commit 0149af2

Please sign in to comment.