- refactoring for MmsServerConnection - removed struct from API

pull/6/head
Michael Zillgith 11 years ago
parent 0fb4ed0efc
commit 6bc7b48e9f

@ -86,10 +86,10 @@ MmsDomain*
ControlObject_getDomain(ControlObject* self); ControlObject_getDomain(ControlObject* self);
bool bool
ControlObject_select(ControlObject* self, MmsServerConnection* connection); ControlObject_select(ControlObject* self, MmsServerConnection connection);
bool bool
ControlObject_unselect(ControlObject* self, MmsServerConnection* connection); ControlObject_unselect(ControlObject* self, MmsServerConnection connection);
void void
ControlObject_installListener(ControlObject* self, ControlHandler listener, void* parameter); ControlObject_installListener(ControlObject* self, ControlHandler listener, void* parameter);

@ -143,7 +143,7 @@ MmsMapping_installWriteAccessHandler(MmsMapping* self, DataAttribute* dataAttrib
MmsDataAccessError MmsDataAccessError
Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig, Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig,
MmsValue* value, MmsServerConnection* connection); MmsValue* value, MmsServerConnection connection);
ControlObject* ControlObject*
Control_lookupControlObject(MmsMapping* self, MmsDomain* domain, char* lnName, char* objectName); Control_lookupControlObject(MmsMapping* self, MmsDomain* domain, char* lnName, char* objectName);

