|
@@ -6,15 +6,13 @@
|
|
#include "ua_transport.h"
|
|
#include "ua_transport.h"
|
|
#include "ua_statuscodes.h"
|
|
#include "ua_statuscodes.h"
|
|
#include "ua_services.h"
|
|
#include "ua_services.h"
|
|
-#include "ua_stack_session_manager.h"
|
|
|
|
-#include "ua_stack_session.h"
|
|
|
|
|
|
+#include "ua_session_manager.h"
|
|
|
|
+#include "ua_session.h"
|
|
|
|
|
|
#define SIZE_SECURECHANNEL_HEADER 12
|
|
#define SIZE_SECURECHANNEL_HEADER 12
|
|
#define SIZE_SEQHEADER_HEADER 8
|
|
#define SIZE_SEQHEADER_HEADER 8
|
|
|
|
|
|
-static UA_Int32 SL_Send(SL_Channel *channel,
|
|
|
|
- const UA_ByteString * responseMessage, UA_Int32 type)
|
|
|
|
-{
|
|
|
|
|
|
+static UA_Int32 SL_Send(SL_Channel *channel, const UA_ByteString * responseMessage, UA_Int32 type) {
|
|
UA_UInt32 pos = 0;
|
|
UA_UInt32 pos = 0;
|
|
UA_Int32 isAsym = (type == UA_OPENSECURECHANNELRESPONSE_NS0); // FIXME: this is a to dumb method to determine asymmetric algorithm setting
|
|
UA_Int32 isAsym = (type == UA_OPENSECURECHANNELRESPONSE_NS0); // FIXME: this is a to dumb method to determine asymmetric algorithm setting
|
|
UA_UInt32 channelId;
|
|
UA_UInt32 channelId;
|
|
@@ -37,9 +35,7 @@ static UA_Int32 SL_Send(SL_Channel *channel,
|
|
+ UA_AsymmetricAlgorithmSecurityHeader_calcSizeBinary(
|
|
+ UA_AsymmetricAlgorithmSecurityHeader_calcSizeBinary(
|
|
asymAlgSettings)
|
|
asymAlgSettings)
|
|
+ UA_NodeId_calcSizeBinary(&resp_nodeid));
|
|
+ UA_NodeId_calcSizeBinary(&resp_nodeid));
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
UA_ByteString_newMembers((UA_ByteString *) response_gather[0], 8 + 16 + // normal header + 4*32bit secure channel information
|
|
UA_ByteString_newMembers((UA_ByteString *) response_gather[0], 8 + 16 + // normal header + 4*32bit secure channel information
|
|
UA_NodeId_calcSizeBinary(&resp_nodeid));
|
|
UA_NodeId_calcSizeBinary(&resp_nodeid));
|
|
}
|
|
}
|
|
@@ -49,14 +45,11 @@ static UA_Int32 SL_Send(SL_Channel *channel,
|
|
UA_ByteString *header = (UA_ByteString *) response_gather[0];
|
|
UA_ByteString *header = (UA_ByteString *) response_gather[0];
|
|
|
|
|
|
/*---encode Secure Conversation Message Header ---*/
|
|
/*---encode Secure Conversation Message Header ---*/
|
|
- if (isAsym)
|
|
|
|
- {
|
|
|
|
|
|
+ if (isAsym) {
|
|
header->data[0] = 'O';
|
|
header->data[0] = 'O';
|
|
header->data[1] = 'P';
|
|
header->data[1] = 'P';
|
|
header->data[2] = 'N';
|
|
header->data[2] = 'N';
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
header->data[0] = 'M';
|
|
header->data[0] = 'M';
|
|
header->data[1] = 'S';
|
|
header->data[1] = 'S';
|
|
header->data[2] = 'G';
|
|
header->data[2] = 'G';
|
|
@@ -74,20 +67,12 @@ static UA_Int32 SL_Send(SL_Channel *channel,
|
|
UA_UInt32_encodeBinary(&channelId, header,&pos);
|
|
UA_UInt32_encodeBinary(&channelId, header,&pos);
|
|
|
|
|
|
/*---encode Algorithm Security Header ---*/
|
|
/*---encode Algorithm Security Header ---*/
|
|
- if (isAsym)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(asymAlgSettings,
|
|
|
|
- header,&pos);
|
|
|
|
|
|
+ if (isAsym) {
|
|
|
|
+ UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(asymAlgSettings, header,&pos);
|
|
UA_free(asymAlgSettings);
|
|
UA_free(asymAlgSettings);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
|
|
+ } else {
|
|
UA_UInt32 tokenId = 0;
|
|
UA_UInt32 tokenId = 0;
|
|
SL_Channel_getTokenId(channel, &tokenId);
|
|
SL_Channel_getTokenId(channel, &tokenId);
|
|
-
|
|
|
|
UA_UInt32_encodeBinary(&tokenId, header,&pos);
|
|
UA_UInt32_encodeBinary(&tokenId, header,&pos);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -163,9 +148,7 @@ static void init_response_header(UA_RequestHeader const * p, UA_ResponseHeader *
|
|
UA_##TYPE##Response_deleteMembers(&r); \
|
|
UA_##TYPE##Response_deleteMembers(&r); \
|
|
|
|
|
|
|
|
|
|
-UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg,
|
|
|
|
- UA_UInt32 *pos)
|
|
|
|
-{
|
|
|
|
|
|
+UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg, UA_UInt32 *pos) {
|
|
UA_Int32 retval = UA_SUCCESS;
|
|
UA_Int32 retval = UA_SUCCESS;
|
|
UA_UInt32 recvOffset = *pos;
|
|
UA_UInt32 recvOffset = *pos;
|
|
UA_UInt32 sendOffset = 0;
|
|
UA_UInt32 sendOffset = 0;
|
|
@@ -180,62 +163,46 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg,
|
|
UA_Int32 serviceid = serviceRequestType.identifier.numeric - 2; // binary encoding has 2 added to the id
|
|
UA_Int32 serviceid = serviceRequestType.identifier.numeric - 2; // binary encoding has 2 added to the id
|
|
UA_Int32 responsetype;
|
|
UA_Int32 responsetype;
|
|
/* stack related services which only need information about the secure Channel */
|
|
/* stack related services which only need information about the secure Channel */
|
|
- if (serviceid == UA_GETENDPOINTSREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ if (serviceid == UA_GETENDPOINTSREQUEST_NS0) {
|
|
RESPONSE_PREPARE(GetEndpoints);
|
|
RESPONSE_PREPARE(GetEndpoints);
|
|
Service_GetEndpoints(channel,&p, &r);
|
|
Service_GetEndpoints(channel,&p, &r);
|
|
RESPONSE_CLEANUP(GetEndpoints);
|
|
RESPONSE_CLEANUP(GetEndpoints);
|
|
//INVOKE_SERVICE(GetEndpoints);
|
|
//INVOKE_SERVICE(GetEndpoints);
|
|
responsetype = UA_GETENDPOINTSRESPONSE_NS0;
|
|
responsetype = UA_GETENDPOINTSRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_OPENSECURECHANNELREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_OPENSECURECHANNELREQUEST_NS0) {
|
|
RESPONSE_PREPARE(OpenSecureChannel);
|
|
RESPONSE_PREPARE(OpenSecureChannel);
|
|
Service_OpenSecureChannel(channel,&p, &r);
|
|
Service_OpenSecureChannel(channel,&p, &r);
|
|
RESPONSE_CLEANUP(OpenSecureChannel);
|
|
RESPONSE_CLEANUP(OpenSecureChannel);
|
|
responsetype = UA_OPENSECURECHANNELRESPONSE_NS0;
|
|
responsetype = UA_OPENSECURECHANNELRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_CLOSESECURECHANNELREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_CLOSESECURECHANNELREQUEST_NS0) {
|
|
RESPONSE_PREPARE(CloseSecureChannel);
|
|
RESPONSE_PREPARE(CloseSecureChannel);
|
|
Service_CloseSecureChannel(channel,&p,&r);
|
|
Service_CloseSecureChannel(channel,&p,&r);
|
|
RESPONSE_CLEANUP(CloseSecureChannel);
|
|
RESPONSE_CLEANUP(CloseSecureChannel);
|
|
responsetype = UA_CLOSESECURECHANNELRESPONSE_NS0;
|
|
responsetype = UA_CLOSESECURECHANNELRESPONSE_NS0;
|
|
- }
|
|
|
|
-
|
|
|
|
- else if (serviceid == UA_CREATESESSIONREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_CREATESESSIONREQUEST_NS0) {
|
|
RESPONSE_PREPARE(CreateSession);
|
|
RESPONSE_PREPARE(CreateSession);
|
|
Service_CreateSession(channel,&p, &r);
|
|
Service_CreateSession(channel,&p, &r);
|
|
RESPONSE_CLEANUP(CreateSession);
|
|
RESPONSE_CLEANUP(CreateSession);
|
|
responsetype = UA_CREATESESSIONRESPONSE_NS0;
|
|
responsetype = UA_CREATESESSIONRESPONSE_NS0;
|
|
}
|
|
}
|
|
/* services which need a session object */
|
|
/* services which need a session object */
|
|
- else if (serviceid == UA_ACTIVATESESSIONREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ else if (serviceid == UA_ACTIVATESESSIONREQUEST_NS0) {
|
|
RESPONSE_PREPARE(ActivateSession);
|
|
RESPONSE_PREPARE(ActivateSession);
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
Service_ActivateSession(channel, session,&p, &r);
|
|
Service_ActivateSession(channel, session,&p, &r);
|
|
RESPONSE_CLEANUP(ActivateSession);
|
|
RESPONSE_CLEANUP(ActivateSession);
|
|
-
|
|
|
|
responsetype = UA_ACTIVATESESSIONRESPONSE_NS0;
|
|
responsetype = UA_ACTIVATESESSIONRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_CLOSESESSIONREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_CLOSESESSIONREQUEST_NS0) {
|
|
RESPONSE_PREPARE(CloseSession);
|
|
RESPONSE_PREPARE(CloseSession);
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
Service_CloseSession(session,&p, &r);
|
|
Service_CloseSession(session,&p, &r);
|
|
RESPONSE_CLEANUP(CloseSession);
|
|
RESPONSE_CLEANUP(CloseSession);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
responsetype = UA_CLOSESESSIONRESPONSE_NS0;
|
|
responsetype = UA_CLOSESESSIONRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_READREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_READREQUEST_NS0) {
|
|
|
|
|
|
RESPONSE_PREPARE(Read);
|
|
RESPONSE_PREPARE(Read);
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
@@ -243,137 +210,96 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg,
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
Service_Read(session,&p, &r);
|
|
Service_Read(session,&p, &r);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Read));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Read));
|
|
RESPONSE_CLEANUP(Read);
|
|
RESPONSE_CLEANUP(Read);
|
|
|
|
|
|
responsetype = UA_READRESPONSE_NS0;
|
|
responsetype = UA_READRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_WRITEREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_WRITEREQUEST_NS0) {
|
|
|
|
|
|
RESPONSE_PREPARE(Write);
|
|
RESPONSE_PREPARE(Write);
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Write));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Write));
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
UA_Session_updateLifetime(session); //renew session timeout
|
|
Service_Write(session,&p, &r);
|
|
Service_Write(session,&p, &r);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Write));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Write));
|
|
RESPONSE_CLEANUP(Write);
|
|
RESPONSE_CLEANUP(Write);
|
|
-
|
|
|
|
-
|
|
|
|
responsetype = UA_WRITERESPONSE_NS0;
|
|
responsetype = UA_WRITERESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_BROWSEREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
|
|
+ } else if (serviceid == UA_BROWSEREQUEST_NS0) {
|
|
RESPONSE_PREPARE(Browse);
|
|
RESPONSE_PREPARE(Browse);
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Browse));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Browse));
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
Service_Browse(session,&p, &r);
|
|
Service_Browse(session,&p, &r);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Browse));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Browse));
|
|
RESPONSE_CLEANUP(Browse);
|
|
RESPONSE_CLEANUP(Browse);
|
|
-
|
|
|
|
-
|
|
|
|
responsetype = UA_BROWSERESPONSE_NS0;
|
|
responsetype = UA_BROWSERESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_CREATESUBSCRIPTIONREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
|
|
+ } else if (serviceid == UA_CREATESUBSCRIPTIONREQUEST_NS0) {
|
|
RESPONSE_PREPARE(CreateSubscription);
|
|
RESPONSE_PREPARE(CreateSubscription);
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", CreateSubscription));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", CreateSubscription));
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
Service_CreateSubscription(session, &p, &r);
|
|
Service_CreateSubscription(session, &p, &r);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", CreateSubscription));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", CreateSubscription));
|
|
RESPONSE_CLEANUP(CreateSubscription);
|
|
RESPONSE_CLEANUP(CreateSubscription);
|
|
responsetype = UA_CREATESUBSCRIPTIONRESPONSE_NS0;
|
|
responsetype = UA_CREATESUBSCRIPTIONRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_TRANSLATEBROWSEPATHSTONODEIDSREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
|
|
+ } else if (serviceid == UA_TRANSLATEBROWSEPATHSTONODEIDSREQUEST_NS0) {
|
|
RESPONSE_PREPARE(TranslateBrowsePathsToNodeIds);
|
|
RESPONSE_PREPARE(TranslateBrowsePathsToNodeIds);
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", TranslateBrowsePathsToNodeIds));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", TranslateBrowsePathsToNodeIds));
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
if (UA_Session_verifyChannel(session,channel)){
|
|
Service_TranslateBrowsePathsToNodeIds(session, &p, &r);
|
|
Service_TranslateBrowsePathsToNodeIds(session, &p, &r);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", TranslateBrowsePathsToNodeIds));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", TranslateBrowsePathsToNodeIds));
|
|
RESPONSE_CLEANUP(TranslateBrowsePathsToNodeIds);
|
|
RESPONSE_CLEANUP(TranslateBrowsePathsToNodeIds);
|
|
responsetype = UA_TRANSLATEBROWSEPATHSTONODEIDSRESPONSE_NS0;
|
|
responsetype = UA_TRANSLATEBROWSEPATHSTONODEIDSRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_PUBLISHREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_PUBLISHREQUEST_NS0) {
|
|
|
|
|
|
RESPONSE_PREPARE(Publish);
|
|
RESPONSE_PREPARE(Publish);
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Publish));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Publish));
|
|
- if (UA_Session_verifyChannel(session,channel)){
|
|
|
|
|
|
+ if (UA_Session_verifyChannel(session,channel)) {
|
|
Service_Publish(session, &p, &r);
|
|
Service_Publish(session, &p, &r);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Publish));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", Publish));
|
|
RESPONSE_CLEANUP(Publish);
|
|
RESPONSE_CLEANUP(Publish);
|
|
responsetype = UA_PUBLISHRESPONSE_NS0;
|
|
responsetype = UA_PUBLISHRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_CREATEMONITOREDITEMSREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_CREATEMONITOREDITEMSREQUEST_NS0) {
|
|
RESPONSE_PREPARE(CreateMonitoredItems);
|
|
RESPONSE_PREPARE(CreateMonitoredItems);
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", CreateMonitoredItems));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", CreateMonitoredItems));
|
|
- if (UA_Session_verifyChannel(session,channel)){
|
|
|
|
|
|
+ if (UA_Session_verifyChannel(session,channel)) {
|
|
Service_CreateMonitoredItems(session, &p, &r);
|
|
Service_CreateMonitoredItems(session, &p, &r);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", CreateMonitoredItems));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", CreateMonitoredItems));
|
|
RESPONSE_CLEANUP(CreateMonitoredItems);
|
|
RESPONSE_CLEANUP(CreateMonitoredItems);
|
|
responsetype = UA_CREATEMONITOREDITEMSRESPONSE_NS0;
|
|
responsetype = UA_CREATEMONITOREDITEMSRESPONSE_NS0;
|
|
- }
|
|
|
|
- else if (serviceid == UA_SETPUBLISHINGMODEREQUEST_NS0)
|
|
|
|
- {
|
|
|
|
|
|
+ } else if (serviceid == UA_SETPUBLISHINGMODEREQUEST_NS0) {
|
|
RESPONSE_PREPARE(SetPublishingMode);
|
|
RESPONSE_PREPARE(SetPublishingMode);
|
|
DBG_VERBOSE(printf("Finished Service: %s\n",SetPublishingMode));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n",SetPublishingMode));
|
|
- if (UA_Session_verifyChannel(session,channel)){
|
|
|
|
|
|
+ if (UA_Session_verifyChannel(session,channel)) {
|
|
Service_SetPublishingMode(session, &p, &r);
|
|
Service_SetPublishingMode(session, &p, &r);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
DBG_VERBOSE(printf("session does not match secure channel"));
|
|
}
|
|
}
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", SetPublishingMode));
|
|
DBG_VERBOSE(printf("Finished Service: %s\n", SetPublishingMode));
|
|
RESPONSE_CLEANUP(SetPublishingMode);
|
|
RESPONSE_CLEANUP(SetPublishingMode);
|
|
responsetype = UA_SETPUBLISHINGMODERESPONSE_NS0;
|
|
responsetype = UA_SETPUBLISHINGMODERESPONSE_NS0;
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- printf(
|
|
|
|
- "SL_processMessage - unknown request, namespace=%d, request=%d\n",
|
|
|
|
- serviceRequestType.ns,
|
|
|
|
- serviceRequestType.identifier.numeric);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ printf("SL_processMessage - unknown request, namespace=%d, request=%d\n",
|
|
|
|
+ serviceRequestType.ns, serviceRequestType.identifier.numeric);
|
|
retval = UA_ERROR;
|
|
retval = UA_ERROR;
|
|
UA_RequestHeader p;
|
|
UA_RequestHeader p;
|
|
UA_ResponseHeader r;
|
|
UA_ResponseHeader r;
|
|
@@ -387,17 +313,16 @@ UA_Int32 SL_handleRequest(SL_Channel *channel, const UA_ByteString* msg,
|
|
UA_ResponseHeader_encodeBinary(&r, &response_msg,&sendOffset);
|
|
UA_ResponseHeader_encodeBinary(&r, &response_msg,&sendOffset);
|
|
responsetype = UA_RESPONSEHEADER_NS0;
|
|
responsetype = UA_RESPONSEHEADER_NS0;
|
|
}
|
|
}
|
|
- if(serviceid != UA_CLOSESECURECHANNELREQUEST_NS0){
|
|
|
|
|
|
+
|
|
|
|
+ if(serviceid != UA_CLOSESECURECHANNELREQUEST_NS0)
|
|
SL_Send(channel, &response_msg, responsetype);
|
|
SL_Send(channel, &response_msg, responsetype);
|
|
- }
|
|
|
|
|
|
+
|
|
UA_ByteString_deleteMembers(&response_msg);
|
|
UA_ByteString_deleteMembers(&response_msg);
|
|
*pos = recvOffset;
|
|
*pos = recvOffset;
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
|
|
|
|
-UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg,
|
|
|
|
- UA_UInt32 *pos)
|
|
|
|
-{
|
|
|
|
|
|
+UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg, UA_UInt32 *pos) {
|
|
UA_Int32 retval = UA_SUCCESS;
|
|
UA_Int32 retval = UA_SUCCESS;
|
|
UA_SequenceHeader sequenceHeader;
|
|
UA_SequenceHeader sequenceHeader;
|
|
UA_AsymmetricAlgorithmSecurityHeader asymHeader;
|
|
UA_AsymmetricAlgorithmSecurityHeader asymHeader;
|
|
@@ -408,23 +333,21 @@ UA_Int32 SL_ProcessOpenChannel(SL_Channel *channel, const UA_ByteString* msg,
|
|
SL_Channel_setRemoteSecuritySettings(channel,&asymHeader,&sequenceHeader);
|
|
SL_Channel_setRemoteSecuritySettings(channel,&asymHeader,&sequenceHeader);
|
|
return SL_handleRequest(channel, msg, pos) | retval;
|
|
return SL_handleRequest(channel, msg, pos) | retval;
|
|
}
|
|
}
|
|
|
|
+
|
|
/* not used anymore */
|
|
/* not used anymore */
|
|
//UA_Int32 SL_ProcessCloseChannel(SL_Channel *channel, const UA_ByteString* msg,
|
|
//UA_Int32 SL_ProcessCloseChannel(SL_Channel *channel, const UA_ByteString* msg,
|
|
// UA_UInt32 *pos)
|
|
// UA_UInt32 *pos)
|
|
//{
|
|
//{
|
|
// return SL_handleRequest(channel, msg, pos);
|
|
// return SL_handleRequest(channel, msg, pos);
|
|
//}
|
|
//}
|
|
-UA_Int32 SL_Process(const UA_ByteString* msg,
|
|
|
|
- UA_UInt32* pos)
|
|
|
|
-{
|
|
|
|
|
|
|
|
|
|
+UA_Int32 SL_Process(const UA_ByteString* msg, UA_UInt32* pos) {
|
|
DBG_VERBOSE(printf("SL_process - entered \n"));
|
|
DBG_VERBOSE(printf("SL_process - entered \n"));
|
|
UA_UInt32 secureChannelId;
|
|
UA_UInt32 secureChannelId;
|
|
UA_UInt32 foundChannelId;
|
|
UA_UInt32 foundChannelId;
|
|
SL_Channel *channel;
|
|
SL_Channel *channel;
|
|
UA_SequenceHeader sequenceHeader;
|
|
UA_SequenceHeader sequenceHeader;
|
|
|
|
|
|
-
|
|
|
|
UA_UInt32_decodeBinary(msg, pos, &secureChannelId);
|
|
UA_UInt32_decodeBinary(msg, pos, &secureChannelId);
|
|
|
|
|
|
//FIXME: we assume SAS, need to check if AAS or SAS
|
|
//FIXME: we assume SAS, need to check if AAS or SAS
|
|
@@ -433,13 +356,9 @@ UA_Int32 SL_Process(const UA_ByteString* msg,
|
|
UA_SymmetricAlgorithmSecurityHeader_decodeBinary(msg, pos,
|
|
UA_SymmetricAlgorithmSecurityHeader_decodeBinary(msg, pos,
|
|
&symAlgSecHeader);
|
|
&symAlgSecHeader);
|
|
|
|
|
|
- if (SL_ChannelManager_getChannel(secureChannelId,
|
|
|
|
- &channel) == UA_SUCCESS)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
|
|
+ if (SL_ChannelManager_getChannel(secureChannelId, &channel) == UA_SUCCESS) {
|
|
SL_Channel_getChannelId(channel, &foundChannelId);
|
|
SL_Channel_getChannelId(channel, &foundChannelId);
|
|
- printf("SL_process - received msg, with channel id: %i \n",
|
|
|
|
- foundChannelId);
|
|
|
|
|
|
+ printf("SL_process - received msg, with channel id: %i \n", foundChannelId);
|
|
|
|
|
|
//sequence number processing
|
|
//sequence number processing
|
|
UA_SequenceHeader_decodeBinary(msg, pos,
|
|
UA_SequenceHeader_decodeBinary(msg, pos,
|
|
@@ -448,11 +367,8 @@ UA_Int32 SL_Process(const UA_ByteString* msg,
|
|
SL_Channel_checkRequestId(channel,sequenceHeader.requestId);
|
|
SL_Channel_checkRequestId(channel,sequenceHeader.requestId);
|
|
//request id processing
|
|
//request id processing
|
|
|
|
|
|
-
|
|
|
|
SL_handleRequest(channel, msg, pos);
|
|
SL_handleRequest(channel, msg, pos);
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ } else {
|
|
printf("SL_process - ERROR could not find channel with id: %i \n",
|
|
printf("SL_process - ERROR could not find channel with id: %i \n",
|
|
secureChannelId);
|
|
secureChannelId);
|
|
//TODO generate ERROR_Bad_SecureChannelUnkown
|
|
//TODO generate ERROR_Bad_SecureChannelUnkown
|