diff --git a/bindings/python/ns3_module_node.py b/bindings/python/ns3_module_node.py index b214fcda6..72cc4cd97 100644 --- a/bindings/python/ns3_module_node.py +++ b/bindings/python/ns3_module_node.py @@ -133,6 +133,8 @@ def register_types(module): module.add_class('SimpleChannel', parent=root_module['ns3::Channel']) ## simple-net-device.h: ns3::SimpleNetDevice [class] module.add_class('SimpleNetDevice', parent=root_module['ns3::NetDevice']) + module.add_container('ns3::olsr::MprSet', 'ns3::Ipv4Address', container_type='set') + module.add_container('std::vector< ns3::Ipv4Address >', 'ns3::Ipv4Address', container_type='vector') ## Register a nested module for the namespace Config @@ -173,7 +175,6 @@ def register_types_ns3_internal(module): def register_types_ns3_olsr(module): root_module = module.get_root() - module.add_container('std::vector< ns3::Ipv4Address >', 'ns3::Ipv4Address', container_type='vector') def register_methods(root_module): register_Ns3Address_methods(root_module, root_module['ns3::Address']) diff --git a/bindings/python/ns3_module_olsr.py b/bindings/python/ns3_module_olsr.py index 7f269fbef..5e5f2e2a3 100644 --- a/bindings/python/ns3_module_olsr.py +++ b/bindings/python/ns3_module_olsr.py @@ -3,6 +3,14 @@ from pybindgen import Module, FileCodeSink, param, retval, cppclass def register_types(module): root_module = module.get_root() + ## olsr-state.h: ns3::OlsrState [class] + module.add_class('OlsrState') + module.add_container('std::vector< ns3::olsr::MprSelectorTuple >', 'ns3::olsr::MprSelectorTuple', container_type='vector') + module.add_container('std::vector< ns3::olsr::NeighborTuple >', 'ns3::olsr::NeighborTuple', container_type='vector') + module.add_container('std::vector< ns3::olsr::TwoHopNeighborTuple >', 'ns3::olsr::TwoHopNeighborTuple', container_type='vector') + module.add_container('std::vector< ns3::olsr::LinkTuple >', 'ns3::olsr::LinkTuple', container_type='vector') + module.add_container('std::vector< ns3::olsr::TopologyTuple >', 'ns3::olsr::TopologyTuple', container_type='vector') + module.add_container('std::vector< ns3::olsr::IfaceAssocTuple >', 'ns3::olsr::IfaceAssocTuple', container_type='vector') ## Register a nested module for the namespace Config @@ -43,8 +51,14 @@ def register_types_ns3_internal(module): def register_types_ns3_olsr(module): root_module = module.get_root() - ## olsr-agent.h: ns3::olsr::Agent [class] - module.add_class('Agent', parent=root_module['ns3::Object']) + ## olsr-agent-impl.h: ns3::olsr::AgentImpl [class] + module.add_class('AgentImpl', parent=root_module['ns3::Ipv4RoutingProtocol']) + ## olsr-repositories.h: ns3::olsr::DuplicateTuple [struct] + module.add_class('DuplicateTuple') + ## olsr-repositories.h: ns3::olsr::IfaceAssocTuple [struct] + module.add_class('IfaceAssocTuple') + ## olsr-repositories.h: ns3::olsr::LinkTuple [struct] + module.add_class('LinkTuple') ## olsr-header.h: ns3::olsr::MessageHeader [class] module.add_class('MessageHeader', parent=root_module['ns3::Header']) ## olsr-header.h: ns3::olsr::MessageHeader::MessageType [enumeration] @@ -61,18 +75,29 @@ def register_types_ns3_olsr(module): module.add_class('Mid', outer_class=root_module['ns3::olsr::MessageHeader']) ## olsr-header.h: ns3::olsr::MessageHeader::Tc [struct] module.add_class('Tc', outer_class=root_module['ns3::olsr::MessageHeader']) + ## olsr-repositories.h: ns3::olsr::MprSelectorTuple [struct] + module.add_class('MprSelectorTuple') + ## olsr-repositories.h: ns3::olsr::NeighborTuple [struct] + module.add_class('NeighborTuple') + ## olsr-repositories.h: ns3::olsr::NeighborTuple::Status [enumeration] + module.add_enum('Status', ['STATUS_NOT_SYM', 'STATUS_SYM'], outer_class=root_module['ns3::olsr::NeighborTuple']) ## olsr-header.h: ns3::olsr::PacketHeader [class] module.add_class('PacketHeader', parent=root_module['ns3::Header']) - ## olsr-routing-table.h: ns3::olsr::RoutingTable [class] - module.add_class('RoutingTable', parent=root_module['ns3::Ipv4RoutingProtocol']) - ## olsr-routing-table.h: ns3::olsr::RoutingTableEntry [struct] + ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry [struct] module.add_class('RoutingTableEntry') + ## olsr-repositories.h: ns3::olsr::TopologyTuple [struct] + module.add_class('TopologyTuple') + ## olsr-repositories.h: ns3::olsr::TwoHopNeighborTuple [struct] + module.add_class('TwoHopNeighborTuple') module.add_container('std::vector< ns3::olsr::MessageHeader::Hello::LinkMessage >', 'ns3::olsr::MessageHeader::Hello::LinkMessage', container_type='vector') module.add_container('std::vector< ns3::olsr::MessageHeader::Hna::Association >', 'ns3::olsr::MessageHeader::Hna::Association', container_type='vector') - module.add_container('std::vector< ns3::olsr::RoutingTableEntry >', 'ns3::olsr::RoutingTableEntry', container_type='vector') def register_methods(root_module): - register_Ns3OlsrAgent_methods(root_module, root_module['ns3::olsr::Agent']) + register_Ns3OlsrState_methods(root_module, root_module['ns3::OlsrState']) + register_Ns3OlsrAgentImpl_methods(root_module, root_module['ns3::olsr::AgentImpl']) + register_Ns3OlsrDuplicateTuple_methods(root_module, root_module['ns3::olsr::DuplicateTuple']) + register_Ns3OlsrIfaceAssocTuple_methods(root_module, root_module['ns3::olsr::IfaceAssocTuple']) + register_Ns3OlsrLinkTuple_methods(root_module, root_module['ns3::olsr::LinkTuple']) register_Ns3OlsrMessageHeader_methods(root_module, root_module['ns3::olsr::MessageHeader']) register_Ns3OlsrMessageHeaderHello_methods(root_module, root_module['ns3::olsr::MessageHeader::Hello']) register_Ns3OlsrMessageHeaderHelloLinkMessage_methods(root_module, root_module['ns3::olsr::MessageHeader::Hello::LinkMessage']) @@ -80,41 +105,296 @@ def register_methods(root_module): register_Ns3OlsrMessageHeaderHnaAssociation_methods(root_module, root_module['ns3::olsr::MessageHeader::Hna::Association']) register_Ns3OlsrMessageHeaderMid_methods(root_module, root_module['ns3::olsr::MessageHeader::Mid']) register_Ns3OlsrMessageHeaderTc_methods(root_module, root_module['ns3::olsr::MessageHeader::Tc']) + register_Ns3OlsrMprSelectorTuple_methods(root_module, root_module['ns3::olsr::MprSelectorTuple']) + register_Ns3OlsrNeighborTuple_methods(root_module, root_module['ns3::olsr::NeighborTuple']) register_Ns3OlsrPacketHeader_methods(root_module, root_module['ns3::olsr::PacketHeader']) - register_Ns3OlsrRoutingTable_methods(root_module, root_module['ns3::olsr::RoutingTable']) register_Ns3OlsrRoutingTableEntry_methods(root_module, root_module['ns3::olsr::RoutingTableEntry']) + register_Ns3OlsrTopologyTuple_methods(root_module, root_module['ns3::olsr::TopologyTuple']) + register_Ns3OlsrTwoHopNeighborTuple_methods(root_module, root_module['ns3::olsr::TwoHopNeighborTuple']) return -def register_Ns3OlsrAgent_methods(root_module, cls): - ## olsr-agent.h: ns3::olsr::Agent::Agent(ns3::olsr::Agent const & arg0) [copy constructor] - cls.add_constructor([param('ns3::olsr::Agent const &', 'arg0')]) - ## olsr-agent.h: ns3::olsr::Agent::Agent() [constructor] +def register_Ns3OlsrState_methods(root_module, cls): + ## olsr-state.h: ns3::OlsrState::OlsrState(ns3::OlsrState const & arg0) [copy constructor] + cls.add_constructor([param('ns3::OlsrState const &', 'arg0')]) + ## olsr-state.h: ns3::OlsrState::OlsrState() [constructor] cls.add_constructor([]) - ## olsr-agent.h: static ns3::TypeId ns3::olsr::Agent::GetTypeId() [member function] + ## olsr-state.h: ns3::olsr::MprSelectorSet const & ns3::OlsrState::GetMprSelectors() const [member function] + cls.add_method('GetMprSelectors', + 'ns3::olsr::MprSelectorSet const &', + [], + is_const=True) + ## olsr-state.h: ns3::olsr::MprSelectorTuple * ns3::OlsrState::FindMprSelectorTuple(ns3::Ipv4Address const & mainAddr) [member function] + cls.add_method('FindMprSelectorTuple', + 'ns3::olsr::MprSelectorTuple *', + [param('ns3::Ipv4Address const &', 'mainAddr')]) + ## olsr-state.h: void ns3::OlsrState::EraseMprSelectorTuple(ns3::olsr::MprSelectorTuple const & tuple) [member function] + cls.add_method('EraseMprSelectorTuple', + 'void', + [param('ns3::olsr::MprSelectorTuple const &', 'tuple')]) + ## olsr-state.h: void ns3::OlsrState::EraseMprSelectorTuples(ns3::Ipv4Address const & mainAddr) [member function] + cls.add_method('EraseMprSelectorTuples', + 'void', + [param('ns3::Ipv4Address const &', 'mainAddr')]) + ## olsr-state.h: void ns3::OlsrState::InsertMprSelectorTuple(ns3::olsr::MprSelectorTuple const & tuple) [member function] + cls.add_method('InsertMprSelectorTuple', + 'void', + [param('ns3::olsr::MprSelectorTuple const &', 'tuple')]) + ## olsr-state.h: std::string ns3::OlsrState::PrintMprSelectorSet() const [member function] + cls.add_method('PrintMprSelectorSet', + 'std::string', + [], + is_const=True) + ## olsr-state.h: ns3::olsr::NeighborSet const & ns3::OlsrState::GetNeighbors() const [member function] + cls.add_method('GetNeighbors', + 'ns3::olsr::NeighborSet const &', + [], + is_const=True) + ## olsr-state.h: ns3::olsr::NeighborSet & ns3::OlsrState::GetNeighbors() [member function] + cls.add_method('GetNeighbors', + 'ns3::olsr::NeighborSet &', + []) + ## olsr-state.h: ns3::olsr::NeighborTuple * ns3::OlsrState::FindNeighborTuple(ns3::Ipv4Address const & mainAddr) [member function] + cls.add_method('FindNeighborTuple', + 'ns3::olsr::NeighborTuple *', + [param('ns3::Ipv4Address const &', 'mainAddr')]) + ## olsr-state.h: ns3::olsr::NeighborTuple const * ns3::OlsrState::FindSymNeighborTuple(ns3::Ipv4Address const & mainAddr) const [member function] + cls.add_method('FindSymNeighborTuple', + 'ns3::olsr::NeighborTuple const *', + [param('ns3::Ipv4Address const &', 'mainAddr')], + is_const=True) + ## olsr-state.h: ns3::olsr::NeighborTuple * ns3::OlsrState::FindNeighborTuple(ns3::Ipv4Address const & mainAddr, uint8_t willingness) [member function] + cls.add_method('FindNeighborTuple', + 'ns3::olsr::NeighborTuple *', + [param('ns3::Ipv4Address const &', 'mainAddr'), param('uint8_t', 'willingness')]) + ## olsr-state.h: void ns3::OlsrState::EraseNeighborTuple(ns3::olsr::NeighborTuple const & neighborTuple) [member function] + cls.add_method('EraseNeighborTuple', + 'void', + [param('ns3::olsr::NeighborTuple const &', 'neighborTuple')]) + ## olsr-state.h: void ns3::OlsrState::EraseNeighborTuple(ns3::Ipv4Address const & mainAddr) [member function] + cls.add_method('EraseNeighborTuple', + 'void', + [param('ns3::Ipv4Address const &', 'mainAddr')]) + ## olsr-state.h: void ns3::OlsrState::InsertNeighborTuple(ns3::olsr::NeighborTuple const & tuple) [member function] + cls.add_method('InsertNeighborTuple', + 'void', + [param('ns3::olsr::NeighborTuple const &', 'tuple')]) + ## olsr-state.h: ns3::olsr::TwoHopNeighborSet const & ns3::OlsrState::GetTwoHopNeighbors() const [member function] + cls.add_method('GetTwoHopNeighbors', + 'ns3::olsr::TwoHopNeighborSet const &', + [], + is_const=True) + ## olsr-state.h: ns3::olsr::TwoHopNeighborSet & ns3::OlsrState::GetTwoHopNeighbors() [member function] + cls.add_method('GetTwoHopNeighbors', + 'ns3::olsr::TwoHopNeighborSet &', + []) + ## olsr-state.h: ns3::olsr::TwoHopNeighborTuple * ns3::OlsrState::FindTwoHopNeighborTuple(ns3::Ipv4Address const & neighbor, ns3::Ipv4Address const & twoHopNeighbor) [member function] + cls.add_method('FindTwoHopNeighborTuple', + 'ns3::olsr::TwoHopNeighborTuple *', + [param('ns3::Ipv4Address const &', 'neighbor'), param('ns3::Ipv4Address const &', 'twoHopNeighbor')]) + ## olsr-state.h: void ns3::OlsrState::EraseTwoHopNeighborTuple(ns3::olsr::TwoHopNeighborTuple const & tuple) [member function] + cls.add_method('EraseTwoHopNeighborTuple', + 'void', + [param('ns3::olsr::TwoHopNeighborTuple const &', 'tuple')]) + ## olsr-state.h: void ns3::OlsrState::EraseTwoHopNeighborTuples(ns3::Ipv4Address const & neighbor) [member function] + cls.add_method('EraseTwoHopNeighborTuples', + 'void', + [param('ns3::Ipv4Address const &', 'neighbor')]) + ## olsr-state.h: void ns3::OlsrState::EraseTwoHopNeighborTuples(ns3::Ipv4Address const & neighbor, ns3::Ipv4Address const & twoHopNeighbor) [member function] + cls.add_method('EraseTwoHopNeighborTuples', + 'void', + [param('ns3::Ipv4Address const &', 'neighbor'), param('ns3::Ipv4Address const &', 'twoHopNeighbor')]) + ## olsr-state.h: void ns3::OlsrState::InsertTwoHopNeighborTuple(ns3::olsr::TwoHopNeighborTuple const & tuple) [member function] + cls.add_method('InsertTwoHopNeighborTuple', + 'void', + [param('ns3::olsr::TwoHopNeighborTuple const &', 'tuple')]) + ## olsr-state.h: bool ns3::OlsrState::FindMprAddress(ns3::Ipv4Address const & address) [member function] + cls.add_method('FindMprAddress', + 'bool', + [param('ns3::Ipv4Address const &', 'address')]) + ## olsr-state.h: void ns3::OlsrState::SetMprSet(ns3::olsr::MprSet mprSet) [member function] + cls.add_method('SetMprSet', + 'void', + [param('ns3::olsr::MprSet', 'mprSet')]) + ## olsr-state.h: ns3::olsr::DuplicateTuple * ns3::OlsrState::FindDuplicateTuple(ns3::Ipv4Address const & address, uint16_t sequenceNumber) [member function] + cls.add_method('FindDuplicateTuple', + 'ns3::olsr::DuplicateTuple *', + [param('ns3::Ipv4Address const &', 'address'), param('uint16_t', 'sequenceNumber')]) + ## olsr-state.h: void ns3::OlsrState::EraseDuplicateTuple(ns3::olsr::DuplicateTuple const & tuple) [member function] + cls.add_method('EraseDuplicateTuple', + 'void', + [param('ns3::olsr::DuplicateTuple const &', 'tuple')]) + ## olsr-state.h: void ns3::OlsrState::InsertDuplicateTuple(ns3::olsr::DuplicateTuple const & tuple) [member function] + cls.add_method('InsertDuplicateTuple', + 'void', + [param('ns3::olsr::DuplicateTuple const &', 'tuple')]) + ## olsr-state.h: ns3::olsr::LinkSet const & ns3::OlsrState::GetLinks() const [member function] + cls.add_method('GetLinks', + 'ns3::olsr::LinkSet const &', + [], + is_const=True) + ## olsr-state.h: ns3::olsr::LinkTuple * ns3::OlsrState::FindLinkTuple(ns3::Ipv4Address const & ifaceAddr) [member function] + cls.add_method('FindLinkTuple', + 'ns3::olsr::LinkTuple *', + [param('ns3::Ipv4Address const &', 'ifaceAddr')]) + ## olsr-state.h: ns3::olsr::LinkTuple * ns3::OlsrState::FindSymLinkTuple(ns3::Ipv4Address const & ifaceAddr, ns3::Time time) [member function] + cls.add_method('FindSymLinkTuple', + 'ns3::olsr::LinkTuple *', + [param('ns3::Ipv4Address const &', 'ifaceAddr'), param('ns3::Time', 'time')]) + ## olsr-state.h: void ns3::OlsrState::EraseLinkTuple(ns3::olsr::LinkTuple const & tuple) [member function] + cls.add_method('EraseLinkTuple', + 'void', + [param('ns3::olsr::LinkTuple const &', 'tuple')]) + ## olsr-state.h: ns3::olsr::LinkTuple & ns3::OlsrState::InsertLinkTuple(ns3::olsr::LinkTuple const & tuple) [member function] + cls.add_method('InsertLinkTuple', + 'ns3::olsr::LinkTuple &', + [param('ns3::olsr::LinkTuple const &', 'tuple')]) + ## olsr-state.h: ns3::olsr::TopologySet const & ns3::OlsrState::GetTopologySet() const [member function] + cls.add_method('GetTopologySet', + 'ns3::olsr::TopologySet const &', + [], + is_const=True) + ## olsr-state.h: ns3::olsr::TopologyTuple * ns3::OlsrState::FindTopologyTuple(ns3::Ipv4Address const & destAddr, ns3::Ipv4Address const & lastAddr) [member function] + cls.add_method('FindTopologyTuple', + 'ns3::olsr::TopologyTuple *', + [param('ns3::Ipv4Address const &', 'destAddr'), param('ns3::Ipv4Address const &', 'lastAddr')]) + ## olsr-state.h: ns3::olsr::TopologyTuple * ns3::OlsrState::FindNewerTopologyTuple(ns3::Ipv4Address const & lastAddr, uint16_t ansn) [member function] + cls.add_method('FindNewerTopologyTuple', + 'ns3::olsr::TopologyTuple *', + [param('ns3::Ipv4Address const &', 'lastAddr'), param('uint16_t', 'ansn')]) + ## olsr-state.h: void ns3::OlsrState::EraseTopologyTuple(ns3::olsr::TopologyTuple const & tuple) [member function] + cls.add_method('EraseTopologyTuple', + 'void', + [param('ns3::olsr::TopologyTuple const &', 'tuple')]) + ## olsr-state.h: void ns3::OlsrState::EraseOlderTopologyTuples(ns3::Ipv4Address const & lastAddr, uint16_t ansn) [member function] + cls.add_method('EraseOlderTopologyTuples', + 'void', + [param('ns3::Ipv4Address const &', 'lastAddr'), param('uint16_t', 'ansn')]) + ## olsr-state.h: void ns3::OlsrState::InsertTopologyTuple(ns3::olsr::TopologyTuple const & tuple) [member function] + cls.add_method('InsertTopologyTuple', + 'void', + [param('ns3::olsr::TopologyTuple const &', 'tuple')]) + ## olsr-state.h: ns3::olsr::IfaceAssocSet const & ns3::OlsrState::GetIfaceAssocSet() const [member function] + cls.add_method('GetIfaceAssocSet', + 'ns3::olsr::IfaceAssocSet const &', + [], + is_const=True) + ## olsr-state.h: ns3::olsr::IfaceAssocSet & ns3::OlsrState::GetIfaceAssocSetMutable() [member function] + cls.add_method('GetIfaceAssocSetMutable', + 'ns3::olsr::IfaceAssocSet &', + []) + ## olsr-state.h: ns3::olsr::IfaceAssocTuple * ns3::OlsrState::FindIfaceAssocTuple(ns3::Ipv4Address const & ifaceAddr) [member function] + cls.add_method('FindIfaceAssocTuple', + 'ns3::olsr::IfaceAssocTuple *', + [param('ns3::Ipv4Address const &', 'ifaceAddr')]) + ## olsr-state.h: ns3::olsr::IfaceAssocTuple const * ns3::OlsrState::FindIfaceAssocTuple(ns3::Ipv4Address const & ifaceAddr) const [member function] + cls.add_method('FindIfaceAssocTuple', + 'ns3::olsr::IfaceAssocTuple const *', + [param('ns3::Ipv4Address const &', 'ifaceAddr')], + is_const=True) + ## olsr-state.h: void ns3::OlsrState::EraseIfaceAssocTuple(ns3::olsr::IfaceAssocTuple const & tuple) [member function] + cls.add_method('EraseIfaceAssocTuple', + 'void', + [param('ns3::olsr::IfaceAssocTuple const &', 'tuple')]) + ## olsr-state.h: void ns3::OlsrState::InsertIfaceAssocTuple(ns3::olsr::IfaceAssocTuple const & tuple) [member function] + cls.add_method('InsertIfaceAssocTuple', + 'void', + [param('ns3::olsr::IfaceAssocTuple const &', 'tuple')]) + ## olsr-state.h: std::vector > ns3::OlsrState::FindNeighborInterfaces(ns3::Ipv4Address const & neighborMainAddr) const [member function] + cls.add_method('FindNeighborInterfaces', + 'std::vector< ns3::Ipv4Address >', + [param('ns3::Ipv4Address const &', 'neighborMainAddr')], + is_const=True) + return + +def register_Ns3OlsrAgentImpl_methods(root_module, cls): + ## olsr-agent-impl.h: ns3::olsr::AgentImpl::AgentImpl(ns3::olsr::AgentImpl const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::AgentImpl const &', 'arg0')]) + ## olsr-agent-impl.h: static ns3::TypeId ns3::olsr::AgentImpl::GetTypeId() [member function] cls.add_method('GetTypeId', 'ns3::TypeId', [], is_static=True) - ## olsr-agent.h: void ns3::olsr::Agent::SetNode(ns3::Ptr node) [member function] + ## olsr-agent-impl.h: ns3::olsr::AgentImpl::AgentImpl() [constructor] + cls.add_constructor([]) + ## olsr-agent-impl.h: void ns3::olsr::AgentImpl::SetNode(ns3::Ptr node) [member function] cls.add_method('SetNode', 'void', - [param('ns3::Ptr< ns3::Node >', 'node')], - is_pure_virtual=True, is_virtual=True) - ## olsr-agent.h: void ns3::olsr::Agent::SetMainInterface(uint32_t interface) [member function] - cls.add_method('SetMainInterface', - 'void', - [param('uint32_t', 'interface')], - is_pure_virtual=True, is_virtual=True) - ## olsr-agent.h: void ns3::olsr::Agent::Start() [member function] + [param('ns3::Ptr< ns3::Node >', 'node')]) + ## olsr-agent-impl.h: void ns3::olsr::AgentImpl::Start() [member function] cls.add_method('Start', + 'void', + []) + ## olsr-agent-impl.h: void ns3::olsr::AgentImpl::SetMainInterface(uint32_t interface) [member function] + cls.add_method('SetMainInterface', + 'void', + [param('uint32_t', 'interface')]) + ## olsr-agent-impl.h: bool ns3::olsr::AgentImpl::RequestRoute(uint32_t ifIndex, ns3::Ipv4Header const & ipHeader, ns3::Ptr packet, ns3::Callback,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> routeReply) [member function] + cls.add_method('RequestRoute', + 'bool', + [param('uint32_t', 'ifIndex'), param('ns3::Ipv4Header const &', 'ipHeader'), param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Callback< void, bool, ns3::Ipv4Route const &, ns3::Ptr< ns3::Packet >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'routeReply')], + visibility='private', is_virtual=True) + ## olsr-agent-impl.h: bool ns3::olsr::AgentImpl::RequestIfIndex(ns3::Ipv4Address destination, uint32_t & ifIndex) [member function] + cls.add_method('RequestIfIndex', + 'bool', + [param('ns3::Ipv4Address', 'destination'), param('uint32_t &', 'ifIndex')], + visibility='private', is_virtual=True) + ## olsr-agent-impl.h: void ns3::olsr::AgentImpl::DoDispose() [member function] + cls.add_method('DoDispose', 'void', [], - is_pure_virtual=True, is_virtual=True) - ## olsr-agent.h: ns3::Ptr ns3::olsr::Agent::GetRoutingTable() const [member function] - cls.add_method('GetRoutingTable', - 'ns3::Ptr< ns3::olsr::RoutingTable const >', - [], - is_pure_virtual=True, is_const=True, is_virtual=True) + visibility='private', is_virtual=True) + return + +def register_Ns3OlsrDuplicateTuple_methods(root_module, cls): + cls.add_binary_comparison_operator('==') + ## olsr-repositories.h: ns3::olsr::DuplicateTuple::DuplicateTuple() [constructor] + cls.add_constructor([]) + ## olsr-repositories.h: ns3::olsr::DuplicateTuple::DuplicateTuple(ns3::olsr::DuplicateTuple const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::DuplicateTuple const &', 'arg0')]) + ## olsr-repositories.h: ns3::olsr::DuplicateTuple::address [variable] + cls.add_instance_attribute('address', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::DuplicateTuple::expirationTime [variable] + cls.add_instance_attribute('expirationTime', 'ns3::Time', is_const=False) + ## olsr-repositories.h: ns3::olsr::DuplicateTuple::ifaceList [variable] + cls.add_instance_attribute('ifaceList', 'std::vector< ns3::Ipv4Address >', is_const=False) + ## olsr-repositories.h: ns3::olsr::DuplicateTuple::retransmitted [variable] + cls.add_instance_attribute('retransmitted', 'bool', is_const=False) + ## olsr-repositories.h: ns3::olsr::DuplicateTuple::sequenceNumber [variable] + cls.add_instance_attribute('sequenceNumber', 'uint16_t', is_const=False) + return + +def register_Ns3OlsrIfaceAssocTuple_methods(root_module, cls): + cls.add_output_stream_operator() + cls.add_binary_comparison_operator('==') + ## olsr-repositories.h: ns3::olsr::IfaceAssocTuple::IfaceAssocTuple() [constructor] + cls.add_constructor([]) + ## olsr-repositories.h: ns3::olsr::IfaceAssocTuple::IfaceAssocTuple(ns3::olsr::IfaceAssocTuple const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::IfaceAssocTuple const &', 'arg0')]) + ## olsr-repositories.h: ns3::olsr::IfaceAssocTuple::ifaceAddr [variable] + cls.add_instance_attribute('ifaceAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::IfaceAssocTuple::mainAddr [variable] + cls.add_instance_attribute('mainAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::IfaceAssocTuple::time [variable] + cls.add_instance_attribute('time', 'ns3::Time', is_const=False) + return + +def register_Ns3OlsrLinkTuple_methods(root_module, cls): + cls.add_output_stream_operator() + cls.add_binary_comparison_operator('==') + ## olsr-repositories.h: ns3::olsr::LinkTuple::LinkTuple() [constructor] + cls.add_constructor([]) + ## olsr-repositories.h: ns3::olsr::LinkTuple::LinkTuple(ns3::olsr::LinkTuple const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::LinkTuple const &', 'arg0')]) + ## olsr-repositories.h: ns3::olsr::LinkTuple::asymTime [variable] + cls.add_instance_attribute('asymTime', 'ns3::Time', is_const=False) + ## olsr-repositories.h: ns3::olsr::LinkTuple::localIfaceAddr [variable] + cls.add_instance_attribute('localIfaceAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::LinkTuple::neighborIfaceAddr [variable] + cls.add_instance_attribute('neighborIfaceAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::LinkTuple::symTime [variable] + cls.add_instance_attribute('symTime', 'ns3::Time', is_const=False) + ## olsr-repositories.h: ns3::olsr::LinkTuple::time [variable] + cls.add_instance_attribute('time', 'ns3::Time', is_const=False) return def register_Ns3OlsrMessageHeader_methods(root_module, cls): @@ -394,6 +674,33 @@ def register_Ns3OlsrMessageHeaderTc_methods(root_module, cls): cls.add_instance_attribute('neighborAddresses', 'std::vector< ns3::Ipv4Address >', is_const=False) return +def register_Ns3OlsrMprSelectorTuple_methods(root_module, cls): + cls.add_binary_comparison_operator('==') + ## olsr-repositories.h: ns3::olsr::MprSelectorTuple::MprSelectorTuple() [constructor] + cls.add_constructor([]) + ## olsr-repositories.h: ns3::olsr::MprSelectorTuple::MprSelectorTuple(ns3::olsr::MprSelectorTuple const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::MprSelectorTuple const &', 'arg0')]) + ## olsr-repositories.h: ns3::olsr::MprSelectorTuple::expirationTime [variable] + cls.add_instance_attribute('expirationTime', 'ns3::Time', is_const=False) + ## olsr-repositories.h: ns3::olsr::MprSelectorTuple::mainAddr [variable] + cls.add_instance_attribute('mainAddr', 'ns3::Ipv4Address', is_const=False) + return + +def register_Ns3OlsrNeighborTuple_methods(root_module, cls): + cls.add_output_stream_operator() + cls.add_binary_comparison_operator('==') + ## olsr-repositories.h: ns3::olsr::NeighborTuple::NeighborTuple() [constructor] + cls.add_constructor([]) + ## olsr-repositories.h: ns3::olsr::NeighborTuple::NeighborTuple(ns3::olsr::NeighborTuple const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::NeighborTuple const &', 'arg0')]) + ## olsr-repositories.h: ns3::olsr::NeighborTuple::neighborMainAddr [variable] + cls.add_instance_attribute('neighborMainAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::NeighborTuple::status [variable] + cls.add_instance_attribute('status', 'ns3::olsr::NeighborTuple::Status', is_const=False) + ## olsr-repositories.h: ns3::olsr::NeighborTuple::willingness [variable] + cls.add_instance_attribute('willingness', 'uint8_t', is_const=False) + return + def register_Ns3OlsrPacketHeader_methods(root_module, cls): cls.add_output_stream_operator() ## olsr-header.h: ns3::olsr::PacketHeader::PacketHeader(ns3::olsr::PacketHeader const & arg0) [copy constructor] @@ -450,85 +757,51 @@ def register_Ns3OlsrPacketHeader_methods(root_module, cls): [param('uint16_t', 'seqnum')]) return -def register_Ns3OlsrRoutingTable_methods(root_module, cls): - ## olsr-routing-table.h: ns3::olsr::RoutingTable::RoutingTable(ns3::olsr::RoutingTable const & arg0) [copy constructor] - cls.add_constructor([param('ns3::olsr::RoutingTable const &', 'arg0')]) - ## olsr-routing-table.h: ns3::olsr::RoutingTable::RoutingTable() [constructor] +def register_Ns3OlsrRoutingTableEntry_methods(root_module, cls): + ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::destAddr [variable] + cls.add_instance_attribute('destAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::nextAddr [variable] + cls.add_instance_attribute('nextAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::interface [variable] + cls.add_instance_attribute('interface', 'uint32_t', is_const=False) + ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::distance [variable] + cls.add_instance_attribute('distance', 'uint32_t', is_const=False) + ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::RoutingTableEntry(ns3::olsr::RoutingTableEntry const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::RoutingTableEntry const &', 'arg0')]) + ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::RoutingTableEntry() [constructor] cls.add_constructor([]) - ## olsr-routing-table.h: void ns3::olsr::RoutingTable::SetIpv4(ns3::Ptr ipv4) [member function] - cls.add_method('SetIpv4', - 'void', - [param('ns3::Ptr< ns3::Ipv4 >', 'ipv4')]) - ## olsr-routing-table.h: void ns3::olsr::RoutingTable::SetMainAddress(ns3::Ipv4Address mainAddress) [member function] - cls.add_method('SetMainAddress', - 'void', - [param('ns3::Ipv4Address', 'mainAddress')]) - ## olsr-routing-table.h: void ns3::olsr::RoutingTable::Clear() [member function] - cls.add_method('Clear', - 'void', - []) - ## olsr-routing-table.h: uint32_t ns3::olsr::RoutingTable::GetSize() const [member function] - cls.add_method('GetSize', - 'uint32_t', - [], - is_const=True) - ## olsr-routing-table.h: std::vector > ns3::olsr::RoutingTable::GetEntries() const [member function] - cls.add_method('GetEntries', - 'std::vector< ns3::olsr::RoutingTableEntry >', - [], - is_const=True) - ## olsr-routing-table.h: void ns3::olsr::RoutingTable::RemoveEntry(ns3::Ipv4Address const & dest) [member function] - cls.add_method('RemoveEntry', - 'void', - [param('ns3::Ipv4Address const &', 'dest')]) - ## olsr-routing-table.h: void ns3::olsr::RoutingTable::AddEntry(ns3::Ipv4Address const & dest, ns3::Ipv4Address const & next, uint32_t interface, uint32_t distance) [member function] - cls.add_method('AddEntry', - 'void', - [param('ns3::Ipv4Address const &', 'dest'), param('ns3::Ipv4Address const &', 'next'), param('uint32_t', 'interface'), param('uint32_t', 'distance')]) - ## olsr-routing-table.h: void ns3::olsr::RoutingTable::AddEntry(ns3::Ipv4Address const & dest, ns3::Ipv4Address const & next, ns3::Ipv4Address const & interfaceAddress, uint32_t distance) [member function] - cls.add_method('AddEntry', - 'void', - [param('ns3::Ipv4Address const &', 'dest'), param('ns3::Ipv4Address const &', 'next'), param('ns3::Ipv4Address const &', 'interfaceAddress'), param('uint32_t', 'distance')]) - ## olsr-routing-table.h: bool ns3::olsr::RoutingTable::Lookup(ns3::Ipv4Address const & dest, ns3::olsr::RoutingTableEntry & outEntry) const [member function] - cls.add_method('Lookup', - 'bool', - [param('ns3::Ipv4Address const &', 'dest'), param('ns3::olsr::RoutingTableEntry &', 'outEntry')], - is_const=True) - ## olsr-routing-table.h: bool ns3::olsr::RoutingTable::FindSendEntry(ns3::olsr::RoutingTableEntry const & entry, ns3::olsr::RoutingTableEntry & outEntry) const [member function] - cls.add_method('FindSendEntry', - 'bool', - [param('ns3::olsr::RoutingTableEntry const &', 'entry'), param('ns3::olsr::RoutingTableEntry &', 'outEntry')], - is_const=True) - ## olsr-routing-table.h: bool ns3::olsr::RoutingTable::RequestRoute(uint32_t ifIndex, ns3::Ipv4Header const & ipHeader, ns3::Ptr packet, ns3::Callback,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> routeReply) [member function] - cls.add_method('RequestRoute', - 'bool', - [param('uint32_t', 'ifIndex'), param('ns3::Ipv4Header const &', 'ipHeader'), param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Callback< void, bool, ns3::Ipv4Route const &, ns3::Ptr< ns3::Packet >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'routeReply')], - is_virtual=True) - ## olsr-routing-table.h: bool ns3::olsr::RoutingTable::RequestIfIndex(ns3::Ipv4Address destination, uint32_t & ifIndex) [member function] - cls.add_method('RequestIfIndex', - 'bool', - [param('ns3::Ipv4Address', 'destination'), param('uint32_t &', 'ifIndex')], - is_virtual=True) - ## olsr-routing-table.h: void ns3::olsr::RoutingTable::DoDispose() [member function] - cls.add_method('DoDispose', - 'void', - [], - visibility='private', is_virtual=True) return -def register_Ns3OlsrRoutingTableEntry_methods(root_module, cls): - ## olsr-routing-table.h: ns3::olsr::RoutingTableEntry::destAddr [variable] - cls.add_instance_attribute('destAddr', 'ns3::Ipv4Address', is_const=False) - ## olsr-routing-table.h: ns3::olsr::RoutingTableEntry::nextAddr [variable] - cls.add_instance_attribute('nextAddr', 'ns3::Ipv4Address', is_const=False) - ## olsr-routing-table.h: ns3::olsr::RoutingTableEntry::interface [variable] - cls.add_instance_attribute('interface', 'uint32_t', is_const=False) - ## olsr-routing-table.h: ns3::olsr::RoutingTableEntry::distance [variable] - cls.add_instance_attribute('distance', 'uint32_t', is_const=False) - ## olsr-routing-table.h: ns3::olsr::RoutingTableEntry::RoutingTableEntry(ns3::olsr::RoutingTableEntry const & arg0) [copy constructor] - cls.add_constructor([param('ns3::olsr::RoutingTableEntry const &', 'arg0')]) - ## olsr-routing-table.h: ns3::olsr::RoutingTableEntry::RoutingTableEntry() [constructor] +def register_Ns3OlsrTopologyTuple_methods(root_module, cls): + cls.add_output_stream_operator() + cls.add_binary_comparison_operator('==') + ## olsr-repositories.h: ns3::olsr::TopologyTuple::TopologyTuple() [constructor] cls.add_constructor([]) + ## olsr-repositories.h: ns3::olsr::TopologyTuple::TopologyTuple(ns3::olsr::TopologyTuple const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::TopologyTuple const &', 'arg0')]) + ## olsr-repositories.h: ns3::olsr::TopologyTuple::destAddr [variable] + cls.add_instance_attribute('destAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::TopologyTuple::expirationTime [variable] + cls.add_instance_attribute('expirationTime', 'ns3::Time', is_const=False) + ## olsr-repositories.h: ns3::olsr::TopologyTuple::lastAddr [variable] + cls.add_instance_attribute('lastAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::TopologyTuple::sequenceNumber [variable] + cls.add_instance_attribute('sequenceNumber', 'uint16_t', is_const=False) + return + +def register_Ns3OlsrTwoHopNeighborTuple_methods(root_module, cls): + cls.add_output_stream_operator() + cls.add_binary_comparison_operator('==') + ## olsr-repositories.h: ns3::olsr::TwoHopNeighborTuple::TwoHopNeighborTuple() [constructor] + cls.add_constructor([]) + ## olsr-repositories.h: ns3::olsr::TwoHopNeighborTuple::TwoHopNeighborTuple(ns3::olsr::TwoHopNeighborTuple const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::TwoHopNeighborTuple const &', 'arg0')]) + ## olsr-repositories.h: ns3::olsr::TwoHopNeighborTuple::expirationTime [variable] + cls.add_instance_attribute('expirationTime', 'ns3::Time', is_const=False) + ## olsr-repositories.h: ns3::olsr::TwoHopNeighborTuple::neighborMainAddr [variable] + cls.add_instance_attribute('neighborMainAddr', 'ns3::Ipv4Address', is_const=False) + ## olsr-repositories.h: ns3::olsr::TwoHopNeighborTuple::twoHopNeighborAddr [variable] + cls.add_instance_attribute('twoHopNeighborAddr', 'ns3::Ipv4Address', is_const=False) return def register_functions(root_module): diff --git a/src/helper/olsr-helper.cc b/src/helper/olsr-helper.cc index fd033726d..98a735be5 100644 --- a/src/helper/olsr-helper.cc +++ b/src/helper/olsr-helper.cc @@ -18,7 +18,7 @@ * Author: Mathieu Lacage */ #include "olsr-helper.h" -#include "ns3/olsr-agent.h" +#include "ns3/olsr-agent-impl.h" #include "ns3/node-list.h" #include "ns3/names.h" @@ -63,15 +63,17 @@ OlsrHelper::Install (NodeContainer container) void OlsrHelper::Install (Ptr node) { - if (node->GetObject () != 0) + if (node->GetObject () != 0) { NS_FATAL_ERROR ("OlsrHelper::Install(): Aggregating " "an Olsr Agent to a node with an existing Olsr Agent"); return; } - Ptr agent = m_agentFactory.Create (); - agent->SetNode (node); + Ptr agent = m_agentFactory.Create (); node->AggregateObject (agent); + Ptr ipv4 = node->GetObject (); + ipv4->AddRoutingProtocol (agent, 10); + agent->SetNode (node); agent->Start (); } void diff --git a/src/routing/olsr/olsr-agent-impl.cc b/src/routing/olsr/olsr-agent-impl.cc index 6252f984d..8096ce543 100644 --- a/src/routing/olsr/olsr-agent-impl.cc +++ b/src/routing/olsr/olsr-agent-impl.cc @@ -44,6 +44,7 @@ #include "ns3/uinteger.h" #include "ns3/enum.h" #include "ns3/trace-source-accessor.h" +#include "ns3/ipv4-header.h" /********** Useful macros **********/ @@ -148,7 +149,7 @@ TypeId AgentImpl::GetTypeId (void) { static TypeId tid = TypeId ("ns3::olsr::AgentImpl") - .SetParent () + .SetParent () .AddConstructor () .AddAttribute ("HelloInterval", "HELLO messages emission interval.", TimeValue (Seconds (2)), @@ -221,13 +222,7 @@ void AgentImpl::DoDispose () } m_socketAddresses.clear (); - if (m_routingTable) - { - m_routingTable->Dispose (); - m_routingTable = 0; - } - - Object::DoDispose (); + Ipv4RoutingProtocol::DoDispose (); } void AgentImpl::Start () @@ -250,13 +245,6 @@ void AgentImpl::Start () NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress); - m_routingTable = CreateObject (); - m_routingTable->SetIpv4 (m_ipv4); - m_routingTable->SetMainAddress (m_mainAddress); - // Add OLSR as routing protocol, with slightly higher priority than - // static routing. - m_ipv4->AddRoutingProtocol (m_routingTable, 10); - Ipv4Address loopback ("127.0.0.1"); for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++) { @@ -765,7 +753,7 @@ AgentImpl::RoutingTableComputation () << ": RoutingTableComputation begin..."); // 1. All the entries from the routing table are removed. - m_routingTable->Clear (); + Clear (); // 2. The new routing entries are added starting with the // symmetric neighbors (h=1) as the destination nodes. @@ -792,10 +780,10 @@ AgentImpl::RoutingTableComputation () NS_LOG_LOGIC ("Link tuple matches neighbor " << nb_tuple.neighborMainAddr << " => adding routing table entry to neighbor"); lt = &link_tuple; - m_routingTable->AddEntry (link_tuple.neighborIfaceAddr, - link_tuple.neighborIfaceAddr, - link_tuple.localIfaceAddr, - 1); + AddEntry (link_tuple.neighborIfaceAddr, + link_tuple.neighborIfaceAddr, + link_tuple.localIfaceAddr, + 1); if (link_tuple.neighborIfaceAddr == nb_tuple.neighborMainAddr) { nb_main_addr = true; @@ -823,10 +811,10 @@ AgentImpl::RoutingTableComputation () { NS_LOG_LOGIC ("no R_dest_addr is equal to the main address of the neighbor " "=> adding additional routing entry"); - m_routingTable->AddEntry(nb_tuple.neighborMainAddr, - lt->neighborIfaceAddr, - lt->localIfaceAddr, - 1); + AddEntry(nb_tuple.neighborMainAddr, + lt->neighborIfaceAddr, + lt->localIfaceAddr, + 1); } } } @@ -892,11 +880,11 @@ AgentImpl::RoutingTableComputation () // R_dest_addr == N_neighbor_main_addr // of the 2-hop tuple; RoutingTableEntry entry; - bool foundEntry = m_routingTable->Lookup (nb2hop_tuple.neighborMainAddr, entry); + bool foundEntry = Lookup (nb2hop_tuple.neighborMainAddr, entry); if (foundEntry) { NS_LOG_LOGIC ("Adding routing entry for two-hop neighbor."); - m_routingTable->AddEntry (nb2hop_tuple.twoHopNeighborAddr, + AddEntry (nb2hop_tuple.twoHopNeighborAddr, entry.nextAddr, entry.interface, 2); @@ -927,8 +915,8 @@ AgentImpl::RoutingTableComputation () NS_LOG_LOGIC ("Looking at topology tuple: " << topology_tuple); RoutingTableEntry destAddrEntry, lastAddrEntry; - bool have_destAddrEntry = m_routingTable->Lookup (topology_tuple.destAddr, destAddrEntry); - bool have_lastAddrEntry = m_routingTable->Lookup (topology_tuple.lastAddr, lastAddrEntry); + bool have_destAddrEntry = Lookup (topology_tuple.destAddr, destAddrEntry); + bool have_lastAddrEntry = Lookup (topology_tuple.lastAddr, lastAddrEntry); if (!have_destAddrEntry && have_lastAddrEntry && lastAddrEntry.distance == h) { NS_LOG_LOGIC ("Adding routing table entry based on the topology tuple."); @@ -942,10 +930,10 @@ AgentImpl::RoutingTableComputation () // R_iface_addr = R_iface_addr of the recorded // route entry where: // R_dest_addr == T_last_addr. - m_routingTable->AddEntry (topology_tuple.destAddr, - lastAddrEntry.nextAddr, - lastAddrEntry.interface, - h + 1); + AddEntry (topology_tuple.destAddr, + lastAddrEntry.nextAddr, + lastAddrEntry.interface, + h + 1); added = true; } else @@ -973,8 +961,8 @@ AgentImpl::RoutingTableComputation () { IfaceAssocTuple const &tuple = *it; RoutingTableEntry entry1, entry2; - bool have_entry1 = m_routingTable->Lookup (tuple.mainAddr, entry1); - bool have_entry2 = m_routingTable->Lookup (tuple.ifaceAddr, entry2); + bool have_entry1 = Lookup (tuple.mainAddr, entry1); + bool have_entry2 = Lookup (tuple.ifaceAddr, entry2); if (have_entry1 && !have_entry2) { // then a route entry is created in the routing table with: @@ -983,15 +971,15 @@ AgentImpl::RoutingTableComputation () // R_next_addr = R_next_addr (of the recorded route entry) // R_dist = R_dist (of the recorded route entry) // R_iface_addr = R_iface_addr (of the recorded route entry). - m_routingTable->AddEntry (tuple.ifaceAddr, - entry1.nextAddr, - entry1.interface, - entry1.distance); + AddEntry (tuple.ifaceAddr, + entry1.nextAddr, + entry1.interface, + entry1.distance); } } NS_LOG_DEBUG ("Node " << m_mainAddress << ": RoutingTableComputation end."); - m_routingTableChanged (m_routingTable->GetSize ()); + m_routingTableChanged (GetSize ()); } @@ -2488,12 +2476,206 @@ AgentImpl::IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr) } } -Ptr -AgentImpl::GetRoutingTable () const +/// +/// \brief Clears the routing table and frees the memory assigned to each one of its entries. +/// +void +AgentImpl::Clear () { - return m_routingTable; + NS_LOG_FUNCTION_NOARGS (); + m_table.clear (); } +/// +/// \brief Deletes the entry whose destination address is given. +/// \param dest address of the destination node. +/// +void +AgentImpl::RemoveEntry (Ipv4Address const &dest) +{ + m_table.erase (dest); +} + +/// +/// \brief Looks up an entry for the specified destination address. +/// \param dest destination address. +/// \param outEntry output parameter to hold the routing entry result, if fuond +/// \return true if found, false if not found +/// +bool +AgentImpl::Lookup (Ipv4Address const &dest, + RoutingTableEntry &outEntry) const +{ + // Get the iterator at "dest" position + std::map::const_iterator it = + m_table.find (dest); + // If there is no route to "dest", return NULL + if (it == m_table.end ()) + return false; + outEntry = it->second; + return true; +} + +/// +/// \brief Finds the appropiate entry which must be used in order to forward +/// a data packet to a next hop (given a destination). +/// +/// Imagine a routing table like this: [A,B] [B,C] [C,C]; being each pair of the +/// form [dest addr,next-hop addr]. In this case, if this function is invoked with +/// [A,B] then pair [C,C] is returned because C is the next hop that must be used +/// to forward a data packet destined to A. That is, C is a neighbor of this node, +/// but B isn't. This function finds the appropiate neighbor for forwarding a packet. +/// +/// \param entry the routing table entry which indicates the destination node +/// we are interested in. +/// \return the appropiate routing table entry which indicates the next +/// hop which must be used for forwarding a data packet, or NULL +/// if there is no such entry. +/// +bool +AgentImpl::FindSendEntry (RoutingTableEntry const &entry, + RoutingTableEntry &outEntry) const +{ + outEntry = entry; + while (outEntry.destAddr != outEntry.nextAddr) + { + if (not Lookup(outEntry.nextAddr, outEntry)) + return false; + } + return true; +} + + +bool +AgentImpl::RequestRoute (uint32_t ifIndex, + const Ipv4Header &ipHeader, + Ptr packet, + RouteReplyCallback routeReply) +{ + RoutingTableEntry entry1, entry2; + if (Lookup (ipHeader.GetDestination (), entry1)) + { + bool foundSendEntry = FindSendEntry (entry1, entry2); + if (!foundSendEntry) + NS_FATAL_ERROR ("FindSendEntry failure"); + + Ipv4Route route = Ipv4Route::CreateHostRouteTo + (ipHeader.GetDestination (), entry2.nextAddr, entry2.interface); + + NS_LOG_DEBUG ("Olsr node " << m_mainAddress + << ": RouteRequest for dest=" << ipHeader.GetDestination () + << " --> nestHop=" << entry2.nextAddr + << " interface=" << entry2.interface); + + routeReply (true, route, packet, ipHeader); + return true; + } + else + { +#ifdef NS3_LOG_ENABLE + NS_LOG_DEBUG ("Olsr node " << m_mainAddress + << ": RouteRequest for dest=" << ipHeader.GetDestination () + << " --> NOT FOUND; ** Dumping routing table..."); + for (std::map::const_iterator iter = m_table.begin (); + iter != m_table.end (); iter++) + { + NS_LOG_DEBUG ("dest=" << iter->first << " --> next=" << iter->second.nextAddr + << " via interface " << iter->second.interface); + } + + NS_LOG_DEBUG ("** Routing table dump end."); +#endif + return false; + } +} + +bool +AgentImpl::RequestIfIndex (Ipv4Address destination, + uint32_t& ifIndex) +{ + RoutingTableEntry entry1, entry2; + if (Lookup (destination, entry1)) + { + bool foundSendEntry = FindSendEntry (entry1, entry2); + if (!foundSendEntry) + NS_FATAL_ERROR ("FindSendEntry failure"); + ifIndex = entry2.interface; + return true; + } + else + { + return false; + } +} + + +/// +/// \brief Adds a new entry into the routing table. +/// +/// If an entry for the given destination existed, it is deleted and freed. +/// +/// \param dest address of the destination node. +/// \param next address of the next hop node. +/// \param iface address of the local interface. +/// \param dist distance to the destination node. +/// +void +AgentImpl::AddEntry (Ipv4Address const &dest, + Ipv4Address const &next, + uint32_t interface, + uint32_t distance) +{ + NS_LOG_FUNCTION (this << dest << next << interface << distance << m_mainAddress); + + NS_ASSERT (distance > 0); + + // Creates a new rt entry with specified values + RoutingTableEntry &entry = m_table[dest]; + + entry.destAddr = dest; + entry.nextAddr = next; + entry.interface = interface; + entry.distance = distance; +} + +void +AgentImpl::AddEntry (Ipv4Address const &dest, + Ipv4Address const &next, + Ipv4Address const &interfaceAddress, + uint32_t distance) +{ + NS_LOG_FUNCTION (this << dest << next << interfaceAddress << distance << m_mainAddress); + + NS_ASSERT (distance > 0); + NS_ASSERT (m_ipv4); + + RoutingTableEntry entry; + for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++) + { + if (m_ipv4->GetAddress (i) == interfaceAddress) + { + AddEntry (dest, next, i, distance); + return; + } + } + NS_ASSERT (false); // should not be reached + AddEntry (dest, next, 0, distance); +} + + +std::vector +AgentImpl::GetEntries () const +{ + std::vector retval; + for (std::map::const_iterator iter = m_table.begin (); + iter != m_table.end (); iter++) + { + retval.push_back (iter->second); + } + return retval; +} + + }} // namespace olsr, ns3 diff --git a/src/routing/olsr/olsr-agent-impl.h b/src/routing/olsr/olsr-agent-impl.h index 94effeba1..e4433625c 100644 --- a/src/routing/olsr/olsr-agent-impl.h +++ b/src/routing/olsr/olsr-agent-impl.h @@ -24,14 +24,9 @@ #ifndef __OLSR_AGENT_IMPL_H__ #define __OLSR_AGENT_IMPL_H__ -#include - -#include "olsr-agent.h" #include "olsr-header.h" #include "olsr-state.h" - -#include "olsr-routing-table.h" -#include "repositories.h" +#include "olsr-repositories.h" #include "ns3/object.h" #include "ns3/packet.h" @@ -40,13 +35,31 @@ #include "ns3/event-garbage-collector.h" #include "ns3/timer.h" #include "ns3/traced-callback.h" +#include "ns3/ipv4.h" + +#include +#include namespace ns3 { namespace olsr { -class AgentImpl : public Agent +/// An %OLSR's routing table entry. +struct RoutingTableEntry +{ + Ipv4Address destAddr; ///< Address of the destination node. + Ipv4Address nextAddr; ///< Address of the next hop. + uint32_t interface; ///< Interface index + uint32_t distance; ///< Distance in hops to the destination. + + RoutingTableEntry () : // default values + destAddr (), nextAddr (), + interface (0), distance (0) {}; +}; + + +class AgentImpl : public Ipv4RoutingProtocol { public: static TypeId GetTypeId (void); @@ -54,13 +67,14 @@ public: AgentImpl (); virtual ~AgentImpl (); - virtual void SetNode (Ptr node); + void SetNode (Ptr node); - virtual void Start (); - virtual void SetMainInterface (uint32_t interface); - virtual Ptr GetRoutingTable () const; + void Start (); + void SetMainInterface (uint32_t interface); private: + std::map m_table; ///< Data structure for the routing table. + EventGarbageCollector m_events; /// Address of the routing agent. @@ -82,14 +96,39 @@ private: /// Willingness for forwarding packets on behalf of other nodes. uint8_t m_willingness; - /// Routing table. - Ptr m_routingTable; /// Internal state with all needed data structs. OlsrState m_state; Ptr m_ipv4; -protected: +private: + + void Clear (); + uint32_t GetSize () const { return m_table.size (); } + std::vector GetEntries () const; + void RemoveEntry (const Ipv4Address &dest); + void AddEntry (const Ipv4Address &dest, + const Ipv4Address &next, + uint32_t interface, + uint32_t distance); + void AddEntry (const Ipv4Address &dest, + const Ipv4Address &next, + const Ipv4Address &interfaceAddress, + uint32_t distance); + bool Lookup (const Ipv4Address &dest, + RoutingTableEntry &outEntry) const; + bool FindSendEntry (const RoutingTableEntry &entry, + RoutingTableEntry &outEntry) const; + + // From Ipv4RoutingProtocol + virtual bool RequestRoute (uint32_t ifIndex, + const Ipv4Header &ipHeader, + Ptr packet, + RouteReplyCallback routeReply); + virtual bool RequestIfIndex (Ipv4Address destination, + uint32_t& ifIndex); + + void DoDispose (); void SendPacket (Ptr packet, const MessageList &containedMessages); diff --git a/src/routing/olsr/olsr-agent.cc b/src/routing/olsr/olsr-agent.cc deleted file mode 100644 index 7b3c200a3..000000000 --- a/src/routing/olsr/olsr-agent.cc +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INESC Porto - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Gustavo J. A. M. Carneiro - */ - -#include "olsr-agent.h" - -namespace ns3 { -namespace olsr { - -NS_OBJECT_ENSURE_REGISTERED (Agent); - -TypeId -Agent::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::olsr::Agent") - .SetParent (); - return tid; -} - -}} diff --git a/src/routing/olsr/olsr-agent.h b/src/routing/olsr/olsr-agent.h deleted file mode 100644 index ab1bec264..000000000 --- a/src/routing/olsr/olsr-agent.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INESC Porto - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Gustavo J. A. M. Carneiro - */ - -#ifndef OLSR_AGENT_H -#define OLSR_AGENT_H - -#include "ns3/node.h" -#include "ns3/olsr-routing-table.h" - -namespace ns3 { -namespace olsr { - -/** - * \brief Class implementing the OLSR state machine - * - * This class represents an instance of the OLSR protocol. It - * attaches itself to a Node, and its lifecycle is bound to that node. - * Normally the functions in the ns3::olsr namespace are more simple - * to use to start OLSR on nodes, but access to the underlying OLSR - * agent can be useful in order to customize the OLSR parameters. - * Example: - * - * \code - * Ptr olsr = Agend::CreateDefault (); - * agent->SetMainInterface (2); - * agent->Start (); - * \endcode - */ -class Agent : public Object -{ -public: - static TypeId GetTypeId (void); - - virtual void SetNode (Ptr node) = 0; - - /** - * \brief Sets the main interface to be used by OLSR - * - * Normally OLSR supports multiple interfaces, but the protocol - * requires the definition of a "main interface". This interface's - * IPv4 address provides the identity of the node, and all outgoing - * OLSR routing messages must have the main interface address, - * regardless of the actual interface used to transmit the packet. - * This method allows one to explicitly select an interface as the - * main interface. It must be called before the agent starts, but - * calling it is optional; if not called, the agent tries to guess - * and uses a suitable interface. - */ - virtual void SetMainInterface (uint32_t interface) = 0; - - /** - * \brief Starts the OLSR protocol operation - * - * Calling this method essentially bootstraps the OLSR protocol, and - * causes the agent to start broadcasting OLSR messages to - * neighbors, as well start listening to messages from neighbors. - */ - virtual void Start () = 0; - - virtual Ptr GetRoutingTable () const = 0; -}; - -}} // namespace olsr, ns3 - -#endif /* OLSR_AGENT_H */ - diff --git a/src/routing/olsr/repositories.h b/src/routing/olsr/olsr-repositories.h similarity index 99% rename from src/routing/olsr/repositories.h rename to src/routing/olsr/olsr-repositories.h index 386c7f221..4990a4094 100644 --- a/src/routing/olsr/repositories.h +++ b/src/routing/olsr/olsr-repositories.h @@ -21,7 +21,7 @@ */ /// -/// \file OLSR_repositories.h +/// \file OLSR_olsr-repositories.h /// \brief Here are defined all data structures needed by an OLSR node. /// diff --git a/src/routing/olsr/olsr-state.h b/src/routing/olsr/olsr-state.h index d647445fe..b2ea6749b 100644 --- a/src/routing/olsr/olsr-state.h +++ b/src/routing/olsr/olsr-state.h @@ -25,7 +25,7 @@ #ifndef __OLSR_STATE_H__ #define __OLSR_STATE_H__ -#include "repositories.h" +#include "olsr-repositories.h" namespace ns3 { diff --git a/src/routing/olsr/wscript b/src/routing/olsr/wscript index 52e835d5b..b46ffbb9e 100644 --- a/src/routing/olsr/wscript +++ b/src/routing/olsr/wscript @@ -6,16 +6,15 @@ def build(bld): module.source = [ 'olsr-header.cc', 'olsr-state.cc', - 'olsr-routing-table.cc', - 'olsr-agent.cc', 'olsr-agent-impl.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'olsr' headers.source = [ - 'olsr-agent.h', + 'olsr-agent-impl.h', 'olsr-header.h', - 'olsr-routing-table.h' + 'olsr-state.h', + 'olsr-repositories.h', ]