blob: 7b958dec924296e2176286f7fd95d086ae14d76e [file] [log] [blame]
akmhoque95b7c8c2014-01-31 15:53:09 -06001#include<iostream>
2#include<cstdlib>
3
4
5
6#include "nlsr.hpp"
7#include "nlsr_dm.hpp"
8#include "nlsr_tokenizer.hpp"
9
10using namespace std;
11using namespace ndn;
12
13void
akmhoquea8cd6b92014-01-31 20:13:26 -060014DataManager::processContent(nlsr& pnlsr,
akmhoque95b7c8c2014-01-31 15:53:09 -060015 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;
akmhoque95b7c8c2014-01-31 15:53:09 -060020
akmhoquea8cd6b92014-01-31 20:13:26 -060021 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
35void
36DataManager::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
akmhoque95b7c8c2014-01-31 15:53:09 -060067}