- some code formatting

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

@ -1,7 +1,7 @@
/*
* iso_connection_parameters.h
*
* Copyright 2013, 2014 Michael Zillgith
* Copyright 2013-2018 Michael Zillgith
*
* 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
{
@ -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
* there should be no reason for the user to call this function.
*
* \return new IsoConnectionParameters
* \return new IsoConnectionParameters instance
*/
LIB61850_API IsoConnectionParameters
IsoConnectionParameters_create(void);

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

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

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

@ -42,16 +42,6 @@
#define DEBUG_MMS_CLIENT 0
#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_REQUESTED 1
#define CONCLUDE_STATE_REJECTED 2
@ -236,8 +226,7 @@ mmsClient_createGetNamedVariableListAttributesRequestAssociationSpecific(uint32_
ByteBuffer* writeBuffer, const char* listNameId);
LIB61850_INTERNAL LinkedList
mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint32_t* invokeId,
bool* /*OUT*/ deletable);
mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, bool* /*OUT*/ deletable);
LIB61850_INTERNAL int
mmsClient_createGetVariableAccessAttributesRequest(

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

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

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

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

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

@ -1,7 +1,7 @@
/*
* mms_client_get_namelist.c
*
* Copyright 2013 Michael Zillgith
* Copyright 2013-2018 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -121,6 +121,7 @@ mmsClient_parseGetNameListResponse(LinkedList* nameList, ByteBuffer* message)
uint8_t tag = buffer[bufPos++];
if (tag == 0xa2) {
// TODO parse confirmed error PDU
goto exit_error;
}
if (tag != 0xa1) goto exit_error;

@ -1,7 +1,7 @@
/*
* mms_client_get_var_access.c
*
* Copyright 2013 Michael Zillgith
* Copyright 2013-2018 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -18,7 +18,7 @@
* 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.
* sSee COPYING file for the complete license text.
*/
#include "libiec61850_platform_includes.h"

@ -250,7 +250,7 @@ parseNamedVariableAttributes(GetNamedVariableListAttributesResponse_t* response,
}
LinkedList /* <MmsVariableAccessSpecification*> */
mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint32_t* invokeId, bool* /*OUT*/deletable)
mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, bool* /*OUT*/deletable)
{
MmsPdu_t* mmsPdu = 0;
@ -262,12 +262,6 @@ mmsClient_parseGetNamedVariableListAttributesResponse(ByteBuffer* message, uint3
if (rval.code == RC_OK) {
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 ==
ConfirmedServiceResponse_PR_getNamedVariableListAttributes)
{
@ -289,7 +283,7 @@ mmsClient_createDefineNamedVariableListRequest(
ByteBuffer* writeBuffer,
const char* domainId,
const char* listNameId,
LinkedList /*<MmsVariableSpecification*>*/listOfVariables,
LinkedList /*<MmsVariableSpecification*>*/ listOfVariables,
bool associationSpecific)
{
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]->choice.unnamed = (AlternateAccessSelection_t*) GLOBAL_CALLOC(1, sizeof(AlternateAccessSelection_t));
alternateAccess->list.array[0]->choice.unnamed->present =
AlternateAccessSelection_PR_selectAlternateAccess;
alternateAccess->list.array[0]->choice.unnamed->present = AlternateAccessSelection_PR_selectAlternateAccess;
alternateAccess->list.array[0]->choice.unnamed->choice.selectAlternateAccess.accessSelection.present =
AlternateAccessSelection__selectAlternateAccess__accessSelection_PR_index;

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

@ -315,7 +315,6 @@ MmsValue*
MmsValue_newBitString(int bitSize)
{
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL)
return NULL;
@ -524,7 +523,6 @@ MmsValue*
MmsValue_newFloat(float variable)
{
MmsValue* self = (MmsValue*) GLOBAL_MALLOC(sizeof(MmsValue));
;
if (self == NULL)
return NULL;
@ -587,7 +585,6 @@ MmsValue*
MmsValue_newIntegerFromInt8(int8_t integer)
{
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
self->type = MMS_INTEGER;
self->value.integer = BerInteger_createFromInt32((int32_t) integer);
@ -599,7 +596,6 @@ MmsValue*
MmsValue_newIntegerFromInt16(int16_t integer)
{
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
self->type = MMS_INTEGER;
self->value.integer = BerInteger_createFromInt32((int32_t) integer);
@ -833,7 +829,6 @@ MmsValue*
MmsValue_newUnsignedFromUint32(uint32_t integer)
{
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL)
return NULL;
@ -848,7 +843,6 @@ MmsValue*
MmsValue_newIntegerFromInt64(int64_t integer)
{
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
;
if (self == NULL)
return NULL;
@ -914,8 +908,6 @@ MmsValue_toFloat(const MmsValue* self)
return val;
}
}
else
printf("MmsValue_toFloat: conversion error. Wrong type!\n");
return 0.f;
}
@ -1081,7 +1073,6 @@ MmsValue_cloneToBuffer(const MmsValue* self, uint8_t* destinationAddress)
return destinationAddress;
}
// create a deep clone
MmsValue*
MmsValue_clone(const MmsValue* self)
{
@ -1168,7 +1159,7 @@ MmsValue_clone(const MmsValue* self)
break;
}
exit_function:
exit_function:
return newValue;
}
@ -1497,7 +1488,7 @@ MmsValue_newDefaultValue(const MmsVariableSpecification* typeSpec)
if (self != NULL)
self->deleteValue = 0;
exit_function:
exit_function:
return self;
}
@ -1526,7 +1517,7 @@ setVisibleStringValue(MmsValue* self, const char* string)
self->value.visibleString.buf[0] = 0;
}
exit_function:
exit_function:
return;
}
@ -1559,7 +1550,7 @@ MmsValue_newString(const char* string, MmsType type)
setVisibleStringValue(self, string);
}
exit_function:
exit_function:
return self;
}
@ -1590,7 +1581,7 @@ MmsValue_newStringWithSize(int size, MmsType type)
self->value.visibleString.buf[0] = 0;
exit_function:
exit_function:
return self;
}
@ -1715,8 +1706,7 @@ void
MmsValue_setMmsString(MmsValue* self, const char* string)
{
if (self->type == MMS_STRING) {
assert(self->value.visibleString.buf != NULL);
if (self->value.visibleString.buf != NULL);
setVisibleStringValue(self, string);
}
}
@ -1740,7 +1730,7 @@ MmsValue_newStringFromByteArray(const uint8_t* byteArray, int size, MmsType type
self = NULL;
}
exit_function:
exit_function:
return self;
}
@ -1760,8 +1750,7 @@ void
MmsValue_setVisibleString(MmsValue* self, const char* string)
{
if (self->type == MMS_VISIBLE_STRING) {
assert(self->value.visibleString.buf != NULL);
if (self->value.visibleString.buf != NULL);
setVisibleStringValue(self, string);
}
}
@ -1809,7 +1798,7 @@ MmsValue_newUtcTime(uint32_t timeval)
valueArray[3] = timeArray[3];
#endif
exit_function:
exit_function:
return self;
}
@ -1856,7 +1845,7 @@ MmsValue_createArray(MmsVariableSpecification* elementType, int size)
}
}
exit_function:
exit_function:
return self;
}
@ -1883,7 +1872,7 @@ MmsValue_createEmptyArray(int size)
self->value.structure.components[i] = NULL;
}
exit_function:
exit_function:
return self;
}

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

Loading…
Cancel
Save