libiec61850  1.6.0
iso_connection_parameters.h
Go to the documentation of this file.
1 /*
2  * iso_connection_parameters.h
3  *
4  * Copyright 2013-2023 Michael Zillgith
5  *
6  * This file is part of libIEC61850.
7  *
8  * libIEC61850 is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * libIEC61850 is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * See COPYING file for the complete license text.
22  */
23 
24 #ifndef ISO_CONNECTION_PARAMETERS_H_
25 #define ISO_CONNECTION_PARAMETERS_H_
26 
27 #ifndef CONFIG_MMS_SUPPORT_TLS
28 #define CONFIG_MMS_SUPPORT_TLS 0
29 #endif
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include "tls_config.h"
36 
46 typedef enum
47 {
50 
53 
56 
58  ACSE_AUTH_TLS = 3
60 
61 
62 typedef struct sAcseAuthenticationParameter* AcseAuthenticationParameter;
63 
65 {
67 
68  union
69  {
70  struct
71  {
72  uint8_t* octetString;
74  } password; /* for mechanism = ACSE_AUTH_PASSWORD */
75 
76  struct
77  {
78  uint8_t* buf;
79  int length;
80  } certificate; /* for mechanism = ACSE_AUTH_CERTIFICATE or ACSE_AUTH_TLS */
81 
82  } value;
83 };
84 
85 LIB61850_API AcseAuthenticationParameter
87 
88 LIB61850_API void
89 AcseAuthenticationParameter_destroy(AcseAuthenticationParameter self);
90 
91 LIB61850_API void
93 
94 LIB61850_API void
95 AcseAuthenticationParameter_setPassword(AcseAuthenticationParameter self, char* password);
96 
97 
108 typedef bool
109 (*AcseAuthenticator)(void* parameter, AcseAuthenticationParameter authParameter, void** securityToken, IsoApplicationReference* appReference);
110 
116 typedef struct {
117  uint8_t size;
118  uint8_t value[4];
119 } TSelector;
120 
126 typedef struct {
127  uint8_t size;
128  uint8_t value[16];
129 } SSelector;
130 
136 typedef struct {
137  uint8_t size;
138  uint8_t value[16];
139 } PSelector;
140 
142 {
143  AcseAuthenticationParameter acseAuthParameter;
144 
145 #if (CONFIG_MMS_SUPPORT_TLS == 1)
146  TLSConfiguration tlsConfiguration;
147 #endif
148 
149  const char* hostname;
150  int tcpPort;
151 
152  const char* localIpAddress;
154 
155  uint8_t remoteApTitle[10];
161 
162 
163  uint8_t localApTitle[10];
169 
170 };
171 
172 typedef struct sIsoConnectionParameters* IsoConnectionParameters;
173 
182 LIB61850_API IsoConnectionParameters
184 
193 LIB61850_API void
194 IsoConnectionParameters_destroy(IsoConnectionParameters self);
195 
196 
197 LIB61850_API void
198 IsoConnectionParameters_setTlsConfiguration(IsoConnectionParameters self, TLSConfiguration tlsConfig);
199 
208 LIB61850_API void
210  AcseAuthenticationParameter acseAuthParameter);
211 
222 LIB61850_API void
223 IsoConnectionParameters_setTcpParameters(IsoConnectionParameters self, const char* hostname, int tcpPort);
224 
235 LIB61850_API void
236 IsoConnectionParameters_setLocalTcpParameters(IsoConnectionParameters self, const char* localIpAddress, int localTcpPort);
237 
250 LIB61850_API void
251 IsoConnectionParameters_setRemoteApTitle(IsoConnectionParameters self, const char* apTitle, int aeQualifier);
252 
265 LIB61850_API void
266 IsoConnectionParameters_setRemoteAddresses(IsoConnectionParameters self, PSelector pSelector, SSelector sSelector, TSelector tSelector);
267 
280 LIB61850_API void
281 IsoConnectionParameters_setLocalApTitle(IsoConnectionParameters self, const char* apTitle, int aeQualifier);
282 
295 LIB61850_API void
296 IsoConnectionParameters_setLocalAddresses(IsoConnectionParameters self, PSelector pSelector, SSelector sSelector, TSelector tSelector);
297 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif /* ISO_CONNECTION_PARAMETERS_H_ */
LIB61850_API void IsoConnectionParameters_destroy(IsoConnectionParameters self)
Destroy an IsoConnectionParameters instance (FOR LIBRARY INTERNAL USE)
LIB61850_API void IsoConnectionParameters_setTcpParameters(IsoConnectionParameters self, const char *hostname, int tcpPort)
Set TCP parameters (FOR LIBRARY INTERNAL USE)
LIB61850_API void IsoConnectionParameters_setLocalAddresses(IsoConnectionParameters self, PSelector pSelector, SSelector sSelector, TSelector tSelector)
set local addresses for the lower layers
bool(* AcseAuthenticator)(void *parameter, AcseAuthenticationParameter authParameter, void **securityToken, IsoApplicationReference *appReference)
Callback function to authenticate a client.
Definition: iso_connection_parameters.h:109
LIB61850_API AcseAuthenticationParameter AcseAuthenticationParameter_create(void)
LIB61850_API void AcseAuthenticationParameter_setPassword(AcseAuthenticationParameter self, char *password)
LIB61850_API void AcseAuthenticationParameter_setAuthMechanism(AcseAuthenticationParameter self, AcseAuthenticationMechanism mechanism)
LIB61850_API void IsoConnectionParameters_setRemoteApTitle(IsoConnectionParameters self, const char *apTitle, int aeQualifier)
set the remote AP-Title and AE-Qualifier
LIB61850_API void IsoConnectionParameters_setAcseAuthenticationParameter(IsoConnectionParameters self, AcseAuthenticationParameter acseAuthParameter)
set the authentication parameter
LIB61850_API IsoConnectionParameters IsoConnectionParameters_create(void)
create a new IsoConnectionParameters instance (FOR LIBRARY INTERNAL USE)
LIB61850_API void IsoConnectionParameters_setRemoteAddresses(IsoConnectionParameters self, PSelector pSelector, SSelector sSelector, TSelector tSelector)
set remote addresses for the lower layers
AcseAuthenticationMechanism
authentication mechanism used by AcseAuthenticator
Definition: iso_connection_parameters.h:47
LIB61850_API void IsoConnectionParameters_setLocalApTitle(IsoConnectionParameters self, const char *apTitle, int aeQualifier)
set the local AP-Title and AE-Qualifier
LIB61850_API void IsoConnectionParameters_setLocalTcpParameters(IsoConnectionParameters self, const char *localIpAddress, int localTcpPort)
Set Local TCP parameters (FOR LIBRARY INTERNAL USE)
LIB61850_API void AcseAuthenticationParameter_destroy(AcseAuthenticationParameter self)
LIB61850_API void IsoConnectionParameters_setTlsConfiguration(IsoConnectionParameters self, TLSConfiguration tlsConfig)
@ ACSE_AUTH_NONE
Definition: iso_connection_parameters.h:49
@ ACSE_AUTH_PASSWORD
Definition: iso_connection_parameters.h:52
@ ACSE_AUTH_CERTIFICATE
Definition: iso_connection_parameters.h:55
@ ACSE_AUTH_TLS
Definition: iso_connection_parameters.h:58
ISO application reference (specifies an ISO application endpoint)
Definition: mms_common.h:169
OSI presentation (P) selector.
Definition: iso_connection_parameters.h:136
uint8_t size
Definition: iso_connection_parameters.h:137
OSI session selector.
Definition: iso_connection_parameters.h:126
uint8_t size
Definition: iso_connection_parameters.h:127
COTP T selector.
Definition: iso_connection_parameters.h:116
uint8_t size
Definition: iso_connection_parameters.h:117
Definition: iso_connection_parameters.h:65
struct sAcseAuthenticationParameter::@0::@2 certificate
int length
Definition: iso_connection_parameters.h:79
struct sAcseAuthenticationParameter::@0::@1 password
AcseAuthenticationMechanism mechanism
Definition: iso_connection_parameters.h:66
uint8_t * buf
Definition: iso_connection_parameters.h:78
int passwordLength
Definition: iso_connection_parameters.h:73
uint8_t * octetString
Definition: iso_connection_parameters.h:72
union sAcseAuthenticationParameter::@0 value
Definition: iso_connection_parameters.h:142
SSelector remoteSSelector
Definition: iso_connection_parameters.h:159
int tcpPort
Definition: iso_connection_parameters.h:150
PSelector localPSelector
Definition: iso_connection_parameters.h:166
SSelector localSSelector
Definition: iso_connection_parameters.h:167
AcseAuthenticationParameter acseAuthParameter
Definition: iso_connection_parameters.h:143
int remoteAEQualifier
Definition: iso_connection_parameters.h:157
TSelector localTSelector
Definition: iso_connection_parameters.h:168
TSelector remoteTSelector
Definition: iso_connection_parameters.h:160
const char * hostname
Definition: iso_connection_parameters.h:149
int localTcpPort
Definition: iso_connection_parameters.h:153
uint8_t remoteApTitle[10]
Definition: iso_connection_parameters.h:155
int remoteApTitleLen
Definition: iso_connection_parameters.h:156
const char * localIpAddress
Definition: iso_connection_parameters.h:152
uint8_t localApTitle[10]
Definition: iso_connection_parameters.h:163
int localAEQualifier
Definition: iso_connection_parameters.h:165
PSelector remotePSelector
Definition: iso_connection_parameters.h:158
int localApTitleLen
Definition: iso_connection_parameters.h:164