blob: ecf26c921693dcf6819f003d359e51cd76ed00d6 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoquefdbddb12014-05-02 18:35:19 -050023#ifndef NLSR_ROUTING_TABLE_HPP
24#define NLSR_ROUTING_TABLE_HPP
akmhoque53353462014-04-22 08:43:45 -050025
26#include <iostream>
27#include <utility>
28#include <string>
akmhoquefdbddb12014-05-02 18:35:19 -050029#include <boost/cstdint.hpp>
akmhoque53353462014-04-22 08:43:45 -050030
31#include "routing-table-entry.hpp"
32
33namespace nlsr {
34
35class Nlsr;
36class NextHop;
37
38class RoutingTable
39{
40public:
41 RoutingTable()
42 : m_NO_NEXT_HOP(-12345)
43 {
44 }
45 void
46 calculate(Nlsr& pnlsr);
47
48 void
akmhoque31d1d4b2014-05-05 22:08:14 -050049 addNextHop(const ndn::Name& destRouter, NextHop& nh);
akmhoque53353462014-04-22 08:43:45 -050050
51 void
52 printRoutingTable();
53
54 void
akmhoque31d1d4b2014-05-05 22:08:14 -050055 addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
akmhoque53353462014-04-22 08:43:45 -050056
57 void
58 printDryRoutingTable();
59
akmhoqueb6450b12014-04-24 00:01:03 -050060 RoutingTableEntry*
akmhoque31d1d4b2014-05-05 22:08:14 -050061 findRoutingTableEntry(const ndn::Name& destRouter);
akmhoque53353462014-04-22 08:43:45 -050062
63 void
64 scheduleRoutingTableCalculation(Nlsr& pnlsr);
65
66 int
67 getNoNextHop()
68 {
69 return m_NO_NEXT_HOP;
70 }
71
72private:
73 void
74 calculateLsRoutingTable(Nlsr& pnlsr);
75
76 void
77 calculateHypRoutingTable(Nlsr& pnlsr);
78
79 void
80 calculateHypDryRoutingTable(Nlsr& pnlsr);
81
82 void
83 clearRoutingTable();
84
85 void
86 clearDryRoutingTable();
87
akmhoque674b0b12014-05-20 14:33:28 -050088 void
89 writeLog();
90
akmhoque53353462014-04-22 08:43:45 -050091 const int m_NO_NEXT_HOP;
92
93 std::list<RoutingTableEntry> m_rTable;
94 std::list<RoutingTableEntry> m_dryTable;
95};
96
97}//namespace nlsr
98
akmhoquefdbddb12014-05-02 18:35:19 -050099#endif //NLSR_ROUTING_TABLE_HPP