Alexander Afanasyev | 3ba44e5 | 2011-11-10 16:38:10 -0800 | [diff] [blame] | 1 | // -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- |
| 2 | // |
| 3 | // Copyright (c) 2008 University of Washington |
| 4 | // |
| 5 | // This program is free software; you can redistribute it and/or modify |
| 6 | // it under the terms of the GNU General Public License version 2 as |
| 7 | // published by the Free Software Foundation; |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program; if not, write to the Free Software |
| 16 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | // |
| 18 | // |
| 19 | |
| 20 | #ifndef IPV4_GLOBAL_ROUTING_UNORDERED_NEXTHOPS_H |
| 21 | #define IPV4_GLOBAL_ROUTING_UNORDERED_NEXTHOPS_H |
| 22 | |
| 23 | #include "ns3/ipv4-global-routing.h" |
| 24 | #include "ns3/trie.h" |
| 25 | #include "ns3/ipv4-routing-table-entry.h" |
| 26 | #include "ns3/simple-ref-count.h" |
| 27 | |
| 28 | #include <boost/multi_index_container.hpp> |
| 29 | #include <boost/multi_index/tag.hpp> |
| 30 | #include <boost/multi_index/ordered_index.hpp> |
| 31 | #include <boost/multi_index/mem_fun.hpp> |
| 32 | #include <boost/multi_index/random_access_index.hpp> |
| 33 | #include <boost/multi_index/sequenced_index.hpp> |
| 34 | |
| 35 | namespace ns3 { |
| 36 | |
| 37 | /** |
| 38 | * \brief Global routing protocol for IP version 4 stacks. |
| 39 | * |
| 40 | * Each prefix entry stores a list of ordered by metric next-hops |
| 41 | * |
| 42 | * This class deals with Ipv4 unicast routes only. |
| 43 | * |
| 44 | * \see Ipv4GlobalRouting |
| 45 | * \see Ipv4RoutingProtocol |
| 46 | * \see GlobalRouteManager |
| 47 | */ |
| 48 | class Ipv4GlobalRoutingUnorderedNexthops : public Ipv4GlobalRouting |
| 49 | { |
| 50 | private: |
| 51 | class EntryContainer |
| 52 | : public SimpleRefCount<EntryContainer> |
| 53 | , public |
| 54 | std::vector<Ipv4RoutingTableEntry> |
| 55 | { |
| 56 | }; |
| 57 | |
| 58 | public: |
| 59 | static TypeId GetTypeId (void); |
| 60 | |
| 61 | Ipv4GlobalRoutingUnorderedNexthops (); |
| 62 | |
| 63 | // These methods inherited from base class |
| 64 | // from Ipv4RoutingProtocol |
| 65 | virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, |
| 66 | Ptr<NetDevice> oif, Socket::SocketErrno &sockerr); |
| 67 | |
| 68 | virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev, |
| 69 | UnicastForwardCallback ucb, MulticastForwardCallback mcb, |
| 70 | LocalDeliverCallback lcb, ErrorCallback ecb); |
| 71 | |
| 72 | virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const; |
| 73 | |
| 74 | // from Ipv4GlobalRouting |
| 75 | virtual void AddRouteTo (Ipv4Address dest, |
| 76 | Ipv4Mask destMask, |
| 77 | Ipv4Address nextHop, |
| 78 | uint32_t interface, |
| 79 | uint32_t metric=0); |
| 80 | |
| 81 | virtual void DeleteRoutes (); |
| 82 | |
| 83 | virtual void FixRoutes (); |
| 84 | |
| 85 | protected: |
| 86 | virtual Ptr<Ipv4Route> LookupGlobal (uint32_t entryNum, Ipv4Address dest, Ptr<NetDevice> oif = 0); |
| 87 | |
| 88 | private: |
| 89 | typedef Ipv4AddressTrie<Ptr<EntryContainer> > Ipv4AddressTrieMap; |
| 90 | Ipv4AddressTrieMap m_routes; |
| 91 | |
| 92 | uint32_t m_numLogicalEntries; |
| 93 | }; |
| 94 | |
| 95 | } // Namespace ns3 |
| 96 | |
| 97 | #endif /* IPV4_GLOBAL_ROUTING_UNORDERED_NEXTHOPS_H */ |