diff --git a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs
index ef6173c..70e7b1d 100644
--- a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs
+++ b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs
@@ -432,19 +432,26 @@ namespace IEC61850
IedConnection_destroy (connection);
}
- }
+ }
+
+ private IsoConnectionParameters isoConnectionParameters = null;
///
/// Gets the connection parameters
///
/// The connection parameters
public IsoConnectionParameters GetConnectionParameters ()
- {
- IntPtr mmsConnection = IedConnection_getMmsConnection(connection);
-
- IntPtr parameters = MmsConnection_getIsoConnectionParameters(mmsConnection);
-
- return new IsoConnectionParameters(parameters);
+ {
+ if (isoConnectionParameters == null)
+ {
+ IntPtr mmsConnection = IedConnection_getMmsConnection(connection);
+
+ IntPtr parameters = MmsConnection_getIsoConnectionParameters(mmsConnection);
+
+ isoConnectionParameters = new IsoConnectionParameters(parameters);
+ }
+
+ return isoConnectionParameters;
}
private void FreeHGlobaleDeleteFunction (IntPtr pointer)
diff --git a/dotnet/IEC61850forCSharp/IsoConnectionParameters.cs b/dotnet/IEC61850forCSharp/IsoConnectionParameters.cs
index 778048c..9192eff 100644
--- a/dotnet/IEC61850forCSharp/IsoConnectionParameters.cs
+++ b/dotnet/IEC61850forCSharp/IsoConnectionParameters.cs
@@ -102,8 +102,6 @@ namespace IEC61850
{
if (authParameter != IntPtr.Zero)
AcseAuthenticationParameter_destroy(authParameter);
-
- //IsoConnectionParameters_destroy(self);
}
///
diff --git a/dotnet/authenticate/Main.cs b/dotnet/authenticate/Main.cs
index afab952..22bff50 100644
--- a/dotnet/authenticate/Main.cs
+++ b/dotnet/authenticate/Main.cs
@@ -21,7 +21,6 @@ namespace authenticate
Console.WriteLine("Connect to " + hostname);
-
try
{
IsoConnectionParameters parameters = con.GetConnectionParameters();
diff --git a/examples/iec61850_client_example5/client_example5.c b/examples/iec61850_client_example5/client_example5.c
index 9dc66b6..5acf11b 100644
--- a/examples/iec61850_client_example5/client_example5.c
+++ b/examples/iec61850_client_example5/client_example5.c
@@ -14,8 +14,9 @@
#include "hal_thread.h"
-int main(int argc, char** argv) {
-
+int
+main(int argc, char** argv)
+{
char* hostname;
int tcpPort = 102;
@@ -46,25 +47,22 @@ int main(int argc, char** argv) {
/* use this to skip AP-Title completely - this may be required by some "obscure" servers */
// IsoConnectionParameters_setRemoteApTitle(parameters, NULL, 0);
// IsoConnectionParameters_setLocalApTitle(parameters, NULL, 0);
+ TSelector localTSelector = { 3, { 0x00, 0x01, 0x02 } };
+ TSelector remoteTSelector = { 2, { 0x00, 0x01 } };
- TSelector localTSelector = { 3, { 0x00, 0x01, 0x02 } };
- TSelector remoteTSelector = { 2, { 0x00, 0x01 } };
-
- SSelector sSelector1 = {2, { 0, 1 } };
- SSelector sSelector2 = {5, { 0, 1, 2, 3, 4 } };
-
+ SSelector sSelector1 = { 2, { 0, 1 } };
+ SSelector sSelector2 = { 5, { 0, 1, 2, 3, 4 } };
/* change parameters for presentation, session and transport layers */
- IsoConnectionParameters_setRemoteAddresses(parameters, 0x12345678, sSelector1, localTSelector);
- IsoConnectionParameters_setLocalAddresses(parameters, 0x87654321, sSelector2 , remoteTSelector);
+ IsoConnectionParameters_setRemoteAddresses(parameters, 0x12345678, sSelector1, localTSelector);
+ IsoConnectionParameters_setLocalAddresses(parameters, 0x87654321, sSelector2, remoteTSelector);
char* password = "top secret";
/* use authentication */
- AcseAuthenticationParameter auth = (AcseAuthenticationParameter) calloc(1, sizeof(struct sAcseAuthenticationParameter));
- auth->mechanism = ACSE_AUTH_PASSWORD;
- auth->value.password.octetString = (uint8_t*) password;
- auth->value.password.passwordLength = strlen(password);
+ AcseAuthenticationParameter auth = AcseAuthenticationParameter_create();
+ AcseAuthenticationParameter_setAuthMechanism(auth, ACSE_AUTH_PASSWORD);
+ AcseAuthenticationParameter_setPassword(auth, password);
IsoConnectionParameters_setAcseAuthenticationParameter(parameters, auth);
@@ -84,6 +82,8 @@ int main(int argc, char** argv) {
}
IedConnection_destroy(con);
+
+ AcseAuthenticationParameter_destroy(auth);
}