From 311cd905f189f6865b9584815c6041182ff27d80 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 18 Dec 2017 08:39:17 +0100 Subject: [PATCH] - MMS client/server: removed mms_indication.h and MmsIndication type --- src/mms/inc_private/mms_common_internal.h | 5 ++- src/mms/inc_private/mms_indication.h | 41 ------------------- src/mms/inc_private/mms_server_connection.h | 5 --- src/mms/inc_private/mms_server_internal.h | 1 - src/mms/iso_mms/client/mms_client_initiate.c | 1 - .../iso_mms/server/mms_server_connection.c | 30 +++++++------- 6 files changed, 20 insertions(+), 63 deletions(-) delete mode 100644 src/mms/inc_private/mms_indication.h diff --git a/src/mms/inc_private/mms_common_internal.h b/src/mms/inc_private/mms_common_internal.h index 6bb28486..2d899037 100644 --- a/src/mms/inc_private/mms_common_internal.h +++ b/src/mms/inc_private/mms_common_internal.h @@ -30,6 +30,10 @@ #include "byte_buffer.h" #include "mms_server.h" +#define DEFAULT_MAX_SERV_OUTSTANDING_CALLING 5 +#define DEFAULT_MAX_SERV_OUTSTANDING_CALLED 5 +#define DEFAULT_DATA_STRUCTURE_NESTING_LEVEL 10 + #if (MMS_FILE_SERVICE == 1) #ifndef CONFIG_MMS_MAX_NUMBER_OF_OPEN_FILES_PER_CONNECTION @@ -73,7 +77,6 @@ FileHandle mmsMsg_openFile(const char* basepath, char* fileName, bool readWrite); #endif /* (MMS_FILE_SERVICE == 1) */ - typedef struct sMmsServiceError { int errorClass; diff --git a/src/mms/inc_private/mms_indication.h b/src/mms/inc_private/mms_indication.h deleted file mode 100644 index b1a67244..00000000 --- a/src/mms/inc_private/mms_indication.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * mms_indication.h - * - * Copyright 2015 Michael Zillgith - * - * 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 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 . - * - * See COPYING file for the complete license text. - * - * - * MMS client connection handling code for libiec61850. - * - * Handles a MMS client connection. - */ - -#ifndef MMS_INDICATION_H_ -#define MMS_INDICATION_H_ - -#define DEFAULT_MAX_SERV_OUTSTANDING_CALLING 5 -#define DEFAULT_MAX_SERV_OUTSTANDING_CALLED 5 -#define DEFAULT_DATA_STRUCTURE_NESTING_LEVEL 10 - -typedef enum -{ - MMS_ERROR, MMS_INITIATE, MMS_CONFIRMED_REQUEST, MMS_OK, MMS_CONCLUDE -} MmsIndication; - -#endif /* MMS_INDICATION_H_ */ diff --git a/src/mms/inc_private/mms_server_connection.h b/src/mms/inc_private/mms_server_connection.h index 8d00abbd..b39028da 100644 --- a/src/mms/inc_private/mms_server_connection.h +++ b/src/mms/inc_private/mms_server_connection.h @@ -31,7 +31,6 @@ #include "libiec61850_platform_includes.h" #include "mms_common.h" -#include "mms_indication.h" #include "mms_device_model.h" #include "mms_value.h" #include "mms_server.h" @@ -61,10 +60,6 @@ MmsServerConnection_getNamedVariableLists(MmsServerConnection self); void MmsServerConnection_deleteNamedVariableList(MmsServerConnection self, char* listName); -MmsIndication -MmsServerConnection_parseMessage(MmsServerConnection connection, ByteBuffer* message, ByteBuffer* response); - - /** \brief send information report for a single VMD specific variable * * \param handlerMode send this message in the context of a stack callback handler diff --git a/src/mms/inc_private/mms_server_internal.h b/src/mms/inc_private/mms_server_internal.h index 6c8df614..fdc05de7 100644 --- a/src/mms/inc_private/mms_server_internal.h +++ b/src/mms/inc_private/mms_server_internal.h @@ -28,7 +28,6 @@ #include "MmsPdu.h" #include "mms_common.h" -#include "mms_indication.h" #include "mms_server_connection.h" #include "mms_device_model.h" #include "mms_common_internal.h" diff --git a/src/mms/iso_mms/client/mms_client_initiate.c b/src/mms/iso_mms/client/mms_client_initiate.c index 5cf93b43..d6c61892 100644 --- a/src/mms/iso_mms/client/mms_client_initiate.c +++ b/src/mms/iso_mms/client/mms_client_initiate.c @@ -24,7 +24,6 @@ #include "libiec61850_platform_includes.h" #include "mms_common.h" #include "mms_common_internal.h" -#include "mms_indication.h" #include "mms_client_connection.h" #include "byte_buffer.h" diff --git a/src/mms/iso_mms/server/mms_server_connection.c b/src/mms/iso_mms/server/mms_server_connection.c index c80b0680..3ddcb47d 100644 --- a/src/mms/iso_mms/server/mms_server_connection.c +++ b/src/mms/iso_mms/server/mms_server_connection.c @@ -507,15 +507,13 @@ handleConfirmedResponsePdu( } /* handleConfirmedResponsePdu */ #endif /* (MMS_OBTAIN_FILE_SERVICE == 1) */ -MmsIndication +static inline void MmsServerConnection_parseMessage(MmsServerConnection self, ByteBuffer* message, ByteBuffer* response) { - MmsIndication retVal; - - uint8_t* buffer = message->buffer; + uint8_t* buffer = message->buffer; if (message->size < 2) - return MMS_ERROR; + goto parsing_error; int bufPos = 0; @@ -525,7 +523,7 @@ MmsServerConnection_parseMessage(MmsServerConnection self, ByteBuffer* message, bufPos = BerDecoder_decodeLength(buffer, &pduLength, bufPos, message->size); if (bufPos < 0) - return MMS_ERROR; + goto parsing_error; if (DEBUG_MMS_SERVER) printf("MMS_SERVER: recvd MMS-PDU type: %02x size: %i\n", pduType, pduLength); @@ -533,39 +531,43 @@ MmsServerConnection_parseMessage(MmsServerConnection self, ByteBuffer* message, switch (pduType) { case 0xa8: /* Initiate request PDU */ mmsServer_handleInitiateRequest(self, buffer, bufPos, bufPos + pduLength, response); - retVal = MMS_INITIATE; break; + case 0xa0: /* Confirmed request PDU */ handleConfirmedRequestPdu(self, buffer, bufPos, bufPos + pduLength, response); - retVal = MMS_CONFIRMED_REQUEST; break; + #if (MMS_OBTAIN_FILE_SERVICE == 1) case 0xa1: /* Confirmed response PDU */ handleConfirmedResponsePdu(self, buffer, bufPos, bufPos + pduLength, response); - retVal = MMS_CONFIRMED_REQUEST; break; + case 0xa2: /* Confirmed error PDU */ handleConfirmedErrorPdu(self, buffer, 0, bufPos + pduLength, response); - retVal = MMS_CONFIRMED_REQUEST; break; #endif /* (MMS_OBTAIN_FILE_SERVICE == 1) */ case 0x8b: /* Conclude request PDU */ mmsServer_writeConcludeResponsePdu(response); - retVal = MMS_CONCLUDE; break; + case 0xa4: /* Reject PDU - silently ignore */ if (DEBUG_MMS_SERVER) printf("MMS_SERVER: received reject PDU!\n"); - retVal = MMS_OK; break; + default: mmsMsg_createMmsRejectPdu(NULL, MMS_ERROR_REJECT_UNKNOWN_PDU_TYPE, response); - retVal = MMS_ERROR; break; } - return retVal; + return; + +parsing_error: + if (DEBUG_MMS_SERVER) + printf("MMS_SERVER: error parsing message\n"); + + return; } static void /* will be called by IsoConnection */