Files
eden-sim/contrib/tsn/model/stream-identity-entry.cc

132 lines
3.3 KiB
C++
Raw Normal View History

2025-12-01 15:56:02 +01:00
#include "stream-identity-entry.h"
#include "ns3/log.h"
#include "ns3/packet.h"
namespace ns3
{
NS_LOG_COMPONENT_DEFINE("StreamIdEntry");
NS_OBJECT_ENSURE_REGISTERED(StreamIdEntry);
TypeId
StreamIdEntry::GetTypeId()
{
static TypeId tid =
TypeId("ns3::StreamIdEntry")
.SetParent<Object>()
.SetGroupName("tsn")
.AddConstructor<StreamIdEntry>()
.AddAttribute("StreamHandle",
"Stream Handle",
UintegerValue(1),
MakeUintegerAccessor(&StreamIdEntry::m_tsnStreamIdHandle),
MakeUintegerChecker<uint32_t>());
return tid;
}
StreamIdEntry::StreamIdEntry()
{
NS_LOG_FUNCTION(this);
}
StreamIdEntry::~StreamIdEntry()
{
NS_LOG_FUNCTION(this);
}
void
StreamIdEntry::SetStreamIdentificationFunction(Ptr<StreamIdentificationFunction> func)
{
NS_LOG_FUNCTION(this);
m_tsnStreamIdIdentificationFunction = func;
}
void
StreamIdEntry::SetOutFacInputPortList(std::vector<Ptr<TsnNetDevice>> portList)
{
NS_LOG_FUNCTION(this);
m_tsnStreamIdOutFacInputPortList = portList;
}
void
StreamIdEntry::SetInFacInputPortList(std::vector<Ptr<TsnNetDevice>> portList)
{
NS_LOG_FUNCTION(this);
m_tsnStreamIdInFacInputPortList = portList;
}
void
StreamIdEntry::SetInFacOutputPortList(std::vector<Ptr<TsnNetDevice>> portList)
{
NS_LOG_FUNCTION(this);
m_tsnStreamIdInFacOutputPortList = portList;
}
void
StreamIdEntry::SetOutFacOutputPortList(std::vector<Ptr<TsnNetDevice>> portList)
{
NS_LOG_FUNCTION(this);
m_tsnStreamIdOutFacOutputPortList = portList;
}
bool
StreamIdEntry::Match(Ptr<TsnNetDevice> net, bool infacing, bool input, Ptr<Packet> p)
{
NS_LOG_FUNCTION(this);
if (!infacing && input) //out-facing input
{
if (std::find(m_tsnStreamIdOutFacInputPortList.begin(), m_tsnStreamIdOutFacInputPortList.end(), net) != m_tsnStreamIdOutFacInputPortList.end())
{
return m_tsnStreamIdIdentificationFunction->Match(p);
}
}
else if(infacing && input)//in-facing input
{
if (std::find(m_tsnStreamIdInFacInputPortList.begin(), m_tsnStreamIdInFacInputPortList.end(), net) != m_tsnStreamIdInFacInputPortList.end())
{
return m_tsnStreamIdIdentificationFunction->Match(p);
}
}
else if(infacing && !input)//in-facing output
{
if (std::find(m_tsnStreamIdInFacOutputPortList.begin(), m_tsnStreamIdInFacOutputPortList.end(), net) != m_tsnStreamIdInFacOutputPortList.end())
{
return m_tsnStreamIdIdentificationFunction->Match(p);
}
}
else if(!infacing && !input)//out-facing output
{
if (std::find(m_tsnStreamIdOutFacOutputPortList.begin(), m_tsnStreamIdOutFacOutputPortList.end(), net) != m_tsnStreamIdOutFacOutputPortList.end())
{
return m_tsnStreamIdIdentificationFunction->Match(p);
}
}
return false;
}
uint32_t
StreamIdEntry::GetStreamHandle()
{
NS_LOG_FUNCTION(this);
return m_tsnStreamIdHandle;
}
void
StreamIdEntry::DoActiveUpdate(Ptr<Packet> p)
{
NS_LOG_FUNCTION(this);
m_tsnStreamIdIdentificationFunction->GetActiveUpdate(p);
}
Time
StreamIdEntry::GetHardwareLatency()
{
NS_LOG_FUNCTION(this);
return m_tsnStreamIdIdentificationFunction->GetHardwareLatency();
}
}