37 upCount = par(
"upCount").longValue();
44 if(
Im == n_addr) {
return vector<Port>(); }
45 if(n_addr.
type < 0 || n_addr.
type > 3) {
46 cerr <<
"Invalid dst addr ("<<n_addr<<
")" << endl;
47 return vector<Port>();
50 auto r =
table.find(n_addr);
51 if(r !=
table.end()) {
53 if(!e.entryType) {
return vector<Port>(); }
56 for(
int i = 0; i<
upCount; i++) {
58 if(e.inverseStorage == (e.ports.find(p) == e.ports.end()) ) {
72 }
else { cerr <<
"!!!" << endl;}
79 }
else { cerr <<
"!!!" << endl;}
88 cerr <<
"Invalid neighbour ("<<n_addr<<
") found for TOR " <<
Im<<endl;
98 for(
int i = 0; i<
upCount; i++) {
105 for(
auto & e :
table) {
106 if(e.second.ports.find(t) != e.second.ports.end()) {
107 e.second.ports.erase(t);
108 if(port !=
nullptr) {
109 e.second.ports.insert(port);
118 if(n_addr ==
Im) {
return; }
120 if(n_addr.
type < 0 || n_addr.
type > 3) {
121 cerr <<
"Invalid dst addr ("<<n_addr<<
")" << endl;
133 for(
const auto & n : next) {
137 switch(n_addr.
type) {
146 if(S == 1 && pIds.find(n_addr.
b) != pIds.end() ){
153 if(S == 1 && pIds.find(n_addr.
a) != pIds.end() ){
171 for(
int i = 0; i<
upCount; i++) {
180 if(par(
"printAtEnd").boolValue()) {
181 cout <<
"-----------------------" << endl;
182 cout <<
"SimpleTORForwarding at "<< endl;
183 cout <<
" " << getFullPath() << endl;
185 cout <<
"I'm TOR "<<
Im << endl;
187 cout <<
"\tUp neighbours:" << endl;
188 for(
int i = 0; i <
upCount; i++) {
189 cout <<
"\t\t1."<<
Im.
a<<
"."<<i<<
" -> Status "<< (
portsArray[i]!=
nullptr?
"ON":
"OFF") << endl;
193 cout <<
"\tNo entries stored" << endl;
195 cout <<
"Stored entries " <<
table.size() << endl;
196 for(
auto & e :
table) {
197 cout <<
"\t\t"<< e.first <<
" -- ";
198 if(e.second.entryType ==
false) {
199 cout <<
"Unreachable";
201 if(e.second.inverseStorage) {
202 cout <<
"(inverse) ";
204 cout << e.second.ports.size() <<
" stored ports:";
207 for(
auto &k : e.second.ports) {
208 cout <<
"\t\t\t" << k->getFullPath() << endl;
Register_Class(SimpleDCGenerator)
void setDst(const DCAddr &n_addr, const set< DCAddr > &next)
virtual void refreshCache(Port oldP, Port newP)
tFWDEntry getFWDEntry(const set< int > &pIds)
map< DCAddr, tFWDEntry > table
vector< Port > search(const DCAddr &n_addr)
bool setNeigh(const DCAddr &n_addr, Port port)