- some code formatting

pull/93/head
Michael Zillgith 7 years ago
parent 46437cdbe1
commit ed75aa3f46

@ -1,7 +1,7 @@
/* /*
* iso_connection_parameters.h * iso_connection_parameters.h
* *
* Copyright 2013, 2014 Michael Zillgith * Copyright 2013-2018 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *
@ -37,7 +37,7 @@ extern "C" {
/** /**
* \brief authentication mechanism úsed by AcseAuthenticator * \brief authentication mechanism used by AcseAuthenticator
*/ */
typedef enum typedef enum
{ {
@ -154,7 +154,7 @@ typedef struct sIsoConnectionParameters* IsoConnectionParameters;
* NOTE: This function used internally by the MMS client library. When using the MMS or IEC 61850 API * NOTE: This function used internally by the MMS client library. When using the MMS or IEC 61850 API
* there should be no reason for the user to call this function. * there should be no reason for the user to call this function.
* *
* \return new IsoConnectionParameters * \return new IsoConnectionParameters instance
*/ */
LIB61850_API IsoConnectionParameters LIB61850_API IsoConnectionParameters
IsoConnectionParameters_create(void); IsoConnectionParameters_create(void);

@ -3,22 +3,22 @@
* *
* Copyright 2013-2018 Michael Zillgith * Copyright 2013-2018 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 * libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* libIEC61850 is distributed in the hope that it will be useful, * libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>. * 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.
*/ */
#ifndef MMS_CLIENT_CONNECTION_H_ #ifndef MMS_CLIENT_CONNECTION_H_

@ -3,22 +3,22 @@
* *
* Copyright 2013-2018 Michael Zillgith * Copyright 2013-2018 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 * libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* libIEC61850 is distributed in the hope that it will be useful, * libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>. * 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.
*/ */
#ifndef MMS_VALUE_H_ #ifndef MMS_VALUE_H_

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

@ -1,7 +1,7 @@
/* /*
* cotp.h * cotp.h
* *
* Copyright 2013, 2014 Michael Zillgith * Copyright 2013-2018 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *

@ -3,22 +3,22 @@
* *
* Copyright 2013 Michael Zillgith * Copyright 2013 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 * libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* libIEC61850 is distributed in the hope that it will be useful, * libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>. * 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.
*/ */
#ifndef ISO_PRESENTATION_H_ #ifndef ISO_PRESENTATION_H_

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

@ -3,22 +3,22 @@
* *
* Copyright 2013-2018 Michael Zillgith * Copyright 2013-2018 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 * libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* libIEC61850 is distributed in the hope that it will be useful, * libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>. * 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.
*/ */
#ifndef MMS_MSG_INTERNAL_H_ #ifndef MMS_MSG_INTERNAL_H_
@ -42,16 +42,6 @@
#define DEBUG_MMS_CLIENT 0 #define DEBUG_MMS_CLIENT 0
#endif #endif
#if 0
typedef enum {
MMS_CON_IDLE,
MMS_CON_WAITING,
MMS_CON_ASSOCIATION_FAILED,
MMS_CON_ASSOCIATED,
MMS_CON_RESPONSE_PENDING
} ConnectionState;
#endif
#define CONCLUDE_STATE_CONNECTION_ACTIVE 0 #define CONCLUDE_STATE_CONNECTION_ACTIVE 0
#define CONCLUDE_STATE_REQUESTED 1 #define CONCLUDE_STATE_REQUESTED 1
#define CONCLUDE_STATE_REJECTED 2 #define CONCLUDE_STATE_REJECTED 2
@ -98,42 +88,42 @@ struct sMmsConnection {
Semaphore lastInvokeIdLock; Semaphore lastInvokeIdLock;
uint32_t lastInvokeId; uint32_t lastInvokeId;
Semaphore outstandingCallsLock; Semaphore outstandingCallsLock;
MmsOutstandingCall outstandingCalls; MmsOutstandingCall outstandingCalls;
uint32_t requestTimeout; uint32_t requestTimeout;
uint32_t connectTimeout; uint32_t connectTimeout;
IsoClientConnection isoClient; IsoClientConnection isoClient;
#if (CONFIG_MMS_THREADLESS_STACK == 0) #if (CONFIG_MMS_THREADLESS_STACK == 0)
Thread connectionHandlingThread; Thread connectionHandlingThread;
bool createThread; bool createThread;
bool connectionThreadRunning; bool connectionThreadRunning;
#endif #endif
volatile MmsConnectionState connectionState; volatile MmsConnectionState connectionState;
Semaphore associationStateLock; Semaphore associationStateLock;
MmsConnectionParameters parameters; MmsConnectionParameters parameters;
IsoConnectionParameters isoParameters; IsoConnectionParameters isoParameters;
MmsConnectionStateChangedHandler stateChangedHandler; MmsConnectionStateChangedHandler stateChangedHandler;
void* stateChangedHandlerParameter; void* stateChangedHandlerParameter;
MmsInformationReportHandler reportHandler; MmsInformationReportHandler reportHandler;
void* reportHandlerParameter; void* reportHandlerParameter;
MmsConnectionLostHandler connectionLostHandler; MmsConnectionLostHandler connectionLostHandler;
void* connectionLostHandlerParameter; void* connectionLostHandlerParameter;
MmsConnection_ConcludeAbortHandler concludeHandler; MmsConnection_ConcludeAbortHandler concludeHandler;
void* concludeHandlerParameter; void* concludeHandlerParameter;
uint64_t concludeTimeout; uint64_t concludeTimeout;
#if (CONFIG_MMS_RAW_MESSAGE_LOGGING == 1) #if (CONFIG_MMS_RAW_MESSAGE_LOGGING == 1)
void* rawMmsMessageHandler; void* rawMmsMessageHandler;
void* rawMmsMessageHandlerParameter; void* rawMmsMessageHandlerParameter;
#endif #endif
#if (MMS_OBTAIN_FILE_SERVICE == 1) #if (MMS_OBTAIN_FILE_SERVICE == 1)
@ -236,8 +226,7 @@ mmsClient_createGetNamedVariableListAttributesRequestAssociationSpecific(uint32_
ByteBuffer* writeBuffer, const char* listNameId); ByteBuffer* writeBuffer, const char* listNameId);
LIB61850_INTERNAL LinkedList LIB61850_INTERNAL LinkedList
mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint32_t* invokeId, mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, bool* /*OUT*/ deletable);
bool* /*OUT*/ deletable);
LIB61850_INTERNAL int LIB61850_INTERNAL int
mmsClient_createGetVariableAccessAttributesRequest( mmsClient_createGetVariableAccessAttributesRequest(

@ -1,7 +1,7 @@
/* /*
* mms_common_internal.h * mms_common_internal.h
* *
* Copyright 2013, 2014, 2015 Michael Zillgith * Copyright 2013-2018 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *
@ -77,6 +77,7 @@ LIB61850_INTERNAL FileHandle
mmsMsg_openFile(const char* basepath, char* fileName, bool readWrite); mmsMsg_openFile(const char* basepath, char* fileName, bool readWrite);
#endif /* (MMS_FILE_SERVICE == 1) */ #endif /* (MMS_FILE_SERVICE == 1) */
typedef struct sMmsServiceError typedef struct sMmsServiceError
{ {
int errorClass; int errorClass;

@ -3,22 +3,22 @@
* *
* Copyright 2013-2018 Michael Zillgith * Copyright 2013-2018 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 * libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* libIEC61850 is distributed in the hope that it will be useful, * libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>. * 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.
*/ */
/** /**

@ -1,24 +1,24 @@
/* /*
* mms_server_internal.h * mms_server_internal.h
* *
* Copyright 2013, 2014 Michael Zillgith * Copyright 2013-2018 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 * libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* libIEC61850 is distributed in the hope that it will be useful, * libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>. * 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.
*/ */
#ifndef MMS_SERVER_INTERNAL_H_ #ifndef MMS_SERVER_INTERNAL_H_

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

@ -82,7 +82,7 @@ handleUnconfirmedMmsPdu(MmsConnection self, ByteBuffer* message)
if (mmsPdu->choice.unconfirmedPDU.unconfirmedService.present == if (mmsPdu->choice.unconfirmedPDU.unconfirmedService.present ==
UnconfirmedService_PR_informationReport) UnconfirmedService_PR_informationReport)
{ {
char* domainId = NULL; char* domainId = NULL;
InformationReport_t* report = InformationReport_t* report =
@ -90,12 +90,13 @@ handleUnconfirmedMmsPdu(MmsConnection self, ByteBuffer* message)
if (report->variableAccessSpecification.present == if (report->variableAccessSpecification.present ==
VariableAccessSpecification_PR_variableListName) VariableAccessSpecification_PR_variableListName)
{ {
if (report->variableAccessSpecification.choice.variableListName.present if (report->variableAccessSpecification.choice.variableListName.present
== ObjectName_PR_vmdspecific) == ObjectName_PR_vmdspecific)
{ {
int nameSize = int nameSize =
report->variableAccessSpecification.choice.variableListName.choice.vmdspecific.size; report->variableAccessSpecification.choice.variableListName.choice.vmdspecific.size;
uint8_t* buffer = uint8_t* buffer =
report->variableAccessSpecification.choice.variableListName.choice.vmdspecific.buf; report->variableAccessSpecification.choice.variableListName.choice.vmdspecific.buf;
@ -116,7 +117,7 @@ handleUnconfirmedMmsPdu(MmsConnection self, ByteBuffer* message)
} }
else if (report->variableAccessSpecification.present == VariableAccessSpecification_PR_listOfVariable) else if (report->variableAccessSpecification.present == VariableAccessSpecification_PR_listOfVariable)
{ {
int listSize = report->listOfAccessResult.list.count; int listSize = report->listOfAccessResult.list.count;
int variableSpecSize = report->variableAccessSpecification.choice.listOfVariable.list.count; int variableSpecSize = report->variableAccessSpecification.choice.listOfVariable.list.count;
@ -133,10 +134,10 @@ handleUnconfirmedMmsPdu(MmsConnection self, ByteBuffer* message)
for (i = 0; i < variableSpecSize; i++) { for (i = 0; i < variableSpecSize; i++) {
if (report->variableAccessSpecification.choice.listOfVariable.list.array[i]->variableSpecification.present if (report->variableAccessSpecification.choice.listOfVariable.list.array[i]->variableSpecification.present
== VariableSpecification_PR_name) == VariableSpecification_PR_name)
{ {
if (report->variableAccessSpecification.choice.listOfVariable.list.array[i] if (report->variableAccessSpecification.choice.listOfVariable.list.array[i]
->variableSpecification.choice.name.present == ObjectName_PR_vmdspecific) ->variableSpecification.choice.name.present == ObjectName_PR_vmdspecific)
{ {
int nameSize = int nameSize =
report->variableAccessSpecification.choice.listOfVariable.list.array[i] report->variableAccessSpecification.choice.listOfVariable.list.array[i]
->variableSpecification.choice.name.choice.vmdspecific.size; ->variableSpecification.choice.name.choice.vmdspecific.size;
@ -158,7 +159,7 @@ handleUnconfirmedMmsPdu(MmsConnection self, ByteBuffer* message)
self->reportHandler(self->reportHandlerParameter, domainId, variableListName, self->reportHandler(self->reportHandlerParameter, domainId, variableListName,
value, false); value, false);
/* report handler should have deleted the MmsValue! */ /* report handler is responsible to delete the MmsValue object */
if (variableSpecSize != 1) if (variableSpecSize != 1)
MmsValue_setElement(values, i, NULL); MmsValue_setElement(values, i, NULL);
else else
@ -169,24 +170,24 @@ handleUnconfirmedMmsPdu(MmsConnection self, ByteBuffer* message)
->variableSpecification.choice.name.present == ObjectName_PR_domainspecific) { ->variableSpecification.choice.name.present == ObjectName_PR_domainspecific) {
int domainNameSize = int domainNameSize =
report->variableAccessSpecification.choice.listOfVariable.list.array[i] report->variableAccessSpecification.choice.listOfVariable.list.array[i]
->variableSpecification.choice.name.choice.domainspecific.domainId.size; ->variableSpecification.choice.name.choice.domainspecific.domainId.size;
int itemNameSize = int itemNameSize =
report->variableAccessSpecification.choice.listOfVariable.list.array[i] report->variableAccessSpecification.choice.listOfVariable.list.array[i]
->variableSpecification.choice.name.choice.domainspecific.itemId.size; ->variableSpecification.choice.name.choice.domainspecific.itemId.size;
if (domainNameSize < 65 && itemNameSize < 65) { if ((domainNameSize < 65) && (itemNameSize < 65)) {
char domainNameStr[65]; char domainNameStr[65];
char itemNameStr[65]; char itemNameStr[65];
uint8_t* domainNameBuffer = uint8_t* domainNameBuffer =
report->variableAccessSpecification.choice.listOfVariable.list.array[i] report->variableAccessSpecification.choice.listOfVariable.list.array[i]
->variableSpecification.choice.name.choice.domainspecific.domainId.buf; ->variableSpecification.choice.name.choice.domainspecific.domainId.buf;
uint8_t* itemNamebuffer = uint8_t* itemNamebuffer =
report->variableAccessSpecification.choice.listOfVariable.list.array[i] report->variableAccessSpecification.choice.listOfVariable.list.array[i]
->variableSpecification.choice.name.choice.domainspecific.itemId.buf; ->variableSpecification.choice.name.choice.domainspecific.itemId.buf;
memcpy(domainNameStr, domainNameBuffer, domainNameSize); memcpy(domainNameStr, domainNameBuffer, domainNameSize);
domainNameStr[domainNameSize] = 0; domainNameStr[domainNameSize] = 0;
@ -201,7 +202,7 @@ handleUnconfirmedMmsPdu(MmsConnection self, ByteBuffer* message)
self->reportHandler(self->reportHandlerParameter, domainNameStr, itemNameStr, self->reportHandler(self->reportHandlerParameter, domainNameStr, itemNameStr,
value, false); value, false);
/* report handler should have deleted the MmsValue! */ /* report handler is responsible to delete the MmsValue object */
if (variableSpecSize != 1) if (variableSpecSize != 1)
MmsValue_setElement(values, i, NULL); MmsValue_setElement(values, i, NULL);
else else
@ -323,6 +324,10 @@ sendMessage(MmsConnection self, ByteBuffer* message)
} }
#endif /* (CONFIG_MMS_RAW_MESSAGE_LOGGING == 1) */ #endif /* (CONFIG_MMS_RAW_MESSAGE_LOGGING == 1) */
#if (CONFIG_MMS_COLLECT_STATISTICS == 1)
self->statAplMessagesSent++;
#endif
IsoClientConnection_sendMessage(self->isoClient, message); IsoClientConnection_sendMessage(self->isoClient, message);
} }
@ -549,6 +554,7 @@ mmsMsg_parseConfirmedErrorPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32
tag = buffer[bufPos++]; tag = buffer[bufPos++];
bufPos = BerDecoder_decodeLength(buffer, &length, bufPos, maxBufPos); bufPos = BerDecoder_decodeLength(buffer, &length, bufPos, maxBufPos);
if (bufPos < 0) if (bufPos < 0)
goto exit_error; goto exit_error;
@ -575,7 +581,7 @@ mmsMsg_parseConfirmedErrorPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32
return bufPos; return bufPos;
exit_error: exit_error:
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: error parsing confirmed error PDU\n"); printf("MMS_CLIENT: error parsing confirmed error PDU\n");
@ -608,6 +614,7 @@ mmsMsg_parseRejectPDU(uint8_t* buffer, int bufPos, int maxBufPos, uint32_t* invo
tag = buffer[bufPos++]; tag = buffer[bufPos++];
bufPos = BerDecoder_decodeLength(buffer, &length, bufPos, maxBufPos); bufPos = BerDecoder_decodeLength(buffer, &length, bufPos, maxBufPos);
if (bufPos < 0) if (bufPos < 0)
goto exit_error; goto exit_error;
@ -717,7 +724,7 @@ handleAsyncResponse(MmsConnection self, ByteBuffer* response, uint32_t bufPos, M
if (response) { if (response) {
bool deletable = false; bool deletable = false;
LinkedList accessSpec = mmsClient_parseGetNamedVariableListAttributesResponse(response, NULL, &deletable); LinkedList accessSpec = mmsClient_parseGetNamedVariableListAttributesResponse(response, &deletable);
if (accessSpec == false) if (accessSpec == false)
err = MMS_ERROR_PARSING_RESPONSE; err = MMS_ERROR_PARSING_RESPONSE;
@ -1061,6 +1068,7 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
} }
} }
else if (tag == 0xa2) { /* confirmed error PDU */ else if (tag == 0xa2) { /* confirmed error PDU */
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: Confirmed error PDU!\n"); printf("MMS_CLIENT: Confirmed error PDU!\n");
@ -1098,6 +1106,7 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
} }
} }
else if (tag == 0xa4) { /* reject PDU */ else if (tag == 0xa4) { /* reject PDU */
if (DEBUG_MMS_CLIENT) if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: reject PDU!\n"); printf("MMS_CLIENT: reject PDU!\n");
@ -1714,11 +1723,15 @@ MmsConnection_abort(MmsConnection self, MmsError* mmsError)
success = true; success = true;
break; break;
} }
else {
Thread_sleep(10);
}
} }
} }
if (success == false) { if (success == false) {
IsoClientConnection_close(self->isoClient);
*mmsError = MMS_ERROR_SERVICE_TIMEOUT; *mmsError = MMS_ERROR_SERVICE_TIMEOUT;
} }
@ -1744,7 +1757,6 @@ concludeHandler(void* parameter, MmsError mmsError, bool success)
Semaphore_post(parameters->sem); Semaphore_post(parameters->sem);
} }
void void
MmsConnection_conclude(MmsConnection self, MmsError* mmsError) MmsConnection_conclude(MmsConnection self, MmsError* mmsError)
{ {
@ -2282,7 +2294,6 @@ exit_function:
return invokeId; return invokeId;
} }
MmsValue* MmsValue*
MmsConnection_readNamedVariableListValues(MmsConnection self, MmsError* mmsError, MmsConnection_readNamedVariableListValues(MmsConnection self, MmsError* mmsError,
const char* domainId, const char* listName, const char* domainId, const char* listName,
@ -2346,14 +2357,12 @@ exit_function:
return invokeId; return invokeId;
} }
MmsValue* MmsValue*
MmsConnection_readNamedVariableListValuesAssociationSpecific( MmsConnection_readNamedVariableListValuesAssociationSpecific(
MmsConnection self, MmsError* mmsError, MmsConnection self, MmsError* mmsError,
const char* listName, const char* listName,
bool specWithResult) bool specWithResult)
{ {
MmsValue* value = NULL; MmsValue* value = NULL;
MmsError err = MMS_ERROR_NONE; MmsError err = MMS_ERROR_NONE;
@ -2638,7 +2647,6 @@ exit_function:
return invokeId; return invokeId;
} }
void void
MmsConnection_defineNamedVariableListAssociationSpecific(MmsConnection self, MmsConnection_defineNamedVariableListAssociationSpecific(MmsConnection self,
MmsError* mmsError, const char* listName, LinkedList variableSpecs) MmsError* mmsError, const char* listName, LinkedList variableSpecs)
@ -2694,7 +2702,6 @@ exit_function:
return invokeId; return invokeId;
} }
bool bool
MmsConnection_deleteNamedVariableList(MmsConnection self, MmsError* mmsError, MmsConnection_deleteNamedVariableList(MmsConnection self, MmsError* mmsError,
const char* domainId, const char* listName) const char* domainId, const char* listName)
@ -4279,14 +4286,13 @@ void
MmsVariableAccessSpecification_destroy(MmsVariableAccessSpecification* self) MmsVariableAccessSpecification_destroy(MmsVariableAccessSpecification* self)
{ {
if (self->domainId != NULL) if (self->domainId != NULL)
GLOBAL_FREEMEM((void* ) self->domainId); GLOBAL_FREEMEM((void*) self->domainId);
if (self->itemId != NULL) if (self->itemId != NULL)
GLOBAL_FREEMEM((void* ) self->itemId); GLOBAL_FREEMEM((void*) self->itemId);
if (self->componentName != NULL) if (self->componentName != NULL)
GLOBAL_FREEMEM((void* ) self->componentName); GLOBAL_FREEMEM((void*) self->componentName);
GLOBAL_FREEMEM(self); GLOBAL_FREEMEM(self);
} }

@ -527,6 +527,7 @@ parseListOfDirectoryEntries(uint8_t* buffer, int bufPos, int maxBufPos, uint32_t
int length; int length;
bufPos = BerDecoder_decodeLength(buffer, &length, bufPos, maxBufPos); bufPos = BerDecoder_decodeLength(buffer, &length, bufPos, maxBufPos);
if (bufPos < 0) return false; if (bufPos < 0) return false;
int endPos = bufPos + length; int endPos = bufPos + length;

@ -1,24 +1,24 @@
/* /*
* mms_client_get_namelist.c * mms_client_get_namelist.c
* *
* Copyright 2013 Michael Zillgith * Copyright 2013-2018 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 * libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* libIEC61850 is distributed in the hope that it will be useful, * libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>. * 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" #include "libiec61850_platform_includes.h"
@ -121,6 +121,7 @@ mmsClient_parseGetNameListResponse(LinkedList* nameList, ByteBuffer* message)
uint8_t tag = buffer[bufPos++]; uint8_t tag = buffer[bufPos++];
if (tag == 0xa2) { if (tag == 0xa2) {
// TODO parse confirmed error PDU
goto exit_error; goto exit_error;
} }
if (tag != 0xa1) goto exit_error; if (tag != 0xa1) goto exit_error;

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

@ -250,7 +250,7 @@ parseNamedVariableAttributes(GetNamedVariableListAttributesResponse_t* response,
} }
LinkedList /* <MmsVariableAccessSpecification*> */ LinkedList /* <MmsVariableAccessSpecification*> */
mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint32_t* invokeId, bool* /*OUT*/deletable) mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, bool* /*OUT*/deletable)
{ {
MmsPdu_t* mmsPdu = 0; MmsPdu_t* mmsPdu = 0;
@ -262,12 +262,6 @@ mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint3
if (rval.code == RC_OK) { if (rval.code == RC_OK) {
if (mmsPdu->present == MmsPdu_PR_confirmedResponsePdu) { if (mmsPdu->present == MmsPdu_PR_confirmedResponsePdu) {
#if 0
//TODO remove
if (invokeId != NULL)
*invokeId = mmsClient_getInvokeId(&mmsPdu->choice.confirmedResponsePdu);
#endif
if (mmsPdu->choice.confirmedResponsePdu.confirmedServiceResponse.present == if (mmsPdu->choice.confirmedResponsePdu.confirmedServiceResponse.present ==
ConfirmedServiceResponse_PR_getNamedVariableListAttributes) ConfirmedServiceResponse_PR_getNamedVariableListAttributes)
{ {
@ -289,7 +283,7 @@ mmsClient_createDefineNamedVariableListRequest(
ByteBuffer* writeBuffer, ByteBuffer* writeBuffer,
const char* domainId, const char* domainId,
const char* listNameId, const char* listNameId,
LinkedList /*<MmsVariableSpecification*>*/listOfVariables, LinkedList /*<MmsVariableSpecification*>*/ listOfVariables,
bool associationSpecific) bool associationSpecific)
{ {
MmsPdu_t* mmsPdu = mmsClient_createConfirmedRequestPdu(invokeId); MmsPdu_t* mmsPdu = mmsClient_createConfirmedRequestPdu(invokeId);
@ -370,8 +364,7 @@ mmsClient_createDefineNamedVariableListRequest(
alternateAccess->list.array[0]->present = AlternateAccess__Member_PR_unnamed; alternateAccess->list.array[0]->present = AlternateAccess__Member_PR_unnamed;
alternateAccess->list.array[0]->choice.unnamed = (AlternateAccessSelection_t*) GLOBAL_CALLOC(1, sizeof(AlternateAccessSelection_t)); alternateAccess->list.array[0]->choice.unnamed = (AlternateAccessSelection_t*) GLOBAL_CALLOC(1, sizeof(AlternateAccessSelection_t));
alternateAccess->list.array[0]->choice.unnamed->present = alternateAccess->list.array[0]->choice.unnamed->present = AlternateAccessSelection_PR_selectAlternateAccess;
AlternateAccessSelection_PR_selectAlternateAccess;
alternateAccess->list.array[0]->choice.unnamed->choice.selectAlternateAccess.accessSelection.present = alternateAccess->list.array[0]->choice.unnamed->choice.selectAlternateAccess.accessSelection.present =
AlternateAccessSelection__selectAlternateAccess__accessSelection_PR_index; AlternateAccessSelection__selectAlternateAccess__accessSelection_PR_index;

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

@ -3,22 +3,22 @@
* *
* Copyright 2013-2018 Michael Zillgith * Copyright 2013-2018 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 * libIEC61850 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* libIEC61850 is distributed in the hope that it will be useful, * libIEC61850 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with libIEC61850. If not, see <http://www.gnu.org/licenses/>. * 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" #include "libiec61850_platform_includes.h"
@ -130,7 +130,7 @@ MmsValue_equals(const MmsValue* self, const MmsValue* otherValue)
return true; return true;
break; break;
case MMS_INTEGER: case MMS_INTEGER:
case MMS_UNSIGNED: case MMS_UNSIGNED:
return Asn1PrimitivaValue_compare(self->value.integer, otherValue->value.integer); return Asn1PrimitivaValue_compare(self->value.integer, otherValue->value.integer);
break; break;
case MMS_UTC_TIME: case MMS_UTC_TIME:
@ -162,7 +162,7 @@ MmsValue_equals(const MmsValue* self, const MmsValue* otherValue)
break; break;
case MMS_VISIBLE_STRING: case MMS_VISIBLE_STRING:
case MMS_STRING: case MMS_STRING:
if (self->value.visibleString.buf != NULL) { if (self->value.visibleString.buf != NULL) {
if (otherValue->value.visibleString.buf != NULL) { if (otherValue->value.visibleString.buf != NULL) {
if (strcmp(self->value.visibleString.buf, otherValue->value.visibleString.buf) == 0) if (strcmp(self->value.visibleString.buf, otherValue->value.visibleString.buf) == 0)
@ -315,7 +315,6 @@ MmsValue*
MmsValue_newBitString(int bitSize) MmsValue_newBitString(int bitSize)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL) if (self == NULL)
return NULL; return NULL;
@ -524,7 +523,6 @@ MmsValue*
MmsValue_newFloat(float variable) MmsValue_newFloat(float variable)
{ {
MmsValue* self = (MmsValue*) GLOBAL_MALLOC(sizeof(MmsValue)); MmsValue* self = (MmsValue*) GLOBAL_MALLOC(sizeof(MmsValue));
;
if (self == NULL) if (self == NULL)
return NULL; return NULL;
@ -587,7 +585,6 @@ MmsValue*
MmsValue_newIntegerFromInt8(int8_t integer) MmsValue_newIntegerFromInt8(int8_t integer)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
self->type = MMS_INTEGER; self->type = MMS_INTEGER;
self->value.integer = BerInteger_createFromInt32((int32_t) integer); self->value.integer = BerInteger_createFromInt32((int32_t) integer);
@ -599,7 +596,6 @@ MmsValue*
MmsValue_newIntegerFromInt16(int16_t integer) MmsValue_newIntegerFromInt16(int16_t integer)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
self->type = MMS_INTEGER; self->type = MMS_INTEGER;
self->value.integer = BerInteger_createFromInt32((int32_t) integer); self->value.integer = BerInteger_createFromInt32((int32_t) integer);
@ -833,7 +829,6 @@ MmsValue*
MmsValue_newUnsignedFromUint32(uint32_t integer) MmsValue_newUnsignedFromUint32(uint32_t integer)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL) if (self == NULL)
return NULL; return NULL;
@ -848,7 +843,6 @@ MmsValue*
MmsValue_newIntegerFromInt64(int64_t integer) MmsValue_newIntegerFromInt64(int64_t integer)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL) if (self == NULL)
return NULL; return NULL;
@ -914,8 +908,6 @@ MmsValue_toFloat(const MmsValue* self)
return val; return val;
} }
} }
else
printf("MmsValue_toFloat: conversion error. Wrong type!\n");
return 0.f; return 0.f;
} }
@ -967,7 +959,7 @@ MmsValue_getSizeInMemory(const MmsValue* self)
switch (self->type) switch (self->type)
{ {
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
{ {
memorySize += (MemoryAllocator_getAlignedSize(sizeof(MmsValue*)) * self->value.structure.size); memorySize += (MemoryAllocator_getAlignedSize(sizeof(MmsValue*)) * self->value.structure.size);
@ -982,7 +974,7 @@ MmsValue_getSizeInMemory(const MmsValue* self)
break; break;
case MMS_INTEGER: case MMS_INTEGER:
case MMS_UNSIGNED: case MMS_UNSIGNED:
memorySize += MemoryAllocator_getAlignedSize(sizeof(Asn1PrimitiveValue)); memorySize += MemoryAllocator_getAlignedSize(sizeof(Asn1PrimitiveValue));
memorySize += MemoryAllocator_getAlignedSize(self->value.integer->maxSize); memorySize += MemoryAllocator_getAlignedSize(self->value.integer->maxSize);
break; break;
@ -1018,7 +1010,7 @@ MmsValue_cloneToBuffer(const MmsValue* self, uint8_t* destinationAddress)
switch (self->type) switch (self->type)
{ {
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
{ {
newValue->value.structure.components = (MmsValue**) destinationAddress; newValue->value.structure.components = (MmsValue**) destinationAddress;
destinationAddress += (sizeof(MmsValue*) * self->value.structure.size); destinationAddress += (sizeof(MmsValue*) * self->value.structure.size);
@ -1038,7 +1030,7 @@ MmsValue_cloneToBuffer(const MmsValue* self, uint8_t* destinationAddress)
break; break;
case MMS_INTEGER: case MMS_INTEGER:
case MMS_UNSIGNED: case MMS_UNSIGNED:
{ {
newValue->value.integer = (Asn1PrimitiveValue*) destinationAddress; newValue->value.integer = (Asn1PrimitiveValue*) destinationAddress;
Asn1PrimitiveValue* newAsn1Value = (Asn1PrimitiveValue*) destinationAddress; Asn1PrimitiveValue* newAsn1Value = (Asn1PrimitiveValue*) destinationAddress;
@ -1067,7 +1059,7 @@ MmsValue_cloneToBuffer(const MmsValue* self, uint8_t* destinationAddress)
break; break;
case MMS_STRING: case MMS_STRING:
case MMS_VISIBLE_STRING: case MMS_VISIBLE_STRING:
newValue->value.visibleString.buf = (char*) destinationAddress; newValue->value.visibleString.buf = (char*) destinationAddress;
newValue->value.visibleString.size = self->value.visibleString.size; newValue->value.visibleString.size = self->value.visibleString.size;
strcpy((char*) destinationAddress, self->value.visibleString.buf); strcpy((char*) destinationAddress, self->value.visibleString.buf);
@ -1081,7 +1073,6 @@ MmsValue_cloneToBuffer(const MmsValue* self, uint8_t* destinationAddress)
return destinationAddress; return destinationAddress;
} }
// create a deep clone
MmsValue* MmsValue*
MmsValue_clone(const MmsValue* self) MmsValue_clone(const MmsValue* self)
{ {
@ -1098,7 +1089,7 @@ MmsValue_clone(const MmsValue* self)
{ {
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
{ {
int componentCount = self->value.structure.size; int componentCount = self->value.structure.size;
newValue->value.structure.size = componentCount; newValue->value.structure.size = componentCount;
@ -1112,7 +1103,7 @@ MmsValue_clone(const MmsValue* self)
break; break;
case MMS_INTEGER: case MMS_INTEGER:
case MMS_UNSIGNED: case MMS_UNSIGNED:
newValue->value.integer = Asn1PrimitiveValue_clone(self->value.integer); newValue->value.integer = Asn1PrimitiveValue_clone(self->value.integer);
break; break;
@ -1153,7 +1144,7 @@ MmsValue_clone(const MmsValue* self)
break; break;
case MMS_VISIBLE_STRING: case MMS_VISIBLE_STRING:
case MMS_STRING: case MMS_STRING:
size = self->value.visibleString.size; size = self->value.visibleString.size;
newValue->value.visibleString.buf = (char*) GLOBAL_MALLOC(size + 1); newValue->value.visibleString.buf = (char*) GLOBAL_MALLOC(size + 1);
newValue->value.visibleString.size = size; newValue->value.visibleString.size = size;
@ -1168,7 +1159,7 @@ MmsValue_clone(const MmsValue* self)
break; break;
} }
exit_function: exit_function:
return newValue; return newValue;
} }
@ -1191,7 +1182,7 @@ MmsValue_delete(MmsValue* self)
switch (self->type) switch (self->type)
{ {
case MMS_INTEGER: case MMS_INTEGER:
case MMS_UNSIGNED: case MMS_UNSIGNED:
Asn1PrimitiveValue_destroy(self->value.integer); Asn1PrimitiveValue_destroy(self->value.integer);
break; break;
case MMS_FLOAT: case MMS_FLOAT:
@ -1204,12 +1195,12 @@ MmsValue_delete(MmsValue* self)
GLOBAL_FREEMEM(self->value.octetString.buf); GLOBAL_FREEMEM(self->value.octetString.buf);
break; break;
case MMS_VISIBLE_STRING: case MMS_VISIBLE_STRING:
case MMS_STRING: case MMS_STRING:
if (self->value.visibleString.buf != NULL) if (self->value.visibleString.buf != NULL)
GLOBAL_FREEMEM(self->value.visibleString.buf); GLOBAL_FREEMEM(self->value.visibleString.buf);
break; break;
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
{ {
int componentCount = self->value.structure.size; int componentCount = self->value.structure.size;
int i; int i;
@ -1237,7 +1228,7 @@ MmsValue_deleteConditional(MmsValue* self)
switch (self->type) switch (self->type)
{ {
case MMS_INTEGER: case MMS_INTEGER:
case MMS_UNSIGNED: case MMS_UNSIGNED:
Asn1PrimitiveValue_destroy(self->value.integer); Asn1PrimitiveValue_destroy(self->value.integer);
break; break;
case MMS_FLOAT: case MMS_FLOAT:
@ -1250,12 +1241,12 @@ MmsValue_deleteConditional(MmsValue* self)
GLOBAL_FREEMEM(self->value.octetString.buf); GLOBAL_FREEMEM(self->value.octetString.buf);
break; break;
case MMS_VISIBLE_STRING: case MMS_VISIBLE_STRING:
case MMS_STRING: case MMS_STRING:
if (self->value.visibleString.buf != NULL) if (self->value.visibleString.buf != NULL)
GLOBAL_FREEMEM(self->value.visibleString.buf); GLOBAL_FREEMEM(self->value.visibleString.buf);
break; break;
case MMS_ARRAY: case MMS_ARRAY:
case MMS_STRUCTURE: case MMS_STRUCTURE:
{ {
int componentCount = self->value.structure.size; int componentCount = self->value.structure.size;
int i; int i;
@ -1497,7 +1488,7 @@ MmsValue_newDefaultValue(const MmsVariableSpecification* typeSpec)
if (self != NULL) if (self != NULL)
self->deleteValue = 0; self->deleteValue = 0;
exit_function: exit_function:
return self; return self;
} }
@ -1526,7 +1517,7 @@ setVisibleStringValue(MmsValue* self, const char* string)
self->value.visibleString.buf[0] = 0; self->value.visibleString.buf[0] = 0;
} }
exit_function: exit_function:
return; return;
} }
@ -1559,7 +1550,7 @@ MmsValue_newString(const char* string, MmsType type)
setVisibleStringValue(self, string); setVisibleStringValue(self, string);
} }
exit_function: exit_function:
return self; return self;
} }
@ -1590,7 +1581,7 @@ MmsValue_newStringWithSize(int size, MmsType type)
self->value.visibleString.buf[0] = 0; self->value.visibleString.buf[0] = 0;
exit_function: exit_function:
return self; return self;
} }
@ -1715,9 +1706,8 @@ void
MmsValue_setMmsString(MmsValue* self, const char* string) MmsValue_setMmsString(MmsValue* self, const char* string)
{ {
if (self->type == MMS_STRING) { if (self->type == MMS_STRING) {
assert(self->value.visibleString.buf != NULL); if (self->value.visibleString.buf != NULL);
setVisibleStringValue(self, string);
setVisibleStringValue(self, string);
} }
} }
@ -1740,7 +1730,7 @@ MmsValue_newStringFromByteArray(const uint8_t* byteArray, int size, MmsType type
self = NULL; self = NULL;
} }
exit_function: exit_function:
return self; return self;
} }
@ -1760,9 +1750,8 @@ void
MmsValue_setVisibleString(MmsValue* self, const char* string) MmsValue_setVisibleString(MmsValue* self, const char* string)
{ {
if (self->type == MMS_VISIBLE_STRING) { if (self->type == MMS_VISIBLE_STRING) {
assert(self->value.visibleString.buf != NULL); if (self->value.visibleString.buf != NULL);
setVisibleStringValue(self, string);
setVisibleStringValue(self, string);
} }
} }
@ -1809,7 +1798,7 @@ MmsValue_newUtcTime(uint32_t timeval)
valueArray[3] = timeArray[3]; valueArray[3] = timeArray[3];
#endif #endif
exit_function: exit_function:
return self; return self;
} }
@ -1856,7 +1845,7 @@ MmsValue_createArray(MmsVariableSpecification* elementType, int size)
} }
} }
exit_function: exit_function:
return self; return self;
} }
@ -1883,7 +1872,7 @@ MmsValue_createEmptyArray(int size)
self->value.structure.components[i] = NULL; self->value.structure.components[i] = NULL;
} }
exit_function: exit_function:
return self; return self;
} }
@ -2013,7 +2002,7 @@ MmsValue_printToBuffer(const MmsValue* self, char* buffer, int bufferSize)
switch (MmsValue_getType(self)) switch (MmsValue_getType(self))
{ {
case MMS_STRUCTURE: case MMS_STRUCTURE:
case MMS_ARRAY: case MMS_ARRAY:
{ {
if (bufferSize == 0) if (bufferSize == 0)
break; break;

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

Loading…
Cancel
Save