36 upCount = par(
"upCount").longValue();
47 if(
Im == n_addr) {
return vector<Port>(); }
48 if(n_addr.
type < 0 || n_addr.
type > 3) {
49 cerr <<
"Invalid dst addr ("<<n_addr<<
")" << endl;
50 return vector<Port>();
53 auto r =
table.find(n_addr);
54 if(r !=
table.end()) {
56 if(e.entryType == 0) {
return vector<Port>(); }
60 int i = (e.entryType == 2)?
upCount:0;
64 if(p ==
nullptr) {
continue; }
65 if(e.inverseStorage == (e.ports.find(p) == e.ports.end()) ) {
75 if(n_addr.
a ==
Im.
a) {
80 }
else { cout <<
"!!! Invalid port to " << (
upCount+n_addr.
b) <<
" at " <<
Im << endl; }
84 if(n_addr.
a ==
Im.
a) {
86 }
else if(n_addr.
b ==
Im.
b) {
91 if(n_addr.
a ==
Im.
b) {
96 }
else { cout <<
"!!! Invalid port to " << (n_addr.
b) <<
" at " <<
Im << endl; }
100 if(n_addr.
b ==
Im.
b) {
105 return vector<Port>();
109 bool invalid =
false;
124 cerr <<
"Invalid neighbour ("<<n_addr<<
") found for Fabric " <<
Im<<endl;
129 if(n_addr.
type == 0){
131 if(t == port) {
return true; }
135 if(t == port) {
return true; }
142 for(
int i = 0; i<
upCount; i++) {
157 for(
auto & e :
table) {
158 if(e.second.ports.find(t) != e.second.ports.end()) {
159 e.second.ports.erase(t);
160 if(port !=
nullptr) {
161 e.second.ports.insert(port);
171 if(n_addr ==
Im) {
return; }
173 if(n_addr.
type < 0 || n_addr.
type > 3) {
174 cerr <<
"Invalid dst addr ("<<n_addr<<
")" << endl;
185 set<int> upIds, downIds;
186 for(
const auto & n : next) {
189 }
else if(n.type == 2) {
193 int upS = upIds.size();
194 int downS = downIds.size();
196 if(upS == 0 && downS == 0) {
201 bool defaultEntry =
false;
202 switch(n_addr.
type) {
217 }
else if(n_addr.
b ==
Im.
b
265 for(
int i = 0; i<
upCount; i++) {
291 for(
int i = 0; i<
upCount; i++) {
305 if(par(
"printAtEnd").boolValue()) {
306 cout <<
"-----------------------" << endl;
307 cout <<
"SimpleFabricForwarding at "<< endl;
308 cout <<
" " << getFullPath() << endl;
310 cout <<
"I'm Fabric "<<
Im << endl;
312 cout <<
"\tUp neighbours:" << endl;
313 for(
int i = 0; i <
upCount; i++) {
314 cout <<
"\t\t2."<<
Im.
b<<
"."<<i<<
" -> Status "<< (
portsArray[i]!=
nullptr?
"ON":
"OFF") << endl;
318 cout <<
"\tDown neighbours:" << endl;
320 cout <<
"\t\t0."<<
Im.
a<<
"."<<i<<
" -> Status "<< (
portsArray[
upCount+i]!=
nullptr?
"ON":
"OFF") << endl;
324 cout <<
"\tNo entries stored" << endl;
326 cout <<
"Stored entries " <<
table.size() << endl;
327 for(
auto & e :
table) {
328 cout <<
"\t\t"<< e.first <<
" -- ";
329 if(e.second.entryType == 0) {
330 cout <<
"Unreachable";
332 switch (e.second.entryType) {
333 case 1: cout <<
"UP - ";
break;
334 case 2: cout <<
"DOWN - ";
break;
335 case 3: cout <<
"BOTH - ";
break;
337 if(e.second.inverseStorage) {
338 cout <<
"(inverse) ";
340 cout << e.second.ports.size() <<
" stored ports:";
343 for(
auto &k : e.second.ports) {
344 cout <<
"\t\t\t" << k->getFullPath() << endl;
Register_Class(SimpleDCGenerator)
virtual void refreshCache(Port oldP, Port newP)
bool setNeigh(const DCAddr &n_addr, Port port)
fFWDEntry getFWDEntryUP(const set< int > &pIds)
vector< Port > search(const DCAddr &n_addr)
fFWDEntry getFWDEntryDOWN(const set< int > &pIds)
void setDst(const DCAddr &n_addr, const set< DCAddr > &next)
fFWDEntry getFWDEntryBOTH(const set< int > &pIdsU, const set< int > &pIdsD)
map< DCAddr, fFWDEntry > table