diff --git a/config/stack_config.h b/config/stack_config.h index aec739c3..b63e45e7 100644 --- a/config/stack_config.h +++ b/config/stack_config.h @@ -28,7 +28,7 @@ #define DEBUG_HAL_ETHERNET 0 /* Maximum MMS PDU SIZE - default is 65000 */ -#define CONFIG_MMS_MAXIMUM_PDU_SIZE 120000 +#define CONFIG_MMS_MAXIMUM_PDU_SIZE 65000 /* * Enable single threaded mode @@ -201,13 +201,9 @@ #define MMS_STATUS_SERVICE 1 #define MMS_IDENTIFY_SERVICE 1 #define MMS_FILE_SERVICE 1 -#define MMS_OBTAIN_FILE_SERVICE 1 +#define MMS_OBTAIN_FILE_SERVICE 1 /* requires MMS_FILE_SERVICE */ #endif /* MMS_DEFAULT_PROFILE */ -#if (MMS_WRITE_SERVICE != 1) -#undef CONFIG_IEC61850_CONTROL_SERVICE -#define CONFIG_IEC61850_CONTROL_SERVICE 0 -#endif /* support flat named variable name space required by IEC 61850-8-1 MMS mapping */ #define CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE 1 @@ -227,9 +223,44 @@ /* Support user access to raw messages */ #define CONFIG_MMS_RAW_MESSAGE_LOGGING 1 -/* Allow to set the virtual filestore basepath for MMS file services at runtime with the - * MmsServer_setFilestoreBasepath function +/* Allow to set the virtual file store base path for MMS file services at runtime with the + * MmsServer_setFilestoreBasepath function. */ #define CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME 1 +/************************************************************************************ + * Check configuration for consistency - DO NOT MODIFY THIS PART! + ************************************************************************************/ + +#if (MMS_JOURNAL_SERVICE != 1) + +#if (CONFIG_IEC61850_LOG_SERVICE == 1) +#warning "Invalid configuration: CONFIG_IEC61850_LOG_SERVICE requires MMS_JOURNAL_SERVICE!" +#endif + +#undef CONFIG_IEC61850_LOG_SERVICE +#define CONFIG_IEC61850_LOG_SERVICE 0 + +#endif + +#if (MMS_WRITE_SERVICE != 1) + +#if (CONFIG_IEC61850_CONTROL_SERVICE == 1) +#warning "Invalid configuration: CONFIG_IEC61850_CONTROL_SERVICE requires MMS_WRITE_SERVICE!" +#endif + +#undef CONFIG_IEC61850_CONTROL_SERVICE +#define CONFIG_IEC61850_CONTROL_SERVICE 0 +#endif + +#if (MMS_FILE_SERVICE != 1) + +#if (MMS_OBTAIN_FILE_SERVICE == 1) +#warning "Invalid configuration: MMS_OBTAIN_FILE_SERVICE requires MMS_FILE_SERVICE!" +#endif + +#undef MMS_OBTAIN_FILE_SERVICE +#define MMS_OBTAIN_FILE_SERVICE 0 +#endif + #endif /* STACK_CONFIG_H_ */ diff --git a/config/stack_config.h.cmake b/config/stack_config.h.cmake index 6e9197f7..e6766b47 100644 --- a/config/stack_config.h.cmake +++ b/config/stack_config.h.cmake @@ -198,11 +198,6 @@ #define MMS_OBTAIN_FILE_SERVICE 1 #endif /* MMS_DEFAULT_PROFILE */ -#if (MMS_WRITE_SERVICE != 1) -#undef CONFIG_IEC61850_CONTROL_SERVICE -#define CONFIG_IEC61850_CONTROL_SERVICE 0 -#endif - /* Sort getNameList response according to the MMS specified collation order - this is required by the standard * Set to 0 only for performance reasons and when no certification is required! */ #define CONFIG_MMS_SORT_NAME_LIST 1 @@ -220,4 +215,39 @@ */ #define CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME 1 +/************************************************************************************ + * Check configuration for consistency - DO NOT MODIFY THIS PART! + ************************************************************************************/ + +#if (MMS_JOURNAL_SERVICE != 1) + +#if (CONFIG_IEC61850_LOG_SERVICE == 1) +#warning "Invalid configuration: CONFIG_IEC61850_LOG_SERVICE requires MMS_JOURNAL_SERVICE!" +#endif + +#undef CONFIG_IEC61850_LOG_SERVICE +#define CONFIG_IEC61850_LOG_SERVICE 0 + +#endif + +#if (MMS_WRITE_SERVICE != 1) + +#if (CONFIG_IEC61850_CONTROL_SERVICE == 1) +#warning "Invalid configuration: CONFIG_IEC61850_CONTROL_SERVICE requires MMS_WRITE_SERVICE!" +#endif + +#undef CONFIG_IEC61850_CONTROL_SERVICE +#define CONFIG_IEC61850_CONTROL_SERVICE 0 +#endif + +#if (MMS_FILE_SERVICE != 1) + +#if (MMS_OBTAIN_FILE_SERVICE == 1) +#warning "Invalid configuration: MMS_OBTAIN_FILE_SERVICE requires MMS_FILE_SERVICE!" +#endif + +#undef MMS_OBTAIN_FILE_SERVICE +#define MMS_OBTAIN_FILE_SERVICE 0 +#endif + #endif /* STACK_CONFIG_H_ */ diff --git a/src/goose/goose_receiver.c b/src/goose/goose_receiver.c index 45d8f842..2a728093 100644 --- a/src/goose/goose_receiver.c +++ b/src/goose/goose_receiver.c @@ -766,6 +766,7 @@ parseGooseMessage(GooseReceiver self, int numbytes) } } +#if (CONFIG_MMS_THREADLESS_STACK == 0) static void gooseReceiverLoop(void* threadParameter) { @@ -789,6 +790,7 @@ gooseReceiverLoop(void* threadParameter) self->stopped = true; } +#endif // start GOOSE receiver in a separate thread void diff --git a/src/iec61850/server/mms_mapping/mms_mapping.c b/src/iec61850/server/mms_mapping/mms_mapping.c index a99bc384..5e4b2fdd 100644 --- a/src/iec61850/server/mms_mapping/mms_mapping.c +++ b/src/iec61850/server/mms_mapping/mms_mapping.c @@ -823,6 +823,8 @@ countSVControlBlocksForLogicalNode(MmsMapping* self, LogicalNode* logicalNode, b #endif /* (CONFIG_IEC61850_SAMPLED_VALUES_SUPPORT == 1) */ +#if (CONFIG_IEC61850_SETTING_GROUPS == 1) + static SettingGroupControlBlock* checkForSgcb(MmsMapping* self, LogicalNode* logicalNode) { @@ -838,6 +840,9 @@ checkForSgcb(MmsMapping* self, LogicalNode* logicalNode) return NULL; } +#endif /* (CONFIG_IEC61850_SETTING_GROUPS == 1) */ + + static MmsVariableSpecification* createNamedVariableFromLogicalNode(MmsMapping* self, MmsDomain* domain, LogicalNode* logicalNode) @@ -851,9 +856,8 @@ createNamedVariableFromLogicalNode(MmsMapping* self, MmsDomain* domain, int componentCount = determineLogicalNodeComponentCount(logicalNode); - SettingGroupControlBlock* sgControlBlock = NULL; - #if (CONFIG_IEC61850_SETTING_GROUPS == 1) + SettingGroupControlBlock* sgControlBlock = NULL; sgControlBlock = checkForSgcb(self, logicalNode); diff --git a/src/mms/iso_mms/client/mms_client_connection.c b/src/mms/iso_mms/client/mms_client_connection.c index ce8f6de4..0fc53122 100644 --- a/src/mms/iso_mms/client/mms_client_connection.c +++ b/src/mms/iso_mms/client/mms_client_connection.c @@ -2074,6 +2074,7 @@ int32_t MmsConnection_fileOpen(MmsConnection self, MmsError* mmsError, const char* filename, uint32_t initialPosition, uint32_t* fileSize, uint64_t* lastModified) { +#if (MMS_FILE_SERVICE == 1) ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient); uint32_t invokeId = getNextInvokeId(self); @@ -2097,11 +2098,19 @@ MmsConnection_fileOpen(MmsConnection self, MmsError* mmsError, const char* filen releaseResponse(self); return frsmId; +#else + if (DEBUG_MMS_CLIENT) + printf("MMS_CLIENT: service not supported\n"); + + *mmsError = MMS_ERROR_OTHER; + return 0; +#endif } void MmsConnection_fileClose(MmsConnection self, MmsError* mmsError, int32_t frsmId) { +#if (MMS_FILE_SERVICE == 1) ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient); uint32_t invokeId = getNextInvokeId(self); @@ -2113,11 +2122,18 @@ MmsConnection_fileClose(MmsConnection self, MmsError* mmsError, int32_t frsmId) /* nothing to do - response contains no data to evaluate */ releaseResponse(self); +#else + if (DEBUG_MMS_CLIENT) + printf("MMS_CLIENT: service not supported\n"); + + *mmsError = MMS_ERROR_OTHER; +#endif } void MmsConnection_fileDelete(MmsConnection self, MmsError* mmsError, const char* fileName) { +#if (MMS_FILE_SERVICE == 1) ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient); uint32_t invokeId = getNextInvokeId(self); @@ -2129,12 +2145,19 @@ MmsConnection_fileDelete(MmsConnection self, MmsError* mmsError, const char* fil /* nothing to do - response contains no data to evaluate */ releaseResponse(self); +#else + if (DEBUG_MMS_CLIENT) + printf("MMS_CLIENT: service not supported\n"); + + *mmsError = MMS_ERROR_OTHER; +#endif } bool MmsConnection_fileRead(MmsConnection self, MmsError* mmsError, int32_t frsmId, MmsFileReadHandler handler, void* handlerParameter) { +#if (MMS_FILE_SERVICE == 1) ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient); uint32_t invokeId = getNextInvokeId(self); @@ -2156,12 +2179,20 @@ MmsConnection_fileRead(MmsConnection self, MmsError* mmsError, int32_t frsmId, M releaseResponse(self); return moreFollows; +#else + if (DEBUG_MMS_CLIENT) + printf("MMS_CLIENT: service not supported\n"); + + *mmsError = MMS_ERROR_OTHER; + return false; +#endif } bool MmsConnection_getFileDirectory(MmsConnection self, MmsError* mmsError, const char* fileSpecification, const char* continueAfter, MmsFileDirectoryHandler handler, void* handlerParameter) { +#if (MMS_FILE_SERVICE == 1) ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient); uint32_t invokeId = getNextInvokeId(self); @@ -2180,11 +2211,19 @@ MmsConnection_getFileDirectory(MmsConnection self, MmsError* mmsError, const cha releaseResponse(self); return moreFollows; +#else + if (DEBUG_MMS_CLIENT) + printf("MMS_CLIENT: service not supported\n"); + + *mmsError = MMS_ERROR_OTHER; + return false; +#endif } void MmsConnection_fileRename(MmsConnection self, MmsError* mmsError, const char* currentFileName, const char* newFileName) { +#if (MMS_FILE_SERVICE == 1) ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient); uint32_t invokeId = getNextInvokeId(self); @@ -2196,11 +2235,18 @@ MmsConnection_fileRename(MmsConnection self, MmsError* mmsError, const char* cur /* nothing to do - response contains no data to evaluate */ releaseResponse(self); +#else + if (DEBUG_MMS_CLIENT) + printf("MMS_CLIENT: service not supported\n"); + + *mmsError = MMS_ERROR_OTHER; +#endif } void MmsConnection_obtainFile(MmsConnection self, MmsError* mmsError, const char* sourceFile, const char* destinationFile) { +#if ((MMS_FILE_SERVICE == 1) && (MMS_OBTAIN_FILE_SERVICE == 1)) ByteBuffer* payload = IsoClientConnection_allocateTransmitBuffer(self->isoClient); uint32_t invokeId = getNextInvokeId(self); @@ -2212,6 +2258,12 @@ MmsConnection_obtainFile(MmsConnection self, MmsError* mmsError, const char* sou /* nothing to do - response contains no data to evaluate */ releaseResponse(self); +#else + if (DEBUG_MMS_CLIENT) + printf("MMS_CLIENT: service not supported\n"); + + *mmsError = MMS_ERROR_OTHER; +#endif } MmsDataAccessError diff --git a/src/mms/iso_mms/client/mms_client_files.c b/src/mms/iso_mms/client/mms_client_files.c index e0886fce..4310da05 100644 --- a/src/mms/iso_mms/client/mms_client_files.c +++ b/src/mms/iso_mms/client/mms_client_files.c @@ -198,6 +198,8 @@ mmsClient_handleFileCloseRequest( #endif /* (MMS_OBTAIN_FILE_SERVICE == 1) */ +#if (MMS_FILE_SERVICE == 1) + void mmsClient_createFileOpenRequest(uint32_t invokeId, ByteBuffer* request, const char* fileName, uint32_t initialPosition) { @@ -777,4 +779,4 @@ mmsClient_createFileCloseRequest(uint32_t invokeId, ByteBuffer* request, int32_t request->size = bufPos; } - +#endif /* (MMS_FILE_SERVICE == 1) */ diff --git a/src/mms/iso_mms/common/mms_common_msg.c b/src/mms/iso_mms/common/mms_common_msg.c index 75443e72..47673a48 100644 --- a/src/mms/iso_mms/common/mms_common_msg.c +++ b/src/mms/iso_mms/common/mms_common_msg.c @@ -1,7 +1,7 @@ /* * mms_common_msg.c * - * Copyright 2013 - 2017 Michael Zillgith + * Copyright 2013-2018 Michael Zillgith * * This file is part of libIEC61850. * @@ -344,6 +344,8 @@ mmsMsg_copyAsn1IdentifierToStringBuffer(Identifier_t identifier, char* buffer, i } } +#if (MMS_FILE_SERVICE == 1) + void mmsMsg_createExtendedFilename(const char* basepath, char* extendedFileName, char* fileName) { @@ -358,7 +360,6 @@ mmsMsg_createExtendedFilename(const char* basepath, char* extendedFileName, char } - FileHandle mmsMsg_openFile(const char* basepath, char* fileName, bool readWrite) { @@ -416,3 +417,6 @@ mmsMsg_parseFileName(char* filename, uint8_t* buffer, int* bufPos, int maxBufPos return true; } + +#endif /* (MMS_FILE_SERVICE == 1) */ + diff --git a/src/mms/iso_mms/server/mms_file_service.c b/src/mms/iso_mms/server/mms_file_service.c index 092e260c..132039e0 100644 --- a/src/mms/iso_mms/server/mms_file_service.c +++ b/src/mms/iso_mms/server/mms_file_service.c @@ -1,7 +1,7 @@ /* * mms_file_service.c * - * Copyright 2013, 2014 Michael Zillgith + * Copyright 2013-2018 Michael Zillgith * * This file is part of libIEC61850. * diff --git a/src/mms/iso_server/iso_connection.c b/src/mms/iso_server/iso_connection.c index eb7fe48e..254cde26 100644 --- a/src/mms/iso_server/iso_connection.c +++ b/src/mms/iso_server/iso_connection.c @@ -432,7 +432,7 @@ exit_function: return; } -#if (CONFIG_MMS_SINGLE_THREADED == 0) +#if ((CONFIG_MMS_SINGLE_THREADED == 0) && (CONFIG_MMS_THREADLESS_STACK == 0)) static void handleTcpConnection(void* parameter) {