- IEC 61850 client: Added ClientGooseControlBlock_getDstAddress/ClientGooseControlBlock_setDstAddress; marked old access functions deprecated

pull/143/head
Michael Zillgith 8 years ago
parent 10ed5af230
commit a07f2cceda

@ -183,6 +183,97 @@ newEmptyPhyCommAddress(void) {
return self;
}
PhyComAddress
ClientGooseControlBlock_getDstAddress(ClientGooseControlBlock self)
{
PhyComAddress retVal;
memset(&retVal, 0, sizeof(retVal));
if (self->dstAddress == NULL) goto exit_error;
if (MmsValue_getType(self->dstAddress) != MMS_STRUCTURE) {
if (DEBUG_IED_CLIENT) printf("IED_CLIENT: GoCB - addr has wrong type\n");
goto exit_error;
}
if (MmsValue_getArraySize(self->dstAddress) != 4) {
if (DEBUG_IED_CLIENT) printf("IED_CLIENT: GoCB - addr has wrong type\n");
goto exit_error;
}
MmsValue* addr = MmsValue_getElement(self->dstAddress, 0);
if (MmsValue_getType(addr) != MMS_OCTET_STRING) {
if (DEBUG_IED_CLIENT) printf("IED_CLIENT: GoCB - addr has wrong type\n");
goto exit_error;
}
if (MmsValue_getOctetStringSize(addr) != 6) {
if (DEBUG_IED_CLIENT) printf("IED_CLIENT: GoCB - addr has wrong size\n");
goto exit_error;
}
uint8_t* addrBuf = MmsValue_getOctetStringBuffer(addr);
memcpy(&(retVal.dstAddress), addrBuf, 6);
MmsValue* prio = MmsValue_getElement(self->dstAddress, 1);
if (MmsValue_getType(prio) != MMS_UNSIGNED) {
if (DEBUG_IED_CLIENT) printf("IED_CLIENT: GoCB - prio has wrong type\n");
goto exit_error;
}
retVal.vlanPriority = MmsValue_toUint32(prio);
MmsValue* vid = MmsValue_getElement(self->dstAddress, 2);
if (MmsValue_getType(vid) != MMS_UNSIGNED) {
if (DEBUG_IED_CLIENT) printf("IED_CLIENT: GoCB - vid has wrong type\n");
goto exit_error;
}
retVal.vlanId = MmsValue_toUint32(vid);
MmsValue* appID = MmsValue_getElement(self->dstAddress, 3);
if (MmsValue_getType(appID) != MMS_UNSIGNED) {
if (DEBUG_IED_CLIENT) printf("IED_CLIENT: GoCB - appID has wrong type\n");
goto exit_error;
}
retVal.appId = MmsValue_toUint32(appID);
exit_error:
return retVal;
}
void
ClientGooseControlBlock_setDstAddress(ClientGooseControlBlock self, PhyComAddress value)
{
if (self->dstAddress == NULL)
self->dstAddress = newEmptyPhyCommAddress();
if (self->dstAddress) {
MmsValue* addr = MmsValue_getElement(self->dstAddress, 0);
MmsValue_setOctetString(addr, value.dstAddress, 6);
MmsValue* prio = MmsValue_getElement(self->dstAddress, 1);
MmsValue_setUint8(prio, value.vlanPriority);
MmsValue* vid = MmsValue_getElement(self->dstAddress, 2);
MmsValue_setUint16(vid, value.vlanId);
MmsValue* appID = MmsValue_getElement(self->dstAddress, 3);
MmsValue_setUint16(appID, value.appId);
}
}
MmsValue*
ClientGooseControlBlock_getDstAddress_addr(ClientGooseControlBlock self)
{

@ -34,6 +34,14 @@ extern "C" {
#include "mms_client_connection.h"
#include "linked_list.h"
#ifndef DEPRECATED
#if defined(__GNUC__) || defined(__clang__)
#define DEPRECATED __attribute__((deprecated))
#else
#define DEPRECATED
#endif
#endif
/**
* * \defgroup iec61850_client_api_group IEC 61850/MMS client API
*/
@ -545,28 +553,34 @@ ClientGooseControlBlock_getMaxTime(ClientGooseControlBlock self);
bool
ClientGooseControlBlock_getFixedOffs(ClientGooseControlBlock self);
MmsValue* /* MMS_OCTET_STRING */
ClientGooseControlBlock_getDstAddress_addr(ClientGooseControlBlock self);
PhyComAddress
ClientGooseControlBlock_getDstAddress(ClientGooseControlBlock self);
void
ClientGooseControlBlock_setDstAddress(ClientGooseControlBlock self, PhyComAddress value);
DEPRECATED MmsValue* /* MMS_OCTET_STRING */
ClientGooseControlBlock_getDstAddress_addr(ClientGooseControlBlock self);
DEPRECATED void
ClientGooseControlBlock_setDstAddress_addr(ClientGooseControlBlock self, MmsValue* macAddr);
uint8_t
DEPRECATED uint8_t
ClientGooseControlBlock_getDstAddress_priority(ClientGooseControlBlock self);
void
DEPRECATED void
ClientGooseControlBlock_setDstAddress_priority(ClientGooseControlBlock self, uint8_t priorityValue);
uint16_t
DEPRECATED uint16_t
ClientGooseControlBlock_getDstAddress_vid(ClientGooseControlBlock self);
void
DEPRECATED void
ClientGooseControlBlock_setDstAddress_vid(ClientGooseControlBlock self, uint16_t vidValue);
uint16_t
DEPRECATED uint16_t
ClientGooseControlBlock_getDstAddress_appid(ClientGooseControlBlock self);
void
DEPRECATED void
ClientGooseControlBlock_setDstAddress_appid(ClientGooseControlBlock self, uint16_t appidValue);

@ -574,4 +574,6 @@ EXPORTS
MmsServer_setLocalIpAddress
MmsServer_isRunning
IedServer_createWithTlsSupport
IedConnection_createWithTlsSupport
IedConnection_createWithTlsSupport
ClientGooseControlBlock_getDstAddress
ClientGooseControlBlock_setDstAddress

@ -655,4 +655,6 @@ EXPORTS
MmsServer_setLocalIpAddress
MmsServer_isRunning
IedServer_createWithTlsSupport
IedConnection_createWithTlsSupport
IedConnection_createWithTlsSupport
ClientGooseControlBlock_getDstAddress
ClientGooseControlBlock_setDstAddress
Loading…
Cancel
Save