|
252 |
m_protocol = protocol; |
252 |
m_protocol = protocol; |
253 |
} |
253 |
} |
254 |
|
254 |
|
|
|
255 |
void |
256 |
Ipv4RawSocketImpl::AddProtocol(uint16_t protocol) |
257 |
{ |
258 |
NS_LOG_FUNCTION(this << protocol); |
259 |
m_protocolList.push_back(protocol); |
260 |
} |
261 |
|
262 |
bool |
263 |
Ipv4RawSocketImpl::CheckProtocols(uint16_t protocol) |
264 |
{ |
265 |
/** |
266 |
* If list is empty, listen all protocols |
267 |
*/ |
268 |
if(m_protocolList.size() == 0 ) |
269 |
return true; |
270 |
|
271 |
for(std::vector<uint16_t>::iterator i = m_protocolList.begin(); i != m_protocolList.end() ; i++) |
272 |
{ |
273 |
if(*i == protocol) |
274 |
return true; |
275 |
} |
276 |
|
277 |
return false; |
278 |
} |
279 |
|
255 |
bool |
280 |
bool |
256 |
Ipv4RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<NetDevice> device) |
281 |
Ipv4RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<NetDevice> device) |
257 |
{ |
282 |
{ |
|
262 |
} |
287 |
} |
263 |
NS_LOG_LOGIC ("src = " << m_src << " dst = " << m_dst); |
288 |
NS_LOG_LOGIC ("src = " << m_src << " dst = " << m_dst); |
264 |
if ((m_src == Ipv4Address::GetAny () || ipHeader.GetDestination () == m_src) && |
289 |
if ((m_src == Ipv4Address::GetAny () || ipHeader.GetDestination () == m_src) && |
265 |
(m_dst == Ipv4Address::GetAny () || ipHeader.GetSource () == m_dst) && |
290 |
(m_dst == Ipv4Address::GetAny () || ipHeader.GetSource () == m_dst) && |
266 |
ipHeader.GetProtocol () == m_protocol) |
291 |
CheckProtocols(ipHeader.GetProtocol()) ) |
267 |
{ |
292 |
{ |
268 |
Ptr<Packet> copy = p->Copy (); |
293 |
Ptr<Packet> copy = p->Copy (); |
269 |
if (m_protocol == 1) |
294 |
if (ipHeader.GetProtocol () == 1) |
270 |
{ |
295 |
{ |
271 |
Icmpv4Header icmpHeader; |
296 |
Icmpv4Header icmpHeader; |
272 |
copy->PeekHeader (icmpHeader); |
297 |
copy->PeekHeader (icmpHeader); |