- C server API: added function IedServer_setLocalIpAddress

- C# server API: added IedServer.SetLocalIpAddress
This commit is contained in:
Michael Zillgith 2017-05-05 09:03:54 +02:00
parent 3aa01687c5
commit 8999487b24
7 changed files with 67 additions and 2 deletions

View file

@ -561,6 +561,9 @@ namespace IEC61850
[DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr IedServer_create(IntPtr modelRef);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServer_setLocalIpAddress(IntPtr self, string localIpAddress);
[DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)]
static extern void IedServer_start(IntPtr self, int tcpPort);
@ -796,7 +799,28 @@ namespace IEC61850
private InternalConnectionHandler internalConnectionHandler = null;
/// <summary>
/// Sets the local ip address for listening
/// </summary>
/// <param name="localIpAddress">Local IP address.</param>
public void SetLocalIpAddress(string localIpAddress)
{
IedServer_setLocalIpAddress (self, localIpAddress);
}
/// <summary>
/// Start MMS server
/// </summary>
/// <param name="localIpAddress">Local IP address.</param>
/// <param name="tcpPort">TCP port to use</param>
public void Start(string localIpAddress, int tcpPort)
{
SetLocalIpAddress (localIpAddress);
Start (tcpPort);
}
/// <summary>Start MMS server</summary>
/// <param name="tcpPort">TCP port to use</param>
public void Start(int tcpPort)
{
if (internalConnectionHandler == null)

View file

@ -7,6 +7,8 @@
<OutputType>Library</OutputType>
<RootNamespace>iec61850dotnet</RootNamespace>
<AssemblyName>iec61850dotnet</AssemblyName>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View file

@ -76,6 +76,15 @@ IedServer_create(IedModel* iedModel);
void
IedServer_destroy(IedServer self);
/**
* \brief Set the local IP address to listen on
*
* \param self the IedServer instance
* \param localIpAddress the local IP address as C string (an internal copy will be created)
*/
void
IedServer_setLocalIpAddress(IedServer self, const char* localIpAddress);
/**
* \brief Start handling client connections
*
@ -106,6 +115,19 @@ IedServer_stop(IedServer self);
void
IedServer_startThreadless(IedServer self, int tcpPort);
/**
* \brief Wait until a server connection is ready (with timeout)
*
* The function will wait until a server connection is ready (data available) or the
* timeout elapsed. This function is intended for the non-threaded mode. Its use is optional.
* It is equivalent of using select on sockets on Linux. If the return value is != 0 the
* IedServer_processIncomingData function should be called.
*
* \param self the IedServer instance
* \param timeoutMs the timeout to wait when no connection is ready
*
* \return 0 if no connection is ready; otherwise at least one connection is ready
*/
int
IedServer_waitReady(IedServer self, unsigned int timeoutMs);

View file

@ -39,6 +39,7 @@ struct sIedServer
MmsDevice* mmsDevice;
MmsServer mmsServer;
IsoServer isoServer;
char* localIpAddress;
MmsMapping* mmsMapping;
LinkedList clientConnections;
uint8_t writeAccessPolicies;

View file

@ -405,6 +405,7 @@ IedServer_create(IedModel* iedModel)
self->model = iedModel;
// self->running = false; /* not required due to CALLOC */
// self->localIpAddress = NULL; /* not required due to CALLOC */
#if (CONFIG_MMS_THREADLESS_STACK != 1)
self->dataModelLock = Semaphore_create(1);
@ -464,6 +465,9 @@ IedServer_destroy(IedServer self)
MmsServer_destroy(self->mmsServer);
IsoServer_destroy(self->isoServer);
if (self->localIpAddress != NULL)
GLOBAL_FREEMEM(self->localIpAddress);
#if ((CONFIG_MMS_SINGLE_THREADED == 1) && (CONFIG_MMS_THREADLESS_STACK == 0))
/* trigger stopping background task thread */
@ -600,6 +604,16 @@ IedServer_stop(IedServer self)
}
#endif /* (CONFIG_MMS_THREADLESS_STACK != 1) */
void
IedServer_setLocalIpAddress(IedServer self, const char* localIpAddress)
{
if (self->localIpAddress != NULL)
GLOBAL_FREEMEM(self->localIpAddress);
self->localIpAddress = StringUtils_copyString(localIpAddress);
IsoServer_setLocalIpAddress(self->isoServer, self->localIpAddress);
}
void
IedServer_startThreadless(IedServer self, int tcpPort)

View file

@ -560,4 +560,5 @@ EXPORTS
IedConnection_readInt64Value
Timestamp_create
Timestamp_destroy
Timestamp_setByMmsUtcTime
Timestamp_setByMmsUtcTime
IedServer_setLocalIpAddress

View file

@ -638,4 +638,5 @@ EXPORTS
IedConnection_readInt64Value
Timestamp_create
Timestamp_destroy
Timestamp_setByMmsUtcTime
Timestamp_setByMmsUtcTime
IedServer_setLocalIpAddress