Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 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 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 21 | #include "ndn-fib-impl.h" |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 22 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 23 | #include "ns3/ndn-face.h" |
Alexander Afanasyev | bd9c18e | 2012-11-19 15:23:41 -0800 | [diff] [blame] | 24 | #include "ns3/ndn-interest.h" |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 25 | #include "ns3/ndn-forwarding-strategy.h" |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 26 | |
| 27 | #include "ns3/node.h" |
| 28 | #include "ns3/assert.h" |
| 29 | #include "ns3/names.h" |
| 30 | #include "ns3/log.h" |
| 31 | |
| 32 | #include <boost/ref.hpp> |
| 33 | #include <boost/lambda/lambda.hpp> |
| 34 | #include <boost/lambda/bind.hpp> |
| 35 | namespace ll = boost::lambda; |
| 36 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 37 | NS_LOG_COMPONENT_DEFINE ("ndn.fib.FibImpl"); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 38 | |
| 39 | namespace ns3 { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 40 | namespace ndn { |
| 41 | namespace fib { |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 42 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 43 | NS_OBJECT_ENSURE_REGISTERED (FibImpl); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 44 | |
| 45 | TypeId |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 46 | FibImpl::GetTypeId (void) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 47 | { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 48 | static TypeId tid = TypeId ("ns3::ndn::fib::Default") // cheating ns3 object system |
| 49 | .SetParent<Fib> () |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 50 | .SetGroupName ("Ndn") |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 51 | .AddConstructor<FibImpl> () |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 52 | ; |
| 53 | return tid; |
| 54 | } |
| 55 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 56 | FibImpl::FibImpl () |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 57 | { |
| 58 | } |
| 59 | |
| 60 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 61 | FibImpl::NotifyNewAggregate () |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 62 | { |
| 63 | Object::NotifyNewAggregate (); |
| 64 | } |
| 65 | |
| 66 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 67 | FibImpl::DoDispose (void) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 68 | { |
| 69 | clear (); |
| 70 | Object::DoDispose (); |
| 71 | } |
| 72 | |
| 73 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 74 | Ptr<Entry> |
Alexander Afanasyev | eae83ee | 2013-03-15 15:01:10 -0700 | [diff] [blame] | 75 | FibImpl::LongestPrefixMatch (const Interest &interest) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 76 | { |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 77 | super::iterator item = super::longest_prefix_match (interest.GetName ()); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 78 | // @todo use predicate to search with exclude filters |
| 79 | |
| 80 | if (item == super::end ()) |
| 81 | return 0; |
| 82 | else |
| 83 | return item->payload (); |
| 84 | } |
| 85 | |
Alexander Afanasyev | e5a8b5a | 2013-03-15 15:15:26 -0700 | [diff] [blame] | 86 | Ptr<fib::Entry> |
| 87 | FibImpl::Find (const Name &prefix) |
| 88 | { |
| 89 | super::iterator item = super::find_exact (prefix); |
| 90 | |
| 91 | if (item == super::end ()) |
| 92 | return 0; |
| 93 | else |
| 94 | return item->payload (); |
| 95 | } |
| 96 | |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 97 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 98 | Ptr<Entry> |
Alexander Afanasyev | cfdc14f | 2013-03-15 14:38:44 -0700 | [diff] [blame] | 99 | FibImpl::Add (const Name &prefix, Ptr<Face> face, int32_t metric) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 100 | { |
Alexander Afanasyev | cfdc14f | 2013-03-15 14:38:44 -0700 | [diff] [blame] | 101 | return Add (Create<Name> (prefix), face, metric); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 104 | Ptr<Entry> |
Alexander Afanasyev | cfdc14f | 2013-03-15 14:38:44 -0700 | [diff] [blame] | 105 | FibImpl::Add (const Ptr<const Name> &prefix, Ptr<Face> face, int32_t metric) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 106 | { |
Alexander Afanasyev | 1ba09b8 | 2012-07-09 09:16:14 -0700 | [diff] [blame] | 107 | NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix) << boost::cref(*face) << metric); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 108 | |
| 109 | // will add entry if doesn't exists, or just return an iterator to the existing entry |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 110 | std::pair< super::iterator, bool > result = super::insert (*prefix, 0); |
| 111 | if (result.first != super::end ()) |
| 112 | { |
| 113 | if (result.second) |
| 114 | { |
Alexander Afanasyev | ff0d9ca | 2013-04-14 23:13:46 -0700 | [diff] [blame] | 115 | Ptr<EntryImpl> newEntry = Create<EntryImpl> (this, prefix); |
| 116 | newEntry->SetTrie (result.first); |
| 117 | result.first->set_payload (newEntry); |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 118 | } |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 119 | |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 120 | super::modify (result.first, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 121 | ll::bind (&Entry::AddOrUpdateRoutingMetric, ll::_1, face, metric)); |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 122 | |
| 123 | if (result.second) |
| 124 | { |
| 125 | // notify forwarding strategy about new FIB entry |
| 126 | NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0); |
| 127 | this->GetObject<ForwardingStrategy> ()->DidAddFibEntry (result.first->payload ()); |
| 128 | } |
| 129 | |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 130 | return result.first->payload (); |
| 131 | } |
| 132 | else |
| 133 | return 0; |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | void |
Alexander Afanasyev | cfdc14f | 2013-03-15 14:38:44 -0700 | [diff] [blame] | 137 | FibImpl::Remove (const Ptr<const Name> &prefix) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 138 | { |
| 139 | NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix)); |
| 140 | |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 141 | super::iterator fibEntry = super::find_exact (*prefix); |
| 142 | if (fibEntry != super::end ()) |
| 143 | { |
| 144 | // notify forwarding strategy about soon be removed FIB entry |
| 145 | NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0); |
| 146 | this->GetObject<ForwardingStrategy> ()->WillRemoveFibEntry (fibEntry->payload ()); |
| 147 | |
| 148 | super::erase (fibEntry); |
| 149 | } |
| 150 | // else do nothing |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 153 | // void |
Alexander Afanasyev | cfdc14f | 2013-03-15 14:38:44 -0700 | [diff] [blame] | 154 | // FibImpl::Invalidate (const Ptr<const Name> &prefix) |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 155 | // { |
| 156 | // NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId () << boost::cref(*prefix)); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 157 | |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 158 | // super::iterator foundItem, lastItem; |
| 159 | // bool reachLast; |
| 160 | // boost::tie (foundItem, reachLast, lastItem) = super::getTrie ().find (*prefix); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 161 | |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 162 | // if (!reachLast || lastItem->payload () == 0) |
| 163 | // return; // nothing to invalidate |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 164 | |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 165 | // super::modify (lastItem, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 166 | // ll::bind (&Entry::Invalidate, ll::_1)); |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 167 | // } |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 168 | |
| 169 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 170 | FibImpl::InvalidateAll () |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 171 | { |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 172 | NS_LOG_FUNCTION (this->GetObject<Node> ()->GetId ()); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 173 | |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 174 | super::parent_trie::recursive_iterator item (super::getTrie ()); |
| 175 | super::parent_trie::recursive_iterator end (0); |
| 176 | for (; item != end; item++) |
| 177 | { |
| 178 | if (item->payload () == 0) continue; |
| 179 | |
| 180 | super::modify (&(*item), |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 181 | ll::bind (&Entry::Invalidate, ll::_1)); |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 182 | } |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 186 | FibImpl::RemoveFace (super::parent_trie &item, Ptr<Face> face) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 187 | { |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 188 | if (item.payload () == 0) return; |
| 189 | NS_LOG_FUNCTION (this); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 190 | |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 191 | super::modify (&item, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 192 | ll::bind (&Entry::RemoveFace, ll::_1, face)); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 196 | FibImpl::RemoveFromAll (Ptr<Face> face) |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 197 | { |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 198 | NS_LOG_FUNCTION (this); |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 199 | |
Alexander Afanasyev | 431e9c7 | 2013-06-03 10:13:47 -0700 | [diff] [blame] | 200 | Ptr<Entry> entry = Begin (); |
| 201 | while (entry != End ()) |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 202 | { |
Alexander Afanasyev | 431e9c7 | 2013-06-03 10:13:47 -0700 | [diff] [blame] | 203 | entry->RemoveFace (face); |
| 204 | if (entry->m_faces.size () == 0) |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 205 | { |
Alexander Afanasyev | 431e9c7 | 2013-06-03 10:13:47 -0700 | [diff] [blame] | 206 | Ptr<Entry> nextEntry = Next (entry); |
| 207 | |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 208 | // notify forwarding strategy about soon be removed FIB entry |
| 209 | NS_ASSERT (this->GetObject<ForwardingStrategy> () != 0); |
Alexander Afanasyev | 431e9c7 | 2013-06-03 10:13:47 -0700 | [diff] [blame] | 210 | this->GetObject<ForwardingStrategy> ()->WillRemoveFibEntry (entry); |
| 211 | |
| 212 | super::erase (StaticCast<EntryImpl> (entry)->to_iterator ()); |
| 213 | entry = nextEntry; |
| 214 | } |
| 215 | else |
| 216 | { |
| 217 | entry = Next (entry); |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 218 | } |
| 219 | } |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 223 | FibImpl::Print (std::ostream &os) const |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 224 | { |
Alexander Afanasyev | 44bb6ea | 2012-07-09 08:44:41 -0700 | [diff] [blame] | 225 | // !!! unordered_set imposes "random" order of item in the same level !!! |
| 226 | super::parent_trie::const_recursive_iterator item (super::getTrie ()); |
| 227 | super::parent_trie::const_recursive_iterator end (0); |
| 228 | for (; item != end; item++) |
| 229 | { |
| 230 | if (item->payload () == 0) continue; |
| 231 | |
| 232 | os << item->payload ()->GetPrefix () << "\t" << *item->payload () << "\n"; |
| 233 | } |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 234 | } |
| 235 | |
Alexander Afanasyev | f1e013f | 2012-07-11 17:59:40 -0700 | [diff] [blame] | 236 | uint32_t |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 237 | FibImpl::GetSize () const |
Alexander Afanasyev | f1e013f | 2012-07-11 17:59:40 -0700 | [diff] [blame] | 238 | { |
| 239 | return super::getPolicy ().size (); |
| 240 | } |
| 241 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 242 | Ptr<const Entry> |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 243 | FibImpl::Begin () const |
Alexander Afanasyev | 95a4fa3 | 2012-07-09 15:23:59 -0700 | [diff] [blame] | 244 | { |
| 245 | super::parent_trie::const_recursive_iterator item (super::getTrie ()); |
| 246 | super::parent_trie::const_recursive_iterator end (0); |
| 247 | for (; item != end; item++) |
| 248 | { |
| 249 | if (item->payload () == 0) continue; |
| 250 | break; |
| 251 | } |
| 252 | |
| 253 | if (item == end) |
| 254 | return End (); |
| 255 | else |
| 256 | return item->payload (); |
| 257 | } |
| 258 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 259 | Ptr<const Entry> |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 260 | FibImpl::End () const |
Alexander Afanasyev | 95a4fa3 | 2012-07-09 15:23:59 -0700 | [diff] [blame] | 261 | { |
| 262 | return 0; |
| 263 | } |
| 264 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 265 | Ptr<const Entry> |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 266 | FibImpl::Next (Ptr<const Entry> from) const |
Alexander Afanasyev | 95a4fa3 | 2012-07-09 15:23:59 -0700 | [diff] [blame] | 267 | { |
| 268 | if (from == 0) return 0; |
| 269 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 270 | super::parent_trie::const_recursive_iterator item (*StaticCast<const EntryImpl> (from)->to_iterator ()); |
Alexander Afanasyev | 95a4fa3 | 2012-07-09 15:23:59 -0700 | [diff] [blame] | 271 | super::parent_trie::const_recursive_iterator end (0); |
| 272 | for (item++; item != end; item++) |
| 273 | { |
| 274 | if (item->payload () == 0) continue; |
| 275 | break; |
| 276 | } |
| 277 | |
| 278 | if (item == end) |
| 279 | return End (); |
| 280 | else |
| 281 | return item->payload (); |
| 282 | } |
| 283 | |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 284 | Ptr<Entry> |
| 285 | FibImpl::Begin () |
| 286 | { |
| 287 | super::parent_trie::recursive_iterator item (super::getTrie ()); |
| 288 | super::parent_trie::recursive_iterator end (0); |
| 289 | for (; item != end; item++) |
| 290 | { |
| 291 | if (item->payload () == 0) continue; |
| 292 | break; |
| 293 | } |
| 294 | |
| 295 | if (item == end) |
| 296 | return End (); |
| 297 | else |
| 298 | return item->payload (); |
| 299 | } |
| 300 | |
| 301 | Ptr<Entry> |
| 302 | FibImpl::End () |
| 303 | { |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | Ptr<Entry> |
| 308 | FibImpl::Next (Ptr<Entry> from) |
| 309 | { |
| 310 | if (from == 0) return 0; |
| 311 | |
| 312 | super::parent_trie::recursive_iterator item (*StaticCast<EntryImpl> (from)->to_iterator ()); |
| 313 | super::parent_trie::recursive_iterator end (0); |
| 314 | for (item++; item != end; item++) |
| 315 | { |
| 316 | if (item->payload () == 0) continue; |
| 317 | break; |
| 318 | } |
| 319 | |
| 320 | if (item == end) |
| 321 | return End (); |
| 322 | else |
| 323 | return item->payload (); |
| 324 | } |
| 325 | |
| 326 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 327 | } // namespace fib |
| 328 | } // namespace ndn |
Alexander Afanasyev | 78057c3 | 2012-07-06 15:18:46 -0700 | [diff] [blame] | 329 | } // namespace ns3 |