akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 1 | #ifndef NLSR_HPP |
| 2 | #define NLSR_HPP |
| 3 | |
| 4 | #include <ndn-cpp-dev/face.hpp> |
| 5 | #include <ndn-cpp-dev/security/key-chain.hpp> |
| 6 | #include <ndn-cpp-dev/util/scheduler.hpp> |
| 7 | |
| 8 | #include "nlsr_conf_param.hpp" |
| 9 | #include "nlsr_adl.hpp" |
| 10 | #include "nlsr_npl.hpp" |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 11 | #include "communication/nlsr_im.hpp" |
| 12 | #include "communication/nlsr_dm.hpp" |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 13 | #include "nlsr_lsdb.hpp" |
| 14 | #include "nlsr_sm.hpp" |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 15 | #include "route/nlsr_rt.hpp" |
| 16 | #include "route/nlsr_npt.hpp" |
| 17 | #include "route/nlsr_fib.hpp" |
| 18 | #include "utility/nlsr_logger.hpp" |
| 19 | #include "security/nlsr_km.hpp" |
| 20 | #include "communication/nlsr_slh.hpp" |
| 21 | |
| 22 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 23 | namespace nlsr |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 24 | { |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 25 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 26 | using namespace ndn; |
| 27 | using namespace std; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 28 | |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame^] | 29 | inline static void |
| 30 | NullDeleter(boost::asio::io_service* variable) |
| 31 | { |
| 32 | // do nothing |
| 33 | } |
| 34 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 35 | class Nlsr |
| 36 | { |
| 37 | public: |
| 38 | Nlsr() |
Yingdi Yu | 40cd1c3 | 2014-04-17 15:02:17 -0700 | [diff] [blame^] | 39 | : m_io(new boost::asio::io_service) |
| 40 | , m_nlsrFace(new Face(shared_ptr<boost::asio::io_service>(&*m_io, &NullDeleter))) |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 41 | , m_scheduler(*m_io) |
| 42 | , m_confParam() |
| 43 | , m_adl() |
| 44 | , m_npl() |
| 45 | , m_im() |
| 46 | , m_dm() |
| 47 | , m_sm() |
| 48 | , m_km() |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 49 | , isDaemonProcess(false) |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 50 | , m_configFileName("nlsr.conf") |
| 51 | , m_nlsrLsdb() |
| 52 | , m_adjBuildCount(0) |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 53 | , isBuildAdjLsaSheduled(0) |
| 54 | , isRouteCalculationScheduled(0) |
| 55 | , isRoutingTableCalculating(0) |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 56 | , m_routingTable() |
| 57 | , m_npt() |
| 58 | , m_fib() |
| 59 | , m_slh(m_io) |
| 60 | , m_nlsrLogger() |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 61 | {} |
| 62 | |
| 63 | void nlsrRegistrationFailed(const ndn::Name& name); |
| 64 | |
| 65 | void setInterestFilterNlsr(const string& name); |
| 66 | void startEventLoop(); |
| 67 | |
| 68 | int usage(const string& progname); |
| 69 | |
| 70 | string getConfFileName() |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 71 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 72 | return m_configFileName; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 73 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 74 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 75 | void setConfFileName(const string& fileName) |
| 76 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 77 | m_configFileName=fileName; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 78 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 79 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 80 | bool getIsSetDaemonProcess() |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 81 | { |
| 82 | return isDaemonProcess; |
| 83 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 84 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 85 | void setIsDaemonProcess(bool value) |
| 86 | { |
| 87 | isDaemonProcess=value; |
| 88 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 89 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 90 | ConfParameter& getConfParameter() |
| 91 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 92 | return m_confParam; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 93 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 94 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 95 | Adl& getAdl() |
| 96 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 97 | return m_adl; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 98 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 99 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 100 | Npl& getNpl() |
| 101 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 102 | return m_npl; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 103 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 104 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 105 | ndn::shared_ptr<boost::asio::io_service>& getIo() |
| 106 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 107 | return m_io; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 108 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 109 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 110 | ndn::Scheduler& getScheduler() |
| 111 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 112 | return m_scheduler; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 113 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 114 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 115 | ndn::shared_ptr<ndn::Face> getNlsrFace() |
| 116 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 117 | return m_nlsrFace; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 118 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 119 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 120 | KeyManager& getKeyManager() |
| 121 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 122 | return m_km; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 123 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 124 | |
akmhoque | 66e6618 | 2014-02-21 17:56:03 -0600 | [diff] [blame] | 125 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 126 | InterestManager& getIm() |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 127 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 128 | return m_im; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 129 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 130 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 131 | DataManager& getDm() |
| 132 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 133 | return m_dm; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 134 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 135 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 136 | SequencingManager& getSm() |
| 137 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 138 | return m_sm; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 139 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 140 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 141 | Lsdb& getLsdb() |
| 142 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 143 | return m_nlsrLsdb; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 144 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 145 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 146 | RoutingTable& getRoutingTable() |
| 147 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 148 | return m_routingTable; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 149 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 150 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 151 | Npt& getNpt() |
| 152 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 153 | return m_npt; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 154 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 155 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 156 | Fib& getFib() |
| 157 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 158 | return m_fib; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 159 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 160 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 161 | long int getAdjBuildCount() |
| 162 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 163 | return m_adjBuildCount; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 164 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 165 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 166 | void incrementAdjBuildCount() |
| 167 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 168 | m_adjBuildCount++; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 169 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 170 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 171 | void setAdjBuildCount(long int abc) |
| 172 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 173 | m_adjBuildCount=abc; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 174 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 175 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 176 | int getIsBuildAdjLsaSheduled() |
| 177 | { |
| 178 | return isBuildAdjLsaSheduled; |
| 179 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 180 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 181 | void setIsBuildAdjLsaSheduled(bool iabls) |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 182 | { |
| 183 | isBuildAdjLsaSheduled=iabls; |
| 184 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 185 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 186 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 187 | void setApiPort(int ap) |
| 188 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 189 | m_apiPort=ap; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 190 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 191 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 192 | int getApiPort() |
| 193 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 194 | return m_apiPort; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 195 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 196 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 197 | bool getIsRoutingTableCalculating() |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 198 | { |
| 199 | return isRoutingTableCalculating; |
| 200 | } |
akmhoque | 85d8833 | 2014-02-17 21:11:21 -0600 | [diff] [blame] | 201 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 202 | void setIsRoutingTableCalculating(bool irtc) |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 203 | { |
| 204 | isRoutingTableCalculating=irtc; |
| 205 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 206 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 207 | bool getIsRouteCalculationScheduled() |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 208 | { |
| 209 | return isRouteCalculationScheduled; |
| 210 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 211 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 212 | void setIsRouteCalculationScheduled(bool ircs) |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 213 | { |
| 214 | isRouteCalculationScheduled=ircs; |
| 215 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 216 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 217 | SyncLogicHandler& getSlh() |
| 218 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 219 | return m_slh; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 220 | } |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 221 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 222 | NlsrLogger& getNlsrLogger() |
| 223 | { |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 224 | return m_nlsrLogger; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 225 | } |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 226 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 227 | void initialize(); |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 228 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 229 | private: |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 230 | ConfParameter m_confParam; |
| 231 | Adl m_adl; |
| 232 | Npl m_npl; |
| 233 | ndn::shared_ptr<boost::asio::io_service> m_io; |
| 234 | ndn::Scheduler m_scheduler; |
| 235 | ndn::shared_ptr<ndn::Face> m_nlsrFace; |
| 236 | InterestManager m_im; |
| 237 | DataManager m_dm; |
| 238 | SequencingManager m_sm; |
| 239 | KeyManager m_km; |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 240 | bool isDaemonProcess; |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 241 | string m_configFileName; |
| 242 | int m_apiPort; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 243 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 244 | Lsdb m_nlsrLsdb; |
| 245 | RoutingTable m_routingTable; |
| 246 | Npt m_npt; |
| 247 | Fib m_fib; |
| 248 | SyncLogicHandler m_slh; |
| 249 | NlsrLogger m_nlsrLogger; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 250 | |
akmhoque | 05d5fcf | 2014-04-15 14:58:45 -0500 | [diff] [blame] | 251 | long int m_adjBuildCount; |
| 252 | bool isBuildAdjLsaSheduled; |
| 253 | bool isRouteCalculationScheduled; |
| 254 | bool isRoutingTableCalculating; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 255 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 256 | |
| 257 | |
akmhoque | 5a44dd4 | 2014-03-12 18:11:32 -0500 | [diff] [blame] | 258 | }; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 259 | |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 260 | } //namespace nlsr |
| 261 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 262 | #endif |