Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <omnetpp.h>
00020 #include "ProtocolMap.h"
00021
00022
00023 void ProtocolMapping::parseProtocolMapping(const char *s)
00024 {
00025 while (isspace(*s)) s++;
00026
00027 while (*s)
00028 {
00029 Entry entry;
00030
00031 if (!isdigit(*s))
00032 throw cRuntimeError("syntax error: protocol number expected");
00033 entry.protocolNumber = atoi(s);
00034 while (isdigit(*s)) s++;
00035
00036 if (*s++!=':')
00037 throw cRuntimeError("syntax error: colon expected");
00038
00039 while (isspace(*s)) s++;
00040 if (!isdigit(*s))
00041 throw cRuntimeError("syntax error in script: output gate index expected");
00042 entry.outGateIndex = atoi(s);
00043 while (isdigit(*s)) s++;
00044
00045
00046 entries.push_back(entry);
00047
00048
00049 while (isspace(*s)) s++;
00050 if (!*s) break;
00051 if (*s++!=',')
00052 throw cRuntimeError("syntax error: comma expected");
00053 while (isspace(*s)) s++;
00054 }
00055
00056 }
00057
00058 int ProtocolMapping::getOutputGateForProtocol(int protocol)
00059 {
00060 for (Entries::iterator i=entries.begin();i!=entries.end();++i)
00061 if (i->protocolNumber==protocol)
00062 return i->outGateIndex;
00063 opp_error("No output gate defined in protocolMapping for protocol number %d", protocol);
00064 return -1;
00065 }
00066