Commit 2d851b5e authored by Patrick Bellot's avatar Patrick Bellot
Browse files

EDP

parent 3a221152
......@@ -94,35 +94,14 @@ public:
public:
Client_02(
SOPC_Channel _hChannel,
const char * _sEndpointUrl,
SOPC_String * _stEndpointUrl,
String * _endPointUrl,
Certificate * _crt_cli,
AsymmetricKey * _priv_cli,
Certificate * _crt_srv,
PKIProvider * _pki,
char * _pRequestedSecurityPolicyUri,
OpcUa_MessageSecurityMode _messageSecurityMode
)
: BaseClient(
_hChannel,
_sEndpointUrl,
_stEndpointUrl,
_endPointUrl,
_crt_cli,
_priv_cli,
_crt_srv,
_pki,
_pRequestedSecurityPolicyUri,
_messageSecurityMode
)
Client_02(int num, SOPC_SecureChannel_Config * pScConfig, uint32_t channel_config_idx,String * endpointUrl)
: BaseClient(num, pScConfig, channel_config_idx,endpointUrl)
{}
virtual ~Client_02()
{}
public:
SOPC_StatusCode createSession()
......@@ -149,7 +128,7 @@ public:
new RequestHeader(
SessionAuthenticationToken::nullNodeId,
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......@@ -266,7 +245,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
new UInt32(5000) // TimeoutHint
......@@ -309,7 +288,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
new UInt32(5000) // TimeoutHint
......@@ -378,7 +357,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......@@ -446,7 +425,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero), // TimeoutHint
......@@ -471,7 +450,7 @@ public:
CallMethodResult * result = results->get(i);
StatusCode * statusCode = result->getStatusCode();
debug_ii(MAIN_LIFE_DBG,"Client_02"," Results number %d, status=0x08x",i,statusCode->get()) ;
debug_ii(MAIN_LIFE_DBG,"Client_02"," Results number %d, status=0x%08x",i,statusCode->get()) ;
TableVariant * outputArguments = result->getOutputArguments();
int32_t len = outputArguments->getLength();
......
......@@ -21,8 +21,17 @@
#define STARTCLIENTS_02_H_
#include "lib/Stacks/All.h"
#include "Client_02.h"
#include "../OpcUa_BaseClient.h"
#include <sopc_toolkit_config.h>
extern "C" {
extern opcua::BaseClient ** the_clients ;
extern int the_nbClient ;
}
#if (WITH_CALL == 1)
......@@ -33,54 +42,43 @@ class StartClients_02
public:
static SOPC_StatusCode startClients(
const char * sEndpointUrl,
SOPC_String * stEndpointUrl,
String * endpointUrl,
Certificate * crt_cli,
AsymmetricKey * priv_cli,
Certificate * crt_srv,
PKIProvider * pki,
const char * pRequestedSecurityPolicyUri,
OpcUa_MessageSecurityMode messageSecurityMode
SOPC_SecureChannel_Config * pScConfig
)
{
int nbClient = 5 ; // Number of client threads
int nbTry = 5 ; // Number of total loops from OpenSecureChannel to CloseSecureChannel
SOPC_Channel hChannel = NULL;
Client_02 ** clients = NULL ;
SOPC_StatusCode status = STATUS_OK ;
uint32_t channel_config_idx = 0 ;
Client_02 ** clients = NULL ;
SOPC_StatusCode status = STATUS_OK ;
// CREATING CHANNEL CONFIGURATION
channel_config_idx = SOPC_ToolkitClient_AddSecureChannelConfig(pScConfig);
if (channel_config_idx == 0) {
debug(COM_ERR,"StartClientss_02","Cannot add secure channel config") ;
goto error ;
} else {
debug_i(IPCS_DBG,"StartClients_02","channel_config_idx=%d",channel_config_idx) ;
}
SOPC_Toolkit_Configured() ;
debug(MAIN_LIFE_DBG,"StartClients_02","Open Secure Channels config succeeds") ;
// EXTERNAL LOOP
while (--nbTry >= 0) {
// CREATING CHANNEL
debug(MAIN_LIFE_DBG,"StartClients_02","Create channel") ;
status = SOPC_Channel_Create(&hChannel, SOPC_ChannelSerializer_Binary);
if(STATUS_OK != status) {
debug_i(COM_ERR,"StartClients_02","Create channel failed: status=0x%08x",status) ;
goto error ;
}
// CREATING CLIENT
// CREATING CLIENTS
debug(MAIN_LIFE_DBG,"StartClients_02","Building clients") ;
clients = new Client_02 *[nbClient] ;
for (int i = 0 ; i < nbClient ; i++)
clients[i]
= new Client_02(
hChannel,
sEndpointUrl,
stEndpointUrl,
endpointUrl,
crt_cli,
priv_cli,
crt_srv,
pki,
(char *)pRequestedSecurityPolicyUri,
messageSecurityMode
) ;
clients[i] = new Client_02(i,pScConfig,channel_config_idx,endpointUrl) ;
the_clients = (BaseClient **)clients ;
the_nbClient = nbClient ;
// OPEN SECURE CHANNEL
......@@ -116,18 +114,6 @@ public:
}
debug(MAIN_LIFE_DBG,"StartClients_02","Close Secure Channel succeeds") ;
// DELETING CHANNEL
debug(MAIN_LIFE_DBG,"StartClients_02","Delete channel") ;
status = SOPC_Channel_Delete(&hChannel);
hChannel = NULL ;
if(STATUS_OK != status) {
debug_i(COM_ERR,"StartClients_02","Delete channel failed: status=0x%08x",status) ;
goto error ;
}
debug(MAIN_LIFE_DBG,"StartClients_02","Delete channel succeeds") ;
// DELETING CLIENTS
debug(MAIN_LIFE_DBG,"StartClients_02","Deleting clients") ;
for (int i = 0 ; i < nbClient ; i++)
......@@ -135,6 +121,8 @@ public:
delete[] clients ;
clients = NULL ;
SOPC_Toolkit_Clear();
debug_i(MAIN_LIFE_DBG,"StartClients_02","End of Loop (%d)",nbTry) ;
} // while (--nbTry >= 0)
......@@ -146,8 +134,7 @@ public:
error:
debug(MAIN_LIFE_DBG,"StartClients_02","Releasing memory with error") ;
if (hChannel != NULL)
SOPC_Channel_Delete(&hChannel);
SOPC_Toolkit_Clear();
if (clients != NULL) {
for (int i = 0 ; i < nbClient ; i++)
......
......@@ -38,8 +38,8 @@ public:
void run()
{
int nbExt = 1000 ; // Number of total loops from CreateSession to CloseSession
int nbInt = 1000 ; // Number of internal loops (after ActivateSession and before CloseSession)
int nbExt = 1 ; // Number of total loops from CreateSession to CloseSession
int nbInt = 1 ; // Number of internal loops (after ActivateSession and before CloseSession)
SOPC_StatusCode status = STATUS_OK ;
......
......@@ -54,22 +54,22 @@ public:
SOPC_StatusCode status = STATUS_OK ;
// EXTERNAL LOOP
while (--nbTry >= 0) {
// CREATING CHANNEL CONFIGURATION
channel_config_idx = SOPC_ToolkitClient_AddSecureChannelConfig(pScConfig);
if (channel_config_idx == 0) {
debug(COM_ERR,"StartClientss_03","Cannot add secure channel config") ;
goto error ;
} else {
debug_i(IPCS_DBG,"StartClients_03","channel_config_idx=%d",channel_config_idx) ;
}
SOPC_Toolkit_Configured() ;
debug(MAIN_LIFE_DBG,"StartClients_03","Open Secure Channels config succeeds") ;
// CREATING CHANNELS
channel_config_idx = SOPC_ToolkitClient_AddSecureChannelConfig(pScConfig);
if (channel_config_idx == 0) {
debug(COM_ERR,"StartClientss_03","Cannot add secure channel config") ;
goto error ;
} else {
debug_i(IPCS_DBG,"StartClients_03","channel_config_idx=%d",channel_config_idx) ;
}
SOPC_Toolkit_Configured() ;
debug(MAIN_LIFE_DBG,"StartClients_03","Open Secure Channels config succeeds") ;
// EXTERNAL LOOP
while (--nbTry >= 0) {
// CREATING CLIENT
// CREATING CLIENTS
debug(MAIN_LIFE_DBG,"StartClients_03","Building clients") ;
clients = new Client_03 *[nbClient] ;
......@@ -79,6 +79,7 @@ public:
the_clients = (BaseClient **)clients ;
the_nbClient = nbClient ;
// OPEN SECURE CHANNEL
debug(MAIN_LIFE_DBG,"StartClients_03","Open Secure Channel begin") ;
status = clients[0]->openSecureChannel() ;
......@@ -112,18 +113,6 @@ public:
}
debug(MAIN_LIFE_DBG,"StartClients_03","Close Secure Channel succeeds") ;
// // DELETING CHANNEL
// debug(MAIN_LIFE_DBG,"StartClients_03","Delete channel") ;
// status = SOPC_Channel_Delete(&hChannel);
// hChannel = NULL ;
// if(STATUS_OK != status) {
// debug_i(COM_ERR,"StartClients_03","Delete channel failed: status=0x%08x",status) ;
// goto error ;
// }
// debug(MAIN_LIFE_DBG,"StartClients_03","Delete channel succeeds") ;
// DELETING CLIENTS
debug(MAIN_LIFE_DBG,"StartClients_03","Deleting clients") ;
for (int i = 0 ; i < nbClient ; i++)
......@@ -131,6 +120,8 @@ public:
delete[] clients ;
clients = NULL ;
SOPC_Toolkit_Clear();
debug_i(MAIN_LIFE_DBG,"StartClients_03","End of Loop (%d)",nbTry) ;
} // while (--nbTry >= 0)
......
......@@ -112,30 +112,8 @@ public:
public:
Client_04(
SOPC_Channel _hChannel,
const char * _sEndpointUrl,
SOPC_String * _stEndpointUrl,
String * _endPointUrl,
Certificate * _crt_cli,
AsymmetricKey * _priv_cli,
Certificate * _crt_srv,
PKIProvider * _pki,
char * _pRequestedSecurityPolicyUri,
OpcUa_MessageSecurityMode _messageSecurityMode
)
: BaseClient(
_hChannel,
_sEndpointUrl,
_stEndpointUrl,
_endPointUrl,
_crt_cli,
_priv_cli,
_crt_srv,
_pki,
_pRequestedSecurityPolicyUri,
_messageSecurityMode
)
Client_04(int num, SOPC_SecureChannel_Config * pScConfig, uint32_t channel_config_idx,String * endpointUrl)
: BaseClient(num, pScConfig, channel_config_idx,endpointUrl)
{}
virtual ~Client_04()
......@@ -167,7 +145,7 @@ public:
new RequestHeader(
SessionAuthenticationToken::nullNodeId,
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......@@ -284,7 +262,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
new UInt32(5000) // TimeoutHint
......@@ -327,7 +305,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
new UInt32(5000) // TimeoutHint
......@@ -396,7 +374,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......@@ -452,7 +430,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......@@ -511,7 +489,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......@@ -570,7 +548,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......
......@@ -21,8 +21,17 @@
#define STARTCLIENTS_04_H_
#include "lib/Stacks/All.h"
#include "Client_04.h"
#include "../OpcUa_BaseClient.h"
#include "../Client_04_Register_Unregister/Client_04.h"
#include <sopc_toolkit_config.h>
extern "C" {
extern opcua::BaseClient ** the_clients ;
extern int the_nbClient ;
}
#if (WITH_REGISTER_UNREGISTER_NODES == 1)
......@@ -33,54 +42,41 @@ class StartClients_04
public:
static SOPC_StatusCode startClients(
const char * sEndpointUrl,
SOPC_String * stEndpointUrl,
String * endpointUrl,
Certificate * crt_cli,
AsymmetricKey * priv_cli,
Certificate * crt_srv,
PKIProvider * pki,
const char * pRequestedSecurityPolicyUri,
OpcUa_MessageSecurityMode messageSecurityMode
SOPC_SecureChannel_Config * pScConfig
)
{
int nbClient = 5 ; // Number of client threads
int nbTry = 5 ; // Number of total loops from OpenSecureChannel to CloseSecureChannel
SOPC_Channel hChannel = NULL;
Client_04 ** clients = NULL ;
uint32_t channel_config_idx = 0 ;
Client_04 ** clients = NULL ;
SOPC_StatusCode status = STATUS_OK ;
// CREATING CHANNEL CONFIGURATION
channel_config_idx = SOPC_ToolkitClient_AddSecureChannelConfig(pScConfig);
if (channel_config_idx == 0) {
debug(COM_ERR,"StartClientss_04","Cannot add secure channel config") ;
goto error ;
} else {
debug_i(IPCS_DBG,"StartClients_04","channel_config_idx=%d",channel_config_idx) ;
}
SOPC_Toolkit_Configured() ;
debug(MAIN_LIFE_DBG,"StartClients_04","Open Secure Channels config succeeds") ;
// EXTERNAL LOOP
while (--nbTry >= 0) {
// CREATING CHANNEL
debug(MAIN_LIFE_DBG,"StartClients_04","Create channel") ;
status = SOPC_Channel_Create(&hChannel, SOPC_ChannelSerializer_Binary);
if(STATUS_OK != status) {
debug_i(COM_ERR,"StartClients_04","Create channel failed: status=0x%08x",status) ;
goto error ;
}
// CREATING CLIENT
// CREATING CLIENTS
debug(MAIN_LIFE_DBG,"StartClients_04","Building clients") ;
clients = new Client_04 *[nbClient] ;
for (int i = 0 ; i < nbClient ; i++)
clients[i]
= new Client_04(
hChannel,
sEndpointUrl,
stEndpointUrl,
endpointUrl,
crt_cli,
priv_cli,
crt_srv,
pki,
(char *)pRequestedSecurityPolicyUri,
messageSecurityMode
) ;
clients[i] = new Client_04(i,pScConfig,channel_config_idx,endpointUrl) ;
the_clients = (BaseClient **)clients ;
the_nbClient = nbClient ;
// OPEN SECURE CHANNEL
......@@ -116,18 +112,6 @@ public:
}
debug(MAIN_LIFE_DBG,"StartClients_04","Close Secure Channel succeeds") ;
// DELETING CHANNEL
debug(MAIN_LIFE_DBG,"StartClients_04","Delete channel") ;
status = SOPC_Channel_Delete(&hChannel);
hChannel = NULL ;
if(STATUS_OK != status) {
debug_i(COM_ERR,"StartClients_04","Delete channel failed: status=0x%08x",status) ;
goto error ;
}
debug(MAIN_LIFE_DBG,"StartClients_04","Delete channel succeeds") ;
// DELETING CLIENTS
debug(MAIN_LIFE_DBG,"StartClients_04","Deleting clients") ;
for (int i = 0 ; i < nbClient ; i++)
......@@ -135,6 +119,8 @@ public:
delete[] clients ;
clients = NULL ;
SOPC_Toolkit_Clear();
debug_i(MAIN_LIFE_DBG,"StartClients_04","End of Loop (%d)",nbTry) ;
} // while (--nbTry >= 0)
......@@ -146,8 +132,7 @@ public:
error:
debug(MAIN_LIFE_DBG,"StartClients_04","Releasing memory with error") ;
if (hChannel != NULL)
SOPC_Channel_Delete(&hChannel);
SOPC_Toolkit_Clear();
if (clients != NULL) {
for (int i = 0 ; i < nbClient ; i++)
......
......@@ -94,30 +94,8 @@ public:
public:
Client_05(
SOPC_Channel _hChannel,
const char * _sEndpointUrl,
SOPC_String * _stEndpointUrl,
String * _endPointUrl,
Certificate * _crt_cli,
AsymmetricKey * _priv_cli,
Certificate * _crt_srv,
PKIProvider * _pki,
char * _pRequestedSecurityPolicyUri,
OpcUa_MessageSecurityMode _messageSecurityMode
)
: BaseClient(
_hChannel,
_sEndpointUrl,
_stEndpointUrl,
_endPointUrl,
_crt_cli,
_priv_cli,
_crt_srv,
_pki,
_pRequestedSecurityPolicyUri,
_messageSecurityMode
)
Client_05(int num, SOPC_SecureChannel_Config * pScConfig, uint32_t channel_config_idx,String * endpointUrl)
: BaseClient(num, pScConfig, channel_config_idx,endpointUrl)
{}
virtual ~Client_05()
......@@ -149,7 +127,7 @@ public:
new RequestHeader(
SessionAuthenticationToken::nullNodeId,
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......@@ -267,7 +245,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
new UInt32(5000) // TimeoutHint
......@@ -310,7 +288,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
new UInt32(5000) // TimeoutHint
......@@ -379,7 +357,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),
new IntegerId(sequence<<8 | num),
UInt32::zero, // ReturnDiagnostics
String::empty, // auditEntryId
UInt32::zero // TimeoutHint
......@@ -462,7 +440,7 @@ public:
new RequestHeader(
new SessionAuthenticationToken(authenticationTokenNum),
UtcTime::now(),
new IntegerId(sequence),