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" |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 11 | namespace nfd { |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 12 | |
| 13 | /** \class Fib |
| 14 | * \brief represents the FIB |
| 15 | */ |
| 16 | class Fib : noncopyable |
| 17 | { |
| 18 | public: |
| 19 | Fib(); |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame^] | 20 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 21 | ~Fib(); |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame^] | 22 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 23 | /** \brief inserts a FIB entry for prefix |
| 24 | * If an entry for exact same prefix exists, that entry is returned. |
| 25 | * \return{ the entry, and true for new entry, false for existing entry } |
| 26 | */ |
| 27 | std::pair<shared_ptr<fib::Entry>, bool> |
| 28 | insert(const Name& prefix); |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame^] | 29 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 30 | /// performs a longest prefix match |
| 31 | shared_ptr<fib::Entry> |
| 32 | findLongestPrefixMatch(const Name& prefix) const; |
Steve DiBenedetto | d5f8793 | 2014-02-05 15:11:39 -0700 | [diff] [blame^] | 33 | |
| 34 | shared_ptr<fib::Entry> |
| 35 | findExactMatch(const Name& prefix) const; |
| 36 | |
| 37 | void |
| 38 | remove(const Name& prefix); |
| 39 | |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 40 | /** \brief removes the NextHop record for face in all entrites |
| 41 | * This is usually invoked when face goes away. |
| 42 | * Removing all NextHops in a FIB entry will not remove the FIB entry. |
| 43 | */ |
| 44 | void |
| 45 | removeNextHopFromAllEntries(shared_ptr<Face> face); |
| 46 | |
| 47 | private: |
| 48 | shared_ptr<fib::Entry> m_rootEntry; |
| 49 | std::list<shared_ptr<fib::Entry> > m_table; |
| 50 | }; |
| 51 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 52 | } // namespace nfd |
Junxiao Shi | c1e1236 | 2014-01-24 20:03:26 -0700 | [diff] [blame] | 53 | |
| 54 | #endif // NFD_TABLE_FIB_HPP |