akmhoque | 95b7c8c | 2014-01-31 15:53:09 -0600 | [diff] [blame] | 1 | #include<iostream> |
| 2 | #include<cstdlib> |
| 3 | |
| 4 | |
| 5 | |
| 6 | #include "nlsr.hpp" |
| 7 | #include "nlsr_dm.hpp" |
| 8 | #include "nlsr_tokenizer.hpp" |
| 9 | |
| 10 | using namespace std; |
| 11 | using namespace ndn; |
| 12 | |
| 13 | void |
akmhoque | a8cd6b9 | 2014-01-31 20:13:26 -0600 | [diff] [blame^] | 14 | DataManager::processContent(nlsr& pnlsr, |
akmhoque | 95b7c8c | 2014-01-31 15:53:09 -0600 | [diff] [blame] | 15 | const ndn::ptr_lib::shared_ptr<const ndn::Interest> &interest, |
| 16 | const ndn::ptr_lib::shared_ptr<ndn::Data> &data) |
| 17 | { |
| 18 | |
| 19 | cout << "I: " << interest->toUri() << endl; |
akmhoque | 95b7c8c | 2014-01-31 15:53:09 -0600 | [diff] [blame] | 20 | |
akmhoque | a8cd6b9 | 2014-01-31 20:13:26 -0600 | [diff] [blame^] | 21 | string dataName(data->getName().toUri()); |
| 22 | string dataContent((char *)data->getContent().value()); |
| 23 | |
| 24 | cout << "D: " << dataName << endl; |
| 25 | cout << "Data Content: " << dataContent << endl; |
| 26 | |
| 27 | nlsrTokenizer nt(dataName,"/"); |
| 28 | string chkString("info"); |
| 29 | if( nt.doesTokenExist(chkString) ){ |
| 30 | processContentInfo(pnlsr,dataName,dataContent); |
| 31 | } |
| 32 | |
| 33 | } |
| 34 | |
| 35 | void |
| 36 | DataManager::processContentInfo(nlsr& pnlsr, string& dataName, |
| 37 | string& dataContent) |
| 38 | { |
| 39 | nlsrTokenizer nt(dataName,"/"); |
| 40 | string chkString("info"); |
| 41 | string neighbor="/" + nt.getFirstToken() |
| 42 | +nt.getTokenString(0,nt.getTokenPosition(chkString)-1); |
| 43 | int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor); |
| 44 | int infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor); |
| 45 | //debugging purpose start |
| 46 | cout <<"Before Updates: " <<endl; |
| 47 | cout <<"Neighbor : "<<neighbor<<endl; |
| 48 | cout<<"Status: "<< status << endl; |
| 49 | cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl; |
| 50 | //debugging purpose end |
| 51 | |
| 52 | pnlsr.getAdl().setStatusOfNeighbor(neighbor,1); |
| 53 | pnlsr.getAdl().setTimedOutInterestCount(neighbor,0); |
| 54 | |
| 55 | status=pnlsr.getAdl().getStatusOfNeighbor(neighbor); |
| 56 | infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor); |
| 57 | |
| 58 | //debugging purpose |
| 59 | cout <<"After Updates: " <<endl; |
| 60 | cout <<"Neighbor : "<<neighbor<<endl; |
| 61 | cout<<"Status: "<< status << endl; |
| 62 | cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl; |
| 63 | //debugging purpose end |
| 64 | |
| 65 | /* Need to schedule event for Adjacency LSA building */ |
| 66 | |
akmhoque | 95b7c8c | 2014-01-31 15:53:09 -0600 | [diff] [blame] | 67 | } |