Skip to content

Commit

Permalink
refactor cmce parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
marenz2569 committed Jul 1, 2024
1 parent 0569f65 commit e28228f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 66 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/circuit_mode_control_entity.cpp
src/l3/short_data_service.cpp
src/utils/address.cpp
src/utils/bit_vector.cpp
Expand Down
36 changes: 21 additions & 15 deletions include/l3/circuit_mode_control_entity.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Transit Live Mapping Solutions
* Copyright (C) 2022-2024 Transit Live Mapping Solutions
* All rights reserved.
*
* Authors:
Expand All @@ -9,24 +9,30 @@
#pragma once

#include "l3/circuit_mode_control_entity_packet.hpp"
#include "l3/circuit_mode_control_entity_packet_builder.hpp"
#include "l3/mobile_link_entity_packet.hpp"
#include "utils/packet_counter_metrics.hpp"
#include "l3/short_data_service.hpp"
#include "utils/packet_parser.hpp"

class CircuitModeControlEntity {
class CircuitModeControlEntityParser : public PacketParser<MobileLinkEntityPacket, CircuitModeControlEntityPacket> {
public:
CircuitModeControlEntity() = delete;
explicit CircuitModeControlEntity(const std::shared_ptr<PrometheusExporter>& prometheus_exporter)
: packet_builder_(prometheus_exporter) {
if (prometheus_exporter) {
metrics_ = std::make_unique<PacketCounterMetrics>(prometheus_exporter, "circuit_mode_control_entity");
}
CircuitModeControlEntityParser() = delete;
explicit CircuitModeControlEntityParser(const std::shared_ptr<PrometheusExporter>& prometheus_exporter)
: PacketParser(prometheus_exporter, "circuit_mode_control_entity")
, sds_(prometheus_exporter){};

private:
auto packet_name(const CircuitModeControlEntityPacket& packet) -> std::string override {
return to_string(packet.packet_type_);
};
~CircuitModeControlEntity() noexcept = default;

auto process(const MobileLinkEntityPacket& packet) -> std::unique_ptr<CircuitModeControlEntityPacket>;
auto forward(const CircuitModeControlEntityPacket& packet)
-> std::unique_ptr<CircuitModeControlEntityPacket> override {
if (packet.sds_data_) {
return sds_.process(packet);
}

private:
CircuitModeControlEntityPacketBuilder packet_builder_;
std::unique_ptr<PacketCounterMetrics> metrics_;
return std::make_unique<CircuitModeControlEntityPacket>(packet);
};

ShortDataService sds_;
};
34 changes: 0 additions & 34 deletions include/l3/circuit_mode_control_entity_packet_builder.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions include/l3/mobile_link_entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MobileLinkEntityParser : public PacketParser<LogicalLinkControlPacket, Mob
case MobileLinkEntityProtocolDiscriminator::kMmProtocol:
return mm_.parse(packet);
case MobileLinkEntityProtocolDiscriminator::kCmceProtocol:
return cmce_.process(packet);
return cmce_.parse(packet);

// Fall through for all other unimplemented packet types
case MobileLinkEntityProtocolDiscriminator::kReserved0:
Expand All @@ -78,7 +78,7 @@ class MobileLinkEntityParser : public PacketParser<LogicalLinkControlPacket, Mob
}
};

CircuitModeControlEntity cmce_;
CircuitModeControlEntityParser cmce_;
MobileManagementParser mm_;

static const auto kExtendedPdu = 7;
Expand Down
14 changes: 0 additions & 14 deletions src/l3/circuit_mode_control_entity.cpp

This file was deleted.

0 comments on commit e28228f

Please sign in to comment.