Classes | Public Member Functions | Protected Types | Protected Attributes

ProtocolMapping Class Reference

#include <ProtocolMap.h>

List of all members.

Classes

struct  Entry

Public Member Functions

 ProtocolMapping ()
 ~ProtocolMapping ()
void parseProtocolMapping (const char *s)
int getOutputGateForProtocol (int protocol)

Protected Types

typedef std::vector< EntryEntries

Protected Attributes

Entries entries

Detailed Description

Maps protocol numbers to output gates

Definition at line 28 of file ProtocolMap.h.


Member Typedef Documentation

typedef std::vector<Entry> ProtocolMapping::Entries [protected]

Definition at line 38 of file ProtocolMap.h.


Constructor & Destructor Documentation

ProtocolMapping::ProtocolMapping (  )  [inline]

Definition at line 42 of file ProtocolMap.h.

{}

ProtocolMapping::~ProtocolMapping (  )  [inline]

Definition at line 43 of file ProtocolMap.h.

{}


Member Function Documentation

int ProtocolMapping::getOutputGateForProtocol ( int  protocol  ) 

Definition at line 58 of file ProtocolMap.cc.

Referenced by IPv6::handleReceivedICMP(), IP::handleReceivedICMP(), IPv6::isLocalAddress(), and IP::reassembleAndDeliver().

{
    for (Entries::iterator i=entries.begin();i!=entries.end();++i)
        if (i->protocolNumber==protocol)
            return i->outGateIndex;
    opp_error("No output gate defined in protocolMapping for protocol number %d", protocol);
    return -1;
}

void ProtocolMapping::parseProtocolMapping ( const char *  s  ) 

Definition at line 23 of file ProtocolMap.cc.

Referenced by IPv6::initialize(), and IP::initialize().

{
    while (isspace(*s)) s++;

    while (*s)
    {
        Entry entry;

        if (!isdigit(*s))
            throw cRuntimeError("syntax error: protocol number expected");
        entry.protocolNumber = atoi(s);
        while (isdigit(*s)) s++;

        if (*s++!=':')
            throw cRuntimeError("syntax error: colon expected");

        while (isspace(*s)) s++;
        if (!isdigit(*s))
            throw cRuntimeError("syntax error in script: output gate index expected");
        entry.outGateIndex = atoi(s);
        while (isdigit(*s)) s++;

        // add
        entries.push_back(entry);

        // skip delimiter
        while (isspace(*s)) s++;
        if (!*s) break;
        if (*s++!=',')
            throw cRuntimeError("syntax error: comma expected");
        while (isspace(*s)) s++;
    }

}


Member Data Documentation

Definition at line 39 of file ProtocolMap.h.

Referenced by getOutputGateForProtocol(), and parseProtocolMapping().


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