37 upCount = par(
"upCount").longValue();
48 if(
Im == n_addr) {
return vector<Port>(); }
49 if(n_addr.
type < 0 || n_addr.
type > 3) {
50 cerr <<
"Invalid dst addr ("<<n_addr<<
")" << endl;
51 return vector<Port>();
54 auto r =
table.find(n_addr);
55 if(r !=
table.end()) {
57 if(e.entryType == 0) {
return vector<Port>(); }
61 int i = (e.entryType != 2)? 0:
upCount;
65 if(e.inverseStorage == (e.ports.find(p) == e.ports.end()) ) {
80 }
else { cerr <<
"!!!" << endl; }
85 if(n_addr.
b ==
Im.
a) {
91 }
else { cerr <<
"!!!" << endl; }
96 return vector<Port>();
100 bool invalid =
false;
115 cerr <<
"Invalid neighbour ("<<n_addr<<
") found for Spine " <<
Im<<endl;
120 if(n_addr.
type == 1){
122 if(t == port) {
return true; }
126 if(t == port) {
return true; }
133 for(
int i = 0; i<
upCount; i++) {
149 for(
auto & e :
table) {
150 if(!e.second.ports.empty()) {
151 if(e.second.ports.find(t) != e.second.ports.end()) {
152 e.second.ports.erase(t);
153 if(port !=
nullptr) {
154 e.second.ports.insert(port);
164 if(n_addr ==
Im) {
return; }
166 if(n_addr.
type < 0 || n_addr.
type > 3) {
167 cerr <<
"Invalid dst addr ("<<n_addr<<
")" << endl;
178 set<int> upIds, downIds;
179 for(
const auto & n : next) {
182 }
else if(n.type == 3) {
186 int upS = upIds.size();
187 int downS = downIds.size();
189 if(upS == 0 && downS == 0) {
194 bool defaultEntry =
false;
195 switch(n_addr.
type) {
210 if(n_addr.
b ==
Im.
a) {
241 for(
int i = 0; i<
upCount; i++) {
268 for(
int i = 0; i<
upCount; i++) {
282 if(par(
"printAtEnd").boolValue()) {
283 cout <<
"-----------------------" << endl;
284 cout <<
"SimpleSpineForwarding at "<< endl;
285 cout <<
" " << getFullPath() << endl;
287 cout <<
"I'm Spine "<<
Im << endl;
289 cout <<
"\tUp neighbours:" << endl;
290 for(
int i = 0; i <
upCount; i++) {
291 cout <<
"\t\t2."<<
Im.
b<<
"."<<i<<
" -> Status "<< (
portsArray[i]!=
nullptr?
"ON":
"OFF") << endl;
295 cout <<
"\tDown neighbours:" << endl;
297 cout <<
"\t\t0."<<
Im.
a<<
"."<<i<<
" -> Status "<< (
portsArray[
upCount+i]!=
nullptr?
"ON":
"OFF") << endl;
301 cout <<
"\tNo entries stored" << endl;
303 cout <<
"Stored entries " <<
table.size() << endl;
304 for(
auto & e :
table) {
305 cout <<
"\t\t"<< e.first <<
" -- ";
306 if(e.second.entryType == 0) {
307 cout <<
"Unreachable";
309 switch (e.second.entryType) {
310 case 1: cout <<
"UP - ";
break;
311 case 2: cout <<
"DOWN - ";
break;
312 case 3: cout <<
"BOTH - ";
break;
314 if(e.second.inverseStorage) {
315 cout <<
"(inverse) ";
317 cout << e.second.ports.size() <<
" stored ports:";
320 for(
auto &k : e.second.ports) {
321 cout <<
"\t\t\t" << k->getFullPath() << endl;
void setDst(const DCAddr &n_addr, const set< DCAddr > &next)
Register_Class(SimpleDCGenerator)
virtual void refreshCache(Port oldP, Port newP)
bool setNeigh(const DCAddr &n_addr, Port port)
map< DCAddr, sFWDEntry > table
sFWDEntry getFWDEntryUP(const set< int > &pIds)
sFWDEntry getFWDEntryDOWN(const set< int > &pIds)
vector< Port > search(const DCAddr &n_addr)
sFWDEntry getFWDEntryBOTH(const set< int > &pIdsU, const set< int > &pIdsD)