akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- 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 | **/ |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 23 | #ifndef NLSR_FIB_ENTRY_HPP |
| 24 | #define NLSR_FIB_ENTRY_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 25 | |
| 26 | #include <list> |
| 27 | #include <iostream> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 28 | #include <boost/cstdint.hpp> |
| 29 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 30 | #include <ndn-cxx/util/scheduler.hpp> |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 31 | #include <ndn-cxx/util/time.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 32 | |
| 33 | #include "nexthop.hpp" |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 34 | #include "nexthop-list.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 35 | |
| 36 | namespace nlsr { |
| 37 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 38 | class FibEntry |
| 39 | { |
| 40 | public: |
| 41 | FibEntry() |
| 42 | : m_name() |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 43 | , m_expirationTimePoint() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 44 | , m_seqNo(0) |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 45 | , m_nexthopList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 46 | { |
| 47 | } |
| 48 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 49 | FibEntry(const ndn::Name& name) |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 50 | : m_expirationTimePoint() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 51 | , m_seqNo(0) |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 52 | , m_nexthopList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 53 | { |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 54 | m_name = name; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 55 | } |
| 56 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 57 | const ndn::Name& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 58 | getName() const |
| 59 | { |
| 60 | return m_name; |
| 61 | } |
| 62 | |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 63 | NexthopList& |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 64 | getNexthopList() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 65 | { |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 66 | return m_nexthopList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 67 | } |
| 68 | |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 69 | const ndn::time::system_clock::TimePoint& |
| 70 | getExpirationTimePoint() const |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 71 | { |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 72 | return m_expirationTimePoint; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 76 | setExpirationTimePoint(const ndn::time::system_clock::TimePoint& ttr) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 77 | { |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 78 | m_expirationTimePoint = ttr; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | void |
| 82 | setExpiringEventId(ndn::EventId feid) |
| 83 | { |
| 84 | m_expiringEventId = feid; |
| 85 | } |
| 86 | |
| 87 | ndn::EventId |
| 88 | getExpiringEventId() const |
| 89 | { |
| 90 | return m_expiringEventId; |
| 91 | } |
| 92 | |
| 93 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 94 | setSeqNo(int32_t fsn) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 95 | { |
| 96 | m_seqNo = fsn; |
| 97 | } |
| 98 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 99 | int32_t |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 100 | getSeqNo() |
| 101 | { |
| 102 | return m_seqNo; |
| 103 | } |
| 104 | |
| 105 | bool |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 106 | isEqualNextHops(NexthopList& nhlOther); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 107 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 108 | void |
| 109 | writeLog(); |
| 110 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 111 | private: |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 112 | ndn::Name m_name; |
akmhoque | c7a79b2 | 2014-05-26 08:06:19 -0500 | [diff] [blame] | 113 | ndn::time::system_clock::TimePoint m_expirationTimePoint; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 114 | ndn::EventId m_expiringEventId; |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 115 | int32_t m_seqNo; |
| 116 | NexthopList m_nexthopList; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 117 | }; |
| 118 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 119 | } //namespace nlsr |
| 120 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 121 | #endif //NLSR_FIB_ENTRY_HPP |