#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() .SetGroupName("tsn") .AddConstructor() .AddAttribute("StreamHandle", "Stream Handle", UintegerValue(1), MakeUintegerAccessor(&StreamIdEntry::m_tsnStreamIdHandle), MakeUintegerChecker()); return tid; } StreamIdEntry::StreamIdEntry() { NS_LOG_FUNCTION(this); } StreamIdEntry::~StreamIdEntry() { NS_LOG_FUNCTION(this); } void StreamIdEntry::SetStreamIdentificationFunction(Ptr func) { NS_LOG_FUNCTION(this); m_tsnStreamIdIdentificationFunction = func; } void StreamIdEntry::SetOutFacInputPortList(std::vector> portList) { NS_LOG_FUNCTION(this); m_tsnStreamIdOutFacInputPortList = portList; } void StreamIdEntry::SetInFacInputPortList(std::vector> portList) { NS_LOG_FUNCTION(this); m_tsnStreamIdInFacInputPortList = portList; } void StreamIdEntry::SetInFacOutputPortList(std::vector> portList) { NS_LOG_FUNCTION(this); m_tsnStreamIdInFacOutputPortList = portList; } void StreamIdEntry::SetOutFacOutputPortList(std::vector> portList) { NS_LOG_FUNCTION(this); m_tsnStreamIdOutFacOutputPortList = portList; } bool StreamIdEntry::Match(Ptr net, bool infacing, bool input, Ptr 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 p) { NS_LOG_FUNCTION(this); m_tsnStreamIdIdentificationFunction->GetActiveUpdate(p); } Time StreamIdEntry::GetHardwareLatency() { NS_LOG_FUNCTION(this); return m_tsnStreamIdIdentificationFunction->GetHardwareLatency(); } }