INET Framework for OMNeT++/OMNEST
LIBTable Class Reference

#include <LIBTable.h>

List of all members.

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< LIBEntrylib

Detailed Description

TODO documentation


Member Function Documentation

void LIBTable::handleMessage ( cMessage *  msg) [protected, virtual]
{
    ASSERT(false);
}
void LIBTable::initialize ( int  stage) [protected, virtual]
{
    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]

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]
{return 5;}
LabelOpVector LIBTable::popLabel ( ) [static]

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]

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]

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]

Referenced by RSVP::commitResv(), LDP::processLABEL_RELEASE(), LDP::rebuildFecList(), and RSVP::removeRsbFilter().

{
    for (unsigned int i = 0; i < lib.size(); i++)
    {
        if (lib[i].inLabel != inLabel)
            continue;

        lib.erase(lib.begin() + i);
        return;
    }
    ASSERT(false);
}
bool LIBTable::resolveLabel ( std::string  inInterface,
int  inLabel,
LabelOpVector outLabel,
std::string &  outInterface,
int &  color 
) [virtual]

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]

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;
}

Member Data Documentation

Referenced by initialize().


The documentation for this class was generated from the following files: