#include <LIBTable.h>
Classes | |
| struct | LIBEntry |
Public Member Functions | |
| virtual bool | resolveLabel (std::string inInterface, int inLabel, LabelOpVector &outLabel, std::string &outInterface, int &color) |
| virtual int | installLibEntry (int inLabel, std::string inInterface, const LabelOpVector &outLabel, std::string outInterface, int color) |
| virtual void | removeLibEntry (int inLabel) |
Static Public Member Functions | |
| static LabelOpVector | pushLabel (int label) |
| static LabelOpVector | swapLabel (int label) |
| static LabelOpVector | popLabel () |
Protected Member Functions | |
| virtual void | initialize (int stage) |
| virtual int | numInitStages () const |
| virtual void | handleMessage (cMessage *msg) |
| virtual void | readTableFromXML (const cXMLElement *libtable) |
Protected Attributes | |
| IPAddress | routerId |
| int | maxLabel |
| std::vector< LIBEntry > | lib |
TODO documentation
Definition at line 45 of file LIBTable.h.
| void LIBTable::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Definition at line 43 of file LIBTable.cc.
{
ASSERT(false);
}
| void LIBTable::initialize | ( | int | stage | ) | [protected, virtual] |
Definition at line 23 of file LIBTable.cc.
{
if (stage==0)
maxLabel = 0;
// we have to wait until routerId gets assigned in stage 3
if (stage==4)
{
RoutingTableAccess routingTableAccess;
IRoutingTable *rt = routingTableAccess.get();
routerId = rt->getRouterId();
// read configuration
readTableFromXML(par("conf").xmlValue());
WATCH_VECTOR(lib);
}
}
| int LIBTable::installLibEntry | ( | int | inLabel, | |
| std::string | inInterface, | |||
| const LabelOpVector & | outLabel, | |||
| std::string | outInterface, | |||
| int | color | |||
| ) | [virtual] |
Definition at line 70 of file LIBTable.cc.
Referenced by RSVP::commitResv(), LDP::processLABEL_MAPPING(), LDP::processLABEL_REQUEST(), and LDP::updateFecListEntry().
{
if (inLabel == -1)
{
LIBEntry newItem;
newItem.inLabel = ++maxLabel;
newItem.inInterface = inInterface;
newItem.outLabel = outLabel;
newItem.outInterface = outInterface;
newItem.color = color;
lib.push_back(newItem);
return newItem.inLabel;
}
else
{
for (unsigned int i = 0; i < lib.size(); i++)
{
if (lib[i].inLabel != inLabel)
continue;
lib[i].inInterface = inInterface;
lib[i].outLabel = outLabel;
lib[i].outInterface = outInterface;
lib[i].color = color;
return inLabel;
}
ASSERT(false);
return 0; // prevent warning
}
}
| virtual int LIBTable::numInitStages | ( | ) | const [inline, protected, virtual] |
Definition at line 67 of file LIBTable.h.
{return 5;}
| LabelOpVector LIBTable::popLabel | ( | ) | [static] |
Definition at line 196 of file LIBTable.cc.
Referenced by LDP::processLABEL_REQUEST(), and LDP::updateFecListEntry().
{
LabelOpVector vec;
LabelOp lop;
lop.optcode = POP_OPER;
lop.label = 0;
vec.push_back(lop);
return vec;
}
| LabelOpVector LIBTable::pushLabel | ( | int | label | ) | [static] |
Definition at line 176 of file LIBTable.cc.
Referenced by LDP::lookupLabel().
{
LabelOpVector vec;
LabelOp lop;
lop.optcode = PUSH_OPER;
lop.label = label;
vec.push_back(lop);
return vec;
}
| void LIBTable::readTableFromXML | ( | const cXMLElement * | libtable | ) | [protected, virtual] |
Definition at line 115 of file LIBTable.cc.
Referenced by initialize().
{
ASSERT(libtable);
ASSERT(!strcmp(libtable->getTagName(), "libtable"));
checkTags(libtable, "libentry");
cXMLElementList list = libtable->getChildrenByTagName("libentry");
for (cXMLElementList::iterator it=list.begin(); it != list.end(); it++)
{
const cXMLElement& entry = **it;
checkTags(&entry, "inLabel inInterface outLabel outInterface color");
LIBEntry newItem;
newItem.inLabel = getParameterIntValue(&entry, "inLabel");
newItem.inInterface = getParameterStrValue(&entry, "inInterface");
newItem.outInterface = getParameterStrValue(&entry, "outInterface");
newItem.color = getParameterIntValue(&entry, "color", 0);
cXMLElementList ops = getUniqueChild(&entry, "outLabel")->getChildrenByTagName("op");
for (cXMLElementList::iterator oit=ops.begin(); oit != ops.end(); oit++)
{
const cXMLElement& op = **oit;
const char *val = op.getAttribute("value");
const char *code = op.getAttribute("code");
ASSERT(code);
LabelOp l;
if (!strcmp(code, "push"))
{
l.optcode = PUSH_OPER;
ASSERT(val);
l.label = atoi(val);
ASSERT(l.label > 0);
}
else if (!strcmp(code, "pop"))
{
l.optcode = POP_OPER;
ASSERT(!val);
}
else if (!strcmp(code, "swap"))
{
l.optcode = SWAP_OPER;
ASSERT(val);
l.label = atoi(val);
ASSERT(l.label > 0);
}
else
ASSERT(false);
newItem.outLabel.push_back(l);
}
lib.push_back(newItem);
ASSERT(newItem.inLabel > 0);
if (newItem.inLabel > maxLabel)
maxLabel = newItem.inLabel;
}
}
| void LIBTable::removeLibEntry | ( | int | inLabel | ) | [virtual] |
Definition at line 102 of file LIBTable.cc.
Referenced by RSVP::commitResv(), LDP::processLABEL_RELEASE(), LDP::rebuildFecList(), and RSVP::removeRsbFilter().
| bool LIBTable::resolveLabel | ( | std::string | inInterface, | |
| int | inLabel, | |||
| LabelOpVector & | outLabel, | |||
| std::string & | outInterface, | |||
| int & | color | |||
| ) | [virtual] |
Definition at line 48 of file LIBTable.cc.
Referenced by SimpleClassifier::lookupLabel(), and MPLS::processMPLSPacketFromL2().
{
bool any = (inInterface.length() == 0);
for (unsigned int i = 0; i < lib.size(); i++)
{
if (!any && lib[i].inInterface != inInterface)
continue;
if (lib[i].inLabel != inLabel)
continue;
outLabel = lib[i].outLabel;
outInterface = lib[i].outInterface;
color = lib[i].color;
return true;
}
return false;
}
| LabelOpVector LIBTable::swapLabel | ( | int | label | ) | [static] |
Definition at line 186 of file LIBTable.cc.
Referenced by LDP::processLABEL_MAPPING(), LDP::processLABEL_REQUEST(), and LDP::updateFecListEntry().
{
LabelOpVector vec;
LabelOp lop;
lop.optcode = SWAP_OPER;
lop.label = label;
vec.push_back(lop);
return vec;
}
std::vector<LIBEntry> LIBTable::lib [protected] |
Definition at line 63 of file LIBTable.h.
Referenced by initialize(), installLibEntry(), readTableFromXML(), removeLibEntry(), and resolveLabel().
int LIBTable::maxLabel [protected] |
Definition at line 62 of file LIBTable.h.
Referenced by initialize(), installLibEntry(), and readTableFromXML().
IPAddress LIBTable::routerId [protected] |
Definition at line 61 of file LIBTable.h.
Referenced by initialize().
1.7.1