- 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; return memory;
} }
void* void*
Memory_calloc(size_t nmemb, size_t size) Memory_calloc(size_t nmemb, size_t size)
{ {
@ -50,7 +49,6 @@ Memory_calloc(size_t nmemb, size_t size)
return memory; return memory;
} }
void * void *
Memory_realloc(void *ptr, size_t size) Memory_realloc(void *ptr, size_t size)
{ {
@ -67,4 +65,3 @@ Memory_free(void* memb)
{ {
free(memb); free(memb);
} }

@ -3,7 +3,7 @@
* *
* IEC 61850 server API for libiec61850. * IEC 61850 server API for libiec61850.
* *
* Copyright 2013-2022 Michael Zillgith * Copyright 2013-2023 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *
@ -783,6 +783,14 @@ typedef void (*IedConnectionIndicationHandler) (IedServer self, ClientConnection
LIB61850_API void LIB61850_API void
IedServer_setConnectionIndicationHandler(IedServer self, IedConnectionIndicationHandler handler, void* parameter); 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 * ied_server.c
* *
* Copyright 2013-2022 Michael Zillgith * Copyright 2013-2023 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *
@ -1909,3 +1909,11 @@ IedServer_setTimeQuality(IedServer self, bool leapSecondKnown, bool clockFailure
self->timeQuality = timeQuality; self->timeQuality = timeQuality;
} }
void
IedServer_ignoreClientRequests(IedServer self, bool enable)
{
if (self->mmsServer) {
MmsServer_ignoreClientRequests(self->mmsServer, enable);
}
}

@ -1,7 +1,7 @@
/* /*
* asn1_ber_primitive_value.c * 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.
* *

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

@ -1,7 +1,7 @@
/* /*
* ber_encoder.c * ber_encoder.c
* *
* Copyright 2013 Michael Zillgith * Copyright 2013-2022 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *
@ -356,6 +356,28 @@ BerEncoder_UInt32determineEncodedSize(uint32_t value)
return size; 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 int
BerEncoder_determineLengthSize(uint32_t length) BerEncoder_determineLengthSize(uint32_t length)
{ {
@ -457,7 +479,6 @@ BerEncoder_encodeOIDToBuffer(const char* oidString, uint8_t* buffer, int maxBufL
requiredBytes--; requiredBytes--;
} }
} }
} }
return encodedBytes; return encodedBytes;

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

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

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

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

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

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

Loading…
Cancel
Save