blob: 22d52229b51b0725b7cb6b029140981f2c24dd9f [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"
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080011namespace nfd {
Junxiao Shic1e12362014-01-24 20:03:26 -070012
13/** \class Fib
14 * \brief represents the FIB
15 */
16class Fib : noncopyable
17{
18public:
19 Fib();
Steve DiBenedettod5f87932014-02-05 15:11:39 -070020
Junxiao Shic1e12362014-01-24 20:03:26 -070021 ~Fib();
Steve DiBenedettod5f87932014-02-05 15:11:39 -070022
Junxiao Shic1e12362014-01-24 20:03:26 -070023 /** \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 DiBenedettod5f87932014-02-05 15:11:39 -070029
Junxiao Shic1e12362014-01-24 20:03:26 -070030 /// performs a longest prefix match
31 shared_ptr<fib::Entry>
32 findLongestPrefixMatch(const Name& prefix) const;
Steve DiBenedettod5f87932014-02-05 15:11:39 -070033
34 shared_ptr<fib::Entry>
35 findExactMatch(const Name& prefix) const;
36
37 void
38 remove(const Name& prefix);
39
Junxiao Shic1e12362014-01-24 20:03:26 -070040 /** \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
47private:
48 shared_ptr<fib::Entry> m_rootEntry;
49 std::list<shared_ptr<fib::Entry> > m_table;
50};
51
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080052} // namespace nfd
Junxiao Shic1e12362014-01-24 20:03:26 -070053
54#endif // NFD_TABLE_FIB_HPP