diff --git a/network/BaseNetwork.cpp b/network/BaseNetwork.cpp
index 0ddc1857..8df9c56e 100644
--- a/network/BaseNetwork.cpp
+++ b/network/BaseNetwork.cpp
@@ -258,9 +258,10 @@ uint8_t* BaseNetwork::readP25(bool& ret, p25::lc::LC& control, p25::data::LowSpe
/// Reads NXDN frame data from the NXDN ring buffer.
///
///
+///
///
///
-uint8_t* BaseNetwork::readNXDN(bool& ret, uint32_t& len)
+uint8_t* BaseNetwork::readNXDN(bool& ret, nxdn::data::Layer3& layer3, uint32_t& len)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) {
ret = false;
@@ -276,7 +277,18 @@ uint8_t* BaseNetwork::readNXDN(bool& ret, uint32_t& len)
m_rxNXDNData.getData(&length, 1U);
m_rxNXDNData.getData(m_buffer, length);
- /* TODO TODO -- process more data out of the raw network frames? */
+ uint8_t messageType = m_buffer[4U];
+
+ uint32_t srcId = (m_buffer[5U] << 16) | (m_buffer[6U] << 8) | (m_buffer[7U] << 0);
+
+ uint32_t dstId = (m_buffer[8U] << 16) | (m_buffer[9U] << 8) | (m_buffer[10U] << 0);
+
+ layer3.setMessageType(messageType);
+ layer3.setSrcId((uint16_t)srcId & 0xFFFFU);
+ layer3.setDstId((uint16_t)dstId & 0xFFFFU);
+
+ bool group = (m_buffer[15U] & 0x40U) == 0x40U ? false : true;
+ layer3.setGroup(group);
uint8_t* data = NULL;
len = m_buffer[23U];
@@ -471,10 +483,11 @@ bool BaseNetwork::writeP25PDU(const p25::data::DataHeader& header, const p25::da
///
/// Writes NXDN frame data to the network.
///
+///
///
///
///
-bool BaseNetwork::writeNXDN(const uint8_t* data, const uint32_t len)
+bool BaseNetwork::writeNXDN(const nxdn::data::Layer3& layer3, const uint8_t* data, const uint32_t len)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
return false;
@@ -485,7 +498,7 @@ bool BaseNetwork::writeNXDN(const uint8_t* data, const uint32_t len)
m_streamId[0] = m_nxdnStreamId;
- return writeNXDN(m_id, m_nxdnStreamId, data, len);
+ return writeNXDN(m_id, m_nxdnStreamId, layer3, data, len);
}
///
@@ -1069,13 +1082,11 @@ bool BaseNetwork::writeP25PDU(const uint32_t id, const uint32_t streamId, const
///
///
///
-///
-///
-///
+///
///
///
///
-bool BaseNetwork::writeNXDN(const uint32_t id, const uint32_t streamId, const uint8_t* data, const uint32_t len)
+bool BaseNetwork::writeNXDN(const uint32_t id, const uint32_t streamId, const nxdn::data::Layer3& layer3, const uint8_t* data, const uint32_t len)
{
if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING)
return false;
@@ -1087,7 +1098,15 @@ bool BaseNetwork::writeNXDN(const uint32_t id, const uint32_t streamId, const ui
::memcpy(buffer + 0U, TAG_NXDN_DATA, 4U);
- /* TODO TODO -- pack more data out of the raw network frames? */
+ buffer[4U] = layer3.getMessageType(); // Message Type
+
+ uint32_t srcId = layer3.getSrcId(); // Source Address
+ __SET_UINT16(srcId, buffer, 5U);
+
+ uint32_t dstId = layer3.getDstId(); // Target Address
+ __SET_UINT16(dstId, buffer, 8U);
+
+ buffer[15U] |= layer3.getGroup() ? 0x00U : 0x40U; // Group
__SET_UINT32(streamId, buffer, 16U); // Stream ID
diff --git a/network/BaseNetwork.h b/network/BaseNetwork.h
index 4d0c1de5..1915f3bb 100644
--- a/network/BaseNetwork.h
+++ b/network/BaseNetwork.h
@@ -43,6 +43,7 @@
#include "p25/lc/TSBK.h"
#include "p25/lc/TDULC.h"
#include "p25/Audio.h"
+#include "nxdn/data/Layer3.h"
#include "network/UDPSocket.h"
#include "RingBuffer.h"
#include "Timer.h"
@@ -140,7 +141,7 @@ namespace network
/// Reads P25 frame data from the P25 ring buffer.
virtual uint8_t* readP25(bool& ret, p25::lc::LC& control, p25::data::LowSpeedData& lsd, uint8_t& duid, uint32_t& len);
/// Reads NXDN frame data from the NXDN ring buffer.
- virtual uint8_t* readNXDN(bool& ret, uint32_t& len);
+ virtual uint8_t* readNXDN(bool& ret, nxdn::data::Layer3& layer3, uint32_t& len);
/// Reads a channel grant request from the network.
virtual bool readGrantRsp(bool& grp, uint32_t& srcId, uint32_t& dstId, uint32_t& grpVchNo);
@@ -160,7 +161,7 @@ namespace network
const uint8_t* data, const uint32_t len);
/// Writes NXDN frame data to the network.
- virtual bool writeNXDN(const uint8_t* data, const uint32_t len);
+ virtual bool writeNXDN(const nxdn::data::Layer3& layer3, const uint8_t* data, const uint32_t len);
/// Writes a channel grant request to the network.
virtual bool writeGrantReq(const bool grp, const uint32_t srcId, const uint32_t dstId);
@@ -239,7 +240,7 @@ namespace network
bool writeP25PDU(const uint32_t id, const uint32_t streamId, const p25::data::DataHeader& header, const p25::data::DataHeader& secHeader, const uint8_t currentBlock,
const uint8_t* data, const uint32_t len);
/// Writes NXDN frame data to the network.
- bool writeNXDN(const uint32_t id, const uint32_t streamId, const uint8_t* data, const uint32_t len);
+ bool writeNXDN(const uint32_t id, const uint32_t streamId, const nxdn::data::Layer3& layer3, const uint8_t* data, const uint32_t len);
/// Writes data to the network.
virtual bool write(const uint8_t* data, uint32_t length);
diff --git a/nxdn/Control.cpp b/nxdn/Control.cpp
index e3aa4254..c81a2882 100644
--- a/nxdn/Control.cpp
+++ b/nxdn/Control.cpp
@@ -463,9 +463,11 @@ void Control::processNetwork()
if (m_rfState != RS_RF_LISTENING && m_netState == RS_NET_IDLE)
return;
+ data::Layer3 layer3;
+
uint32_t length = 100U;
bool ret = false;
- uint8_t* data = m_network->readNXDN(ret, length);
+ uint8_t* data = m_network->readNXDN(ret, layer3, length);
if (!ret)
return;
if (length == 0U)
@@ -494,10 +496,10 @@ void Control::processNetwork()
switch (usc) {
case NXDN_LICH_USC_UDCH:
- ret = m_data->processNetwork(option, data, length);
+ ret = m_data->processNetwork(option, layer3, data, length);
break;
default:
- ret = m_voice->processNetwork(usc, option, data, length);
+ ret = m_voice->processNetwork(usc, option, layer3, data, length);
break;
}
diff --git a/nxdn/packet/Data.cpp b/nxdn/packet/Data.cpp
index da1c27ee..1be6fd06 100644
--- a/nxdn/packet/Data.cpp
+++ b/nxdn/packet/Data.cpp
@@ -285,7 +285,7 @@ bool Data::process(uint8_t option, uint8_t* data, uint32_t len)
/// Buffer containing data frame.
/// Length of data frame.
///
-bool Data::processNetwork(uint8_t option, uint8_t* data, uint32_t len)
+bool Data::processNetwork(uint8_t option, data::Layer3& netLayer3, uint8_t* data, uint32_t len)
{
assert(data != NULL);
@@ -427,5 +427,5 @@ void Data::writeNetwork(const uint8_t *data, uint32_t len)
if (m_nxdn->m_rfTimeout.isRunning() && m_nxdn->m_rfTimeout.hasExpired())
return;
- m_network->writeNXDN(data, len);
+ m_network->writeNXDN(m_nxdn->m_rfLayer3, data, len);
}
diff --git a/nxdn/packet/Data.h b/nxdn/packet/Data.h
index 9e2c9cf5..1a09a604 100644
--- a/nxdn/packet/Data.h
+++ b/nxdn/packet/Data.h
@@ -63,7 +63,7 @@ namespace nxdn
/// Process a data frame from the RF interface.
virtual bool process(uint8_t option, uint8_t* data, uint32_t len);
/// Process a data frame from the network.
- virtual bool processNetwork(uint8_t option, uint8_t* data, uint32_t len);
+ virtual bool processNetwork(uint8_t option, data::Layer3& netLayer3, uint8_t* data, uint32_t len);
protected:
friend class nxdn::Control;
diff --git a/nxdn/packet/Voice.cpp b/nxdn/packet/Voice.cpp
index 745ca4e8..3c5344ad 100644
--- a/nxdn/packet/Voice.cpp
+++ b/nxdn/packet/Voice.cpp
@@ -574,7 +574,7 @@ bool Voice::process(uint8_t usc, uint8_t option, uint8_t* data, uint32_t len)
/// Buffer containing data frame.
/// Length of data frame.
///
-bool Voice::processNetwork(uint8_t usc, uint8_t option, uint8_t* data, uint32_t len)
+bool Voice::processNetwork(uint8_t usc, uint8_t option, data::Layer3& netLayer3, uint8_t* data, uint32_t len)
{
assert(data != NULL);
@@ -965,5 +965,5 @@ void Voice::writeNetwork(const uint8_t *data, uint32_t len)
if (m_nxdn->m_rfTimeout.isRunning() && m_nxdn->m_rfTimeout.hasExpired())
return;
- m_network->writeNXDN(data, len);
+ m_network->writeNXDN(m_nxdn->m_rfLayer3, data, len);
}
diff --git a/nxdn/packet/Voice.h b/nxdn/packet/Voice.h
index 9c6acf55..ea0ba4f8 100644
--- a/nxdn/packet/Voice.h
+++ b/nxdn/packet/Voice.h
@@ -64,7 +64,7 @@ namespace nxdn
/// Process a data frame from the RF interface.
virtual bool process(uint8_t usc, uint8_t option, uint8_t* data, uint32_t len);
/// Process a data frame from the network.
- virtual bool processNetwork(uint8_t usc, uint8_t option, uint8_t* data, uint32_t len);
+ virtual bool processNetwork(uint8_t usc, uint8_t option, data::Layer3& netLayer3, uint8_t* data, uint32_t len);
protected:
friend class packet::Data;