GCC Code Coverage Report


Directory: Svc/Ccsds/CcsdsSdlsDeframer/
File: CcsdsSdlsDeframer.cpp
Date: 2026-09-03 21:16:23
Exec Total Coverage
Lines: 29 29 100.0%
Functions: 6 6 100.0%
Branches: 13 14 92.9%

Line Branch Exec Source
1 // ======================================================================
2 // \title CcsdsSdlsDeframer.cpp
3 // \author mstarch
4 // \brief cpp file for CcsdsSdlsDeframer component implementation class
5 // ======================================================================
6
7 #include "Svc/Ccsds/CcsdsSdlsDeframer/CcsdsSdlsDeframer.hpp"
8
9 namespace Svc {
10
11 namespace Ccsds {
12
13 // ----------------------------------------------------------------------
14 // Component construction and destruction
15 // ----------------------------------------------------------------------
16
17 5 CcsdsSdlsDeframer ::CcsdsSdlsDeframer(const char* const compName) : CcsdsSdlsDeframerComponentBase(compName) {}
18
19 10 CcsdsSdlsDeframer ::~CcsdsSdlsDeframer() {}
20
21 // ----------------------------------------------------------------------
22 // Handler implementations for typed input ports
23 // ----------------------------------------------------------------------
24
25 1656 void CcsdsSdlsDeframer ::bufferReturnIn_handler(FwIndexType portNum,
26 Fw::Buffer& data,
27 const ComCfg::FrameContext& context) {
28 // The decryption helper has returned the original frame buffer: send it back upstream
29 1656 this->dataReturnOut_out(0, data, context);
30 1656 }
31
32 3336 void CcsdsSdlsDeframer ::dataIn_handler(FwIndexType portNum, Fw::Buffer& data, const ComCfg::FrameContext& context) {
33
2/2
✓ Branch 4 taken 1641 times.
✓ Branch 5 taken 1695 times.
3336 if (data.getSize() < sizeof(U16)) {
34 // The frame is not long enough to contain the security association index, so we cannot process it
35 1641 this->log_WARNING_HI_InsufficientLength();
36 1641 this->dataReturnOut_out(0, data, context); // Drop the frame
37 } else {
38 1695 U16 saIndex = 0;
39
2/2
✓ Branch 2 taken 1695 times.
✓ Branch 8 taken 1695 times.
1695 Fw::SerializeStatus deserializeStatus = data.getDeserializer().deserializeTo(saIndex);
40 1695 FW_ASSERT(deserializeStatus == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(deserializeStatus));
41
42 // Copy context and set the security association index to the value we just deserialized from the frame
43
1/1
✓ Branch 2 taken 1695 times.
1695 ComCfg::FrameContext newContext = context;
44
1/1
✓ Branch 2 taken 1695 times.
1695 newContext.set_saIndex(saIndex);
45
46 // Remove the security association index: the decryption helper receives only the iv/data
47
1/1
✓ Branch 4 taken 1695 times.
1695 data.advance(static_cast<FwSignedSizeType>(sizeof(U16)));
48
49
1/1
✓ Branch 5 taken 1695 times.
1695 this->decryptOut_out(0, saIndex, data, newContext);
50 1695 }
51 3336 }
52
53 1692 void CcsdsSdlsDeframer ::dataReturnIn_handler(FwIndexType portNum,
54 Fw::Buffer& data,
55 const ComCfg::FrameContext& context) {
56 // Pass the data back to the decryption subsystem when it is returned from the rest of the chain
57 1692 this->decryptReturnOut_out(0, data, context);
58 1692 }
59
60 3322 void CcsdsSdlsDeframer ::decryptIn_handler(FwIndexType portNum,
61 const Svc::Ccsds::SdlsStatus& status,
62 Fw::Buffer& data,
63 const ComCfg::FrameContext& context) {
64
2/2
✓ Branch 4 taken 1722 times.
✓ Branch 5 taken 1600 times.
3322 if (status != Svc::Ccsds::SdlsStatus::SUCCESS) {
65 1722 this->log_WARNING_HI_DecryptionFailed(status);
66
1/2
✓ Branch 5 taken 1722 times.
✗ Branch 6 not taken.
1722 if (this->isConnected_errorNotify_OutputPort(0)) {
67
2/2
✓ Branch 6 taken 1722 times.
✓ Branch 10 taken 1722 times.
1722 this->errorNotify_out(0, Svc::Ccsds::FrameError::SDLS_DECRYPTION_FAILURE);
68 }
69 // Return ownership of the failed buffer to the decryption subsystem
70 1722 this->decryptReturnOut_out(0, data, context);
71 } else {
72 // Once the decryption has finished, we can route the decryption output to the dataOut port for further
73 // processing
74 1600 this->dataOut_out(0, data, context);
75 }
76 3322 }
77
78 } // namespace Ccsds
79
80 } // namespace Svc
81