diff --git a/bin/inet_diffingerprints b/bin/inet_diffingerprints index 81b31b17e95..1eee6232e5c 100755 --- a/bin/inet_diffingerprints +++ b/bin/inet_diffingerprints @@ -3,57 +3,49 @@ import sys import re def computeUniqueFingerprints(fingerprints): - i = 0 uniqueFingerprints = list() - while i < len(fingerprints): - fingerprint = fingerprints[i] - j = i - while (j < len(fingerprints)) and (fingerprint == fingerprints[j]): - j = j + 1 - uniqueFingerprints.append([j-1, fingerprint]) - i = j + for i in range(1, len(fingerprints)): + fingerprint = fingerprints[i-1] + if (fingerprints[i][1] != fingerprint[1]): + uniqueFingerprints.append(fingerprint) + if fingerprints: + uniqueFingerprints.append(fingerprints[-1]) return uniqueFingerprints def readFingerprints1(eventlogFile): "RegExp version" - regExp = re.compile(r"^E # ([0-9]+) t ((?:[0-9]*\.)?[0-9]+) m [0-9]+ ce [0-9]+ msg [0-9]+ f (?:\"([^\"]*)\"|(\S+))$") + regExp = re.compile(r"^E # ([0-9]+) t ((?:[0-9]*\.)?[0-9]+) m [0-9]+ ce -?[0-9]+ msg -?[0-9]+ f (?:\"([^\"]*)\"|(\S+))$") fingerprints = list() for line in eventlogFile: match = regExp.match(line) if match: fingerprint = match.group(3) if match.group(3) else match.group(4) - fingerprints.append(fingerprint) + fingerprints.append([match.group(1), fingerprint]) return fingerprints def isNewEvent(line): return len(line) >= 4 and line[0:4] == "E # " -def getFingerprint(line): - n = len(line) - 1 - return line[(n-14):(n-5)] - -def readFingerprints2(eventlogFile): - fingerprints = list() - eventlogFile.readline() # skip the first line - for line in eventlogFile: - if isNewEvent(line): - fingerprint = getFingerprint(line) - fingerprints.append(fingerprint) - return fingerprints - def diffingerprint(elog1Fingerprints, elog2Fingerprints): - minSize = min(len(elog1Fingerprints), len(elog2Fingerprints)) - 1 + minSize = min(len(elog1Fingerprints), len(elog2Fingerprints)) for i in range(0,minSize): elog1Fingerprint = elog1Fingerprints[i] elog2Fingerprint = elog2Fingerprints[i] if elog1Fingerprint[1] != elog2Fingerprint[1]: return "Diff elog1: " + str(elog1Fingerprint[0]) + " fingerprint = " + elog1Fingerprint[1] + ", elog2: " + str(elog2Fingerprint[0]) + " fingerprint = " + elog2Fingerprint[1] + if len(elog1Fingerprints) > minSize: + elog1Fingerprint = elog1Fingerprints[i] + return "The elog1 fingerprint list longer than elog2, last equals: elog1: " + str(elog1Fingerprint[0]) + " fingerprint = " + elog1Fingerprint[1] + ", elog2: " + str(elog2Fingerprint[0]) + " fingerprint = " + elog2Fingerprint[1] + elif len(elog2Fingerprints) > minSize: + elog2Fingerprint = elog2Fingerprints[i] + return "The elog2 fingerprint list longer than elog1, last equals: elog1: " + str(elog1Fingerprint[0]) + " fingerprint = " + elog1Fingerprint[1] + ", elog2: " + str(elog2Fingerprint[0]) + " fingerprint = " + elog2Fingerprint[1] return "No differences" elog1FilePath = sys.argv[1] elog2FilePath = sys.argv[2] +print(elog1FilePath) elog1File = open(elog1FilePath) elog2File = open(elog2FilePath) uniqueElog1Fingerprints = computeUniqueFingerprints(readFingerprints1(elog1File)) @@ -62,4 +54,3 @@ print(diffingerprint(uniqueElog1Fingerprints, uniqueElog2Fingerprints)) elog1File.close() elog2File.close() - diff --git a/bin/inet_fingerprinttest b/bin/inet_fingerprinttest index bcf341b733f..6640d259bb9 100755 --- a/bin/inet_fingerprinttest +++ b/bin/inet_fingerprinttest @@ -44,6 +44,7 @@ writeOutfile = True useColors = sys.stdout.isatty() defaultFingerprintCalculator = 'inet::FingerprintCalculator' +defaultExecutable = "inet" txtPASS = "PASS" txtPASS_unexpected = "PASS (unexpected)" @@ -798,7 +799,7 @@ if __name__ == "__main__": parser.add_argument('-x', '--exclude', action='append', metavar='regex', help='Negative line filter: a line (more precisely, workingdir+SPACE+args) must NOT match any of the regular expressions in order for that test case to be run') parser.add_argument('-t', '--threads', type=int, default=defaultNumThreads, help='number of parallel threads (default: number of CPUs, currently '+str(defaultNumThreads)+')') parser.add_argument('-r', '--repeat', type=int, default=1, help='number of repeating each test (default: 1)') - parser.add_argument('-e', '--executable', default='inet', help='Determines which binary to execute (e.g. opp_run_dbg, opp_run_release) if the command column in the CSV file does not specify one.') + parser.add_argument('-e', '--executable', default=defaultExecutable, help='Determines which binary to execute (e.g. opp_run_dbg, opp_run_release) if the command column in the CSV file does not specify one.') parser.add_argument('-C', '--directory', help='Change to DIRECTORY before executing the tests. Working dirs in the CSV files are relative to this.') parser.add_argument('-d', '--debug', action='store_true', help='Run debug executables: use the debug version of the executable (appends _dbg to the executable name)') parser.add_argument('-s', '--release', action='store_true', help='Run release executables: use the release version of the executable (appends _release to the executable name)') diff --git a/python/requirements.txt b/python/requirements.txt index ff022ae72a6..01d8617a457 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -5,3 +5,7 @@ distributed >=2024.10.0 optimparallel >=0.1.3 sewar >=0.4.6 py4j >=0.10.9 + + +matplotlib +pandas diff --git a/src/inet/clock/common/ClockEvent.h b/src/inet/clock/common/ClockEvent.h index 393aa7574b1..b98f45379ec 100644 --- a/src/inet/clock/common/ClockEvent.h +++ b/src/inet/clock/common/ClockEvent.h @@ -4,38 +4,4 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // - -#ifndef __INET_COMMON_CLOCKEVENT_H -#define __INET_COMMON_CLOCKEVENT_H - #include "inet/clock/common/ClockEvent_m.h" - -namespace inet { - -class ClockBase; - -class INET_API ClockEvent : public ClockEvent_Base -{ - friend ClockBase; - - protected: - virtual void execute() override; - - void callBaseExecute() { ClockEvent_Base::execute(); } - - public: - ClockEvent(const char *name = nullptr, short kind = 0) : ClockEvent_Base(name, kind) {} - ClockEvent(const ClockEvent& other) : ClockEvent_Base(other) {} - - ClockEvent& operator=(const ClockEvent& other) { - if (this == &other) return *this; - ClockEvent_Base::operator=(other); - return *this; - } - virtual ClockEvent *dup() const override { return new ClockEvent(*this); } -}; - -} // namespace inet - -#endif - diff --git a/src/inet/clock/common/ClockEvent.msg b/src/inet/clock/common/ClockEvent.msg index 52b54aca40f..e8ef7186bbb 100644 --- a/src/inet/clock/common/ClockEvent.msg +++ b/src/inet/clock/common/ClockEvent.msg @@ -10,6 +10,10 @@ import inet.clock.contract.IClock; namespace inet; +cplusplus {{ +class ClockBase; +}} + enum OverdueClockEventHandlingMode { UNSPECIFIED = -1; EXECUTE = 0; @@ -19,9 +23,16 @@ enum OverdueClockEventHandlingMode { message ClockEvent { - @customize; IClock *clock; bool relative = false; clocktime_t arrivalClockTime = -1; OverdueClockEventHandlingMode overdueClockEventHandlingMode = UNSPECIFIED; } + +cplusplus(ClockEvent) {{ + friend ClockBase; + + protected: + virtual void execute() override; + void callBaseExecute() { cMessage::execute(); } +}} diff --git a/src/inet/common/INETDefs.h b/src/inet/common/INETDefs.h index db83f4062e5..4841c83a573 100644 --- a/src/inet/common/INETDefs.h +++ b/src/inet/common/INETDefs.h @@ -35,7 +35,7 @@ using namespace omnetpp; # error At least OMNeT++/OMNEST version 6.0 required #endif -#define INET_VERSION 0x0405 +#define INET_VERSION 0x0406 #define INET_PATCH_LEVEL 0x00 #if defined(INET_EXPORT) diff --git a/src/inet/linklayer/ethernet/base/EthernetModes.cc b/src/inet/linklayer/ethernet/base/EthernetModes.cc index 9732b08e4cc..547051551f5 100644 --- a/src/inet/linklayer/ethernet/base/EthernetModes.cc +++ b/src/inet/linklayer/ethernet/base/EthernetModes.cc @@ -120,6 +120,15 @@ const EthernetModes::EthernetMode EthernetModes::ethernetModes[NUM_OF_ETHERNETMO B(0), 0, 0 + }, + { + EIGHTHUNDRED_GIGABIT_ETHERNET_TXRATE, + 0, + B(0), + B(-1), // half-duplex is not supported + B(0), + 0, + 0 } }; diff --git a/src/inet/linklayer/ethernet/base/EthernetModes.h b/src/inet/linklayer/ethernet/base/EthernetModes.h index d4c3f38bd3b..d6baf9ae63e 100644 --- a/src/inet/linklayer/ethernet/base/EthernetModes.h +++ b/src/inet/linklayer/ethernet/base/EthernetModes.h @@ -34,7 +34,7 @@ class INET_API EthernetModes protected: enum { - NUM_OF_ETHERNETMODES = 11 + NUM_OF_ETHERNETMODES = 12 }; // MAC constants for bitrates and modes diff --git a/src/inet/linklayer/ethernet/basic/EthernetMacPhy.cc b/src/inet/linklayer/ethernet/basic/EthernetMacPhy.cc index 1eff8106350..fa308efa53f 100644 --- a/src/inet/linklayer/ethernet/basic/EthernetMacPhy.cc +++ b/src/inet/linklayer/ethernet/basic/EthernetMacPhy.cc @@ -30,6 +30,12 @@ EthernetMacPhy::EthernetMacPhy() { } +EthernetMacPhy::~EthernetMacPhy() +{ + cancelAndDelete(endRxTimer); + delete currentRxSignal; +} + void EthernetMacPhy::initialize(int stage) { EthernetMacBase::initialize(stage); @@ -55,8 +61,14 @@ void EthernetMacPhy::initializeFlags() { EthernetMacBase::initializeFlags(); + // read parameters + emitReceptionStarted = par("emitReceptionStarted"); + if (emitReceptionStarted) { + endRxTimer = new cMessage("EndReception", ENDRECEPTION); + setTxUpdateSupport(true); + } duplexMode = true; - physInGate->setDeliverImmediately(false); + physInGate->setDeliverImmediately(emitReceptionStarted); } void EthernetMacPhy::handleMessageWhenUp(cMessage *msg) @@ -68,8 +80,27 @@ void EthernetMacPhy::handleMessageWhenUp(cMessage *msg) handleSelfMessage(msg); else if (msg->getArrivalGateId() == upperLayerInGateId) handleUpperPacket(check_and_cast(msg)); - else if (msg->getArrivalGate() == physInGate) - processMsgFromNetwork(check_and_cast(msg)); + else if (msg->getArrivalGate() == physInGate) { + Signal *signal = check_and_cast(msg); + if (emitReceptionStarted) { + if (signal->isUpdate()) { + EV_DETAIL << "Rx update: " << signal << endl; + ASSERT(endRxTimer->isScheduled() && currentRxSignal != nullptr); + rescheduleAfter(signal->getRemainingDuration(), endRxTimer); + } + else { + EV_DETAIL << "Rx start: " << signal << endl; + ASSERT(!endRxTimer->isScheduled()); + simtime_t remainingDuration = signal->getRemainingDuration(); + scheduleAfter(remainingDuration, endRxTimer); + emit(receptionStartedSignal, signal); + } + currentRxSignal = signal; + } + else { + processMsgFromNetwork(signal); + } + } else throw cRuntimeError("Message received from unknown gate!"); processAtHandleMessageFinished(); @@ -85,6 +116,12 @@ void EthernetMacPhy::handleSelfMessage(cMessage *msg) handleEndIFGPeriod(); else if (msg == endPauseTimer) handleEndPausePeriod(); + else if (msg == endRxTimer) { + EV_DETAIL << "Rx end: " << currentRxSignal << endl; + processMsgFromNetwork(currentRxSignal); + currentRxSignal = nullptr; + processAtHandleMessageFinished(); + } else throw cRuntimeError("Unknown self message received!"); } diff --git a/src/inet/linklayer/ethernet/basic/EthernetMacPhy.h b/src/inet/linklayer/ethernet/basic/EthernetMacPhy.h index 75f298a2c0e..1af0ca6f751 100644 --- a/src/inet/linklayer/ethernet/basic/EthernetMacPhy.h +++ b/src/inet/linklayer/ethernet/basic/EthernetMacPhy.h @@ -22,6 +22,7 @@ class INET_API EthernetMacPhy : public EthernetMacBase { public: EthernetMacPhy(); + virtual ~EthernetMacPhy(); // IActivePacketSink: virtual void handleCanPullPacketChanged(const cGate *gate) override; @@ -52,6 +53,15 @@ class INET_API EthernetMacPhy : public EthernetMacBase virtual void scheduleEndPausePeriod(int pauseUnits); virtual void beginSendFrames(); + // parameter values + bool emitReceptionStarted = false; + + // self messages + cMessage *endRxTimer = nullptr; + + // other variables + Signal *currentRxSignal = nullptr; + // statistics simtime_t totalSuccessfulRxTime; // total duration of successful transmissions on channel }; diff --git a/src/inet/linklayer/ethernet/basic/EthernetMacPhy.ned b/src/inet/linklayer/ethernet/basic/EthernetMacPhy.ned index ebd0836508b..4e1c4679204 100644 --- a/src/inet/linklayer/ethernet/basic/EthernetMacPhy.ned +++ b/src/inet/linklayer/ethernet/basic/EthernetMacPhy.ned @@ -115,6 +115,7 @@ module EthernetMacPhy extends Module like IEtherMac bool duplexMode; // Must be set to "true", as EthernetMacPhy does not support half-duplex operation // (parameter is present to reduce the risk of accidental misconfiguration) bool allowNonstandardBitrate = default(false); // Allows any bitrate and uses the first larger bitrate specified parameters + bool emitReceptionStarted = default(false); int mtu @unit(B) = default(1500B); string fcsMode @enum("declared", "computed"); @lifecycleSupport; @@ -137,6 +138,7 @@ module EthernetMacPhy extends Module like IEtherMac @signal[receptionStateChanged](type=long); // Enum=MacReceiveState @signal[transmissionStarted](type=inet::physicallayer::EthernetSignalBase); @signal[transmissionEnded](type=inet::physicallayer::EthernetSignalBase); + @signal[receptionStarted](type=inet::physicallayer::Signal); @signal[receptionEnded](type=inet::physicallayer::Signal); @statistic[transmitting](title="transmitting state"; type=int; source=count(transmissionStarted) - count(transmissionEnded); record=vector; interpolationmode=sample-hold); diff --git a/src/inet/linklayer/ethernet/common/Ethernet.h b/src/inet/linklayer/ethernet/common/Ethernet.h index 2da521b5937..dd9d7bf0e86 100644 --- a/src/inet/linklayer/ethernet/common/Ethernet.h +++ b/src/inet/linklayer/ethernet/common/Ethernet.h @@ -38,6 +38,7 @@ const b INTERFRAME_GAP_BITS = b(96); #define HUNDRED_GIGABIT_ETHERNET_TXRATE 100000000000.0 /* 100 Gbit/sec (in bit/s) */ #define TWOHUNDRED_GIGABIT_ETHERNET_TXRATE 200000000000.0 /* 200 Gbit/sec (in bit/s) */ #define FOURHUNDRED_GIGABIT_ETHERNET_TXRATE 400000000000.0 /* 400 Gbit/sec (in bit/s) */ +#define EIGHTHUNDRED_GIGABIT_ETHERNET_TXRATE 800000000000.0 /* 800 Gbit/sec (in bit/s) */ #define MAX_ATTEMPTS 16 #define BACKOFF_RANGE_LIMIT 10 diff --git a/src/inet/routing/eigrp/messages/EigrpMessage.msg b/src/inet/routing/eigrp/messages/EigrpMessage.msg index 558d0e82b94..17ec89841f4 100644 --- a/src/inet/routing/eigrp/messages/EigrpMessage.msg +++ b/src/inet/routing/eigrp/messages/EigrpMessage.msg @@ -260,7 +260,6 @@ struct EigrpMsgRoute // Message request message EigrpMsgReq { - @customize(true); int8_t opcode; // Type of message bool goodbyeMsg = false; // Message is Hello goodbye @@ -279,3 +278,9 @@ message EigrpMsgReq int numOfAck; // Number of acknowledges EigrpMsgRoute routes[]; }; + +cplusplus(EigrpMsgReq) {{ + public: + bool isMsgReliable() { return getOpcode() != EIGRP_HELLO_MSG; } + int findMsgRoute(int routeId) const; +}} diff --git a/src/inet/routing/eigrp/messages/EigrpMsgReq.h b/src/inet/routing/eigrp/messages/EigrpMsgReq.h index 6d3785b535f..c45b4b3324b 100644 --- a/src/inet/routing/eigrp/messages/EigrpMsgReq.h +++ b/src/inet/routing/eigrp/messages/EigrpMsgReq.h @@ -10,24 +10,5 @@ * @author Vladimir Vesely (ivesely@fit.vutbr.cz) * @copyright Brno University of Technology (www.fit.vutbr.cz) under GPLv3 */ -#ifndef __INET_EIGRPMSGREQ_H -#define __INET_EIGRPMSGREQ_H #include "inet/routing/eigrp/messages/EigrpMessage_m.h" -namespace inet { -class INET_API EigrpMsgReq : public EigrpMsgReq_Base -{ - public: - EigrpMsgReq(const char *name = nullptr) : EigrpMsgReq_Base(name) {} - EigrpMsgReq(const EigrpMsgReq& other) : EigrpMsgReq_Base(other) {} - EigrpMsgReq& operator=(const EigrpMsgReq& other) - { EigrpMsgReq_Base::operator=(other); return *this; } - virtual EigrpMsgReq *dup() const { return new EigrpMsgReq(*this); } - bool isMsgReliable() { return getOpcode() != EIGRP_HELLO_MSG; } - int findMsgRoute(int routeId) const; -}; - -//Register_Class(EigrpMsgReq); -} // namespace inet -#endif - diff --git a/src/inet/transportlayer/sctp/SctpHeader.cc b/src/inet/transportlayer/sctp/SctpHeader.cc index 0e844f90ecc..cc8173f2e7c 100644 --- a/src/inet/transportlayer/sctp/SctpHeader.cc +++ b/src/inet/transportlayer/sctp/SctpHeader.cc @@ -13,55 +13,13 @@ namespace inet { namespace sctp { -Register_Class(SctpHeader); - -SctpHeader& SctpHeader::operator=(const SctpHeader& other) -{ - if (this == &other) - return *this; - clean(); - SctpHeader_Base::operator=(other); - copy(other); - return *this; -} - -void SctpHeader::copy(const SctpHeader& other) -{ -// handleChange(); - setVTag(other.getVTag()); - setSrcPort(other.getSrcPort()); - setDestPort(other.getDestPort()); - setChecksumOk(other.getChecksumOk()); - for (const auto& elem : other.sctpChunkList) { - SctpChunk *chunk = (elem)->dup(); - take(chunk); - sctpChunkList.push_back(chunk); - } - ASSERT(getChunkLength().get() == other.getChunkLength().get()); -} - -SctpHeader::~SctpHeader() -{ - clean(); -} - void SctpHeader::clean() { -// handleChange(); - - if (this->getSctpChunksArraySize() > 0) { - auto iterator = sctpChunkList.begin(); - while (iterator != sctpChunkList.end()) { - SctpChunk *chunk = (*iterator); - sctpChunkList.erase(iterator); - drop(chunk); - delete chunk; - } + for (SctpChunk *chunk : sctpChunkList) { + drop(chunk); + delete chunk; } - - /* sctpChunkList.clear(); - setHeaderLength(SCTP_COMMON_HEADER); - setChunkLength(B(SCTP_COMMON_HEADER));*/ + sctpChunkList.clear(); } void SctpHeader::setSctpChunksArraySize(size_t size) @@ -157,27 +115,6 @@ SctpChunk *SctpHeader::peekLastChunk() const return msg; } -Register_Class(SctpErrorChunk); - -SctpErrorChunk& SctpErrorChunk::operator=(const SctpErrorChunk& other) -{ - if (this == &other) - return *this; - clean(); - SctpErrorChunk_Base::operator=(other); - copy(other); - return *this; -} - -void SctpErrorChunk::copy(const SctpErrorChunk& other) -{ - for (const auto& elem : other.parameterList) { - SctpParameter *param = (elem)->dup(); - take(param); - parameterList.push_back(param); - } -} - void SctpErrorChunk::setParametersArraySize(size_t size) { throw cException(this, "setParametersArraySize() not supported, use addParameter()"); @@ -218,11 +155,6 @@ SctpParameter *SctpErrorChunk::removeParameter() return msg; } -SctpErrorChunk::~SctpErrorChunk() -{ - clean(); -} - void SctpErrorChunk::clean() { while (!parameterList.empty()) { @@ -232,28 +164,6 @@ void SctpErrorChunk::clean() } } -Register_Class(SctpStreamResetChunk); - -SctpStreamResetChunk& SctpStreamResetChunk::operator=(const SctpStreamResetChunk& other) -{ - SctpStreamResetChunk_Base::operator=(other); - - this->setByteLength(SCTP_STREAM_RESET_CHUNK_LENGTH); - for (const auto& elem : other.parameterList) - addParameter((elem)->dup()); - - return *this; -} - -void SctpStreamResetChunk::copy(const SctpStreamResetChunk& other) -{ - for (const auto& elem : other.parameterList) { - SctpParameter *param = (elem)->dup(); - take(param); - parameterList.push_back(param); - } -} - void SctpStreamResetChunk::setParametersArraySize(size_t size) { throw cException(this, "setParametersArraySize() not supported, use addParameter()"); @@ -297,11 +207,6 @@ cPacket *SctpStreamResetChunk::removeParameter() return msg; } -SctpStreamResetChunk::~SctpStreamResetChunk() -{ - clean(); -} - void SctpStreamResetChunk::clean() { while (!parameterList.empty()) { @@ -311,29 +216,12 @@ void SctpStreamResetChunk::clean() } } -Register_Class(SctpIncomingSsnResetRequestParameter); - -void SctpIncomingSsnResetRequestParameter::copy(const SctpIncomingSsnResetRequestParameter& other) +void SctpAsconfChunk::clean() { - setSrReqSn(other.getSrReqSn()); - setStreamNumbersArraySize(other.getStreamNumbersArraySize()); - for (uint16_t i = 0; i < other.getStreamNumbersArraySize(); i++) { - setStreamNumbers(i, other.getStreamNumbers(i)); + for (SctpParameter *param : parameterList) { + dropAndDelete(param); } -} - -Register_Class(SctpAsconfChunk); - -SctpAsconfChunk& SctpAsconfChunk::operator=(const SctpAsconfChunk& other) -{ - SctpAsconfChunk_Base::operator=(other); - - this->setByteLength(SCTP_ADD_IP_CHUNK_LENGTH + 8); - this->setAddressParam(other.getAddressParam()); - for (const auto& elem : other.parameterList) - addAsconfParam((elem)->dup()); - - return *this; + parameterList.clear(); } void SctpAsconfChunk::setAsconfParamsArraySize(size_t size) @@ -375,17 +263,12 @@ SctpParameter *SctpAsconfChunk::removeAsconfParam() return msg; } -Register_Class(SctpAsconfAckChunk); - -SctpAsconfAckChunk& SctpAsconfAckChunk::operator=(const SctpAsconfAckChunk& other) +void SctpAsconfAckChunk::clean() { - SctpAsconfAckChunk_Base::operator=(other); - - this->setByteLength(SCTP_ADD_IP_CHUNK_LENGTH); - for (const auto& elem : other.parameterList) - addAsconfResponse((elem)->dup()); - - return *this; + for (SctpParameter *param : parameterList) { + dropAndDelete(param); + } + parameterList.clear(); } void SctpAsconfAckChunk::setAsconfResponseArraySize(size_t size) diff --git a/src/inet/transportlayer/sctp/SctpHeader.h b/src/inet/transportlayer/sctp/SctpHeader.h index 79030d31ec6..497556821cb 100644 --- a/src/inet/transportlayer/sctp/SctpHeader.h +++ b/src/inet/transportlayer/sctp/SctpHeader.h @@ -5,256 +5,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // - -#ifndef __INET_SCTPHEADER_H -#define __INET_SCTPHEADER_H - -#include - #include "inet/common/INETDefs.h" -//#include "inet/transportlayer/contract/ITransportPacket.h" #include "inet/transportlayer/sctp/SctpHeader_m.h" - -namespace inet { -namespace sctp { - -/** - * Represents an SCTP Message. More info in the SctpHeader.msg file - * (and the documentation generated from it). - */ -class INET_API SctpHeader : public SctpHeader_Base -{ - protected: - typedef std::vector SctpChunkList; - SctpChunkList sctpChunkList; - - private: - void copy(const SctpHeader& other); - void clean(); - - public: - SctpHeader() : SctpHeader_Base() {} - SctpHeader(const SctpHeader& other) : SctpHeader_Base(other) { copy(other); } - ~SctpHeader(); - SctpHeader& operator=(const SctpHeader& other); - virtual SctpHeader *dup() const override { return new SctpHeader(*this); } - - virtual void setSctpChunksArraySize(size_t size) override; - - virtual void setSctpChunks(size_t k, SctpChunk *sctpChunks) override; - /** - * Returns the number of chunks in this SCTP packet - */ - virtual size_t getSctpChunksArraySize() const override; - - /** - * Returns the kth chunk in this SCTP packet - */ -// virtual SctpChunk *getSctpChunks(size_t k) const override; - - virtual const SctpChunk *getSctpChunks(size_t k) const override { return sctpChunkList.at(k); } - - /** - * Adds a message object to the SCTP packet. The packet length will be adjusted - */ - virtual void appendSctpChunks(SctpChunk *sctpChunks) override; - using SctpHeader_Base::insertSctpChunks; - virtual void insertSctpChunks(size_t k, SctpChunk *sctpChunks) override; - virtual void eraseSctpChunks(size_t k) override {} - virtual void replaceSctpChunk(SctpChunk *msg, uint32_t k); - -// virtual void addChunk(SctpChunk * chunk); - - /** - * Removes and returns the first message object in this SCTP packet. - */ - virtual SctpChunk *removeFirstChunk(); - virtual SctpChunk *removeLastChunk(); - virtual SctpChunk *peekFirstChunk() const; - virtual SctpChunk *peekLastChunk() const; - - virtual unsigned int getSourcePort() const override { return SctpHeader_Base::getSrcPort(); } - virtual void setSourcePort(unsigned int port) override { SctpHeader_Base::setSrcPort(port); } - virtual unsigned int getDestinationPort() const override { return SctpHeader_Base::getDestPort(); } - virtual void setDestinationPort(unsigned int port) override { SctpHeader_Base::setDestPort(port); } -}; - -class INET_API SctpErrorChunk : public SctpErrorChunk_Base -{ - protected: - std::vector parameterList; - - private: - void copy(const SctpErrorChunk& other); - void clean(); - - public: - SctpErrorChunk(const char *name = nullptr, int32_t kind = 0) : SctpErrorChunk_Base() {}; - SctpErrorChunk(const SctpErrorChunk& other) : SctpErrorChunk_Base(other) { copy(other); }; - SctpErrorChunk& operator=(const SctpErrorChunk& other); - ~SctpErrorChunk(); - - virtual SctpErrorChunk *dup() const override { return new SctpErrorChunk(*this); } - virtual void setParametersArraySize(size_t size) override; - virtual size_t getParametersArraySize() const override; - /** Generated but unused method, should not be called. */ - virtual void setParameters(size_t k, SctpParameter *parameters) override; - - virtual void appendParameters(SctpParameter *parameters) override { throw cRuntimeError("Unimplemented function"); } - using SctpErrorChunk_Base::insertParameters; - virtual void insertParameters(size_t k, SctpParameter *parameters) override { throw cRuntimeError("Unimplemented function"); } - virtual void eraseParameters(size_t k) override { throw cRuntimeError("Unimplemented function"); } - /** - * Returns the kth parameter in this SCTP Error Chunk - */ - virtual SctpParameter *getParameters(size_t k) const override; -// virtual cPacketPtr& getParameters(uint32_t k) override; - - /** - * Adds a message object to the SCTP packet. The packet length will be adjusted - */ - virtual void addParameters(SctpParameter *msg); - - /** - * Removes and returns the first message object in this SCTP packet. - */ - virtual SctpParameter *removeParameter(); -}; - -class INET_API SctpStreamResetChunk : public SctpStreamResetChunk_Base -{ - protected: - std::vector parameterList; - - private: - void copy(const SctpStreamResetChunk& other); - void clean(); - - public: - SctpStreamResetChunk(const char *name = nullptr, int32_t kind = 0) : SctpStreamResetChunk_Base() {}; - SctpStreamResetChunk(const SctpStreamResetChunk& other) : SctpStreamResetChunk_Base(other) { operator=(other); }; - SctpStreamResetChunk& operator=(const SctpStreamResetChunk& other); - ~SctpStreamResetChunk(); - - virtual SctpStreamResetChunk *dup() const override { return new SctpStreamResetChunk(*this); } - - virtual void setParametersArraySize(size_t size) override; - virtual size_t getParametersArraySize() const override; - - /** Generated but unused method, should not be called. */ - virtual void setParameters(size_t k, SctpParameter *parameters) override; - - virtual void appendParameters(SctpParameter *parameters) override { throw cRuntimeError("Unimplemented function"); } - using SctpStreamResetChunk_Base::insertParameters; - virtual void insertParameters(size_t k, SctpParameter *parameters) override { throw cRuntimeError("Unimplemented function"); } - virtual void eraseParameters(size_t k) override { throw cRuntimeError("Unimplemented function"); } - /** - * Returns the kth parameter in this SCTP Reset Chunk - */ - virtual const SctpParameter *getParameters(size_t k) const override; - - /** - * Adds a message object to the SCTP packet. The packet length will be adjusted - */ - virtual void addParameter(SctpParameter *msg); - - /** - * Removes and returns the first message object in this SCTP packet. - */ - virtual cPacket *removeParameter(); -}; - -class INET_API SctpAsconfChunk : public SctpAsconfChunk_Base -{ - protected: - std::vector parameterList; - - public: - SctpAsconfChunk(const char *name = nullptr, int32_t kind = 0) : SctpAsconfChunk_Base() {}; - SctpAsconfChunk(const SctpAsconfChunk& other) : SctpAsconfChunk_Base(other) { operator=(other); }; - SctpAsconfChunk& operator=(const SctpAsconfChunk& other); - - virtual SctpAsconfChunk *dup() const override { return new SctpAsconfChunk(*this); } - - virtual void setAsconfParamsArraySize(size_t size) override; - virtual size_t getAsconfParamsArraySize() const override; - - /** - * Returns the kth parameter in this SCTP Reset Chunk - */ - virtual const SctpParameter *getAsconfParams(size_t k) const override; - - /** Generated but unused method, should not be called. */ - virtual void setAsconfParams(size_t k, SctpParameter *asconfParams) override; - - virtual void appendAsconfParams(SctpParameter *asconfParams) override { throw cRuntimeError("Unimplemented function"); } - using SctpAsconfChunk_Base::insertAsconfParams; - virtual void insertAsconfParams(size_t k, SctpParameter *asconfParams) override { throw cRuntimeError("Unimplemented function"); } - virtual void eraseAsconfParams(size_t k) override { throw cRuntimeError("Unimplemented function"); } - - /** - * Adds a message object to the SCTP packet. The packet length will be adjusted - */ - virtual void addAsconfParam(SctpParameter *msg); - - /** - * Removes and returns the first message object in this SCTP packet. - */ - virtual SctpParameter *removeAsconfParam(); -}; - -class INET_API SctpIncomingSsnResetRequestParameter : public SctpIncomingSsnResetRequestParameter_Base -{ - private: - void copy(const SctpIncomingSsnResetRequestParameter& other); - - public: - SctpIncomingSsnResetRequestParameter(const char *name = nullptr, int kind = 0) : SctpIncomingSsnResetRequestParameter_Base() {} - SctpIncomingSsnResetRequestParameter(const SctpIncomingSsnResetRequestParameter& other) : SctpIncomingSsnResetRequestParameter_Base(other) { copy(other); } - SctpIncomingSsnResetRequestParameter& operator=(const SctpIncomingSsnResetRequestParameter& other) { if (this == &other) return *this; SctpIncomingSsnResetRequestParameter_Base::operator=(other); copy(other); return *this; } - virtual SctpIncomingSsnResetRequestParameter *dup() const override { return new SctpIncomingSsnResetRequestParameter(*this); } -}; - -class INET_API SctpAsconfAckChunk : public SctpAsconfAckChunk_Base -{ - protected: - std::vector parameterList; - - public: - SctpAsconfAckChunk(const char *name = nullptr, int32_t kind = 0) : SctpAsconfAckChunk_Base() {}; - SctpAsconfAckChunk(const SctpAsconfAckChunk& other) : SctpAsconfAckChunk_Base(other) { operator=(other); }; - SctpAsconfAckChunk& operator=(const SctpAsconfAckChunk& other); - - virtual SctpAsconfAckChunk *dup() const override { return new SctpAsconfAckChunk(*this); } - virtual void setAsconfResponseArraySize(size_t size) override; - virtual size_t getAsconfResponseArraySize() const override; - - /** Generated but unused method, should not be called. */ - virtual void setAsconfResponse(size_t k, SctpParameter *asconfResponse) override; - - virtual void appendAsconfResponse(SctpParameter *asconfResponse) override { throw cRuntimeError("Unimplemented function"); } - using SctpAsconfAckChunk_Base::insertAsconfResponse; - virtual void insertAsconfResponse(size_t k, SctpParameter *asconfResponse) override { throw cRuntimeError("Unimplemented function"); } - virtual void eraseAsconfResponse(size_t k) override { throw cRuntimeError("Unimplemented function"); } - - /** - * Returns the kth parameter in this SCTP Reset Chunk - */ - virtual SctpParameter *getAsconfResponse(size_t k) const override; - - /** - * Adds a message object to the SCTP packet. The packet length will be adjusted - */ - virtual void addAsconfResponse(SctpParameter *msg); - - /** - * Removes and returns the first message object in this SCTP packet. - */ - virtual SctpParameter *removeAsconfResponse(); -}; - -} // namespace sctp -} // namespace inet - -#endif - diff --git a/src/inet/transportlayer/sctp/SctpHeader.msg b/src/inet/transportlayer/sctp/SctpHeader.msg index 7d48de229dd..b96ce7ab7cd 100644 --- a/src/inet/transportlayer/sctp/SctpHeader.msg +++ b/src/inet/transportlayer/sctp/SctpHeader.msg @@ -15,7 +15,6 @@ namespace inet::sctp; class SctpHeader extends TransportHeaderBase { - @customize; // Source Port uint16_t srcPort; // Destination Port @@ -26,8 +25,76 @@ class SctpHeader extends TransportHeaderBase uint32_t checksum = 0; ChecksumMode checksumMode = CHECKSUM_MODE_UNDEFINED; unsigned short headerLength = 12; - abstract SctpChunk *sctpChunks[]; -} + SctpChunk *sctpChunks[] @custom; +} + +cplusplus(SctpHeader) {{ + protected: + std::vector sctpChunkList; + + private: + void clean(); + + public: + virtual void setSctpChunksArraySize(size_t size); + + virtual void setSctpChunks(size_t k, SctpChunk *sctpChunks); + + /** + * Returns the number of chunks in this SCTP packet + */ + virtual size_t getSctpChunksArraySize() const; + + /** + * Returns the kth chunk in this SCTP packet + */ +// virtual SctpChunk *getSctpChunks(size_t k) const override; + + virtual const SctpChunk *getSctpChunks(size_t k) const { return sctpChunkList.at(k); } + + /** + * Adds a message object to the SCTP packet. The packet length will be adjusted + */ + virtual void appendSctpChunks(SctpChunk *sctpChunks); + virtual void insertSctpChunks(size_t k, SctpChunk *sctpChunks); + virtual void eraseSctpChunks(size_t k) {} + virtual void replaceSctpChunk(SctpChunk *msg, uint32_t k); + + /** + * Removes and returns the first message object in this SCTP packet. + */ + virtual SctpChunk *removeFirstChunk(); + virtual SctpChunk *removeLastChunk(); + virtual SctpChunk *peekFirstChunk() const; + virtual SctpChunk *peekLastChunk() const; + + virtual unsigned int getSourcePort() const override { return getSrcPort(); } + virtual void setSourcePort(unsigned int port) override { setSrcPort(port); } + virtual unsigned int getDestinationPort() const override { return getDestPort(); } + virtual void setDestinationPort(unsigned int port) override { setDestPort(port); } +}} + +cplusplus(SctpHeader::copy) {{ + clean(); + for (const auto& elem : other.sctpChunkList) { + SctpChunk *chunk = (elem)->dup(); + take(chunk); + sctpChunkList.push_back(chunk); + } + ASSERT(getChunkLength().get() == other.getChunkLength().get()); +}} + +cplusplus(SctpHeader::~SctpHeader) {{ + clean(); +}} + +cplusplus(SctpHeader::parsimPack) {{ + doParsimPacking(b, sctpChunkList); +}} + +cplusplus(SctpHeader::parsimUnpack) {{ + doParsimUnpacking(b, sctpChunkList); +}} class SctpChunk extends cPacket { @@ -218,11 +285,63 @@ class SctpShutdownCompleteChunk extends SctpChunk class SctpErrorChunk extends SctpChunk { - @customize; bool TBit = 0; bool MBit = 0; - abstract SctpParameter *parameters[]; -} + SctpParameter *parameters[] @custom; +} + +cplusplus(SctpErrorChunk) {{ + protected: + std::vector parameterList; + + private: + void clean(); + + public: + virtual void setParametersArraySize(size_t size); + virtual size_t getParametersArraySize() const; + /** Generated but unused method, should not be called. */ + virtual void setParameters(size_t k, SctpParameter *parameters); + + virtual void appendParameters(SctpParameter *parameters) { throw cRuntimeError("Unimplemented function"); } + virtual void insertParameters(size_t k, SctpParameter *parameters) { throw cRuntimeError("Unimplemented function"); } + virtual void eraseParameters(size_t k) { throw cRuntimeError("Unimplemented function"); } + /** + * Returns the kth parameter in this SCTP Error Chunk + */ + virtual SctpParameter *getParameters(size_t k) const; + + /** + * Adds a message object to the SCTP packet. The packet length will be adjusted + */ + virtual void addParameters(SctpParameter *msg); + + /** + * Removes and returns the first message object in this SCTP packet. + */ + virtual SctpParameter *removeParameter(); +}} + +cplusplus(SctpErrorChunk::copy) {{ + clean(); + for (const auto& elem : other.parameterList) { + SctpParameter *param = (elem)->dup(); + take(param); + parameterList.push_back(param); + } +}} + +cplusplus(SctpErrorChunk::~SctpErrorChunk) {{ + clean(); +}} + +cplusplus(SctpErrorChunk::parsimPack) {{ + doParsimPacking(b, parameterList); +}} + +cplusplus(SctpErrorChunk::parsimUnpack) {{ + doParsimUnpacking(b, parameterList); +}} class SctpParameter extends cPacket { @@ -243,10 +362,63 @@ class SctpPacketDropChunk extends SctpChunk class SctpStreamResetChunk extends SctpChunk { - @customize; - abstract SctpParameter *parameters[]; + SctpParameter *parameters[] @custom; } +cplusplus(SctpStreamResetChunk) {{ + protected: + std::vector parameterList; + + private: + void clean(); + + public: + virtual void setParametersArraySize(size_t size); + virtual size_t getParametersArraySize() const; + + /** Generated but unused method, should not be called. */ + virtual void setParameters(size_t k, SctpParameter *parameters); + + virtual void appendParameters(SctpParameter *parameters) { throw cRuntimeError("Unimplemented function"); } + virtual void insertParameters(size_t k, SctpParameter *parameters) { throw cRuntimeError("Unimplemented function"); } + virtual void eraseParameters(size_t k) { throw cRuntimeError("Unimplemented function"); } + /** + * Returns the kth parameter in this SCTP Reset Chunk + */ + virtual const SctpParameter *getParameters(size_t k) const; + + /** + * Adds a message object to the SCTP packet. The packet length will be adjusted + */ + virtual void addParameter(SctpParameter *msg); + + /** + * Removes and returns the first message object in this SCTP packet. + */ + virtual cPacket *removeParameter(); +}} + +cplusplus(SctpStreamResetChunk::copy) {{ + clean(); + for (const auto& elem : other.parameterList) { + SctpParameter *param = (elem)->dup(); + take(param); + parameterList.push_back(param); + } +}} + +cplusplus(SctpStreamResetChunk::~SctpStreamResetChunk) {{ + clean(); +}} + +cplusplus(SctpStreamResetChunk::parsimPack) {{ + doParsimPacking(b, parameterList); +}} + +cplusplus(SctpStreamResetChunk::parsimUnpack) {{ + doParsimUnpacking(b, parameterList); +}} + class SctpOutgoingSsnResetRequestParameter extends SctpParameter { uint32_t srReqSn; //Stream Reset Request Sequence Number: initialized with the initial TSN, then incremented @@ -257,7 +429,6 @@ class SctpOutgoingSsnResetRequestParameter extends SctpParameter class SctpIncomingSsnResetRequestParameter extends SctpParameter { - @customize; uint32_t srReqSn; //Stream Reset Request Sequence Number uint16_t streamNumbers[]; } @@ -300,19 +471,127 @@ class SctpAuthenticationChunk extends SctpChunk class SctpAsconfChunk extends SctpChunk { - @customize; uint32_t serialNumber; L3Address addressParam; uint32_t peerVTag; //for NAT - abstract SctpParameter *asconfParams[]; + SctpParameter *asconfParams[] @custom; } +cplusplus(SctpAsconfChunk) {{ + protected: + std::vector parameterList; + + private: + void clean(); + + public: + virtual void setAsconfParamsArraySize(size_t size); + virtual size_t getAsconfParamsArraySize() const; + + /** + * Returns the kth parameter in this SCTP Reset Chunk + */ + virtual const SctpParameter *getAsconfParams(size_t k) const; + + /** Generated but unused method, should not be called. */ + virtual void setAsconfParams(size_t k, SctpParameter *asconfParams); + + virtual void appendAsconfParams(SctpParameter *asconfParams) { throw cRuntimeError("Unimplemented function"); } + virtual void insertAsconfParams(size_t k, SctpParameter *asconfParams) { throw cRuntimeError("Unimplemented function"); } + virtual void eraseAsconfParams(size_t k) { throw cRuntimeError("Unimplemented function"); } + + /** + * Adds a message object to the SCTP packet. The packet length will be adjusted + */ + virtual void addAsconfParam(SctpParameter *msg); + + /** + * Removes and returns the first message object in this SCTP packet. + */ + virtual SctpParameter *removeAsconfParam(); +}} + +cplusplus(SctpAsconfChunk::copy) {{ + clean(); + for (const auto& elem : other.parameterList) { + SctpParameter *param = (elem)->dup(); + take(param); + parameterList.push_back(param); + } +}} + +cplusplus(SctpAsconfChunk::~SctpAsconfChunk) {{ + clean(); +}} + +cplusplus(SctpAsconfChunk::parsimPack) {{ + doParsimPacking(b, parameterList); +}} + +cplusplus(SctpAsconfChunk::parsimUnpack) {{ + doParsimUnpacking(b, parameterList); +}} + class SctpAsconfAckChunk extends SctpChunk { - @customize; uint32_t serialNumber; - abstract SctpParameter *asconfResponse[]; -} + SctpParameter *asconfResponse[] @custom; +} + +cplusplus(SctpAsconfAckChunk) {{ + protected: + std::vector parameterList; + + private: + void clean(); + + public: + virtual void setAsconfResponseArraySize(size_t size); + virtual size_t getAsconfResponseArraySize() const; + + /** Generated but unused method, should not be called. */ + virtual void setAsconfResponse(size_t k, SctpParameter *asconfResponse); + + virtual void appendAsconfResponse(SctpParameter *asconfResponse) { throw cRuntimeError("Unimplemented function"); } + virtual void insertAsconfResponse(size_t k, SctpParameter *asconfResponse) { throw cRuntimeError("Unimplemented function"); } + virtual void eraseAsconfResponse(size_t k) { throw cRuntimeError("Unimplemented function"); } + + /** + * Returns the kth parameter in this SCTP Reset Chunk + */ + virtual SctpParameter *getAsconfResponse(size_t k) const; + + /** + * Adds a message object to the SCTP packet. The packet length will be adjusted + */ + virtual void addAsconfResponse(SctpParameter *msg); + + /** + * Removes and returns the first message object in this SCTP packet. + */ + virtual SctpParameter *removeAsconfResponse(); +}} + +cplusplus(SctpAsconfAckChunk::copy) {{ + clean(); + for (const auto& elem : other.parameterList) { + SctpParameter *param = (elem)->dup(); + take(param); + parameterList.push_back(param); + } +}} + +cplusplus(SctpAsconfAckChunk::~SctpAsconfAckChunk) {{ + clean(); +}} + +cplusplus(SctpAsconfAckChunk::parsimPack) {{ + doParsimPacking(b, parameterList); +}} + +cplusplus(SctpAsconfAckChunk::parsimUnpack) {{ + doParsimUnpacking(b, parameterList); +}} class SctpAddIPParameter extends SctpParameter { diff --git a/tests/fingerprint/gen_runallexamples.pl b/tests/fingerprint/gen_runallexamples.pl index e56bdbf482b..985572dbd2f 100755 --- a/tests/fingerprint/gen_runallexamples.pl +++ b/tests/fingerprint/gen_runallexamples.pl @@ -24,18 +24,13 @@ #print "-",join("-\n-",keys(%skiplist)),"-\n"; #die(); -$DN = `dirname $0`; -chomp $DN; -#print "DN='$DN'\n"; +$PROJECT_ROOT=$ENV{'INET_ROOT'}; +chomp $PROJECT_ROOT; +#print "INETROOT='$PROJECT_ROOT'\n"; -chdir "$DN/../.."; +chdir "$PROJECT_ROOT"; -$INETROOT=`pwd`; -chomp $INETROOT; -#print "INETROOT='$INETROOT'\n"; - - -@inifiles = sort `find examples -name '*.ini'`; +@inifiles = sort `find examples -name '*.ini' -type f`; die("Not found ini files\n") if ($#inifiles lt 0);