17 #include "QuManager.h"
21 using namespace forest;
38 int maxNode = 100000;
int maxLink = 10000;
39 int maxRtr = 5000;
int maxCtl = 200;
46 cerr <<
"buildTables: cannot read input\n";
56 cerr <<
"buildTables: could not build interface table "
57 <<
"for router " << r << endl;
60 string iftName = rName +
"/ift";
61 ofstream ifts; ifts.open(iftName.c_str());
63 cerr <<
"buildTables:: can't open interface table\n";
67 ifts << ifTbl->
toString(s); ifts.close();
71 if (!buildLinkTable(r,
net, *lnkTbl)) {
72 cerr <<
"buildTables: could not build link table "
73 <<
"for router " << r << endl;
76 string ltName = rName +
"/lt";
77 ofstream lts; lts.open(ltName.c_str());
79 cerr <<
"buildTables:: can't open link table\n";
82 lts << lnkTbl->
toString(s); lts.close();
88 cerr <<
"buildTables: could not build comtree table "
89 <<
"for router " << r << endl;
92 string cttName = rName +
"/ctt";
93 ofstream ctts; ctts.open(cttName.c_str());
95 cerr <<
"buildTables:: can't open comtree table\n";
98 ctts << comtTbl->
toString(s); ctts.close();
100 delete lnkTbl;
delete comtTbl;
105 for (
int i = 1; i <= net.
getNumIf(r); i++) {
106 if (!net.
validIf(r,i))
continue;
121 for (
int i = 1; i <= net.
getNumIf(r); i++) {
122 if (!net.
validIf(r,i))
continue;
123 pair<int,int> leafRange; net.
getIfLinks(r,i,leafRange);
124 if (llnk >= leafRange.first &&
125 llnk <= leafRange.second) {
133 for (
int i = 1; i <= net.
getNumIf(peer); i++) {
134 if (!net.
validIf(peer,i))
continue;
135 pair<int,int> leafRange;
137 if (plnk >= leafRange.first &&
138 plnk <= leafRange.second) {
139 peerIface = i;
break;
147 lt.
addEntry(llnk, peerIp, peerPort, 0);
148 lt.setIface(llnk,iface);
167 int ctRoot = comtrees.
getRoot(ctx);
168 if (r == ctRoot)
return 0;
170 queue<int> pending; pending.push(ctRoot);
173 for (
int i = 1; i <= net.
getMaxNode(); i++) plink[i] = 0;
175 while (!pending.empty()) {
176 vertex u = pending.front(); pending.pop();
179 if (!comtrees.
isComtLink(ctx,e) || e == plink[u])
continue;
182 cerr <<
"findParentLink: found cycle in "
183 <<
"comtree " << ctx << endl;
186 if (v == r)
return e;
187 pending.push(v); plink[v] = e;
190 cerr <<
"findParentLink: could not find target node " << r
191 <<
" in comtree " << comtrees.
getComtree(ctx) << endl;
204 comtreeSet.insert(ctx);
207 set<int>::iterator p;
208 for (p = comtreeSet.begin(); p != comtreeSet.end(); p++) {
212 cerr <<
"buildComtTable: detected inconsistency "
213 <<
"while building comtree table for router "
214 << r <<
" comtree " << comtrees.
getComtree(ctx)
234 int plink = comtrees.
getPlink(ctx,r);