Classes | Public Member Functions | Protected Member Functions | Protected Attributes

SimpleClassifier Class Reference

#include <SimpleClassifier.h>

Inheritance diagram for SimpleClassifier:
IScriptable IRSVPClassifier IClassifier

List of all members.

Classes

struct  FECEntry

Public Member Functions

 SimpleClassifier ()

Protected Member Functions

virtual void initialize (int stage)
virtual int numInitStages () const
virtual void handleMessage (cMessage *msg)
virtual void processCommand (const cXMLElement &node)
virtual bool lookupLabel (IPDatagram *ipdatagram, LabelOpVector &outLabel, std::string &outInterface, int &color)
virtual void bind (const SessionObj_t &session, const SenderTemplateObj_t &sender, int inLabel)
virtual void readTableFromXML (const cXMLElement *fectable)
virtual void readItemFromXML (const cXMLElement *fec)
std::vector< FECEntry >::iterator findFEC (int fecid)

Protected Attributes

IPAddress routerId
int maxLabel
std::vector< FECEntrybindings
LIBTablelt
RSVPrsvp

Detailed Description

TODO documentation

Definition at line 34 of file SimpleClassifier.h.


Constructor & Destructor Documentation

SimpleClassifier::SimpleClassifier (  )  [inline]

Definition at line 59 of file SimpleClassifier.h.

{}


Member Function Documentation

void SimpleClassifier::bind ( const SessionObj_t &  session,
const SenderTemplateObj_t &  sender,
int  inLabel 
) [protected, virtual]

Implements IRSVPClassifier.

Definition at line 93 of file SimpleClassifier.cc.

{
    std::vector<FECEntry>::iterator it;
    for (it = bindings.begin(); it != bindings.end(); it++)
    {
        if (it->session != session)
            continue;

        if (it->sender != sender)
            continue;

        it->inLabel = inLabel;
    }
}

std::vector< SimpleClassifier::FECEntry >::iterator SimpleClassifier::findFEC ( int  fecid  )  [protected]

Definition at line 213 of file SimpleClassifier.cc.

Referenced by readItemFromXML().

{
    std::vector<FECEntry>::iterator it;
    for (it = bindings.begin(); it != bindings.end(); it++)
    {
        if (it->id != fecid)
            continue;

        break;
    }
    return it;
}

void SimpleClassifier::handleMessage ( cMessage *  msg  )  [protected, virtual]

Definition at line 48 of file SimpleClassifier.cc.

{
    ASSERT(false);
}

void SimpleClassifier::initialize ( int  stage  )  [protected, virtual]

Definition at line 25 of file SimpleClassifier.cc.

{
    // we have to wait until routerId gets assigned in stage 3
    if (stage!=4)
        return;

    maxLabel = 0;

    RoutingTableAccess routingTableAccess;
    IRoutingTable *rt = routingTableAccess.get();
    routerId = rt->getRouterId();

    LIBTableAccess libTableAccess;
    lt = libTableAccess.get();

    RSVPAccess rsvpAccess;
    rsvp = rsvpAccess.get();

    readTableFromXML(par("conf").xmlValue());

    WATCH_VECTOR(bindings);
}

bool SimpleClassifier::lookupLabel ( IPDatagram *  ipdatagram,
LabelOpVector outLabel,
std::string &  outInterface,
int &  color 
) [protected, virtual]

The ipdatagram argument is an input parameter, the rest (outLabel, outInterface, color) are output parameters only.

In subclasses, this function should be implemented to determine the forwarding equivalence class for the IP datagram passed, and map it to an outLabel and outInterface.

The color parameter (which can be set to an arbitrary value) will only be used for the NAM trace if one will be recorded.

Implements IClassifier.

Definition at line 55 of file SimpleClassifier.cc.

{
    // never label OSPF(TED) and RSVP traffic

    switch(ipdatagram->getTransportProtocol())
    {
        case IP_PROT_OSPF:
        case IP_PROT_RSVP:
            return false;

        default:
            ;
    }

    // forwarding decision for non-labeled datagrams

    std::vector<FECEntry>::iterator it;
    for (it = bindings.begin(); it != bindings.end(); it++)
    {
        if (!it->dest.isUnspecified() && !it->dest.equals(ipdatagram->getDestAddress()))
            continue;

        if (!it->src.isUnspecified() && !it->src.equals(ipdatagram->getSrcAddress()))
            continue;

        EV << "packet belongs to fecid=" << it->id << endl;

        if (it->inLabel < 0)
            return false;

        return lt->resolveLabel("", it->inLabel, outLabel, outInterface, color);
    }

    return false;
}

