- MMS server: add function to ignore client requests (for test purposes)

v1.6_develop_387
Michael Zillgith 3 years ago
parent 398d06684a
commit 6895d8214b

@ -38,7 +38,6 @@ Memory_malloc(size_t size)
return memory;
}
void*
Memory_calloc(size_t nmemb, size_t size)
{
@ -50,7 +49,6 @@ Memory_calloc(size_t nmemb, size_t size)
return memory;
}
void *
Memory_realloc(void *ptr, size_t size)
{
@ -67,4 +65,3 @@ Memory_free(void* memb)
{
free(memb);
}

@ -3,7 +3,7 @@
*
* IEC 61850 server API for libiec61850.
*
* Copyright 2013-2022 Michael Zillgith
* Copyright 2013-2023 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -783,6 +783,14 @@ typedef void (*IedConnectionIndicationHandler) (IedServer self, ClientConnection
LIB61850_API void
IedServer_setConnectionIndicationHandler(IedServer self, IedConnectionIndicationHandler handler, void* parameter);
/**
* \brief Ignore all requests from clients
*
* \param self the instance of IedServer to configure.
* \param enable when true all requests from clients will be ignored
*/
void
IedServer_ignoreClientRequests(IedServer self, bool enable);
/**@}*/

@ -1,7 +1,7 @@
/*
* ied_server.c
*
* Copyright 2013-2022 Michael Zillgith
* Copyright 2013-2023 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -1909,3 +1909,11 @@ IedServer_setTimeQuality(IedServer self, bool leapSecondKnown, bool clockFailure
self->timeQuality = timeQuality;
}
void
IedServer_ignoreClientRequests(IedServer self, bool enable)
{
if (self->mmsServer) {
MmsServer_ignoreClientRequests(self->mmsServer, enable);
}
}

@ -1,24 +1,24 @@
/*
* asn1_ber_primitive_value.c
*
* Copyright 2013-2020 Michael Zillgith
* Copyright 2013-2022 Michael Zillgith
*
* This file is part of libIEC61850.
* This file is part of libIEC61850.
*
* libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
*
* See COPYING file for the complete license text.
* See COPYING file for the complete license text.
*/
#include "libiec61850_platform_includes.h"

@ -1,7 +1,7 @@
/*
* ber_decoder.c
*
* Copyright 2013 Michael Zillgith
* Copyright 2013-2022 Michael Zillgith
*
* This file is part of libIEC61850.
*

@ -1,7 +1,7 @@
/*
* ber_encoder.c
*
* Copyright 2013 Michael Zillgith
* Copyright 2013-2022 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -356,6 +356,28 @@ BerEncoder_UInt32determineEncodedSize(uint32_t value)
return size;
}
int
BerEncoder_Int32determineEncodedSize(int32_t value)
{
uint8_t* valueArray = (uint8_t*) &value;
uint8_t valueBuffer[5];
valueBuffer[0] = 0;
int i;
for (i = 0; i < 4; i++) {
valueBuffer[i + 1] = valueArray[i];
}
#if (ORDER_LITTLE_ENDIAN == 1)
BerEncoder_revertByteOrder(valueBuffer + 1, 4);
#endif
int size = BerEncoder_compressInteger(valueBuffer, 5);
return size;
}
int
BerEncoder_determineLengthSize(uint32_t length)
{
@ -457,7 +479,6 @@ BerEncoder_encodeOIDToBuffer(const char* oidString, uint8_t* buffer, int maxBufL
requiredBytes--;
}
}
}
return encodedBytes;

@ -1,7 +1,7 @@
/*
* ber_integer.c
*
* Copyright 2013-2020 Michael Zillgith
* Copyright 2013-2022 Michael Zillgith
*
* This file is part of libIEC61850.
*

@ -1,7 +1,7 @@
/*
* mms_server.h
*
* Copyright 2013-2018 Michael Zillgith
* Copyright 2013-2023 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -370,6 +370,9 @@ MmsServerConnection_getLocalAddress(MmsServerConnection self);
LIB61850_INTERNAL void*
MmsServerConnection_getSecurityToken(MmsServerConnection self);
LIB61850_INTERNAL void
MmsServer_ignoreClientRequests(MmsServer self, bool enable);;
/**@}*/
#ifdef __cplusplus

@ -135,7 +135,8 @@ struct sMmsServer {
Map openConnections;
Map valueCaches;
bool isLocked;
bool blockRequests;
ByteBuffer* transmitBuffer; /* global buffer for encoding reports, delayed responses... */
#if (CONFIG_MMS_THREADLESS_STACK != 1)

@ -1,7 +1,7 @@
/*
* mms_server_libinternal.h
*
* Copyright 2013-2022 Michael Zillgith
* Copyright 2013-2023 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -196,7 +196,7 @@ MmsServer_getConnectionCounter(MmsServer self);
LIB61850_INTERNAL void
MmsServer_stopListeningThreadless(MmsServer self);
LIB61850_INTERNAL const char*
LIB61850_INTERNAL const char*
MmsServer_getFilesystemBasepath(MmsServer self);
#endif /* MMS_SERVER_LIBINTERNAL_H_ */

@ -1,7 +1,7 @@
/*
* mms_server.c
*
* Copyright 2013-2020 Michael Zillgith
* Copyright 2013-2023 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -95,13 +95,13 @@ MmsServer_create(MmsDevice* device, TLSConfiguration tlsConfiguration)
if (self->valueCaches == NULL)
goto exit_error;
self->isLocked = false;
self->transmitBuffer = ByteBuffer_create(NULL, CONFIG_MMS_MAXIMUM_PDU_SIZE);
if (self->transmitBuffer == NULL)
goto exit_error;
self->blockRequests = false;
#if (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1)
self->fileServiceEnabled = true;
self->dynamicVariableListServiceEnabled = true;
@ -820,4 +820,8 @@ MmsServer_getFilesystemBasepath(MmsServer self)
#endif
}
void
MmsServer_ignoreClientRequests(MmsServer self, bool enable)
{
self->blockRequests = enable;
}

@ -665,6 +665,9 @@ handleConfirmedResponsePdu(
static inline void
MmsServerConnection_parseMessage(MmsServerConnection self, ByteBuffer* message, ByteBuffer* response)
{
if (self->server->blockRequests)
return;
uint8_t* buffer = message->buffer;
if (message->size < 2)

Loading…
Cancel
Save