- .NET: in IedConnection: added internal reference to IsoConnectionParameters object to avoid deletion of internal AcseAuthenticationParameters by garbage collector
This commit is contained in:
parent
003f1ef730
commit
6273a18c48
4 changed files with 28 additions and 24 deletions
|
@ -432,19 +432,26 @@ namespace IEC61850
|
|||
|
||||
IedConnection_destroy (connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IsoConnectionParameters isoConnectionParameters = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the connection parameters
|
||||
/// </summary>
|
||||
/// <returns>The connection parameters</returns>
|
||||
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)
|
||||
|
|
|
@ -102,8 +102,6 @@ namespace IEC61850
|
|||
{
|
||||
if (authParameter != IntPtr.Zero)
|
||||
AcseAuthenticationParameter_destroy(authParameter);
|
||||
|
||||
//IsoConnectionParameters_destroy(self);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -21,7 +21,6 @@ namespace authenticate
|
|||
|
||||
Console.WriteLine("Connect to " + hostname);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
IsoConnectionParameters parameters = con.GetConnectionParameters();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue