diff -r 78d13ba7e074 src/internet-stack/ipv4-raw-socket-impl.cc --- a/src/internet-stack/ipv4-raw-socket-impl.cc Tue May 04 09:27:10 2010 -0400 +++ b/src/internet-stack/ipv4-raw-socket-impl.cc Mon Jun 14 06:07:01 2010 +0530 @@ -252,6 +252,31 @@ m_protocol = protocol; } +void +Ipv4RawSocketImpl::AddProtocol(uint16_t protocol) +{ + NS_LOG_FUNCTION(this << protocol); + m_protocolList.push_back(protocol); +} + +bool +Ipv4RawSocketImpl::CheckProtocols(uint16_t protocol) +{ + /** + * If list is empty, listen all protocols + */ + if(m_protocolList.size() == 0 ) + return true; + + for(std::vector::iterator i = m_protocolList.begin(); i != m_protocolList.end() ; i++) + { + if(*i == protocol) + return true; + } + + return false; +} + bool Ipv4RawSocketImpl::ForwardUp (Ptr p, Ipv4Header ipHeader, Ptr device) { @@ -262,11 +287,11 @@ } NS_LOG_LOGIC ("src = " << m_src << " dst = " << m_dst); if ((m_src == Ipv4Address::GetAny () || ipHeader.GetDestination () == m_src) && - (m_dst == Ipv4Address::GetAny () || ipHeader.GetSource () == m_dst) && - ipHeader.GetProtocol () == m_protocol) + (m_dst == Ipv4Address::GetAny () || ipHeader.GetSource () == m_dst) && + CheckProtocols(ipHeader.GetProtocol()) ) { Ptr copy = p->Copy (); - if (m_protocol == 1) + if (ipHeader.GetProtocol () == 1) { Icmpv4Header icmpHeader; copy->PeekHeader (icmpHeader);