@ -69,7 +69,7 @@ typedef struct {
uint32_t bufTm; uint32_t bufTm;
uint64_t nextIntgReportTime; uint64_t nextIntgReportTime;
uint64_t reservationTimeout; uint64_t reservationTimeout;
MmsServerConnection* clientConnection; MmsServerConnection clientConnection;
uint64_t lastEntryId; uint64_t lastEntryId;
@ -112,7 +112,7 @@ Reporting_createMmsUnbufferedRCBs(MmsMapping* self, MmsDomain* domain,
MmsDataAccessError MmsDataAccessError
Reporting_RCBWriteAccessHandler(MmsMapping* self, ReportControl* rc, char* elementName, MmsValue* value, Reporting_RCBWriteAccessHandler(MmsMapping* self, ReportControl* rc, char* elementName, MmsValue* value,
MmsServerConnection* connection); MmsServerConnection connection);
void void
Reporting_activateBufferedReports(MmsMapping* self); Reporting_activateBufferedReports(MmsMapping* self);
@ -121,6 +121,6 @@ void
Reporting_processReportEvents(MmsMapping* self, uint64_t currentTimeInMs); Reporting_processReportEvents(MmsMapping* self, uint64_t currentTimeInMs);
void void
Reporting_deactivateReportsForConnection(MmsMapping* self, MmsServerConnection* connection); Reporting_deactivateReportsForConnection(MmsMapping* self, MmsServerConnection connection);
#endif /* REPORTING_H_ */ #endif /* REPORTING_H_ */

@ -1,7 +1,7 @@
/* /*
* client_connection.c * client_connection.c
* *
* Copyright 2013 Michael Zillgith * Copyright 2013, 2014, 2015 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *
@ -29,6 +29,7 @@
#include "hal_thread.h" #include "hal_thread.h"
#include "ied_server_private.h" #include "ied_server_private.h"
#include "mms_server.h"
struct sClientConnection { struct sClientConnection {
@ -121,16 +122,16 @@ private_ClientConnection_getServerConnectionHandle(ClientConnection self)
const char* const char*
ClientConnection_getPeerAddress(ClientConnection self) ClientConnection_getPeerAddress(ClientConnection self)
{ {
MmsServerConnection* mmsConnection = (MmsServerConnection*) self->serverConnectionHandle; MmsServerConnection mmsConnection = (MmsServerConnection) self->serverConnectionHandle;
return IsoConnection_getPeerAddress(mmsConnection->isoConnection); return IsoConnection_getPeerAddress(MmsServerConnection_getIsoConnection(mmsConnection));
} }
void* void*
ClientConnection_getSecurityToken(ClientConnection self) ClientConnection_getSecurityToken(ClientConnection self)
{ {
MmsServerConnection* mmsConnection = (MmsServerConnection*) self->serverConnectionHandle; MmsServerConnection mmsConnection = (MmsServerConnection) self->serverConnectionHandle;
return IsoConnection_getSecurityToken(mmsConnection->isoConnection); return IsoConnection_getSecurityToken(MmsServerConnection_getIsoConnection(mmsConnection));
} }

@ -91,7 +91,7 @@ struct sControlObject
uint64_t operateTime; uint64_t operateTime;
bool operateOnce; bool operateOnce;
MmsServerConnection* mmsConnection; MmsServerConnection mmsConnection;
MmsValue* emptyString; MmsValue* emptyString;
@ -115,7 +115,7 @@ struct sControlObject
}; };
void void
ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connection, char* ctlVariable, int error, ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection connection, char* ctlVariable, int error,
ControlAddCause addCause, MmsValue* ctlNum, MmsValue* origin, bool handlerMode); ControlAddCause addCause, MmsValue* ctlNum, MmsValue* origin, bool handlerMode);
void void
@ -126,7 +126,7 @@ ControlObject_sendCommandTerminationNegative(ControlObject* self);
MmsValue* MmsValue*
Control_readAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig, Control_readAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig,
MmsServerConnection* connection); MmsServerConnection connection);
static void static void
setState(ControlObject* self, int newState) setState(ControlObject* self, int newState)
@ -600,7 +600,7 @@ ControlObject_getMmsValue(ControlObject* self)
} }
static void static void
selectObject(ControlObject* self, uint64_t selectTime, MmsServerConnection* connection) selectObject(ControlObject* self, uint64_t selectTime, MmsServerConnection connection)
{ {
updateSboTimeoutValue(self); updateSboTimeoutValue(self);
self->selected = true; self->selected = true;
@ -627,7 +627,7 @@ checkSelectTimeout(ControlObject* self, uint64_t currentTime)
} }
bool bool
ControlObject_unselect(ControlObject* self, MmsServerConnection* connection) ControlObject_unselect(ControlObject* self, MmsServerConnection connection)
{ {
if (self->mmsConnection == connection) { if (self->mmsConnection == connection) {
abortControlOperation(self); abortControlOperation(self);
@ -949,7 +949,7 @@ ControlObject_sendCommandTerminationNegative(ControlObject* self)
void void
ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connection, char* ctlVariable, int error, ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection connection, char* ctlVariable, int error,
ControlAddCause addCause, MmsValue* ctlNum, MmsValue* origin, bool handlerMode) ControlAddCause addCause, MmsValue* ctlNum, MmsValue* origin, bool handlerMode)
{ {
MmsValue lastApplErrorMemory; MmsValue lastApplErrorMemory;
@ -1033,7 +1033,7 @@ doesElementEquals(char* element, char* name)
MmsValue* MmsValue*
Control_readAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig, Control_readAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig,
MmsServerConnection* connection) MmsServerConnection connection)
{ {
MmsValue* value = NULL; MmsValue* value = NULL;
@ -1207,7 +1207,7 @@ getDataAccessErrorFromCheckHandlerResult(CheckHandlerResult checkResult)
MmsDataAccessError MmsDataAccessError
Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig, Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig,
MmsValue* value, MmsServerConnection* connection) MmsValue* value, MmsServerConnection connection)
{ {
MmsDataAccessError indication = DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED; MmsDataAccessError indication = DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED;

@ -75,7 +75,7 @@ typedef struct
#if (CONFIG_IEC61850_CONTROL_SERVICE == 1) #if (CONFIG_IEC61850_CONTROL_SERVICE == 1)
MmsValue* MmsValue*
Control_readAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig, Control_readAccessControlObject(MmsMapping* self, MmsDomain* domain, char* variableIdOrig,
MmsServerConnection* connection); MmsServerConnection connection);
#endif #endif
void /* Create PHYCOMADDR ACSI type instance */ void /* Create PHYCOMADDR ACSI type instance */
@ -559,7 +559,7 @@ unselectSettingGroup(SettingGroup* settingGroup)
} }
static void static void
unselectAllSettingGroups(MmsMapping* self, MmsServerConnection* serverCon) unselectAllSettingGroups(MmsMapping* self, MmsServerConnection serverCon)
{ {
LinkedList settingGroupElement = LinkedList_getNext(self->settingGroups); LinkedList settingGroupElement = LinkedList_getNext(self->settingGroups);
@ -1459,7 +1459,7 @@ getAccessPolicyForFC(MmsMapping* self, FunctionalConstraint fc)
static MmsDataAccessError static MmsDataAccessError
mmsWriteHandler(void* parameter, MmsDomain* domain, mmsWriteHandler(void* parameter, MmsDomain* domain,
char* variableId, MmsValue* value, MmsServerConnection* connection) char* variableId, MmsValue* value, MmsServerConnection connection)
{ {
MmsMapping* self = (MmsMapping*) parameter; MmsMapping* self = (MmsMapping*) parameter;
@ -1865,31 +1865,35 @@ readAccessGooseControlBlock(MmsMapping* self, MmsDomain* domain, char* variableI
#endif /* (CONFIG_INCLUDE_GOOSE_SUPPORT == 1) */ #endif /* (CONFIG_INCLUDE_GOOSE_SUPPORT == 1) */
static MmsValue* static MmsValue*
mmsReadHandler(void* parameter, MmsDomain* domain, char* variableId, MmsServerConnection* connection) mmsReadHandler(void* parameter, MmsDomain* domain, char* variableId, MmsServerConnection connection)
{ {
MmsMapping* self = (MmsMapping*) parameter; MmsMapping* self = (MmsMapping*) parameter;
MmsValue* retValue = NULL;
if (DEBUG_IED_SERVER) if (DEBUG_IED_SERVER)
printf("IED_SERVER: mmsReadHandler: Requested %s\n", variableId); printf("IED_SERVER: mmsReadHandler: Requested %s\n", variableId);
char* separator = strchr(variableId, '$'); char* separator = strchr(variableId, '$');
if (separator == NULL) if (separator == NULL)
return NULL; goto exit_function;
int lnNameLength = separator - variableId; int lnNameLength = separator - variableId;
#if (CONFIG_IEC61850_CONTROL_SERVICE == 1) #if (CONFIG_IEC61850_CONTROL_SERVICE == 1)
/* Controllable objects - CO */ /* Controllable objects - CO */
if (isControllable(separator)) { if (isControllable(separator)) {
return Control_readAccessControlObject(self, domain, variableId, connection); retValue = Control_readAccessControlObject(self, domain, variableId, connection);
goto exit_function;
} }
#endif #endif
/* GOOSE control blocks - GO */ /* GOOSE control blocks - GO */
#if (CONFIG_INCLUDE_GOOSE_SUPPORT == 1) #if (CONFIG_INCLUDE_GOOSE_SUPPORT == 1)
if (isGooseControlBlock(separator)) { if (isGooseControlBlock(separator)) {
return readAccessGooseControlBlock(self, domain, variableId); retValue = readAccessGooseControlBlock(self, domain, variableId);
goto exit_function;
} }
#endif #endif
@ -1903,8 +1907,10 @@ mmsReadHandler(void* parameter, MmsDomain* domain, char* variableId, MmsServerCo
char* reportName = MmsMapping_getNextNameElement(separator + 1); char* reportName = MmsMapping_getNextNameElement(separator + 1);
if (reportName == NULL) if (reportName == NULL) {
return NULL; retValue = NULL;
goto exit_function;
}
separator = strchr(reportName, '$'); separator = strchr(reportName, '$');
@ -1940,7 +1946,9 @@ mmsReadHandler(void* parameter, MmsDomain* domain, char* variableId, MmsServerCo
else else
value = rc->rcbValues; value = rc->rcbValues;
return value; retValue = value;
goto exit_function;
} }
} }
@ -1950,7 +1958,8 @@ mmsReadHandler(void* parameter, MmsDomain* domain, char* variableId, MmsServerCo
} }
#endif /* (CONFIG_IEC61850_REPORT_SERVICE == 1) */ #endif /* (CONFIG_IEC61850_REPORT_SERVICE == 1) */
return NULL; exit_function:
return retValue;
} }
void void
@ -1961,7 +1970,7 @@ MmsMapping_setMmsServer(MmsMapping* self, MmsServer server)
#if (CONFIG_IEC61850_CONTROL_SERVICE == 1) #if (CONFIG_IEC61850_CONTROL_SERVICE == 1)
static void static void
unselectControlsForConnection(MmsMapping* self, MmsServerConnection* connection) unselectControlsForConnection(MmsMapping* self, MmsServerConnection connection)
{ {
LinkedList controlObjectElement = LinkedList_getNext(self->controlObjects); LinkedList controlObjectElement = LinkedList_getNext(self->controlObjects);
@ -1977,7 +1986,7 @@ unselectControlsForConnection(MmsMapping* self, MmsServerConnection* connection)
#endif /* (CONFIG_IEC61850_CONTROL_SERVICE == 1) */ #endif /* (CONFIG_IEC61850_CONTROL_SERVICE == 1) */
static void /* is called by MMS server layer */ static void /* is called by MMS server layer */
mmsConnectionHandler(void* parameter, MmsServerConnection* connection, MmsServerEvent event) mmsConnectionHandler(void* parameter, MmsServerConnection connection, MmsServerEvent event)
{ {
MmsMapping* self = (MmsMapping*) parameter; MmsMapping* self = (MmsMapping*) parameter;
@ -2025,7 +2034,7 @@ mmsConnectionHandler(void* parameter, MmsServerConnection* connection, MmsServer
} }
static MmsDataAccessError static MmsDataAccessError
mmsReadAccessHandler (void* parameter, MmsDomain* domain, char* variableId, MmsServerConnection* connection) mmsReadAccessHandler (void* parameter, MmsDomain* domain, char* variableId, MmsServerConnection connection)
{ {
MmsMapping* self = (MmsMapping*) parameter; MmsMapping* self = (MmsMapping*) parameter;
@ -2054,7 +2063,7 @@ mmsReadAccessHandler (void* parameter, MmsDomain* domain, char* variableId, MmsS
static bool static bool
variableListChangedHandler (void* parameter, bool create, MmsVariableListType listType, MmsDomain* domain, variableListChangedHandler (void* parameter, bool create, MmsVariableListType listType, MmsDomain* domain,
char* listName, MmsServerConnection* connection) char* listName, MmsServerConnection connection)
{ {
bool allow = true; bool allow = true;

@ -462,7 +462,7 @@ createDataSetValuesShadowBuffer(ReportControl* rc)
} }
static bool static bool
updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet, MmsServerConnection* connection) updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet, MmsServerConnection connection)
{ {
bool success = false; bool success = false;
@ -1084,7 +1084,7 @@ Reporting_createMmsUnbufferedRCBs(MmsMapping* self, MmsDomain* domain,
#define CONFIG_REPORTING_SUPPORTS_OWNER 1 #define CONFIG_REPORTING_SUPPORTS_OWNER 1
static void static void
updateOwner(ReportControl* rc, MmsServerConnection* connection) updateOwner(ReportControl* rc, MmsServerConnection connection)
{ {
rc->clientConnection = connection; rc->clientConnection = connection;
@ -1182,7 +1182,7 @@ increaseConfRev(ReportControl* self)
MmsDataAccessError MmsDataAccessError
Reporting_RCBWriteAccessHandler(MmsMapping* self, ReportControl* rc, char* elementName, MmsValue* value, Reporting_RCBWriteAccessHandler(MmsMapping* self, ReportControl* rc, char* elementName, MmsValue* value,
MmsServerConnection* connection) MmsServerConnection connection)
{ {
MmsDataAccessError retVal = DATA_ACCESS_ERROR_SUCCESS; MmsDataAccessError retVal = DATA_ACCESS_ERROR_SUCCESS;
@ -1428,7 +1428,7 @@ exit_function:
} }
void void
Reporting_deactivateReportsForConnection(MmsMapping* self, MmsServerConnection* connection) Reporting_deactivateReportsForConnection(MmsMapping* self, MmsServerConnection connection)
{ {
LinkedList reportControl = self->reportControls; LinkedList reportControl = self->reportControls;

@ -32,8 +32,6 @@
extern "C" { extern "C" {
#endif #endif
#include "stack_config.h"
#include "mms_device_model.h" #include "mms_device_model.h"
#include "mms_value.h" #include "mms_value.h"
#include "iso_server.h" #include "iso_server.h"
@ -44,42 +42,7 @@ typedef enum {
typedef struct sMmsServer* MmsServer; typedef struct sMmsServer* MmsServer;
#if (MMS_FILE_SERVICE == 1) typedef struct sMmsServerConnection* MmsServerConnection;
#ifndef CONFIG_MMS_MAX_NUMBER_OF_OPEN_FILES_PER_CONNECTION
#define CONFIG_MMS_MAX_NUMBER_OF_OPEN_FILES_PER_CONNECTION 5
#endif
#include "hal_filesystem.h"
typedef struct {
int32_t frsmId;
uint32_t readPosition;
uint32_t fileSize;
FileHandle fileHandle;
} MmsFileReadStateMachine;
#endif /* (MMS_FILE_SERVICE == 1) */
typedef struct sMmsServerConnection {
int maxServOutstandingCalling;
int maxServOutstandingCalled;
int dataStructureNestingLevel;
int maxPduSize; /* local detail */
IsoConnection isoConnection;
MmsServer server;
uint32_t lastInvokeId;
#if (MMS_DYNAMIC_DATA_SETS == 1)
LinkedList /*<MmsNamedVariableList>*/namedVariableLists; /* aa-specific named variable lists */
#endif
#if (MMS_FILE_SERVICE == 1)
int32_t nextFrsmId;
MmsFileReadStateMachine frsms[CONFIG_MMS_MAX_NUMBER_OF_OPEN_FILES_PER_CONNECTION];
#endif
} MmsServerConnection;
typedef enum { typedef enum {
MMS_DOMAIN_SPECIFIC, MMS_DOMAIN_SPECIFIC,
@ -88,17 +51,17 @@ typedef enum {
} MmsVariableListType; } MmsVariableListType;
typedef MmsValue* (*MmsReadVariableHandler)(void* parameter, MmsDomain* domain, typedef MmsValue* (*MmsReadVariableHandler)(void* parameter, MmsDomain* domain,
char* variableId, MmsServerConnection* connection); char* variableId, MmsServerConnection connection);
typedef MmsDataAccessError (*MmsReadAccessHandler) (void* parameter, MmsDomain* domain, typedef MmsDataAccessError (*MmsReadAccessHandler) (void* parameter, MmsDomain* domain,
char* variableId, MmsServerConnection* connection); char* variableId, MmsServerConnection connection);
typedef MmsDataAccessError (*MmsWriteVariableHandler)(void* parameter, typedef MmsDataAccessError (*MmsWriteVariableHandler)(void* parameter,
MmsDomain* domain, char* variableId, MmsValue* value, MmsDomain* domain, char* variableId, MmsValue* value,
MmsServerConnection* connection); MmsServerConnection connection);
typedef void (*MmsConnectionHandler)(void* parameter, typedef void (*MmsConnectionHandler)(void* parameter,
MmsServerConnection* connection, MmsServerEvent event); MmsServerConnection connection, MmsServerEvent event);
MmsServer MmsServer
MmsServer_create(IsoServer isoServer, MmsDevice* device); MmsServer_create(IsoServer isoServer, MmsDevice* device);
@ -150,7 +113,7 @@ MmsServer_isLocked(MmsServer self);
* is returned to the client. * is returned to the client.
*/ */
typedef bool (*MmsNamedVariableListChangedHandler)(void* parameter, bool create, MmsVariableListType listType, MmsDomain* domain, typedef bool (*MmsNamedVariableListChangedHandler)(void* parameter, bool create, MmsVariableListType listType, MmsDomain* domain,
char* listName, MmsServerConnection* connection); char* listName, MmsServerConnection connection);
/** /**
* \brief Install callback handler that is called when a named variable list changes (is created or deleted) * \brief Install callback handler that is called when a named variable list changes (is created or deleted)
@ -326,7 +289,7 @@ MmsServer_getRevision(MmsServer self);
* \param connection is the MmsServerConnection instance that received the MMS status request * \param connection is the MmsServerConnection instance that received the MMS status request
* \param extendedDerivation indicates if the request contains the extendedDerivation parameter * \param extendedDerivation indicates if the request contains the extendedDerivation parameter
*/ */
typedef void (*MmsStatusRequestListener)(void* parameter, MmsServer mmsServer, MmsServerConnection* connection, bool extendedDerivation); typedef void (*MmsStatusRequestListener)(void* parameter, MmsServer mmsServer, MmsServerConnection connection, bool extendedDerivation);
/** /**
* \brief set the VMD state values for the VMD status service * \brief set the VMD state values for the VMD status service
@ -368,6 +331,12 @@ MmsServer_getVMDPhysicalStatus(MmsServer self);
void void
MmsServer_setStatusRequestListener(MmsServer self, MmsStatusRequestListener listener, void* parameter); MmsServer_setStatusRequestListener(MmsServer self, MmsStatusRequestListener listener, void* parameter);
char*
MmsServerConnection_getClientAddress(MmsServerConnection self);
IsoConnection
MmsServerConnection_getIsoConnection(MmsServerConnection self);
/**@}*/ /**@}*/
#ifdef __cplusplus #ifdef __cplusplus

@ -39,30 +39,26 @@
#include "linked_list.h" #include "linked_list.h"
#include "byte_buffer.h" #include "byte_buffer.h"
MmsServerConnection* MmsServerConnection
MmsServerConnection_init(MmsServerConnection* connection, MmsServer server, IsoConnection isoCon); MmsServerConnection_init(MmsServerConnection connection, MmsServer server, IsoConnection isoCon);
void void
MmsServerConnection_destroy(MmsServerConnection* connection); MmsServerConnection_destroy(MmsServerConnection connection);
bool bool
MmsServerConnection_addNamedVariableList(MmsServerConnection* self, MmsNamedVariableList variableList); MmsServerConnection_addNamedVariableList(MmsServerConnection self, MmsNamedVariableList variableList);
MmsNamedVariableList MmsNamedVariableList
MmsServerConnection_getNamedVariableList(MmsServerConnection* self, char* variableListName); MmsServerConnection_getNamedVariableList(MmsServerConnection self, char* variableListName);
LinkedList LinkedList
MmsServerConnection_getNamedVariableLists(MmsServerConnection* self); MmsServerConnection_getNamedVariableLists(MmsServerConnection self);
void void
MmsServerConnection_deleteNamedVariableList(MmsServerConnection* self, char* listName); MmsServerConnection_deleteNamedVariableList(MmsServerConnection self, char* listName);
char*
MmsServerConnection_getClientAddress(MmsServerConnection* self);
MmsIndication MmsIndication
MmsServerConnection_parseMessage MmsServerConnection_parseMessage(MmsServerConnection connection, ByteBuffer* message, ByteBuffer* response);
(MmsServerConnection* connection, ByteBuffer* message, ByteBuffer* response);
/** \brief send information report for a single VMD specific variable /** \brief send information report for a single VMD specific variable
@ -70,7 +66,7 @@ MmsServerConnection_parseMessage
* \param handlerMode send this message in the context of a stack callback handler * \param handlerMode send this message in the context of a stack callback handler
*/ */
void void
MmsServerConnection_sendInformationReportSingleVariableVMDSpecific(MmsServerConnection* self, MmsServerConnection_sendInformationReportSingleVariableVMDSpecific(MmsServerConnection self,
char* itemId, MmsValue* value, bool handlerMode); char* itemId, MmsValue* value, bool handlerMode);
@ -79,7 +75,7 @@ MmsServerConnection_sendInformationReportSingleVariableVMDSpecific(MmsServerConn
* \param handlerMode send this message in the context of a stack callback handler * \param handlerMode send this message in the context of a stack callback handler
*/ */
void /* send information report for a VMD specific named variable list */ void /* send information report for a VMD specific named variable list */
MmsServerConnection_sendInformationReportVMDSpecific(MmsServerConnection* self, char* itemId, LinkedList values MmsServerConnection_sendInformationReportVMDSpecific(MmsServerConnection self, char* itemId, LinkedList values
, bool handlerMode); , bool handlerMode);
/** \brief send information report for list of variables /** \brief send information report for list of variables
@ -88,19 +84,19 @@ MmsServerConnection_sendInformationReportVMDSpecific(MmsServerConnection* self,
*/ */
void void
MmsServerConnection_sendInformationReportListOfVariables( MmsServerConnection_sendInformationReportListOfVariables(
MmsServerConnection* self, MmsServerConnection self,
LinkedList /* MmsVariableAccessSpecification */ variableAccessDeclarations, LinkedList /* MmsVariableAccessSpecification */ variableAccessDeclarations,
LinkedList /* MmsValue */ values, LinkedList /* MmsValue */ values,
bool handlerMode bool handlerMode
); );
void void
MmsServerConnection_sendWriteResponse(MmsServerConnection* self, uint32_t invokeId, MmsDataAccessError indication, MmsServerConnection_sendWriteResponse(MmsServerConnection self, uint32_t invokeId, MmsDataAccessError indication,
bool handlerMode); bool handlerMode);
uint32_t uint32_t
MmsServerConnection_getLastInvokeId(MmsServerConnection* self); MmsServerConnection_getLastInvokeId(MmsServerConnection self);
#endif /* MMS_SERVER_CONNECTION_H_ */ #endif /* MMS_SERVER_CONNECTION_H_ */

@ -99,26 +99,63 @@ struct sMmsServer {
#endif /* MMS_IDENTIFY_SERVICE == 1 */ #endif /* MMS_IDENTIFY_SERVICE == 1 */
}; };
#if (MMS_FILE_SERVICE == 1)
#ifndef CONFIG_MMS_MAX_NUMBER_OF_OPEN_FILES_PER_CONNECTION
#define CONFIG_MMS_MAX_NUMBER_OF_OPEN_FILES_PER_CONNECTION 5
#endif
#include "hal_filesystem.h"
typedef struct {
int32_t frsmId;
uint32_t readPosition;
uint32_t fileSize;
FileHandle fileHandle;
} MmsFileReadStateMachine;
#endif /* (MMS_FILE_SERVICE == 1) */
struct sMmsServerConnection {
int maxServOutstandingCalling;
int maxServOutstandingCalled;
int dataStructureNestingLevel;
int maxPduSize; /* local detail */
IsoConnection isoConnection;
MmsServer server;
uint32_t lastInvokeId;
#if (MMS_DYNAMIC_DATA_SETS == 1)
LinkedList /*<MmsNamedVariableList>*/namedVariableLists; /* aa-specific named variable lists */
#endif
#if (MMS_FILE_SERVICE == 1)
int32_t nextFrsmId;
MmsFileReadStateMachine frsms[CONFIG_MMS_MAX_NUMBER_OF_OPEN_FILES_PER_CONNECTION];
#endif
};
/* write_out function required for ASN.1 encoding */ /* write_out function required for ASN.1 encoding */
int int
mmsServer_write_out(const void *buffer, size_t size, void *app_key); mmsServer_write_out(const void *buffer, size_t size, void *app_key);
void void
mmsServer_handleDeleteNamedVariableListRequest(MmsServerConnection* connection, mmsServer_handleDeleteNamedVariableListRequest(MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleGetNamedVariableListAttributesRequest( mmsServer_handleGetNamedVariableListAttributesRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleReadRequest( mmsServer_handleReadRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
@ -134,47 +171,47 @@ mmsServer_writeConcludeResponsePdu(ByteBuffer* response);
void void
mmsServer_handleInitiateRequest ( mmsServer_handleInitiateRequest (
MmsServerConnection* self, MmsServerConnection self,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
ByteBuffer* response); ByteBuffer* response);
int int
mmsServer_handleGetVariableAccessAttributesRequest( mmsServer_handleGetVariableAccessAttributesRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleDefineNamedVariableListRequest( mmsServer_handleDefineNamedVariableListRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleGetNameListRequest( mmsServer_handleGetNameListRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleWriteRequest( mmsServer_handleWriteRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleIdentifyRequest( mmsServer_handleIdentifyRequest(
MmsServerConnection* connection, MmsServerConnection connection,
int invokeId, int invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleStatusRequest( mmsServer_handleStatusRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* requestBuffer, uint8_t* requestBuffer,
int bufPos, int bufPos,
int invokeId, int invokeId,
@ -182,42 +219,42 @@ mmsServer_handleStatusRequest(
void void
mmsServer_handleFileDirectoryRequest( mmsServer_handleFileDirectoryRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleFileOpenRequest( mmsServer_handleFileOpenRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleFileDeleteRequest( mmsServer_handleFileDeleteRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleFileRenameRequest( mmsServer_handleFileRenameRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleFileReadRequest( mmsServer_handleFileReadRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
void void
mmsServer_handleFileCloseRequest( mmsServer_handleFileCloseRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response); ByteBuffer* response);
@ -236,13 +273,13 @@ mmsServer_deleteVariableList(LinkedList namedVariableLists, char* variableListNa
MmsDataAccessError MmsDataAccessError
mmsServer_setValue(MmsServer self, MmsDomain* domain, char* itemId, MmsValue* value, mmsServer_setValue(MmsServer self, MmsDomain* domain, char* itemId, MmsValue* value,
MmsServerConnection* connection); MmsServerConnection connection);
MmsValue* MmsValue*
mmsServer_getValue(MmsServer self, MmsDomain* domain, char* itemId, MmsServerConnection* connection); mmsServer_getValue(MmsServer self, MmsDomain* domain, char* itemId, MmsServerConnection connection);
int int
mmsServer_createMmsWriteResponse(MmsServerConnection* connection, mmsServer_createMmsWriteResponse(MmsServerConnection connection,
int invokeId, ByteBuffer* response, int numberOfItems, MmsDataAccessError* accessResults); int invokeId, ByteBuffer* response, int numberOfItems, MmsDataAccessError* accessResults);
void void
@ -250,6 +287,6 @@ mmsServer_writeMmsRejectPdu(uint32_t* invokeId, int reason, ByteBuffer* response
bool bool
mmsServer_callVariableListChangedHandler(bool create, MmsVariableListType listType, MmsDomain* domain, mmsServer_callVariableListChangedHandler(bool create, MmsVariableListType listType, MmsDomain* domain,
char* listName, MmsServerConnection* connection); char* listName, MmsServerConnection connection);
#endif /* MMS_SERVER_INTERNAL_H_ */ #endif /* MMS_SERVER_INTERNAL_H_ */

@ -134,7 +134,7 @@ encodeInitResponseDetail(uint8_t* buffer, int bufPos, bool encode)
static int static int
createInitiateResponse(MmsServerConnection* self, ByteBuffer* writeBuffer) createInitiateResponse(MmsServerConnection self, ByteBuffer* writeBuffer)
{ {
uint8_t* buffer = writeBuffer->buffer; uint8_t* buffer = writeBuffer->buffer;
int bufPos = 0; int bufPos = 0;
@ -167,7 +167,7 @@ createInitiateResponse(MmsServerConnection* self, ByteBuffer* writeBuffer)
} }
static bool static bool
parseInitiateRequestPdu(MmsServerConnection* self, uint8_t* buffer, int bufPos, int maxBufPos) parseInitiateRequestPdu(MmsServerConnection self, uint8_t* buffer, int bufPos, int maxBufPos)
{ {
self->maxPduSize = CONFIG_MMS_MAXIMUM_PDU_SIZE; self->maxPduSize = CONFIG_MMS_MAXIMUM_PDU_SIZE;
@ -230,7 +230,7 @@ parseInitiateRequestPdu(MmsServerConnection* self, uint8_t* buffer, int bufPos,
void void
mmsServer_handleInitiateRequest ( mmsServer_handleInitiateRequest (
MmsServerConnection* self, MmsServerConnection self,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
ByteBuffer* response) ByteBuffer* response)
{ {

@ -53,7 +53,7 @@ createNullResponseExtendedTag(uint32_t invokeId, ByteBuffer* response, uint8_t t
} }
static MmsFileReadStateMachine* static MmsFileReadStateMachine*
getFreeFrsm(MmsServerConnection* connection) getFreeFrsm(MmsServerConnection connection)
{ {
int i; int i;
@ -71,7 +71,7 @@ getFreeFrsm(MmsServerConnection* connection)
static MmsFileReadStateMachine* static MmsFileReadStateMachine*
getFrsm(MmsServerConnection* connection, int32_t frsmId) getFrsm(MmsServerConnection connection, int32_t frsmId)
{ {
int i; int i;
@ -90,7 +90,7 @@ getFrsm(MmsServerConnection* connection, int32_t frsmId)
} }
static int32_t static int32_t
getNextFrsmId(MmsServerConnection* connection) getNextFrsmId(MmsServerConnection connection)
{ {
uint32_t nextFrsmId = connection->nextFrsmId; uint32_t nextFrsmId = connection->nextFrsmId;
connection->nextFrsmId++; connection->nextFrsmId++;
@ -195,7 +195,7 @@ parseFileName(char* filename, uint8_t* buffer, int* bufPos, int maxBufPos , uint
void void
mmsServer_handleFileDeleteRequest( mmsServer_handleFileDeleteRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -240,7 +240,7 @@ exit_reject_invalid_pdu:
void void
mmsServer_handleFileOpenRequest( mmsServer_handleFileOpenRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -315,7 +315,7 @@ exit_reject_invalid_pdu:
static void static void
createFileReadResponse(MmsServerConnection* connection, uint32_t invokeId, createFileReadResponse(MmsServerConnection connection, uint32_t invokeId,
ByteBuffer* response, MmsFileReadStateMachine* frsm) ByteBuffer* response, MmsFileReadStateMachine* frsm)
{ {
/* determine remaining bytes in file */ /* determine remaining bytes in file */
@ -372,7 +372,7 @@ createFileReadResponse(MmsServerConnection* connection, uint32_t invokeId,
void void
mmsServer_handleFileReadRequest( mmsServer_handleFileReadRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -399,7 +399,7 @@ createFileCloseResponse(uint32_t invokeId, ByteBuffer* response)
void void
mmsServer_handleFileCloseRequest( mmsServer_handleFileCloseRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -582,7 +582,7 @@ createFileDirectoryResponse(uint32_t invokeId, ByteBuffer* response, char* direc
void void
mmsServer_handleFileRenameRequest( mmsServer_handleFileRenameRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -648,7 +648,7 @@ mmsServer_handleFileRenameRequest(
void void
mmsServer_handleFileDirectoryRequest( mmsServer_handleFileDirectoryRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)

@ -41,7 +41,7 @@
#define OBJECT_SCOPE_ASSOCIATION 2 #define OBJECT_SCOPE_ASSOCIATION 2
static LinkedList static LinkedList
getDomainNames(MmsServerConnection* connection) getDomainNames(MmsServerConnection connection)
{ {
MmsDevice* device = MmsServer_getDevice(connection->server); MmsDevice* device = MmsServer_getDevice(connection->server);
@ -59,7 +59,7 @@ getDomainNames(MmsServerConnection* connection)
#if (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) #if (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1)
static LinkedList static LinkedList
getNameListVMDSpecific(MmsServerConnection* connection) getNameListVMDSpecific(MmsServerConnection connection)
{ {
MmsDevice* device = MmsServer_getDevice(connection->server); MmsDevice* device = MmsServer_getDevice(connection->server);
@ -127,7 +127,7 @@ addSubNamedVaribleNamesToList(LinkedList nameList, char* prefix, MmsVariableSpec
#endif /* (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1) */ #endif /* (CONFIG_MMS_SUPPORT_FLATTED_NAME_SPACE == 1) */
static LinkedList static LinkedList
getNameListDomainSpecific(MmsServerConnection* connection, char* domainName) { getNameListDomainSpecific(MmsServerConnection connection, char* domainName) {
MmsDevice* device = MmsServer_getDevice(connection->server); MmsDevice* device = MmsServer_getDevice(connection->server);
LinkedList nameList = NULL; LinkedList nameList = NULL;
@ -176,7 +176,7 @@ createStringsFromNamedVariableList(LinkedList nameList, LinkedList variableLists
} }
static LinkedList static LinkedList
getNamedVariableListsDomainSpecific(MmsServerConnection* connection, char* domainName) getNamedVariableListsDomainSpecific(MmsServerConnection connection, char* domainName)
{ {
MmsDevice* device = MmsServer_getDevice(connection->server); MmsDevice* device = MmsServer_getDevice(connection->server);
@ -194,7 +194,7 @@ getNamedVariableListsDomainSpecific(MmsServerConnection* connection, char* domai
} }
static LinkedList static LinkedList
getnamedVariableListsVMDSpecific(MmsServerConnection* connection) getnamedVariableListsVMDSpecific(MmsServerConnection connection)
{ {
MmsDevice* device = MmsServer_getDevice(connection->server); MmsDevice* device = MmsServer_getDevice(connection->server);
@ -209,7 +209,7 @@ getnamedVariableListsVMDSpecific(MmsServerConnection* connection)
#if (MMS_DYNAMIC_DATA_SETS == 1) #if (MMS_DYNAMIC_DATA_SETS == 1)
static LinkedList static LinkedList
getNamedVariableListAssociationSpecific(MmsServerConnection* connection) getNamedVariableListAssociationSpecific(MmsServerConnection connection)
{ {
LinkedList nameList = NULL; LinkedList nameList = NULL;
@ -225,7 +225,7 @@ getNamedVariableListAssociationSpecific(MmsServerConnection* connection)
static void static void
createNameListResponse( createNameListResponse(
MmsServerConnection* connection, MmsServerConnection connection,
int invokeId, int invokeId,
LinkedList nameList, LinkedList nameList,
ByteBuffer* response, ByteBuffer* response,
@ -329,7 +329,7 @@ createNameListResponse(
void void
mmsServer_handleGetNameListRequest( mmsServer_handleGetNameListRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)

@ -204,7 +204,7 @@ deleteVariableAccessAttributesResponse(
static void static void
createVariableAccessAttributesResponse( createVariableAccessAttributesResponse(
MmsServerConnection* connection, MmsServerConnection connection,
char* domainId, char* domainId,
char* nameId, char* nameId,
int invokeId, int invokeId,
@ -281,7 +281,7 @@ exit_function:
int int
mmsServer_handleGetVariableAccessAttributesRequest( mmsServer_handleGetVariableAccessAttributesRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)

@ -27,7 +27,7 @@
void void
mmsServer_handleIdentifyRequest( mmsServer_handleIdentifyRequest(
MmsServerConnection* connection, MmsServerConnection connection,
int invokeId, int invokeId,
ByteBuffer* response) ByteBuffer* response)
{ {

@ -30,7 +30,7 @@
#include "ber_encoder.h" #include "ber_encoder.h"
void void
MmsServerConnection_sendInformationReportSingleVariableVMDSpecific(MmsServerConnection* self, MmsServerConnection_sendInformationReportSingleVariableVMDSpecific(MmsServerConnection self,
char* itemId, MmsValue* value, bool handlerMode) char* itemId, MmsValue* value, bool handlerMode)
{ {
uint32_t itemIdSize = strlen(itemId); uint32_t itemIdSize = strlen(itemId);
@ -79,7 +79,7 @@ MmsServerConnection_sendInformationReportSingleVariableVMDSpecific(MmsServerConn
void void
MmsServerConnection_sendInformationReportListOfVariables( MmsServerConnection_sendInformationReportListOfVariables(
MmsServerConnection* self, MmsServerConnection self,
LinkedList /* MmsVariableAccessSpecification */ variableAccessDeclarations, LinkedList /* MmsVariableAccessSpecification */ variableAccessDeclarations,
LinkedList /* MmsValue */ values, LinkedList /* MmsValue */ values,
bool handlerMode bool handlerMode
@ -201,7 +201,7 @@ MmsServerConnection_sendInformationReportListOfVariables(
void /* send information report for a named variable list */ void /* send information report for a named variable list */
MmsServerConnection_sendInformationReportVMDSpecific(MmsServerConnection* self, char* itemId, LinkedList values, MmsServerConnection_sendInformationReportVMDSpecific(MmsServerConnection self, char* itemId, LinkedList values,
bool handlerMode) bool handlerMode)
{ {
uint32_t variableAccessSpecSize = 0; uint32_t variableAccessSpecSize = 0;

@ -49,7 +49,7 @@
bool bool
mmsServer_callVariableListChangedHandler(bool create, MmsVariableListType listType, MmsDomain* domain, mmsServer_callVariableListChangedHandler(bool create, MmsVariableListType listType, MmsDomain* domain,
char* listName, MmsServerConnection* connection) char* listName, MmsServerConnection connection)
{ {
MmsServer self = connection->server; MmsServer self = connection->server;
@ -96,7 +96,7 @@ createDeleteNamedVariableListResponse(uint32_t invokeId, ByteBuffer* response,
} }
void void
mmsServer_handleDeleteNamedVariableListRequest(MmsServerConnection* connection, mmsServer_handleDeleteNamedVariableListRequest(MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -354,7 +354,7 @@ exit_function:
void void
mmsServer_handleDefineNamedVariableListRequest( mmsServer_handleDefineNamedVariableListRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -556,7 +556,7 @@ createGetNamedVariableListAttributesResponse(int invokeId, ByteBuffer* response,
void void
mmsServer_handleGetNamedVariableListAttributesRequest( mmsServer_handleGetNamedVariableListAttributesRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)

@ -46,7 +46,7 @@ typedef struct sVarAccessSpec {
} VarAccessSpec; } VarAccessSpec;
static MmsValue* static MmsValue*
addNamedVariableValue(MmsVariableSpecification* namedVariable, MmsServerConnection* connection, addNamedVariableValue(MmsVariableSpecification* namedVariable, MmsServerConnection connection,
MmsDomain* domain, char* itemId) MmsDomain* domain, char* itemId)
{ {
MmsValue* value = NULL; MmsValue* value = NULL;
@ -97,7 +97,7 @@ addNamedVariableValue(MmsVariableSpecification* namedVariable, MmsServerConnecti
static void static void
addComplexValueToResultList(MmsVariableSpecification* namedVariable, addComplexValueToResultList(MmsVariableSpecification* namedVariable,
LinkedList typedValues, MmsServerConnection* connection, LinkedList typedValues, MmsServerConnection connection,
MmsDomain* domain, char* nameIdStr) MmsDomain* domain, char* nameIdStr)
{ {
@ -181,7 +181,7 @@ getComponentOfArrayElement(AlternateAccess_t* alternateAccess, MmsVariableSpecif
} }
static void static void
alternateArrayAccess(MmsServerConnection* connection, alternateArrayAccess(MmsServerConnection connection,
AlternateAccess_t* alternateAccess, MmsDomain* domain, AlternateAccess_t* alternateAccess, MmsDomain* domain,
char* itemId, LinkedList values, char* itemId, LinkedList values,
MmsVariableSpecification* namedVariable) MmsVariableSpecification* namedVariable)
@ -252,7 +252,7 @@ alternateArrayAccess(MmsServerConnection* connection,
static void static void
addNamedVariableToResultList(MmsVariableSpecification* namedVariable, MmsDomain* domain, char* nameIdStr, addNamedVariableToResultList(MmsVariableSpecification* namedVariable, MmsDomain* domain, char* nameIdStr,
LinkedList /*<MmsValue>*/ values, MmsServerConnection* connection, AlternateAccess_t* alternateAccess) LinkedList /*<MmsValue>*/ values, MmsServerConnection connection, AlternateAccess_t* alternateAccess)
{ {
if (namedVariable != NULL) { if (namedVariable != NULL) {
@ -371,7 +371,7 @@ encodeVariableAccessSpecification(VarAccessSpec* accessSpec, uint8_t* buffer, in
} }
static void static void
encodeReadResponse(MmsServerConnection* connection, encodeReadResponse(MmsServerConnection connection,
uint32_t invokeId, ByteBuffer* response, LinkedList values, uint32_t invokeId, ByteBuffer* response, LinkedList values,
VarAccessSpec* accessSpec) VarAccessSpec* accessSpec)
{ {
@ -469,7 +469,7 @@ encodeReadResponse(MmsServerConnection* connection,
static void static void
handleReadListOfVariablesRequest( handleReadListOfVariablesRequest(
MmsServerConnection* connection, MmsServerConnection connection,
ReadRequest_t* read, ReadRequest_t* read,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -568,7 +568,7 @@ exit:
#if (MMS_DATA_SET_SERVICE == 1) #if (MMS_DATA_SET_SERVICE == 1)
static void static void
createNamedVariableListResponse(MmsServerConnection* connection, MmsNamedVariableList namedList, createNamedVariableListResponse(MmsServerConnection connection, MmsNamedVariableList namedList,
int invokeId, ByteBuffer* response, ReadRequest_t* read, VarAccessSpec* accessSpec) int invokeId, ByteBuffer* response, ReadRequest_t* read, VarAccessSpec* accessSpec)
{ {
@ -607,7 +607,7 @@ createNamedVariableListResponse(MmsServerConnection* connection, MmsNamedVariabl
static void static void
handleReadNamedVariableListRequest( handleReadNamedVariableListRequest(
MmsServerConnection* connection, MmsServerConnection connection,
ReadRequest_t* read, ReadRequest_t* read,
int invokeId, int invokeId,
ByteBuffer* response) ByteBuffer* response)
@ -682,7 +682,7 @@ handleReadNamedVariableListRequest(
void void
mmsServer_handleReadRequest( mmsServer_handleReadRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)

@ -129,7 +129,7 @@ MmsServer_setClientAuthenticator(MmsServer self, AcseAuthenticator authenticator
static void static void
closeConnection(void* con) closeConnection(void* con)
{ {
MmsServerConnection* connection = (MmsServerConnection*) con; MmsServerConnection connection = (MmsServerConnection) con;
MmsServerConnection_destroy(connection); MmsServerConnection_destroy(connection);
} }
@ -176,7 +176,7 @@ MmsServer_insertIntoCache(MmsServer self, MmsDomain* domain, char* itemId, MmsVa
MmsDataAccessError MmsDataAccessError
mmsServer_setValue(MmsServer self, MmsDomain* domain, char* itemId, MmsValue* value, mmsServer_setValue(MmsServer self, MmsDomain* domain, char* itemId, MmsValue* value,
MmsServerConnection* connection) MmsServerConnection connection)
{ {
MmsDataAccessError indication; MmsDataAccessError indication;
@ -203,7 +203,7 @@ mmsServer_setValue(MmsServer self, MmsDomain* domain, char* itemId, MmsValue* va
MmsValue* MmsValue*
mmsServer_getValue(MmsServer self, MmsDomain* domain, char* itemId, MmsServerConnection* connection) mmsServer_getValue(MmsServer self, MmsDomain* domain, char* itemId, MmsServerConnection connection)
{ {
MmsValue* value = NULL; MmsValue* value = NULL;
@ -249,7 +249,7 @@ isoConnectionIndicationHandler(IsoConnectionIndication indication,
MmsServer mmsServer = (MmsServer) parameter; MmsServer mmsServer = (MmsServer) parameter;
if (indication == ISO_CONNECTION_OPENED) { if (indication == ISO_CONNECTION_OPENED) {
MmsServerConnection* mmsCon = MmsServerConnection_init(0, mmsServer, connection); MmsServerConnection mmsCon = MmsServerConnection_init(0, mmsServer, connection);
Map_addEntry(mmsServer->openConnections, connection, mmsCon); Map_addEntry(mmsServer->openConnections, connection, mmsCon);
@ -258,7 +258,7 @@ isoConnectionIndicationHandler(IsoConnectionIndication indication,
mmsCon, MMS_SERVER_NEW_CONNECTION); mmsCon, MMS_SERVER_NEW_CONNECTION);
} }
else if (indication == ISO_CONNECTION_CLOSED) { else if (indication == ISO_CONNECTION_CLOSED) {
MmsServerConnection* mmsCon = (MmsServerConnection*) MmsServerConnection mmsCon = (MmsServerConnection)
Map_removeEntry(mmsServer->openConnections, connection, false); Map_removeEntry(mmsServer->openConnections, connection, false);
if (mmsServer->connectionHandler != NULL) if (mmsServer->connectionHandler != NULL)

@ -79,7 +79,7 @@ mmsServer_writeMmsRejectPdu(uint32_t* invokeId, int reason, ByteBuffer* response
static void static void
handleConfirmedRequestPdu( handleConfirmedRequestPdu(
MmsServerConnection* self, MmsServerConnection self,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
ByteBuffer* response) ByteBuffer* response)
{ {
@ -225,7 +225,7 @@ handleConfirmedRequestPdu(
} }
MmsIndication MmsIndication
MmsServerConnection_parseMessage(MmsServerConnection* self, ByteBuffer* message, ByteBuffer* response) MmsServerConnection_parseMessage(MmsServerConnection self, ByteBuffer* message, ByteBuffer* response)
{ {
MmsIndication retVal; MmsIndication retVal;
@ -276,7 +276,7 @@ MmsServerConnection_parseMessage(MmsServerConnection* self, ByteBuffer* message,
static void /* will be called by IsoConnection */ static void /* will be called by IsoConnection */
messageReceived(void* parameter, ByteBuffer* message, ByteBuffer* response) messageReceived(void* parameter, ByteBuffer* message, ByteBuffer* response)
{ {
MmsServerConnection* self = (MmsServerConnection*) parameter; MmsServerConnection self = (MmsServerConnection) parameter;
MmsServerConnection_parseMessage(self, message, response); MmsServerConnection_parseMessage(self, message, response);
} }
@ -285,13 +285,13 @@ messageReceived(void* parameter, ByteBuffer* message, ByteBuffer* response)
* MMS server connection public API functions * MMS server connection public API functions
*********************************************************************************************/ *********************************************************************************************/
MmsServerConnection* MmsServerConnection
MmsServerConnection_init(MmsServerConnection* connection, MmsServer server, IsoConnection isoCon) MmsServerConnection_init(MmsServerConnection connection, MmsServer server, IsoConnection isoCon)
{ {
MmsServerConnection* self; MmsServerConnection self;
if (connection == NULL) if (connection == NULL)
self = (MmsServerConnection*) GLOBAL_CALLOC(1, sizeof(MmsServerConnection)); self = (MmsServerConnection) GLOBAL_CALLOC(1, sizeof(struct sMmsServerConnection));
else else
self = connection; self = connection;
@ -312,7 +312,7 @@ MmsServerConnection_init(MmsServerConnection* connection, MmsServer server, IsoC
} }
void void
MmsServerConnection_destroy(MmsServerConnection* self) MmsServerConnection_destroy(MmsServerConnection self)
{ {
#if (MMS_FILE_SERVICE == 1) #if (MMS_FILE_SERVICE == 1)
@ -332,7 +332,7 @@ MmsServerConnection_destroy(MmsServerConnection* self)
#if (MMS_DYNAMIC_DATA_SETS == 1) #if (MMS_DYNAMIC_DATA_SETS == 1)
bool bool
MmsServerConnection_addNamedVariableList(MmsServerConnection* self, MmsNamedVariableList variableList) MmsServerConnection_addNamedVariableList(MmsServerConnection self, MmsNamedVariableList variableList)
{ {
//TODO check if operation is allowed! //TODO check if operation is allowed!
@ -342,13 +342,13 @@ MmsServerConnection_addNamedVariableList(MmsServerConnection* self, MmsNamedVari
} }
void void
MmsServerConnection_deleteNamedVariableList(MmsServerConnection* self, char* listName) MmsServerConnection_deleteNamedVariableList(MmsServerConnection self, char* listName)
{ {
mmsServer_deleteVariableList(self->namedVariableLists, listName); mmsServer_deleteVariableList(self->namedVariableLists, listName);
} }
MmsNamedVariableList MmsNamedVariableList
MmsServerConnection_getNamedVariableList(MmsServerConnection* self, char* variableListName) MmsServerConnection_getNamedVariableList(MmsServerConnection self, char* variableListName)
{ {
//TODO remove code duplication - similar to MmsDomain_getNamedVariableList ! //TODO remove code duplication - similar to MmsDomain_getNamedVariableList !
MmsNamedVariableList variableList = NULL; MmsNamedVariableList variableList = NULL;
@ -372,21 +372,27 @@ MmsServerConnection_getNamedVariableList(MmsServerConnection* self, char* variab
char* char*
MmsServerConnection_getClientAddress(MmsServerConnection* self) MmsServerConnection_getClientAddress(MmsServerConnection self)
{ {
return IsoConnection_getPeerAddress(self->isoConnection); return IsoConnection_getPeerAddress(self->isoConnection);
} }
IsoConnection
MmsServerConnection_getIsoConnection(MmsServerConnection self)
{
return self->isoConnection;
}
#if (MMS_DYNAMIC_DATA_SETS == 1) #if (MMS_DYNAMIC_DATA_SETS == 1)
LinkedList LinkedList
MmsServerConnection_getNamedVariableLists(MmsServerConnection* self) MmsServerConnection_getNamedVariableLists(MmsServerConnection self)
{ {
return self->namedVariableLists; return self->namedVariableLists;
} }
#endif /* (MMS_DYNAMIC_DATA_SETS == 1) */ #endif /* (MMS_DYNAMIC_DATA_SETS == 1) */
uint32_t uint32_t
MmsServerConnection_getLastInvokeId(MmsServerConnection* self) MmsServerConnection_getLastInvokeId(MmsServerConnection self)
{ {
return self->lastInvokeId; return self->lastInvokeId;
} }

@ -27,7 +27,7 @@
void void
mmsServer_handleStatusRequest( mmsServer_handleStatusRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* requestBuffer, uint8_t* requestBuffer,
int bufPos, int bufPos,
int invokeId, int invokeId,

@ -34,7 +34,7 @@
*********************************************************************************************/ *********************************************************************************************/
int int
mmsServer_createMmsWriteResponse(MmsServerConnection* connection, mmsServer_createMmsWriteResponse(MmsServerConnection connection,
int invokeId, ByteBuffer* response, int numberOfItems, MmsDataAccessError* accessResults) int invokeId, ByteBuffer* response, int numberOfItems, MmsDataAccessError* accessResults)
{ {
MmsPdu_t* mmsPdu = mmsServer_createConfirmedResponse(invokeId); MmsPdu_t* mmsPdu = mmsServer_createConfirmedResponse(invokeId);
@ -72,7 +72,7 @@ mmsServer_createMmsWriteResponse(MmsServerConnection* connection,
void void
MmsServerConnection_sendWriteResponse(MmsServerConnection* self, uint32_t invokeId, MmsDataAccessError indication, bool handlerMode) MmsServerConnection_sendWriteResponse(MmsServerConnection self, uint32_t invokeId, MmsDataAccessError indication, bool handlerMode)
{ {
ByteBuffer* response = ByteBuffer_create(NULL, self->maxPduSize); ByteBuffer* response = ByteBuffer_create(NULL, self->maxPduSize);
@ -85,7 +85,7 @@ MmsServerConnection_sendWriteResponse(MmsServerConnection* self, uint32_t invoke
void void
mmsServer_handleWriteRequest( mmsServer_handleWriteRequest(
MmsServerConnection* connection, MmsServerConnection connection,
uint8_t* buffer, int bufPos, int maxBufPos, uint8_t* buffer, int bufPos, int maxBufPos,
uint32_t invokeId, uint32_t invokeId,
ByteBuffer* response) ByteBuffer* response)

Loading…
Cancel
Save