(LIB61850-513)

->API IsoApplicationReference_getAeQualifier, IsoApplicationReference_getApTitle, ItuObjectIdentifier_getArcCount, ItuObjectIdentifier_getArc added
v1.6
Maxson Ramon dos Anjos Medeiros 4 weeks ago
parent 779c038d5c
commit edbf23870a

@ -114,9 +114,70 @@ namespace IEC61850
{
private IntPtr self = IntPtr.Zero;
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IsoApplicationReference_getAeQualifier(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr IsoApplicationReference_getApTitle(IntPtr self);
public IsoApplicationReference(IntPtr self)
{
this.self= self;
}
public int GetAeQualifier()
{
return IsoApplicationReference_getAeQualifier(self);
}
public ItuObjectIdentifier GetApTitle()
{
IntPtr identfier = IsoApplicationReference_getApTitle(self);
if (identfier == IntPtr.Zero)
return null;
return new ItuObjectIdentifier(identfier);
}
}
public class ItuObjectIdentifier
{
private IntPtr self = IntPtr.Zero;
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int ItuObjectIdentifier_getArcCount(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ItuObjectIdentifier_getArc(IntPtr self);
public ItuObjectIdentifier(IntPtr self)
{
this.self = self;
}
public int GetArcCount()
{
return ItuObjectIdentifier_getArcCount(self);
}
public ushort[] GetArcs()
{
int count = ItuObjectIdentifier_getArcCount(self);
if (count <= 0 || count > 10) return Array.Empty<ushort>();
IntPtr arcPtr = ItuObjectIdentifier_getArc(self);
ushort[] arcs = new ushort[count];
short[] temp = new short[count];
Marshal.Copy(arcPtr, temp, 0, count);
for (int i = 0; i < count; i++)
arcs[i] = (ushort)temp[i];
return arcs;
}
}
}

@ -8,6 +8,7 @@
using System;
using IEC61850.Server;
using IEC61850.Common;
using IEC61850;
using System.Threading;
using System.Net;
using static IEC61850.Server.IedServer;
@ -17,7 +18,7 @@ using IEC61850.Client;
using ReportControlBlock = IEC61850.Server.ReportControlBlock;
using IEC61850.Model;
using System.Data.Common;
using IEC61850;
using System.Security.Cryptography;
namespace server_access_control
{
@ -348,8 +349,27 @@ namespace server_access_control
bool clientAuthenticator (object parameter, AcseAuthenticationParameter authParameter, object securityToken, IsoApplicationReference isoApplicationReference)
{
List<string> passwords = parameter as List<string>;
int aeQualifier = isoApplicationReference.GetAeQualifier();
ItuObjectIdentifier ituObjectIdentifier = isoApplicationReference.GetApTitle();
int arcCount = ituObjectIdentifier.GetArcCount();
ushort[] arc = ituObjectIdentifier.GetArcs();
Console.WriteLine("ACSE Authenticator:\n");
string appTitle = "";
for (int i = 0; i < arcCount; i++)
{
appTitle += arc[i];
if (i != (arcCount - 1))
appTitle += ".";
}
Console.WriteLine(" client ap-title: " + appTitle);
Console.WriteLine("\n client ae-qualifier: "+ aeQualifier + " \n");
IEC61850.AcseAuthenticationMechanism acseAuthenticationMechanism = authParameter.GetAuthMechanism();
if (acseAuthenticationMechanism == IEC61850.AcseAuthenticationMechanism.ACSE_AUTH_PASSWORD)

@ -103,8 +103,19 @@ AcseAuthenticationParameter_getPassword(AcseAuthenticationParameter self);
LIB61850_API int
AcseAuthenticationParameter_getPasswordLength(AcseAuthenticationParameter self);
LIB61850_API int
IsoApplicationReference_getAeQualifier(IsoApplicationReference self);
/**
LIB61850_API const ItuObjectIdentifier*
IsoApplicationReference_getApTitle(const IsoApplicationReference* self);
LIB61850_API int
ItuObjectIdentifier_getArcCount(ItuObjectIdentifier* self);
LIB61850_API const uint16_t*
ItuObjectIdentifier_getArc(ItuObjectIdentifier* self);
/**
* \brief Callback function to authenticate a client
*
* \param parameter user provided parameter - set when user registers the authenticator

@ -93,6 +93,38 @@ AcseAuthenticationParameter_getAuthMechanism(AcseAuthenticationParameter self)
return self->mechanism;
}
LIB61850_API int
IsoApplicationReference_getAeQualifier(IsoApplicationReference self)
{
return self.aeQualifier;
}
LIB61850_API const ItuObjectIdentifier*
IsoApplicationReference_getApTitle(const IsoApplicationReference* self)
{
if (self == NULL)
return NULL;
return &(self->apTitle);
}
LIB61850_API int
ItuObjectIdentifier_getArcCount(ItuObjectIdentifier* self)
{
if (self == NULL)
return NULL;
return self->arcCount;
}
LIB61850_API const uint16_t*
ItuObjectIdentifier_getArc(ItuObjectIdentifier* self)
{
if (self == NULL)
return NULL;
return self->arc;
}
IsoConnectionParameters
IsoConnectionParameters_create()
{

Loading…
Cancel
Save