Skip to content

Commit

Permalink
- IEC 61850 server: number of dynamic data sets configurable at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mzillgith committed Sep 4, 2018
1 parent a0adcf9 commit aa86d3b
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 15 deletions.
64 changes: 64 additions & 0 deletions dotnet/IEC61850forCSharp/IedServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ public class IedServerConfig : IDisposable
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_enableDynamicDataSetService(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool enable);

[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setMaxAssociationSpecificDataSets(IntPtr self, int maxDataSets);

[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getMaxAssociationSpecificDataSets(IntPtr self);

[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setMaxDomainSpecificDataSets(IntPtr self, int maxDataSets);

[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getMaxDomainSpecificDataSets(IntPtr self);

[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setMaxDataSetEntries(IntPtr self, int maxDataSetEntries);

[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getMaxDatasSetEntries(IntPtr self);

internal IntPtr self;

public IedServerConfig ()
Expand Down Expand Up @@ -132,6 +150,10 @@ public int MaxMmsConnections
}
}

/// <summary>
/// Enable/Disable dynamic data set service for MMS
/// </summary>
/// <value><c>true</c> if dynamic data set service enabled; otherwise, <c>false</c>.</value>
public bool DynamicDataSetServiceEnabled
{
get {
Expand All @@ -142,6 +164,48 @@ public bool DynamicDataSetServiceEnabled
}
}

/// <summary>
/// Gets or sets the maximum number of data set entries for dynamic data sets
/// </summary>
/// <value>The max. number data set entries.</value>
public int MaxDataSetEntries
{
get {
return IedServerConfig_getMaxDatasSetEntries (self);
}
set {
IedServerConfig_setMaxDataSetEntries (self, value);
}
}

/// <summary>
/// Gets or sets the maximum number of association specific (non-permanent) data sets.
/// </summary>
/// <value>The max. number of association specific data sets.</value>
public int MaxAssociationSpecificDataSets
{
get {
return IedServerConfig_getMaxAssociationSpecificDataSets (self);
}
set {
IedServerConfig_setMaxAssociationSpecificDataSets (self, value);
}
}

/// <summary>
/// Gets or sets the maximum number of domain specific (permanent) data sets.
/// </summary>
/// <value>The max. numebr of domain specific data sets.</value>
public int MaxDomainSpecificDataSets
{
get {
return IedServerConfig_getMaxDomainSpecificDataSets (self);
}
set {
IedServerConfig_setMaxDomainSpecificDataSets (self, value);
}
}

/// <summary>
/// Releases all resource used by the <see cref="IEC61850.Server.IedServerConfig"/> object.
/// </summary>
Expand Down
61 changes: 47 additions & 14 deletions src/iec61850/inc/iec61850_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ struct sIedServerConfig
/** when true (default) enable dynamic data set services for MMS */
bool enableDynamicDataSetService;

/** the maximum number of allowed association specific data sets */
int maxAssociationSpecificDataSets;

/** the maximum number of allowed domain specific data sets */
int maxDomainSpecificDataSets;

/** maximum number of data set entries of dynamic data sets */
int maxDataSetEntries;

Expand Down Expand Up @@ -141,6 +147,8 @@ IedServerConfig_getMaxMmsConnections(IedServerConfig self);
/**
* \brief Set the basepath of the file services
*
* NOTE: the basepath specifies the local directory that is served by MMS file services
*
* \param basepath new file service base path
*/
void
Expand Down Expand Up @@ -168,12 +176,6 @@ IedServerConfig_enableFileService(IedServerConfig self, bool enable);
bool
IedServerConfig_isFileServiceEnabled(IedServerConfig self);

void
IedServerConfig_enableSetFileService(IedServerConfig self, bool enable);

bool
IedServerConfig_isSetFileServiceEnabled(IedServerConfig self);

/**
* \brief Enable/disable the dynamic data set service for MMS
*
Expand All @@ -190,30 +192,61 @@ IedServerConfig_enableDynamicDataSetService(IedServerConfig self, bool enable);
bool
IedServerConfig_isDynamicDataSetServiceEnabled(IedServerConfig self);


/**
* \brief Set the maximum allowed number of association specific (non-permanent) data sets
*
* NOTE: This specifies the maximum number of non-permanent data sets per connection. When
* the connection is closed these data sets are deleted automatically.
*
* \param maxDataSets maximum number of allowed data sets.
*/
void
IedServerConfig_setMaxAssociationSpecificDataSets(IedServerConfig self, int maxDataSets);

/**
* \brief Get the maximum allowed number of association specific (non-permanent) data sets
*
* \return maximum number of allowed data sets.
*/
int
IedServerConfig_getMaxAssociationSpecificDataSets(IedServerConfig self);

/**
* \brief Set the maximum allowed number of domain specific (permanent) data sets
*
* \param maxDataSets maximum number of allowed data sets.
*/
void
IedServerConfig_setMaxDomainSpecificDataSets(IedServerConfig self, int maxDataSets);

/**
* \brief Set the maximum number of entries in a dynamic data set
* \brief Get the maximum allowed number of domain specific (permanent) data sets
*
* \return maximum number of allowed data sets.
*/
int
IedServerConfig_getMaxDomainSpecificDataSets(IedServerConfig self);

/**
* \brief Set the maximum number of entries in dynamic data sets
*
* NOTE: this comprises the base data set entries (can be simple or complex variables).
* When the client tries to create a data set with more member the request will be
* rejected and the data set will not be created.
*
* \param maxDataSetEntries the maximum number of entries allowed in a data set
*/
void
IedServerConfig_setMaxDataSetEntries(IedServerConfig self, int maxDataSetEntries);

/**
* \brief Get the maximum number of entries in dynamic data sets
*
* \return the maximum number of entries allowed in a data sets
*/
int
IedServerConfig_getMaxDatasSetEntries(IedServerConfig self);

void
IedServerConfig_enableWriteDataSetService(IedServerConfig self, bool enable);

bool
IedServerConfig_isWriteDataSetServiceEnabled(IedServerConfig self);

/**
* \brief Enable/disable the log service for MMS
*
Expand Down
2 changes: 2 additions & 0 deletions src/iec61850/server/impl/ied_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ IedServer_createWithConfig(IedModel* dataModel, TLSConfiguration tlsConfiguratio
if (serverConfiguration) {
MmsServer_enableFileService(self->mmsServer, serverConfiguration->enableFileService);
MmsServer_enableDynamicNamedVariableListService(self->mmsServer, serverConfiguration->enableDynamicDataSetService);
MmsServer_setMaxAssociationSpecificDataSets(self->mmsServer, serverConfiguration->maxAssociationSpecificDataSets);
MmsServer_setMaxDomainSpecificDataSets(self->mmsServer, serverConfiguration->maxDomainSpecificDataSets);
MmsServer_setMaxDataSetEntries(self->mmsServer, serverConfiguration->maxDataSetEntries);
MmsServer_enableJournalService(self->mmsServer, serverConfiguration->enableLogService);
MmsServer_setFilestoreBasepath(self->mmsServer, serverConfiguration->fileServiceBasepath);
Expand Down
34 changes: 34 additions & 0 deletions src/iec61850/server/impl/ied_server_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
#define CONFIG_MMS_MAX_NUMBER_OF_DATA_SET_MEMBERS 100
#endif

#ifndef CONFIG_MMS_MAX_NUMBER_OF_ASSOCIATION_SPECIFIC_DATA_SETS
#define CONFIG_MMS_MAX_NUMBER_OF_ASSOCIATION_SPECIFIC_DATA_SETS 10
#endif

#ifndef CONFIG_MMS_MAX_NUMBER_OF_DOMAIN_SPECIFIC_DATA_SETS
#define CONFIG_MMS_MAX_NUMBER_OF_DOMAIN_SPECIFIC_DATA_SETS 10
#endif

IedServerConfig
IedServerConfig_create()
{
Expand All @@ -38,6 +46,8 @@ IedServerConfig_create()
self->fileServiceBasepath = StringUtils_copyString(CONFIG_VIRTUAL_FILESTORE_BASEPATH);
self->enableFileService = true;
self->enableDynamicDataSetService = true;
self->maxAssociationSpecificDataSets = CONFIG_MMS_MAX_NUMBER_OF_ASSOCIATION_SPECIFIC_DATA_SETS;
self->maxDomainSpecificDataSets = CONFIG_MMS_MAX_NUMBER_OF_DOMAIN_SPECIFIC_DATA_SETS;
self->maxDataSetEntries = CONFIG_MMS_MAX_NUMBER_OF_DATA_SET_MEMBERS;
self->enableLogService = true;
self->edition = IEC_61850_EDITION_2;
Expand Down Expand Up @@ -119,6 +129,30 @@ IedServerConfig_isDynamicDataSetServiceEnabled(IedServerConfig self)
return self->enableDynamicDataSetService;
}

void
IedServerConfig_setMaxAssociationSpecificDataSets(IedServerConfig self, int maxDataSets)
{
self->maxAssociationSpecificDataSets = maxDataSets;
}

int
IedServerConfig_getMaxAssociationSpecificDataSets(IedServerConfig self)
{
return self->maxAssociationSpecificDataSets;
}

void
IedServerConfig_setMaxDomainSpecificDataSets(IedServerConfig self, int maxDataSets)
{
self->maxDomainSpecificDataSets = maxDataSets;
}

int
IedServerConfig_getMaxDomainSpecificDataSets(IedServerConfig self)
{
return self->maxDomainSpecificDataSets;
}

void
IedServerConfig_setMaxDataSetEntries(IedServerConfig self, int maxDataSetEntries)
{
Expand Down
20 changes: 19 additions & 1 deletion src/mms/inc/mms_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,29 @@ MmsServer_enableFileService(MmsServer self, bool enable);
void
MmsServer_enableDynamicNamedVariableListService(MmsServer self, bool enable);

/**
* \brief Set the maximum number of association specific data sets (per connection)
*
* \param[in] self the MmsServer instance
* \param[in] maxDataSets maximum number association specific data sets
*/
void
MmsServer_setMaxAssociationSpecificDataSets(MmsServer self, int maxDataSets);

/**
* \brief Set the maximum number of domain specific data sets
*
* \param[in] self the MmsServer instance
* \param[in] maxDataSets maximum number domain specific data sets
*/
void
MmsServer_setMaxDomainSpecificDataSets(MmsServer self, int maxDataSets);

/**
* \brief Set the maximum number of data set entries (for dynamic data sets)
*
* \param[in] self the MmsServer instance
* \param[in] maximum number of dynamic data set entires
* \param[in] maxDataSetEntries maximum number of dynamic data set entries
*/
void
MmsServer_setMaxDataSetEntries(MmsServer self, int maxDataSetEntries);
Expand Down
2 changes: 2 additions & 0 deletions src/mms/inc_private/mms_server_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ struct sMmsServer {
bool dynamicVariableListServiceEnabled;
int maxDataSetEntries;
bool journalServiceEnabled;
int maxAssociationSpecificDataSets;
int maxDomainSpecificDataSets;
#endif /* (CONFIG_SET_FILESTORE_BASEPATH_AT_RUNTIME == 1) */

};
Expand Down
8 changes: 8 additions & 0 deletions src/mms/iso_mms/server/mms_named_variable_list_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,11 @@ mmsServer_handleDefineNamedVariableListRequest(
goto exit_free_struct;
}

#if (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1)
if (LinkedList_size(domain->namedVariableLists) < connection->server->maxDomainSpecificDataSets) {
#else
if (LinkedList_size(domain->namedVariableLists) < CONFIG_MMS_MAX_NUMBER_OF_DOMAIN_SPECIFIC_DATA_SETS) {
#endif
char variableListName[65];

if (request->variableListName.choice.domainspecific.itemId.size > 64) {
Expand Down Expand Up @@ -498,7 +502,11 @@ mmsServer_handleDefineNamedVariableListRequest(
}
else if (request->variableListName.present == ObjectName_PR_aaspecific) {

#if (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1)
if (LinkedList_size(connection->namedVariableLists) < connection->server->maxAssociationSpecificDataSets) {
#else
if (LinkedList_size(connection->namedVariableLists) < CONFIG_MMS_MAX_NUMBER_OF_ASSOCIATION_SPECIFIC_DATA_SETS) {
#endif

char variableListName[65];

Expand Down
14 changes: 14 additions & 0 deletions src/mms/iso_mms/server/mms_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ MmsServer_create(MmsDevice* device, TLSConfiguration tlsConfiguration)
self->dynamicVariableListServiceEnabled = true;
self->journalServiceEnabled = true;
self->maxDataSetEntries = CONFIG_MMS_MAX_NUMBER_OF_DATA_SET_MEMBERS;
self->maxAssociationSpecificDataSets = CONFIG_MMS_MAX_NUMBER_OF_ASSOCIATION_SPECIFIC_DATA_SETS;
self->maxDomainSpecificDataSets = CONFIG_MMS_MAX_NUMBER_OF_DOMAIN_SPECIFIC_DATA_SETS;
#endif /* (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1) */

return self;
Expand Down Expand Up @@ -138,6 +140,18 @@ MmsServer_enableJournalService(MmsServer self, bool enable)
self->journalServiceEnabled = enable;
}

void
MmsServer_setMaxAssociationSpecificDataSets(MmsServer self, int maxDataSets)
{
self->maxAssociationSpecificDataSets = maxDataSets;
}

void
MmsServer_setMaxDomainSpecificDataSets(MmsServer self, int maxDataSets)
{
self->maxDomainSpecificDataSets = maxDataSets;
}

#endif /* (CONFIG_MMS_SERVER_CONFIG_SERVICES_AT_RUNTIME == 1) */

void
Expand Down
5 changes: 5 additions & 0 deletions src/vs/libiec61850-wo-goose.def
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,8 @@ EXPORTS
IedServerConfig_getMaxMmsConnections
IedServerConfig_setMaxDataSetEntries
IedServerConfig_getMaxDatasSetEntries
IedServerConfig_setMaxAssociationSpecificDataSets
IedServerConfig_getMaxAssociationSpecificDataSets
IedServerConfig_setMaxDomainSpecificDataSets
IedServerConfig_getMaxDomainSpecificDataSets

4 changes: 4 additions & 0 deletions src/vs/libiec61850.def
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,7 @@ EXPORTS
IedServerConfig_getMaxMmsConnections
IedServerConfig_setMaxDataSetEntries
IedServerConfig_getMaxDatasSetEntries
IedServerConfig_setMaxAssociationSpecificDataSets
IedServerConfig_getMaxAssociationSpecificDataSets
IedServerConfig_setMaxDomainSpecificDataSets
IedServerConfig_getMaxDomainSpecificDataSets

0 comments on commit aa86d3b

Please sign in to comment.