Skip to content

Commit

Permalink
Merge branch 'inet-framework:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
aarizaq authored Oct 15, 2024
2 parents 53d95ae + 1cd9b16 commit cf8fc15
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/chart-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
echo "::endgroup::"
echo "::group::Installing Python packages"
python3 -m pip install --upgrade matplotlib numpy pandas seaborn scipy ipython posix-ipc cppyy sewar dask distributed optimparallel
python3 -m pip install --upgrade matplotlib numpy pandas seaborn scipy ipython posix-ipc cppyy sewar dask distributed optimparallel --break-system-packages
echo "::endgroup::"
source $GITHUB_WORKSPACE/inet/_scripts/github/build-inet.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/statistical-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
echo "::endgroup::"
echo "::group::Installing Python packages"
python3 -m pip install --upgrade matplotlib numpy pandas seaborn scipy ipython posix-ipc cppyy sewar dask distributed optimparallel
python3 -m pip install --upgrade matplotlib numpy pandas seaborn scipy ipython posix-ipc cppyy sewar dask distributed optimparallel --break-system-packages
echo "::endgroup::"
source $GITHUB_WORKSPACE/inet/_scripts/github/build-inet.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
echo "::endgroup::"
echo "::group::Installing Python packages"
python3 -m pip install --upgrade matplotlib numpy pandas seaborn scipy ipython posix-ipc cppyy sewar dask distributed optimparallel
python3 -m pip install --upgrade matplotlib numpy pandas seaborn scipy ipython posix-ipc cppyy sewar dask distributed optimparallel --break-system-packages
echo "::endgroup::"
source $GITHUB_WORKSPACE/inet/_scripts/github/build-inet.sh
Expand Down
4 changes: 3 additions & 1 deletion python/inet/common/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TaskResult:
result are the result, reason and error_message.
"""

def __init__(self, task=None, result="DONE", expected_result="DONE", reason=None, error_message=None, exception=None, store_complete_binary_hash=False, store_complete_source_hash=False, store_partial_binary_hash=False, store_partial_source_hash=False, elapsed_wall_time=None, possible_results=["DONE", "SKIP", "CANCEL", "ERROR"], possible_result_colors=[COLOR_GREEN, COLOR_CYAN, COLOR_CYAN, COLOR_RED], **kwargs):
def __init__(self, task=None, result="DONE", expected_result="DONE", reason=None, stdout=None, stderr=None, error_message=None, exception=None, store_complete_binary_hash=False, store_complete_source_hash=False, store_partial_binary_hash=False, store_partial_source_hash=False, elapsed_wall_time=None, possible_results=["DONE", "SKIP", "CANCEL", "ERROR"], possible_result_colors=[COLOR_GREEN, COLOR_CYAN, COLOR_CYAN, COLOR_RED], **kwargs):
"""
Initializes a new task result object.
Expand Down Expand Up @@ -96,6 +96,8 @@ def __init__(self, task=None, result="DONE", expected_result="DONE", reason=None
self.expected_result = expected_result
self.expected = expected_result == result
self.reason = reason
self.stdout = stdout
self.stderr = stderr
self.error_message = error_message
self.exception = exception
self.elapsed_wall_time = elapsed_wall_time
Expand Down
3 changes: 2 additions & 1 deletion python/inet/test/opp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ def run_protected(self, capture_output=True, **kwargs):
args = [executable, "runtest", self.test_file_name]
subprocess_result = subprocess.run(args, cwd=self.working_directory, capture_output=capture_output, env=self.simulation_project.get_env())
stdout = subprocess_result.stdout.decode("utf-8")
stderr = subprocess_result.stderr.decode("utf-8")
match = re.search(r"Aggregate result: (\w+)", stdout)
if subprocess_result.returncode == signal.SIGINT.value or subprocess_result.returncode == -signal.SIGINT.value:
return self.task_result_class(self, result="CANCEL", reason="Cancel by user")
elif match and subprocess_result.returncode == 0:
return self.task_result_class(self, result=match.group(1))
else:
return self.task_result_class(self, result="FAIL", reason=f"Non-zero exit code: {subprocess_result.returncode}")
return self.task_result_class(self, result="FAIL", reason=f"Non-zero exit code: {subprocess_result.returncode}", stdout=stdout, stderr=stderr)

def get_opp_test_tasks(test_folder, simulation_project=None, filter=".*", full_match=False, **kwargs):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/inet/applications/netperfmeter/NetPerfMeter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ void NetPerfMeter::sendDataOfSaturatedStreams(const unsigned long long bytesAvai
if (SendingAllowed) {
// ====== SCTP tells current queue occupation for each stream =========
unsigned long long contingent;
unsigned long long queued[ActualOutboundStreams];
unsigned long long *queued = new unsigned long long[ActualOutboundStreams];
if (sendQueueAbatedIndication == nullptr) {
// At the moment, the actual queue size is unknown.
// => Assume it to be bytesAvailableInQueue.
Expand Down Expand Up @@ -1075,6 +1075,7 @@ void NetPerfMeter::sendDataOfSaturatedStreams(const unsigned long long bytesAvai
LastStreamID = (LastStreamID + 1) % ActualOutboundStreams;
} while (LastStreamID != startStreamID);
} while ((newlyQueuedBytes < bytesAvailableInQueue) && (progress == true));
delete [] queued;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/inet/applications/sctpapp/SctpNatPeer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void SctpNatPeer::handleMessage(cMessage *msg)
if (rendezvous) {
const auto& smsg = message->peekDataAsBytes();
int bufferlen = B(smsg->getChunkLength()).get();
uint8_t buffer[bufferlen];
uint8_t *buffer = new uint8_t[bufferlen];
std::vector<uint8_t> vec = smsg->getBytes();
for (int i = 0; i < bufferlen; i++) {
buffer[i] = vec[i];
Expand All @@ -372,6 +372,7 @@ void SctpNatPeer::handleMessage(cMessage *msg)
}
peerPort = nat->portPeer2;
delete msg;
delete [] buffer;
}
else {
auto j = rcvdBytesPerAssoc.find(id);
Expand Down
3 changes: 2 additions & 1 deletion src/inet/applications/sctpapp/SctpNatServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void SctpNatServer::handleMessage(cMessage *msg)
id = ind->getSocketId();
const auto& smsg = message->peekDataAsBytes();
int bufferlen = B(smsg->getChunkLength()).get();
uint8_t buffer[bufferlen];
uint8_t *buffer = new uint8_t[bufferlen];
std::vector<uint8_t> vec = smsg->getBytes();
for (int i = 0; i < bufferlen; i++) {
buffer[i] = vec[i];
Expand Down Expand Up @@ -358,6 +358,7 @@ void SctpNatServer::handleMessage(cMessage *msg)
printNatVector();

delete msg;
delete [] buffer;
break;
}

Expand Down
3 changes: 2 additions & 1 deletion src/inet/applications/voipstream/VoipStreamReceiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ void VoipStreamReceiver::Connection::writeLostSamples(int sampleCount)
{
int pktBytes = sampleCount * av_get_bytes_per_sample(decCtx->sample_fmt);
if (outFile.isOpen()) {
uint8_t decBuf[pktBytes];
uint8_t *decBuf = new uint8_t[pktBytes];
memset(decBuf, 0, pktBytes);
outFile.write(decBuf, pktBytes);
delete [] decBuf;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/inet/emulation/linklayer/ethernet/ExtEthernetSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ void ExtEthernetSocket::handleMessage(cMessage *message)
socket_address.sll_addr[4] = macAddress.getAddressByte(4);
socket_address.sll_addr[5] = macAddress.getAddressByte(5);

uint8_t buffer[packet->getByteLength()];
size_t bufferSize = packet->getByteLength();
uint8_t *buffer = new uint8_t[bufferSize];
auto bytesChunk = packet->peekAllAsBytes();
size_t packetLength = bytesChunk->copyToBuffer(buffer, sizeof(buffer));
size_t packetLength = bytesChunk->copyToBuffer(buffer, bufferSize);
ASSERT(packetLength == (size_t)packet->getByteLength());

int sent = sendto(fd, buffer, packetLength, 0, (struct sockaddr *)&socket_address, sizeof(socket_address));
Expand All @@ -81,6 +82,7 @@ void ExtEthernetSocket::handleMessage(cMessage *message)

numSent++;
delete packet;
delete [] buffer;
}

void ExtEthernetSocket::refreshDisplay() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void ExtEthernetTapDevice::handleMessage(cMessage *msg)
const auto& ethHeader = packet->peekAtFront<EthernetMacHeader>();
packet->popAtBack<EthernetFcs>(ETHER_FCS_BYTES);
auto bytesChunk = packet->peekDataAsBytes();
uint8_t buffer[packet->getByteLength() + 4];
uint8_t *buffer = new uint8_t[packet->getByteLength() + 4];
buffer[0] = 0;
buffer[1] = 0;
buffer[2] = 0x86; // Ethernet
Expand All @@ -78,6 +78,7 @@ void ExtEthernetTapDevice::handleMessage(cMessage *msg)
else
EV_ERROR << "Sending Ethernet packet FAILED! (sendto returned " << nwrite << " (" << strerror(errno) << ") instead of " << packetLength << ").\n";
delete packet;
delete [] buffer;
}

void ExtEthernetTapDevice::refreshDisplay() const
Expand Down
3 changes: 2 additions & 1 deletion src/inet/emulation/networklayer/ipv4/ExtIpv4TunDevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void ExtIpv4TunDevice::handleMessage(cMessage *msg)
throw cRuntimeError("Accepts IPv4 packets only");
const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
auto bytesChunk = packet->peekDataAsBytes();
uint8_t buffer[packet->getByteLength()];
uint8_t *buffer = new uint8_t[packet->getByteLength()];
size_t packetLength = bytesChunk->copyToBuffer(buffer, packet->getByteLength());
ASSERT(packetLength == (size_t)packet->getByteLength());
ssize_t nwrite = write(fd, buffer, packetLength);
Expand All @@ -74,6 +74,7 @@ void ExtIpv4TunDevice::handleMessage(cMessage *msg)
else
EV_ERROR << "Sending IPv4 packet FAILED! (sendto returned " << nwrite << " (" << strerror(errno) << ") instead of " << packetLength << ").\n";
delete packet;
delete [] buffer;
}

void ExtIpv4TunDevice::refreshDisplay() const
Expand Down
3 changes: 2 additions & 1 deletion src/inet/emulation/transportlayer/udp/ExtLowerUdp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void ExtLowerUdp::processPacketFromUpper(Packet *packet)
else {
auto socket = it->second;
auto bytesChunk = packet->peekAllAsBytes();
uint8_t buffer[packet->getByteLength()];
uint8_t *buffer = new uint8_t[packet->getByteLength()];
size_t packetLength = bytesChunk->copyToBuffer(buffer, packet->getByteLength());
ASSERT(packetLength == (size_t)packet->getByteLength());
if (auto addressReq = packet->findTag<L3AddressReq>()) {
Expand All @@ -279,6 +279,7 @@ void ExtLowerUdp::processPacketFromUpper(Packet *packet)
throw cRuntimeError("Calling send failed: %d", n);
}
emit(packetSentSignal, packet);
delete [] buffer;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/inet/networklayer/ipv4/Ipv4HeaderSerializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ const Ptr<Chunk> Ipv4HeaderSerializer::deserialize(MemoryInputStream& stream) co
{
auto position = stream.getPosition();
B bufsize = stream.getRemainingLength();
uint8_t buffer[B(IPv4_MIN_HEADER_LENGTH).get()];
uint8_t *buffer = new uint8_t[B(IPv4_MIN_HEADER_LENGTH).get()];
stream.readBytes(buffer, IPv4_MIN_HEADER_LENGTH);
auto ipv4Header = makeShared<Ipv4Header>();
const struct ip& iphdr = *static_cast<const struct ip *>((void *)&buffer);
const struct ip& iphdr = *static_cast<const struct ip *>((void *)buffer);
B totalLength, headerLength;

ipv4Header->setVersion(iphdr.ip_v);
Expand Down Expand Up @@ -198,7 +198,7 @@ const Ptr<Chunk> Ipv4HeaderSerializer::deserialize(MemoryInputStream& stream) co

ipv4Header->setCrc(ntohs(iphdr.ip_sum));
ipv4Header->setCrcMode(CRC_COMPUTED);

delete [] buffer;
return ipv4Header;
}

Expand Down
10 changes: 6 additions & 4 deletions src/inet/transportlayer/sctp/SctpAssociationUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,8 @@ inline static bool writeCompressedValue(uint8_t *outputBuffer,

static uint32_t compressGaps(const SctpGapList *gapList, const SctpGapList::GapType type, size_t& space)
{
uint8_t compressedDataBuffer[1 + 6 * gapList->getNumGaps(type)]; // Worst-case size
size_t compressedDataBufferSize = 1 + 6 * gapList->getNumGaps(type);
uint8_t *compressedDataBuffer = new uint8_t[compressedDataBufferSize]; // Worst-case size

size_t outputPos = 0;
unsigned int entriesWritten = 0;
Expand All @@ -1448,8 +1449,8 @@ static uint32_t compressGaps(const SctpGapList *gapList, const SctpGapList::GapT
const uint16_t startOffset = gapList->getGapStart(type, i) - last;
const uint16_t stopOffset = gapList->getGapStop(type, i) - gapList->getGapStart(type, i);
const size_t lastOutputPos = outputPos;
if ((writeCompressedValue((uint8_t *)&compressedDataBuffer, sizeof(compressedDataBuffer), outputPos, startOffset) == false) ||
(writeCompressedValue((uint8_t *)&compressedDataBuffer, sizeof(compressedDataBuffer), outputPos, stopOffset) == false) ||
if ((writeCompressedValue(compressedDataBuffer, compressedDataBufferSize, outputPos, startOffset) == false) ||
(writeCompressedValue(compressedDataBuffer, compressedDataBufferSize, outputPos, stopOffset) == false) ||
(outputPos + 1 > space))
{
outputPos = lastOutputPos;
Expand All @@ -1458,9 +1459,10 @@ static uint32_t compressGaps(const SctpGapList *gapList, const SctpGapList::GapT
entriesWritten++;
last = gapList->getGapStop(type, i);
}
ASSERT(writeCompressedValue((uint8_t *)&compressedDataBuffer, sizeof(compressedDataBuffer), outputPos, 0x00) == true);
ASSERT(writeCompressedValue(compressedDataBuffer, compressedDataBufferSize, outputPos, 0x00) == true);
space = outputPos;

delete [] compressedDataBuffer;
return entriesWritten;
}

Expand Down
6 changes: 4 additions & 2 deletions src/inet/transportlayer/sctp/SctpHeaderSerializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1124,11 +1124,11 @@ const Ptr<Chunk> SctpHeaderSerializer::deserialize(MemoryInputStream& stream) co

// auto position = stream.getPosition();
int bufsize = B(stream.getRemainingLength()).get();
uint8_t buffer[bufsize];
uint8_t *buffer = new uint8_t[bufsize];
stream.readBytes(buffer, B(bufsize));
auto dest = makeShared<SctpHeader>();

struct common_header *common_header = (struct common_header *)((void *)&buffer);
struct common_header *common_header = (struct common_header *)((void *)buffer);
int32_t tempChecksum = common_header->checksum;
common_header->checksum = 0;
int32_t chksum = SctpChecksum::checksum((unsigned char *)common_header, bufsize);
Expand Down Expand Up @@ -1156,6 +1156,7 @@ const Ptr<Chunk> SctpHeaderSerializer::deserialize(MemoryInputStream& stream) co
int32_t chunkType = chunk->type;
woPadding = ntohs(chunk->length);
if (woPadding == 0) {
delete [] buffer;
return dest;
}
cLen = ADD_PADDING(woPadding);
Expand Down Expand Up @@ -2147,6 +2148,7 @@ const Ptr<Chunk> SctpHeaderSerializer::deserialize(MemoryInputStream& stream) co
chunkPtr += cLen;
} // end of while()
EV_INFO << "SctpSerializer - pkt info - " << B(dest->getChunkLength()).get() << " bytes" << endl;
delete [] buffer;
return dest;
}

Expand Down
5 changes: 3 additions & 2 deletions src/inet/transportlayer/tcp_common/TcpHeaderSerializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ void TcpHeaderSerializer::serializeOption(MemoryOutputStream& stream, const TcpO
const Ptr<Chunk> TcpHeaderSerializer::deserialize(MemoryInputStream& stream) const
{
auto position = stream.getPosition();
uint8_t buffer[B(TCP_MIN_HEADER_LENGTH).get()];
uint8_t *buffer = new uint8_t[B(TCP_MIN_HEADER_LENGTH).get()];
stream.readBytes(buffer, TCP_MIN_HEADER_LENGTH);
auto tcpHeader = makeShared<TcpHeader>();
const struct tcphdr& tcp = *static_cast<const struct tcphdr *>((void *)&buffer);
const struct tcphdr& tcp = *static_cast<const struct tcphdr *>((void *)buffer);
ASSERT(B(sizeof(tcp)) == TCP_MIN_HEADER_LENGTH);

// fill Tcp header structure
Expand Down Expand Up @@ -194,6 +194,7 @@ const Ptr<Chunk> TcpHeaderSerializer::deserialize(MemoryInputStream& stream) con
tcpHeader->setHeaderLength(headerLength);
tcpHeader->setCrc(ntohs(tcp.th_sum));
tcpHeader->setCrcMode(CRC_COMPUTED);
delete [] buffer;
return tcpHeader;
}

Expand Down

0 comments on commit cf8fc15

Please sign in to comment.