packet tag for recvif diff -r e5b8703bb1eb src/node/node.cc --- a/src/node/node.cc Wed Jan 06 01:27:01 2010 +0900 +++ b/src/node/node.cc Wed Jan 06 01:33:39 2010 +0900 @@ -30,6 +30,7 @@ #include "ns3/assert.h" #include "ns3/global-value.h" #include "ns3/boolean.h" +#include "ns3/socket.h" NS_LOG_COMPONENT_DEFINE ("Node"); @@ -251,6 +252,10 @@ << ") Packet UID " << packet->GetUid ()); bool found = false; + SocketRecvIfTag tag; + tag.SetRecvIf (device->GetIfIndex()); + packet->AddPacketTag (tag); + for (ProtocolHandlerList::iterator i = m_handlers.begin (); i != m_handlers.end (); i++) { diff -r e5b8703bb1eb src/node/socket.cc --- a/src/node/socket.cc Wed Jan 06 01:27:01 2010 +0900 +++ b/src/node/socket.cc Wed Jan 06 01:33:39 2010 +0900 @@ -428,4 +428,58 @@ os << (m_dontFragment?"true":"false"); } + +SocketRecvIfTag::SocketRecvIfTag () +{ +} + +void +SocketRecvIfTag::SetRecvIf (uint32_t ifindex) +{ + m_ifindex = ifindex; +} + +uint32_t +SocketRecvIfTag::GetRecvIf (void) const +{ + return m_ifindex; +} + + +TypeId +SocketRecvIfTag::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::SocketRecvIfTag") + .SetParent () + .AddConstructor () + ; + return tid; +} +TypeId +SocketRecvIfTag::GetInstanceTypeId (void) const +{ + return GetTypeId (); +} + +uint32_t +SocketRecvIfTag::GetSerializedSize (void) const +{ + return sizeof(uint32_t); +} +void +SocketRecvIfTag::Serialize (TagBuffer i) const +{ + i.WriteU32 (m_ifindex); +} +void +SocketRecvIfTag::Deserialize (TagBuffer i) +{ + m_ifindex = i.ReadU32 (); +} +void +SocketRecvIfTag::Print (std::ostream &os) const +{ + os << "RecvIf=" << (uint32_t) m_ifindex; +} + }//namespace ns3 diff -r e5b8703bb1eb src/node/socket.h --- a/src/node/socket.h Wed Jan 06 01:27:01 2010 +0900 +++ b/src/node/socket.h Wed Jan 06 01:33:39 2010 +0900 @@ -79,6 +79,8 @@ ERROR_INVAL, ERROR_BADF, ERROR_NOROUTETOHOST, + ERROR_NODEV, + ERROR_ADDRNOTAVAIL, SOCKET_ERRNO_LAST }; @@ -579,6 +581,29 @@ bool m_dontFragment; }; +/** + * \brief This class implements a tag that carries the information of + * received interface of a packet to the socket layer + */ +class SocketRecvIfTag : public Tag +{ +public: + SocketRecvIfTag (); + void SetRecvIf (uint32_t ifindex); + uint32_t GetRecvIf (void) const; + + static TypeId GetTypeId (void); + virtual TypeId GetInstanceTypeId (void) const; + virtual uint32_t GetSerializedSize (void) const; + virtual void Serialize (TagBuffer i) const; + virtual void Deserialize (TagBuffer i); + virtual void Print (std::ostream &os) const; + +private: + uint8_t m_ifindex; +}; + + } //namespace ns3 #endif /* SOCKET_H */