15NS_LOG_COMPONENT_DEFINE(
"NrEpcTft");
29 case NrEpcTft::DOWNLINK:
32 case NrEpcTft::UPLINK:
36 os <<
"BIDIRECTIONAL";
50operator<<(std::ostream& os,
const NrEpcTft::PacketFilter& f)
52 os <<
" direction: " << f.direction <<
" remoteAddress: " << f.remoteAddress
53 <<
" remoteMask: " << f.remoteMask <<
" remoteIpv6Address: " << f.remoteIpv6Address
54 <<
" remoteIpv6Prefix: " << f.remoteIpv6Prefix <<
" localAddress: " << f.localAddress
55 <<
" localMask: " << f.localMask <<
" localIpv6Address: " << f.localIpv6Address
56 <<
" localIpv6Prefix: " << f.localIpv6Prefix <<
" remotePortStart: " << f.remotePortStart
57 <<
" remotePortEnd: " << f.remotePortEnd <<
" localPortStart: " << f.localPortStart
58 <<
" localPortEnd: " << f.localPortEnd <<
" typeOfService: 0x" << std::hex
59 << (uint16_t)f.typeOfService << std::dec <<
" typeOfServiceMask: 0x" << std::hex
60 << (uint16_t)f.typeOfServiceMask << std::dec;
64NrEpcTft::PacketFilter::PacketFilter()
66 direction(BIDIRECTIONAL),
67 remoteMask(
"0.0.0.0"),
76 NS_LOG_FUNCTION(
this);
87 NS_LOG_FUNCTION(
this << d << ra << la << rp << lp << (uint16_t)tos);
90 NS_LOG_LOGIC(
"d matches");
91 if (remoteMask.IsMatch(remoteAddress, ra))
93 NS_LOG_LOGIC(
"ra matches");
94 if (localMask.IsMatch(localAddress, la))
96 NS_LOG_LOGIC(
"la matches");
97 if (remotePortStart <= rp && rp <= remotePortEnd)
99 NS_LOG_LOGIC(
"rp matches");
100 if (localPortStart <= lp && lp <= localPortEnd)
102 NS_LOG_LOGIC(
"lp matches");
103 if ((tos & typeOfServiceMask) == (typeOfService & typeOfServiceMask))
105 NS_LOG_LOGIC(
"tos matches --> have match!");
110 NS_LOG_LOGIC(
"tos doesn't match: tos="
111 << tos <<
" f.tos=" << typeOfService
112 <<
" f.tosmask=" << typeOfServiceMask);
117 NS_LOG_LOGIC(
"lp doesn't match: lp=" << lp <<
" f.lps=" << localPortStart
118 <<
" f.lpe=" << localPortEnd);
123 NS_LOG_LOGIC(
"rp doesn't match: rp=" << rp <<
" f.rps=" << remotePortStart
124 <<
" f.lpe=" << remotePortEnd);
129 NS_LOG_LOGIC(
"la doesn't match: la=" << la <<
" f.la=" << localAddress
130 <<
" f.lmask=" << localMask);
135 NS_LOG_LOGIC(
"ra doesn't match: ra=" << ra <<
" f.ra=" << remoteAddress
136 <<
" f.rmask=" << remoteMask);
141 NS_LOG_LOGIC(
"d doesn't match: d=0x" << std::hex << d <<
" f.d=0x" << std::hex << direction
155 NS_LOG_FUNCTION(
this << d << ra << la << rp << lp << (uint16_t)tos);
158 NS_LOG_LOGIC(
"d matches");
159 if (remoteIpv6Prefix.IsMatch(remoteIpv6Address, ra))
161 NS_LOG_LOGIC(
"ra matches");
162 if (localIpv6Prefix.IsMatch(localIpv6Address, la))
164 NS_LOG_LOGIC(
"la matches");
165 if (remotePortStart <= rp && rp <= remotePortEnd)
167 NS_LOG_LOGIC(
"rp matches");
168 if (localPortStart <= lp && lp <= localPortEnd)
170 NS_LOG_LOGIC(
"lp matches");
171 if ((tos & typeOfServiceMask) == (typeOfService & typeOfServiceMask))
173 NS_LOG_LOGIC(
"tos matches --> have match!");
178 NS_LOG_LOGIC(
"tos doesn't match: tos="
179 << tos <<
" f.tos=" << typeOfService
180 <<
" f.tosmask=" << typeOfServiceMask);
185 NS_LOG_LOGIC(
"lp doesn't match: lp=" << lp <<
" f.lps=" << localPortStart
186 <<
" f.lpe=" << localPortEnd);
191 NS_LOG_LOGIC(
"rp doesn't match: rp=" << rp <<
" f.rps=" << remotePortStart
192 <<
" f.lpe=" << remotePortEnd);
197 NS_LOG_LOGIC(
"la doesn't match: la=" << la <<
" f.la=" << localIpv6Address
198 <<
" f.lprefix=" << localIpv6Prefix);
203 NS_LOG_LOGIC(
"ra doesn't match: ra=" << ra <<
" f.ra=" << remoteIpv6Address
204 <<
" f.rprefix=" << remoteIpv6Prefix);
209 NS_LOG_LOGIC(
"d doesn't match: d=0x" << std::hex << d <<
" f.d=0x" << std::hex << direction
218 Ptr<NrEpcTft> tft = Create<NrEpcTft>();
220 tft->Add(defaultPacketFilter);
227 NS_LOG_FUNCTION(
this);
233 NS_LOG_FUNCTION(
this << f);
234 NS_ABORT_IF(m_numFilters >= 16);
236 std::list<PacketFilter>::iterator it;
237 for (it = m_filters.begin(); (it != m_filters.end()) && (it->precedence <= f.
precedence); ++it)
240 m_filters.insert(it, f);
242 return (m_numFilters - 1);
247 Ipv4Address remoteAddress,
248 Ipv4Address localAddress,
251 uint8_t typeOfService)
253 NS_LOG_FUNCTION(
this << direction << remoteAddress << localAddress << std::dec << remotePort
254 << localPort << (uint16_t)typeOfService);
255 for (
auto it = m_filters.begin(); it != m_filters.end(); ++it)
257 if (it->Matches(direction,
272 Ipv6Address remoteAddress,
273 Ipv6Address localAddress,
276 uint8_t typeOfService)
278 NS_LOG_FUNCTION(
this << direction << remoteAddress << localAddress << std::dec << remotePort
279 << localPort << (uint16_t)typeOfService);
280 for (
auto it = m_filters.begin(); it != m_filters.end(); ++it)
282 if (it->Matches(direction,
295std::list<NrEpcTft::PacketFilter>
298 NS_LOG_FUNCTION(
this);
std::list< PacketFilter > GetPacketFilters() const
uint8_t Add(PacketFilter f)
bool Matches(Direction direction, Ipv4Address remoteAddress, Ipv4Address localAddress, uint16_t remotePort, uint16_t localPort, uint8_t typeOfService)