blob: 266191177b326362187a66d1fa67941207cd8f49 [file] [log] [blame]
Junxiao Shic1e12362014-01-24 20:03:26 -07001/* -*- 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 Shidbe71732014-02-21 22:23:28 -070011#include "pit-entry.hpp"
12#include "measurements-entry.hpp"
13
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080014namespace nfd {
Junxiao Shic1e12362014-01-24 20:03:26 -070015
16/** \class Fib
17 * \brief represents the FIB
18 */
19class Fib : noncopyable
20{
21public:
22 Fib();
Steve DiBenedettod5f87932014-02-05 15:11:39 -070023
Junxiao Shic1e12362014-01-24 20:03:26 -070024 ~Fib();
Steve DiBenedettod5f87932014-02-05 15:11:39 -070025
Junxiao Shic1e12362014-01-24 20:03:26 -070026 /** \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 DiBenedettod5f87932014-02-05 15:11:39 -070032
Junxiao Shic1e12362014-01-24 20:03:26 -070033 /// performs a longest prefix match
34 shared_ptr<fib::Entry>
35 findLongestPrefixMatch(const Name& prefix) const;
Steve DiBenedettod5f87932014-02-05 15:11:39 -070036
Junxiao Shidbe71732014-02-21 22:23:28 -070037 /// 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 DiBenedettod5f87932014-02-05 15:11:39 -070045 shared_ptr<fib::Entry>
46 findExactMatch(const Name& prefix) const;
47
48 void
49 remove(const Name& prefix);
50
Junxiao Shic1e12362014-01-24 20:03:26 -070051 /** \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
58private:
59 shared_ptr<fib::Entry> m_rootEntry;
60 std::list<shared_ptr<fib::Entry> > m_table;
61};
62
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080063} // namespace nfd
Junxiao Shic1e12362014-01-24 20:03:26 -070064
65#endif // NFD_TABLE_FIB_HPP