virtual int SimpleClassifier::numInitStages (  )  const [inline, protected, virtual]

Definition at line 63 of file SimpleClassifier.h.

{return 5;}

void SimpleClassifier::processCommand ( const cXMLElement &  node  )  [protected, virtual]

Definition at line 110 of file SimpleClassifier.cc.

{
    if (!strcmp(node.getTagName(), "bind-fec"))
    {
        readItemFromXML(&node);
    }
    else
        ASSERT(false);
}

void SimpleClassifier::readItemFromXML ( const cXMLElement *  fec  )  [protected, virtual]

Definition at line 133 of file SimpleClassifier.cc.

Referenced by processCommand(), and readTableFromXML().

{
    ASSERT(fec);
    ASSERT(!strcmp(fec->getTagName(), "fecentry") || !strcmp(fec->getTagName(), "bind-fec"));

    int fecid = getParameterIntValue(fec, "id");

    std::vector<FECEntry>::iterator it = findFEC(fecid);

    if (getUniqueChildIfExists(fec, "label"))
    {
        // bind-fec to label
        checkTags(fec, "id label destination source");

        EV << "binding to a given label" << endl;

        FECEntry newFec;

        newFec.id = fecid;
        newFec.dest = getParameterIPAddressValue(fec, "destination");
        newFec.src = getParameterIPAddressValue(fec, "source", IPAddress());

        newFec.inLabel = getParameterIntValue(fec, "label");

        if (it == bindings.end())
        {
            // create new binding
            bindings.push_back(newFec);
        }
        else
        {
            // update existing binding
            *it = newFec;
        }
    }
    else if (getUniqueChildIfExists(fec, "lspid"))
    {
        // bind-fec to LSP
        checkTags(fec, "id destination source tunnel_id extended_tunnel_id endpoint lspid");

        EV << "binding to a given path" << endl;

        FECEntry newFec;

        newFec.id = fecid;
        newFec.dest = getParameterIPAddressValue(fec, "destination");
        newFec.src = getParameterIPAddressValue(fec, "source", IPAddress());

        newFec.session.Tunnel_Id = getParameterIntValue(fec, "tunnel_id");
        newFec.session.Extended_Tunnel_Id = getParameterIPAddressValue(fec, "extened_tunnel_id", routerId).getInt();
        newFec.session.DestAddress = getParameterIPAddressValue(fec, "endpoint", newFec.dest); // ??? always use newFec.dest ???

        newFec.sender.Lsp_Id = getParameterIntValue(fec, "lspid");
        newFec.sender.SrcAddress = routerId;

        newFec.inLabel = rsvp->getInLabel(newFec.session, newFec.sender);

        if (it == bindings.end())
        {
            // create new binding
            bindings.push_back(newFec);
        }
        else
        {
            // update existing binding
            *it = newFec;
        }
    }
    else
    {
        // un-bind
        checkTags(fec, "id");

        if (it != bindings.end())
        {
            bindings.erase(it);
        }
    }
}

void SimpleClassifier::readTableFromXML ( const cXMLElement *  fectable  )  [protected, virtual]

Definition at line 123 of file SimpleClassifier.cc.

Referenced by initialize().

{
    ASSERT(fectable);
    ASSERT(!strcmp(fectable->getTagName(), "fectable"));
    checkTags(fectable, "fecentry");
    cXMLElementList list = fectable->getChildrenByTagName("fecentry");
    for (cXMLElementList::iterator it=list.begin(); it != list.end(); it++)
        readItemFromXML(*it);
}


Member Data Documentation

std::vector<FECEntry> SimpleClassifier::bindings [protected]

Definition at line 54 of file SimpleClassifier.h.

Referenced by bind(), findFEC(), initialize(), lookupLabel(), and readItemFromXML().

Definition at line 55 of file SimpleClassifier.h.

Referenced by initialize(), and lookupLabel().

int SimpleClassifier::maxLabel [protected]

Definition at line 52 of file SimpleClassifier.h.

Referenced by initialize().

Definition at line 51 of file SimpleClassifier.h.

Referenced by initialize(), and readItemFromXML().

Definition at line 56 of file SimpleClassifier.h.

Referenced by initialize(), and readItemFromXML().


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