pace complete PDU transactions for air and hotspot modems; correct TIA-102 enhanced AES CBC-MAC generation; start outbound KMM message numbering at one; clear completed FNE response state before the next PDU; decode and log authenticated and invalid-MAC KMM NACKs; add KMM changeover command/response support;
parent
cd4496b56c
commit
aba9c330ef
@ -0,0 +1,100 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Digital Voice Modem - Common Library
|
||||
* GPLv2 Open Source. Use is subject to license terms.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright (C) 2026 Bryan Biedenkapp, N2PLL
|
||||
*
|
||||
*/
|
||||
#include "Defines.h"
|
||||
#include "p25/P25Defines.h"
|
||||
#include "p25/kmm/KMMChangeover.h"
|
||||
#include "Log.h"
|
||||
|
||||
using namespace p25;
|
||||
using namespace p25::defines;
|
||||
using namespace p25::kmm;
|
||||
|
||||
#include <cassert>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Public Class Members
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/* Initializes a new instance of the KMMChangeover class. */
|
||||
|
||||
KMMChangeover::KMMChangeover() : KMMFrame(),
|
||||
m_supersededKeysetId(0U),
|
||||
m_activeKeysetId(0U)
|
||||
{
|
||||
m_messageId = KMM_MessageType::CHANGEOVER_CMD;
|
||||
m_respKind = KMM_ResponseKind::IMMEDIATE;
|
||||
}
|
||||
|
||||
/* Finalizes a instance of the KMMChangeover class. */
|
||||
|
||||
KMMChangeover::~KMMChangeover() = default;
|
||||
|
||||
/* Gets the byte length of this KMMChangeover. */
|
||||
|
||||
uint32_t KMMChangeover::length() const
|
||||
{
|
||||
uint32_t len = KMMFrame::length() + 3U;
|
||||
return len;
|
||||
}
|
||||
|
||||
/* Decode a KMM changeover command. */
|
||||
|
||||
bool KMMChangeover::decode(const uint8_t* data)
|
||||
{
|
||||
assert(data != nullptr);
|
||||
|
||||
KMMFrame::decodeHeader(data);
|
||||
|
||||
uint8_t noChangeovers = data[10U + m_bodyOffset];
|
||||
|
||||
if (noChangeovers >= 1U) {
|
||||
m_supersededKeysetId = data[11U + m_bodyOffset];
|
||||
m_activeKeysetId = data[12U + m_bodyOffset];
|
||||
}
|
||||
|
||||
// we don't support extra instructions -- only the first one
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Encode a KMM changeover command. */
|
||||
|
||||
void KMMChangeover::encode(uint8_t* data)
|
||||
{
|
||||
assert(data != nullptr);
|
||||
m_messageLength = length();
|
||||
|
||||
KMMFrame::encodeHeader(data);
|
||||
|
||||
data[10U + m_bodyOffset] = 1U; // number of changeovers
|
||||
data[11U + m_bodyOffset] = m_supersededKeysetId;
|
||||
data[12U + m_bodyOffset] = m_activeKeysetId;
|
||||
}
|
||||
|
||||
/* Returns a string that represents the current KMM frame. */
|
||||
|
||||
std::string KMMChangeover::toString()
|
||||
{
|
||||
return std::string("KMM, CHANGEOVER_CMD (Changeover Command)");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Protected Class Members
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/* Internal helper to copy the the class. */
|
||||
|
||||
void KMMChangeover::copy(const KMMChangeover& data)
|
||||
{
|
||||
KMMFrame::copy(data);
|
||||
|
||||
m_supersededKeysetId = data.m_supersededKeysetId;
|
||||
m_activeKeysetId = data.m_activeKeysetId;
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Digital Voice Modem - Common Library
|
||||
* GPLv2 Open Source. Use is subject to license terms.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* Copyright (C) 2026 Bryan Biedenkapp, N2PLL
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @file KMMChangeover.h
|
||||
* @ingroup p25_kmm
|
||||
* @file KMMChangeover.cpp
|
||||
* @ingroup p25_kmm
|
||||
*/
|
||||
#if !defined(__P25_KMM__KMM_CHANGEOVER_H__)
|
||||
#define __P25_KMM__KMM_CHANGEOVER_H__
|
||||
|
||||
#include "common/Defines.h"
|
||||
#include "common/p25/kmm/KMMFrame.h"
|
||||
#include "common/p25/kmm/KeysetItem.h"
|
||||
#include "common/Utils.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace p25
|
||||
{
|
||||
namespace kmm
|
||||
{
|
||||
// ---------------------------------------------------------------------------
|
||||
// Class Declaration
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief Represents a KMM changeover command/response.
|
||||
* @ingroup p25_kmm
|
||||
*/
|
||||
class DVM_COMMON_API KMMChangeover : public KMMFrame {
|
||||
public:
|
||||
/**
|
||||
* @brief Initializes a new instance of the KMMChangeover class.
|
||||
*/
|
||||
KMMChangeover();
|
||||
/**
|
||||
* @brief Finalizes a instance of the KMMChangeover class.
|
||||
*/
|
||||
~KMMChangeover();
|
||||
|
||||
/**
|
||||
* @brief Gets the byte length of this KMMFrame.
|
||||
* @return uint32_t Length of KMMFrame.
|
||||
*/
|
||||
uint32_t length() const override;
|
||||
|
||||
/**
|
||||
* @brief Decode a KMM changeover command.
|
||||
* @param[in] data Buffer containing KMM frame data to decode.
|
||||
* @returns bool True, if decoded, otherwise false.
|
||||
*/
|
||||
bool decode(const uint8_t* data) override;
|
||||
/**
|
||||
* @brief Encode a KMM changeover command.
|
||||
* @param[out] data Buffer to encode KMM frame data to.
|
||||
*/
|
||||
void encode(uint8_t* data) override;
|
||||
|
||||
/**
|
||||
* @brief Returns a string that represents the current KMM frame.
|
||||
* @returns std::string String representation of the KMM frame.
|
||||
*/
|
||||
std::string toString() override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Superseded keyset ID.
|
||||
*/
|
||||
DECLARE_PROPERTY(uint8_t, supersededKeysetId, SupersededKeysetId);
|
||||
/**
|
||||
* @brief Active keyset ID.
|
||||
*/
|
||||
DECLARE_PROPERTY(uint8_t, activeKeysetId, ActiveKeysetId);
|
||||
|
||||
DECLARE_COPY(KMMChangeover);
|
||||
};
|
||||
} // namespace kmm
|
||||
} // namespace p25
|
||||
|
||||
#endif // __P25_KMM__KMM_CHANGEOVER_H__
|
||||
Loading…
Reference in new issue