akmhoque | 87347a3 | 2014-01-31 11:00:44 -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 | |
akmhoque | 204e754 | 2014-01-31 16:08:25 -0600 | [diff] [blame] | 8 | #include "nlsr_conf_param.hpp" |
| 9 | #include "nlsr_adl.hpp" |
| 10 | #include "nlsr_npl.hpp" |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 11 | #include "nlsr_im.hpp" |
| 12 | #include "nlsr_dm.hpp" |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame^] | 13 | #include "nlsr_lsdb.hpp" |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 14 | |
| 15 | |
| 16 | using namespace ndn; |
| 17 | using namespace std; |
| 18 | |
| 19 | class nlsr |
| 20 | { |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 21 | public: |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 22 | nlsr() |
| 23 | : io(ndn::make_shared<boost::asio::io_service>()) |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 24 | , nlsrFace(io) |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 25 | , scheduler(*io) |
| 26 | , configFileName() |
| 27 | , confParam() |
| 28 | , adl() |
| 29 | , npl() |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 30 | , im() |
| 31 | , dm() |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame^] | 32 | , nlsrLsdb() |
| 33 | , nameLsaSeq(0) |
| 34 | , adjLsaSeq(0) |
| 35 | , corLsaSeq(0) |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 36 | { |
| 37 | isDaemonProcess=false; |
| 38 | configFileName="nlsr.conf"; |
| 39 | } |
| 40 | |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame^] | 41 | nlsr(string confFile, uint32_t nlsn, uint32_t alsn, uint32_t clsn) |
| 42 | : io(ndn::make_shared<boost::asio::io_service>()) |
| 43 | , nlsrFace(io) |
| 44 | , scheduler(*io) |
| 45 | , configFileName() |
| 46 | , confParam() |
| 47 | , adl() |
| 48 | , npl() |
| 49 | , im() |
| 50 | , dm() |
| 51 | , nlsrLsdb() |
| 52 | { |
| 53 | isDaemonProcess=false; |
| 54 | configFileName=confFile; |
| 55 | nameLsaSeq=nlsn; |
| 56 | adjLsaSeq=alsn; |
| 57 | corLsaSeq=clsn; |
| 58 | } |
| 59 | |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 60 | void nlsrRegistrationFailed(const ptr_lib::shared_ptr<const Name>&); |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 61 | |
| 62 | void setInterestFilterNlsr(const string& name); |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 63 | void startEventLoop(); |
| 64 | |
| 65 | int usage(const string& progname); |
| 66 | |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 67 | string getConfFileName() |
| 68 | { |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 69 | return configFileName; |
| 70 | } |
| 71 | |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 72 | void setConfFileName(const string& fileName) |
| 73 | { |
| 74 | configFileName=fileName; |
| 75 | } |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 76 | |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 77 | bool isSetDaemonProcess() |
| 78 | { |
| 79 | return isDaemonProcess; |
| 80 | } |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 81 | |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 82 | void setIsDaemonProcess(bool value) |
| 83 | { |
| 84 | isDaemonProcess=value; |
| 85 | } |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 86 | |
akmhoque | a8cd6b9 | 2014-01-31 20:13:26 -0600 | [diff] [blame] | 87 | ConfParameter& getConfParameter(){ |
| 88 | return confParam; |
| 89 | } |
| 90 | |
| 91 | Adl& getAdl(){ |
| 92 | return adl; |
| 93 | } |
| 94 | |
| 95 | Npl& getNpl(){ |
| 96 | return npl; |
| 97 | } |
| 98 | |
| 99 | ndn::shared_ptr<boost::asio::io_service>& getIo() |
| 100 | { |
| 101 | return io; |
| 102 | } |
| 103 | |
| 104 | ndn::Scheduler& getScheduler(){ |
| 105 | return scheduler; |
| 106 | } |
| 107 | |
| 108 | ndn::Face& getNlsrFace(){ |
| 109 | return nlsrFace; |
| 110 | } |
| 111 | |
| 112 | ndn::KeyChain& getKeyChain(){ |
| 113 | return kChain; |
| 114 | } |
| 115 | |
| 116 | interestManager& getIm(){ |
| 117 | return im; |
| 118 | } |
| 119 | |
| 120 | DataManager& getDm(){ |
| 121 | return dm; |
| 122 | } |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame^] | 123 | |
| 124 | Lsdb& getLsdb(){ |
| 125 | return nlsrLsdb; |
| 126 | } |
| 127 | |
| 128 | uint32_t getNameLsaSeq() |
| 129 | { |
| 130 | return nameLsaSeq; |
| 131 | } |
| 132 | |
| 133 | void setNameLsaSeq(uint32_t nlsn){ |
| 134 | nameLsaSeq=nlsn; |
| 135 | } |
| 136 | |
| 137 | uint32_t getAdjLsaSeq() |
| 138 | { |
| 139 | return adjLsaSeq; |
| 140 | } |
| 141 | |
| 142 | void setAdjLsaSeq(uint32_t alsn){ |
| 143 | adjLsaSeq=alsn; |
| 144 | } |
| 145 | |
| 146 | uint32_t getCorLsaSeq() |
| 147 | { |
| 148 | return corLsaSeq; |
| 149 | } |
| 150 | |
| 151 | void setCorLsaSeq(uint32_t clsn){ |
| 152 | corLsaSeq=clsn; |
| 153 | } |
akmhoque | a8cd6b9 | 2014-01-31 20:13:26 -0600 | [diff] [blame] | 154 | |
| 155 | private: |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 156 | ConfParameter confParam; |
| 157 | Adl adl; |
| 158 | Npl npl; |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 159 | ndn::shared_ptr<boost::asio::io_service> io; |
| 160 | ndn::Scheduler scheduler; |
| 161 | ndn::Face nlsrFace; |
| 162 | ndn::KeyChain kChain; |
akmhoque | 147f499 | 2014-01-31 15:52:49 -0600 | [diff] [blame] | 163 | interestManager im; |
| 164 | DataManager dm; |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 165 | bool isDaemonProcess; |
| 166 | string configFileName; |
akmhoque | bd7c8e6 | 2014-02-01 14:57:40 -0600 | [diff] [blame^] | 167 | Lsdb nlsrLsdb; |
| 168 | uint32_t nameLsaSeq; |
| 169 | uint32_t adjLsaSeq; |
| 170 | uint32_t corLsaSeq; |
| 171 | |
akmhoque | 87347a3 | 2014-01-31 11:00:44 -0600 | [diff] [blame] | 172 | |
| 173 | }; |
| 174 | |
| 175 | #endif |