akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 1 | #include<iostream> |
| 2 | #include<fstream> |
| 3 | #include<string> |
| 4 | #include<cstdlib> |
| 5 | #include <sstream> |
| 6 | |
| 7 | #include "nlsr_conf_processor.hpp" |
| 8 | #include "nlsr_conf_param.hpp" |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 9 | #include "utility/nlsr_tokenizer.hpp" |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 10 | #include "nlsr_adjacent.hpp" |
| 11 | |
| 12 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 13 | namespace nlsr |
| 14 | { |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 15 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 16 | using namespace std; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 17 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 18 | int |
| 19 | ConfFileProcessor::processConfFile(Nlsr& pnlsr) |
| 20 | { |
| 21 | int ret=0; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 22 | if ( !confFileName.empty()) |
| 23 | { |
| 24 | std::ifstream inputFile(confFileName.c_str()); |
| 25 | if ( inputFile.is_open()) |
| 26 | { |
| 27 | for( string line; getline( inputFile, line ); ) |
| 28 | { |
| 29 | if (!line.empty() ) |
| 30 | { |
| 31 | if(line[0]!= '#' && line[0]!='!') |
| 32 | { |
| 33 | ret=processConfCommand(pnlsr, line); |
| 34 | if( ret == -1 ) |
| 35 | { |
| 36 | break; |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | else |
| 43 | { |
| 44 | std::cerr <<"Configuration file: ("<<confFileName<<") does not exist :("; |
| 45 | std::cerr <<endl; |
| 46 | ret=-1; |
| 47 | } |
| 48 | } |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 49 | return ret; |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 50 | } |
| 51 | |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 52 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 53 | int |
| 54 | ConfFileProcessor::processConfCommand(Nlsr& pnlsr, string command) |
| 55 | { |
| 56 | int ret=0; |
| 57 | nlsrTokenizer nt(command," "); |
| 58 | if( (nt.getFirstToken() == "network")) |
| 59 | { |
| 60 | ret=processConfCommandNetwork(pnlsr,nt.getRestOfLine()); |
| 61 | } |
| 62 | else if( (nt.getFirstToken() == "site-name")) |
| 63 | { |
| 64 | ret=processConfCommandSiteName(pnlsr,nt.getRestOfLine()); |
| 65 | } |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 66 | else if ( (nt.getFirstToken() == "root-key-prefix")) |
| 67 | { |
| 68 | ret=processConfCommandRootKeyPrefix(pnlsr,nt.getRestOfLine()); |
| 69 | } |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 70 | else if ( (nt.getFirstToken() == "router-name")) |
| 71 | { |
| 72 | ret=processConfCommandRouterName(pnlsr,nt.getRestOfLine()); |
| 73 | } |
| 74 | else if( (nt.getFirstToken() == "ndnneighbor") ) |
| 75 | { |
| 76 | ret=processConfCommandNdnNeighbor(pnlsr, nt.getRestOfLine()); |
| 77 | } |
| 78 | else if( (nt.getFirstToken() == "link-cost")) |
| 79 | { |
| 80 | ret=processConfCommandLinkCost(pnlsr, nt.getRestOfLine()); |
| 81 | } |
| 82 | else if( (nt.getFirstToken() == "ndnname") ) |
| 83 | { |
| 84 | ret=processConfCommandNdnName(pnlsr, nt.getRestOfLine()); |
| 85 | } |
| 86 | else if( (nt.getFirstToken() == "interest-retry-num")) |
| 87 | { |
| 88 | processConfCommandInterestRetryNumber(pnlsr,nt.getRestOfLine()); |
| 89 | } |
| 90 | else if( (nt.getFirstToken() == "interest-resend-time")) |
| 91 | { |
| 92 | processConfCommandInterestResendTime(pnlsr,nt.getRestOfLine()); |
| 93 | } |
| 94 | else if( (nt.getFirstToken() == "lsa-refresh-time")) |
| 95 | { |
| 96 | processConfCommandLsaRefreshTime(pnlsr,nt.getRestOfLine()); |
| 97 | } |
| 98 | else if( (nt.getFirstToken() == "max-faces-per-prefix")) |
| 99 | { |
| 100 | processConfCommandMaxFacesPerPrefix(pnlsr,nt.getRestOfLine()); |
| 101 | } |
akmhoque | eb764c5 | 2014-03-11 16:01:09 -0500 | [diff] [blame] | 102 | else if( (nt.getFirstToken() == "log-dir")) |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 103 | { |
| 104 | processConfCommandLogDir(pnlsr,nt.getRestOfLine()); |
| 105 | } |
akmhoque | eb764c5 | 2014-03-11 16:01:09 -0500 | [diff] [blame] | 106 | else if( (nt.getFirstToken() == "cert-dir")) |
| 107 | { |
| 108 | processConfCommandCertDir(pnlsr,nt.getRestOfLine()); |
| 109 | } |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 110 | else if( (nt.getFirstToken() == "detailed-logging") ) |
| 111 | { |
| 112 | processConfCommandDetailedLogging(pnlsr,nt.getRestOfLine()); |
| 113 | } |
| 114 | else if( (nt.getFirstToken() == "debugging") ) |
| 115 | { |
| 116 | processConfCommandDebugging(pnlsr,nt.getRestOfLine()); |
| 117 | } |
| 118 | else if( (nt.getFirstToken() == "chronosync-sync-prefix") ) |
| 119 | { |
| 120 | processConfCommandChronosyncSyncPrefix(pnlsr,nt.getRestOfLine()); |
| 121 | } |
| 122 | else if( (nt.getFirstToken() == "hyperbolic-cordinate") ) |
| 123 | { |
| 124 | processConfCommandHyperbolicCordinate(pnlsr,nt.getRestOfLine()); |
| 125 | } |
| 126 | else if( (nt.getFirstToken() == "hyperbolic-routing")) |
| 127 | { |
| 128 | processConfCommandIsHyperbolicCalc(pnlsr,nt.getRestOfLine()); |
| 129 | } |
| 130 | else if( (nt.getFirstToken() == "tunnel-type")) |
| 131 | { |
| 132 | processConfCommandTunnelType(pnlsr,nt.getRestOfLine()); |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | cout << "Wrong configuration Command: "<< nt.getFirstToken()<<endl; |
| 137 | } |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 138 | return ret; |
| 139 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 140 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 141 | int |
| 142 | ConfFileProcessor::processConfCommandNetwork(Nlsr& pnlsr, string command) |
| 143 | { |
| 144 | if(command.empty() ) |
| 145 | { |
| 146 | cerr <<" Network can not be null or empty :( !"<<endl; |
| 147 | return -1; |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | if(command[command.size()-1] == '/' ) |
| 152 | { |
| 153 | command.erase(command.size() - 1); |
| 154 | } |
| 155 | if(command[0] == '/' ) |
| 156 | { |
| 157 | command.erase(0,1); |
| 158 | } |
| 159 | pnlsr.getConfParameter().setNetwork(command); |
| 160 | } |
| 161 | return 0; |
| 162 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 163 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 164 | int |
| 165 | ConfFileProcessor::processConfCommandSiteName(Nlsr& pnlsr, string command) |
| 166 | { |
| 167 | if(command.empty() ) |
| 168 | { |
| 169 | cerr <<"Site name can not be null or empty :( !"<<endl; |
| 170 | return -1; |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | if(command[command.size()-1] == '/' ) |
| 175 | { |
| 176 | command.erase(command.size() - 1); |
| 177 | } |
| 178 | if(command[0] == '/' ) |
| 179 | { |
| 180 | command.erase(0,1); |
| 181 | } |
| 182 | pnlsr.getConfParameter().setSiteName(command); |
| 183 | } |
| 184 | return 0; |
| 185 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 186 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 187 | int |
akmhoque | 2bb198e | 2014-02-28 11:46:27 -0600 | [diff] [blame] | 188 | ConfFileProcessor::processConfCommandRootKeyPrefix(Nlsr& pnlsr, string command) |
| 189 | { |
| 190 | if(command.empty() ) |
| 191 | { |
| 192 | cerr <<"Root Key Prefix can not be null or empty :( !"<<endl; |
| 193 | return -1; |
| 194 | } |
| 195 | else |
| 196 | { |
| 197 | if(command[command.size()-1] == '/' ) |
| 198 | { |
| 199 | command.erase(command.size() - 1); |
| 200 | } |
| 201 | if(command[0] == '/' ) |
| 202 | { |
| 203 | command.erase(0,1); |
| 204 | } |
| 205 | pnlsr.getConfParameter().setRootKeyPrefix(command); |
| 206 | } |
| 207 | return 0; |
| 208 | } |
| 209 | |
| 210 | |
| 211 | int |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 212 | ConfFileProcessor::processConfCommandRouterName(Nlsr& pnlsr, string command) |
| 213 | { |
| 214 | if(command.empty() ) |
| 215 | { |
| 216 | cerr <<" Router name can not be null or empty :( !"<<endl; |
| 217 | return -1; |
| 218 | } |
| 219 | else |
| 220 | { |
| 221 | if(command[command.size()-1] == '/' ) |
| 222 | { |
| 223 | command.erase(command.size() - 1); |
| 224 | } |
| 225 | if(command[0] == '/' ) |
| 226 | { |
| 227 | command.erase(0,1); |
| 228 | } |
| 229 | pnlsr.getConfParameter().setRouterName(command); |
| 230 | } |
| 231 | return 0; |
| 232 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 233 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 234 | int |
| 235 | ConfFileProcessor::processConfCommandInterestRetryNumber(Nlsr& pnlsr, |
| 236 | string command) |
| 237 | { |
| 238 | if(command.empty() ) |
| 239 | { |
| 240 | cerr <<" Wrong command format ! [interest-retry-num n]"<<endl; |
| 241 | } |
| 242 | else |
| 243 | { |
| 244 | int irn; |
| 245 | stringstream ss(command.c_str()); |
| 246 | ss>>irn; |
| 247 | if ( irn >=1 && irn <=5) |
| 248 | { |
| 249 | pnlsr.getConfParameter().setInterestRetryNumber(irn); |
| 250 | } |
| 251 | } |
| 252 | return 0; |
| 253 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 254 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 255 | int |
| 256 | ConfFileProcessor::processConfCommandInterestResendTime(Nlsr& pnlsr, |
| 257 | string command) |
| 258 | { |
| 259 | if(command.empty() ) |
| 260 | { |
| 261 | cerr <<" Wrong command format ! [interest-resend-time s]"<<endl; |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | int irt; |
| 266 | stringstream ss(command.c_str()); |
| 267 | ss>>irt; |
| 268 | if( irt>=1 && irt <=20) |
| 269 | { |
| 270 | pnlsr.getConfParameter().setInterestResendTime(irt); |
| 271 | } |
| 272 | } |
| 273 | return 0; |
| 274 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 275 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 276 | int |
| 277 | ConfFileProcessor::processConfCommandLsaRefreshTime(Nlsr& pnlsr, string command) |
| 278 | { |
| 279 | if(command.empty() ) |
| 280 | { |
| 281 | cerr <<" Wrong command format ! [interest-resend-time s]"<<endl; |
| 282 | } |
| 283 | else |
| 284 | { |
| 285 | int lrt; |
| 286 | stringstream ss(command.c_str()); |
| 287 | ss>>lrt; |
| 288 | if ( lrt>= 240 && lrt<=7200) |
| 289 | { |
| 290 | pnlsr.getConfParameter().setLsaRefreshTime(lrt); |
| 291 | } |
| 292 | } |
| 293 | return 0; |
| 294 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 295 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 296 | int |
| 297 | ConfFileProcessor::processConfCommandMaxFacesPerPrefix(Nlsr& pnlsr, |
| 298 | string command) |
| 299 | { |
| 300 | if(command.empty() ) |
| 301 | { |
| 302 | cerr <<" Wrong command format ! [max-faces-per-prefix n]"<<endl; |
| 303 | } |
| 304 | else |
| 305 | { |
| 306 | int mfpp; |
| 307 | stringstream ss(command.c_str()); |
| 308 | ss>>mfpp; |
| 309 | if ( mfpp>=0 && mfpp<=60) |
| 310 | { |
| 311 | pnlsr.getConfParameter().setMaxFacesPerPrefix(mfpp); |
| 312 | } |
| 313 | } |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | int |
| 318 | ConfFileProcessor::processConfCommandTunnelType(Nlsr& pnlsr, string command) |
| 319 | { |
| 320 | if(command.empty() ) |
| 321 | { |
| 322 | cerr <<" Wrong command format ! [tunnel-type tcp/udp]!"<<endl; |
| 323 | } |
| 324 | else |
| 325 | { |
| 326 | if(command == "tcp" || command == "TCP" ) |
| 327 | { |
| 328 | pnlsr.getConfParameter().setTunnelType(1); |
| 329 | } |
| 330 | else if(command == "udp" || command == "UDP") |
| 331 | { |
| 332 | pnlsr.getConfParameter().setTunnelType(0); |
| 333 | } |
| 334 | else |
| 335 | { |
| 336 | cerr <<" Wrong command format ! [tunnel-type tcp/udp]!"<<endl; |
| 337 | } |
| 338 | } |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | int |
| 343 | ConfFileProcessor::processConfCommandChronosyncSyncPrefix(Nlsr& pnlsr, |
| 344 | string command) |
| 345 | { |
| 346 | if(command.empty() ) |
| 347 | { |
| 348 | cerr <<" Wrong command format ! [chronosync-sync-prefix name/prefix]!"<<endl; |
| 349 | } |
| 350 | else |
| 351 | { |
| 352 | pnlsr.getConfParameter().setChronosyncSyncPrefix(command); |
| 353 | } |
| 354 | return 0; |
| 355 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 356 | |
| 357 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 358 | int |
| 359 | ConfFileProcessor::processConfCommandLogDir(Nlsr& pnlsr, string command) |
| 360 | { |
| 361 | if(command.empty() ) |
| 362 | { |
| 363 | cerr <<" Wrong command format ! [log-dir /path/to/log/dir]!"<<endl; |
| 364 | } |
| 365 | else |
| 366 | { |
| 367 | pnlsr.getConfParameter().setLogDir(command); |
| 368 | } |
| 369 | return 0; |
| 370 | } |
akmhoque | eb764c5 | 2014-03-11 16:01:09 -0500 | [diff] [blame] | 371 | |
| 372 | int |
| 373 | ConfFileProcessor::processConfCommandCertDir(Nlsr& pnlsr, string command) |
| 374 | { |
| 375 | if(command.empty() ) |
| 376 | { |
| 377 | cerr <<" Wrong command format ! [cert-dir /path/to/cert/dir]!"<<endl; |
| 378 | } |
| 379 | else |
| 380 | { |
| 381 | pnlsr.getConfParameter().setCertDir(command); |
| 382 | } |
| 383 | return 0; |
| 384 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 385 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 386 | int |
| 387 | ConfFileProcessor::processConfCommandDebugging(Nlsr& pnlsr, string command) |
| 388 | { |
| 389 | if(command.empty() ) |
| 390 | { |
| 391 | cerr <<" Wrong command format ! [debugging on/of]!"<<endl; |
| 392 | } |
| 393 | else |
| 394 | { |
| 395 | if(command == "on" || command == "ON" ) |
| 396 | { |
| 397 | pnlsr.getConfParameter().setDebugging(1); |
| 398 | } |
| 399 | else if(command == "off" || command == "off") |
| 400 | { |
| 401 | pnlsr.getConfParameter().setDebugging(0); |
| 402 | } |
| 403 | else |
| 404 | { |
| 405 | cerr <<" Wrong command format ! [debugging on/off]!"<<endl; |
| 406 | } |
| 407 | } |
| 408 | return 0; |
| 409 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 410 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 411 | int |
| 412 | ConfFileProcessor::processConfCommandDetailedLogging(Nlsr& pnlsr, |
| 413 | string command) |
| 414 | { |
| 415 | if(command.empty() ) |
| 416 | { |
| 417 | cerr <<" Wrong command format ! [detailed-logging on/off]!"<<endl; |
| 418 | } |
| 419 | else |
| 420 | { |
| 421 | if(command == "on" || command == "ON" ) |
| 422 | { |
| 423 | pnlsr.getConfParameter().setDetailedLogging(1); |
| 424 | } |
| 425 | else if(command == "off" || command == "off") |
| 426 | { |
| 427 | pnlsr.getConfParameter().setDetailedLogging(0); |
| 428 | } |
| 429 | else |
| 430 | { |
| 431 | cerr <<" Wrong command format ! [detailed-logging on/off]!"<<endl; |
| 432 | } |
| 433 | } |
| 434 | return 0; |
| 435 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 436 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 437 | int |
| 438 | ConfFileProcessor::processConfCommandIsHyperbolicCalc(Nlsr& pnlsr, |
| 439 | string command) |
| 440 | { |
| 441 | if(command.empty() ) |
| 442 | { |
| 443 | cerr <<" Wrong command format ! [hyperbolic-routing on/off/dry-run]!"<<endl; |
| 444 | } |
| 445 | else |
| 446 | { |
| 447 | if(command == "on" || command == "ON" ) |
| 448 | { |
| 449 | pnlsr.getConfParameter().setIsHyperbolicCalc(1); |
| 450 | } |
| 451 | else if(command == "dry-run" || command == "DRY-RUN") |
| 452 | { |
| 453 | pnlsr.getConfParameter().setIsHyperbolicCalc(2); |
| 454 | } |
| 455 | else if(command == "off" || command == "off") |
| 456 | { |
| 457 | pnlsr.getConfParameter().setIsHyperbolicCalc(0); |
| 458 | } |
| 459 | else |
| 460 | { |
| 461 | cerr <<" Wrong command format ! [hyperbolic-routing on/off/dry-run]!"<<endl; |
| 462 | } |
| 463 | } |
| 464 | return 0; |
| 465 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 466 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 467 | int |
| 468 | ConfFileProcessor::processConfCommandHyperbolicCordinate(Nlsr& pnlsr, |
| 469 | string command) |
| 470 | { |
| 471 | if(command.empty() ) |
| 472 | { |
| 473 | cerr <<" Wrong command format ! [hyperbolic-cordinate r 0]!"<<endl; |
| 474 | if (pnlsr.getConfParameter().getIsHyperbolicCalc() > 0 ) |
| 475 | { |
| 476 | return -1; |
| 477 | } |
| 478 | } |
| 479 | else |
| 480 | { |
| 481 | nlsrTokenizer nt(command," "); |
| 482 | stringstream ssr(nt.getFirstToken().c_str()); |
| 483 | stringstream sst(nt.getRestOfLine().c_str()); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 484 | double r,theta; |
| 485 | ssr>>r; |
| 486 | sst>>theta; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 487 | pnlsr.getConfParameter().setCorR(r); |
| 488 | pnlsr.getConfParameter().setCorTheta(theta); |
| 489 | } |
| 490 | return 0; |
| 491 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 492 | |
| 493 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 494 | int |
| 495 | ConfFileProcessor::processConfCommandNdnNeighbor(Nlsr& pnlsr, string command) |
| 496 | { |
| 497 | if(command.empty() ) |
| 498 | { |
| 499 | cerr <<" Wrong command format ! [ndnneighbor /nbr/name/ FaceId]!"<<endl; |
| 500 | } |
| 501 | else |
| 502 | { |
| 503 | nlsrTokenizer nt(command," "); |
| 504 | if( nt.getRestOfLine().empty()) |
| 505 | { |
| 506 | cerr <<" Wrong command format ! [ndnneighbor /nbr/name/ FaceId]!"<<endl; |
| 507 | return 0; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | stringstream sst(nt.getRestOfLine().c_str()); |
| 512 | int faceId; |
| 513 | sst>>faceId; |
| 514 | Adjacent adj(nt.getFirstToken(),faceId,0.0,0,0); |
| 515 | pnlsr.getAdl().insert(adj); |
| 516 | } |
| 517 | } |
| 518 | return 0; |
| 519 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 520 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 521 | int |
| 522 | ConfFileProcessor::processConfCommandNdnName(Nlsr& pnlsr, string command) |
| 523 | { |
| 524 | if(command.empty() ) |
| 525 | { |
| 526 | cerr <<" Wrong command format ! [ndnname name/prefix]!"<<endl; |
| 527 | } |
| 528 | else |
| 529 | { |
| 530 | pnlsr.getNpl().insertIntoNpl(command); |
| 531 | } |
| 532 | return 0; |
| 533 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 534 | |
| 535 | |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 536 | int |
| 537 | ConfFileProcessor::processConfCommandLinkCost(Nlsr& pnlsr, string command) |
| 538 | { |
| 539 | if(command.empty() ) |
| 540 | { |
| 541 | cerr <<" Wrong command format ! [link-cost nbr/name cost]!"<<endl; |
| 542 | if (pnlsr.getConfParameter().getIsHyperbolicCalc() > 0 ) |
| 543 | { |
| 544 | return -1; |
| 545 | } |
| 546 | } |
| 547 | else |
| 548 | { |
| 549 | nlsrTokenizer nt(command," "); |
| 550 | stringstream sst(nt.getRestOfLine().c_str()); |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 551 | double cost; |
| 552 | sst>>cost; |
akmhoque | 1fd8c1e | 2014-02-19 19:41:49 -0600 | [diff] [blame] | 553 | pnlsr.getAdl().updateAdjacentLinkCost(nt.getFirstToken(),cost); |
| 554 | } |
| 555 | return 0; |
| 556 | } |
akmhoque | 298385a | 2014-02-13 14:13:09 -0600 | [diff] [blame] | 557 | |
akmhoque | b1710aa | 2014-02-19 17:13:36 -0600 | [diff] [blame] | 558 | } //namespace nlsr |
| 559 | |