Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_TABLE_FIB_HPP |
| 8 | #define NFD_TABLE_FIB_HPP |
| 9 | |
| 10 | #include "fib-entry.hpp" |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame^] | 11 | #include "pit-entry.hpp" |
| 12 | #include "measurements-entry.hpp" |
| 13 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 14 | namespace nfd { |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 15 | |
| 16 | /** \class Fib |
| 17 | * \brief represents the FIB |
| 18 | */ |
| 19 | class Fib : noncopyable |
| 20 | { |
| 21 | public: |
| 22 | Fib(); |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame] | 23 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 24 | ~Fib(); |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame] | 25 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 26 | /** \brief inserts a FIB entry for prefix |
| 27 | * If an entry for exact same prefix exists, that entry is returned. |
| 28 | * \return{ the entry, and true for new entry, false for existing entry } |
| 29 | */ |
| 30 | std::pair<shared_ptr<fib::Entry>, bool> |
| 31 | insert(const Name& prefix); |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame] | 32 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 33 | /// performs a longest prefix match |
| 34 | shared_ptr<fib::Entry> |
| 35 | findLongestPrefixMatch(const Name& prefix) const; |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame] | 36 | |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame^] | 37 | /// performs a longest prefix match |
| 38 | shared_ptr<fib::Entry> |
| 39 | findLongestPrefixMatch(const pit::Entry& pitEntry) const; |
| 40 | |
| 41 | /// performs a longest prefix match |
| 42 | shared_ptr<fib::Entry> |
| 43 | findLongestPrefixMatch(const measurements::Entry& measurementsEntry) const; |
| 44 | |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame] | 45 | shared_ptr<fib::Entry> |
| 46 | findExactMatch(const Name& prefix) const; |
| 47 | |
| 48 | void |
| 49 | remove(const Name& prefix); |
| 50 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 51 | /** \brief removes the NextHop record for face in all entrites |
| 52 | * This is usually invoked when face goes away. |
| 53 | * Removing all NextHops in a FIB entry will not remove the FIB entry. |
| 54 | */ |
| 55 | void |
| 56 | removeNextHopFromAllEntries(shared_ptr<Face> face); |
| 57 | |
| 58 | private: |
| 59 | shared_ptr<fib::Entry> m_rootEntry; |
| 60 | std::list<shared_ptr<fib::Entry> > m_table; |
| 61 | }; |
| 62 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 63 | } // namespace nfd |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 64 | |
| 65 | #endif // NFD_TABLE_FIB_HPP |