Browse Source

changed service signature

FlorianPalm 10 years ago
parent
commit
f629701261

+ 1 - 1
src/Makefile.am

@@ -20,7 +20,7 @@ libopen62541_la_SOURCES = opcua.c \
 			ua_application.c \
 			ua_xml.c\
 			ua_stack_session.c\
-			ua_stack_sessionManager.c\
+			ua_stack_session_manager.c\
 			ua_stack_channel.c \
 			ua_stack_channel_manager.c \
 			ua_transport_connection_manager.c \

+ 11 - 11
src/ua_services.h

@@ -10,7 +10,7 @@
 #include "opcua.h"
 #include "ua_application.h"
 #include "ua_transport_binary_secure.h"
-
+#include "ua_stack_session.h"
 /**
  * @defgroup services Services
  *
@@ -34,7 +34,7 @@
  * the configuration information required to establish a SecureChannel and a
  * Session.
  */
-UA_Int32 Service_GetEndpoints(const UA_GetEndpointsRequest* request, UA_GetEndpointsResponse *response);
+UA_Int32 Service_GetEndpoints(UA_Session session, const UA_GetEndpointsRequest* request, UA_GetEndpointsResponse *response);
 // Service_RegisterServer
 /** @} */
 
@@ -58,7 +58,7 @@ UA_Int32 Service_OpenSecureChannel(SL_secureChannel channel,const UA_OpenSecureC
 /**
  * @brief This Service is used to terminate a SecureChannel.
  */
-UA_Int32 Service_CloseSecureChannel(const UA_CloseSecureChannelRequest *request, UA_CloseSecureChannelResponse *response);
+UA_Int32 Service_CloseSecureChannel(UA_Session session, const UA_CloseSecureChannelRequest *request, UA_CloseSecureChannelResponse *response);
 /** @} */
 
 /**
@@ -77,7 +77,7 @@ UA_Int32 Service_CloseSecureChannel(const UA_CloseSecureChannelRequest *request,
  * logs and in the Server’s address space. The second is the authenticationToken
  * which is used to associate an incoming request with a Session.
  */
-UA_Int32 Service_CreateSession(const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response);
+UA_Int32 Service_CreateSession(UA_Session session, const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response);
 
 /**
  * @brief This Service is used by the Client to submit its SoftwareCertificates
@@ -86,12 +86,12 @@ UA_Int32 Service_CreateSession(const UA_CreateSessionRequest *request, UA_Create
  * Client before it issues any other Service request after CreateSession.
  * Failure to do so shall cause the Server to close the Session.
  */
-UA_Int32 Service_ActivateSession(const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response);
+UA_Int32 Service_ActivateSession(UA_Session session, const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response);
 
 /**
  * @brief This Service is used to terminate a Session.
  */
-UA_Int32 Service_CloseSession(const UA_CloseSessionRequest *request, UA_CloseSessionResponse *response);
+UA_Int32 Service_CloseSession(UA_Session session, const UA_CloseSessionRequest *request, UA_CloseSessionResponse *response);
 // Service_Cancel
 /** @} */
 
@@ -108,7 +108,7 @@ UA_Int32 Service_CloseSession(const UA_CloseSessionRequest *request, UA_CloseSes
 /**
  * @brief This Service is used to add one or more Nodes into the AddressSpace hierarchy.
  */
-UA_Int32 Service_AddNodes( const UA_AddNodesRequest *request, UA_AddNodesResponse *response);
+UA_Int32 Service_AddNodes(UA_Session session, const UA_AddNodesRequest *request, UA_AddNodesResponse *response);
 // Service_AddReferences
 // Service_DeleteNodes
 // Service_DeleteReferences
@@ -128,12 +128,12 @@ UA_Int32 Service_AddNodes( const UA_AddNodesRequest *request, UA_AddNodesRespons
  * The browse can be further limited by the use of a View. This Browse Service
  * also supports a primitive filtering capability.
  */ 
-UA_Int32 Service_Browse( const UA_BrowseRequest *request, UA_BrowseResponse *response);
+UA_Int32 Service_Browse(UA_Session session, const UA_BrowseRequest *request, UA_BrowseResponse *response);
 
 /**
  * @brief This Service is used to translate textual node paths to their respective ids.
  */
-UA_Int32 Service_TranslateBrowsePathsToNodeIds( const UA_TranslateBrowsePathsToNodeIdsRequest *request, UA_TranslateBrowsePathsToNodeIdsResponse *response);
+UA_Int32 Service_TranslateBrowsePathsToNodeIds(UA_Session session,  const UA_TranslateBrowsePathsToNodeIdsRequest *request, UA_TranslateBrowsePathsToNodeIdsResponse *response);
 // Service_BrowseNext
 // Service_TranslateBrowsePathsToNodeIds
 // Service_RegisterNodes
@@ -176,7 +176,7 @@ UA_Int32 Service_TranslateBrowsePathsToNodeIds( const UA_TranslateBrowsePathsToN
  * values as a composite, to read individual elements or to read ranges of
  * elements of the composite.
  */
-UA_Int32 Service_Read(const UA_ReadRequest *request, UA_ReadResponse *response);
+UA_Int32 Service_Read(UA_Session session, const UA_ReadRequest *request, UA_ReadResponse *response);
 // Service_HistoryRead
 // Service_Write
 // Service_HistoryUpdate
@@ -210,7 +210,7 @@ a component of an Object.
  * triggered item links to be deleted, but has no effect on the MonitoredItems
  * referenced by the triggered items.
  */
-UA_Int32 Service_CreateMonitoredItems(const UA_CreateMonitoredItemsRequest *request, UA_CreateMonitoredItemsResponse *response);
+UA_Int32 Service_CreateMonitoredItems(UA_Session session, const UA_CreateMonitoredItemsRequest *request, UA_CreateMonitoredItemsResponse *response);
 // Service_ModifyMonitoredItems
 // Service_SetMonitoringMode
 // Service_SetTriggering

+ 1 - 1
src/ua_services_attribute.c

@@ -185,7 +185,7 @@ static UA_DataValue *service_read_node(Application * app, const UA_ReadValueId *
 	return v;
 }
 
-UA_Int32 Service_Read(const UA_ReadRequest * request, UA_ReadResponse * response) {
+UA_Int32 Service_Read(UA_Session session, const UA_ReadRequest * request, UA_ReadResponse * response) {
 //TODO GET SESSION HERE//if(channel->session == UA_NULL || channel->session->application == UA_NULL)
 	//	return UA_ERROR;	// TODO: Return error message
 

+ 1 - 1
src/ua_services_discovery.c

@@ -1,5 +1,5 @@
 #include "ua_services.h"
-UA_Int32 Service_GetEndpoints(const UA_GetEndpointsRequest* request, UA_GetEndpointsResponse *response) {
+UA_Int32 Service_GetEndpoints(UA_Session session, const UA_GetEndpointsRequest* request, UA_GetEndpointsResponse *response) {
 	UA_String_printx("endpointUrl=", &request->endpointUrl);
 	response->endpointsSize = 1;
 	UA_Array_new((void***) &response->endpoints,response->endpointsSize,UA_ENDPOINTDESCRIPTION);

+ 1 - 1
src/ua_services_monitoreditems.c

@@ -3,7 +3,7 @@
 #if 0
 /* Activate once the infrastructure for pushing events is in place. */
 
-UA_Int32 Service_CreateMonitoredItems(SL_Channel *channel, const UA_CreateMonitoredItemsRequest *request, UA_CreateMonitoredItemsResponse *response) {
+UA_Int32 Service_CreateMonitoredItems(UA_Session session, const UA_CreateMonitoredItemsRequest *request, UA_CreateMonitoredItemsResponse *response) {
 	if (request->itemsToCreateSize > 0) {
 		response->resultsSize = request->itemsToCreateSize;
 		UA_Array_new((void**)&(response->results),response->resultsSize,UA_MONITOREDITEMCREATERESULT);

+ 1 - 1
src/ua_services_nodemanagement.c

@@ -66,7 +66,7 @@ static UA_AddNodesResult * addSingleNode(Application *app, UA_AddNodesItem *item
 	return result;
 }
 
-UA_Int32 Service_AddNodes(const UA_AddNodesRequest *request, UA_AddNodesResponse *response) {
+UA_Int32 Service_AddNodes(UA_Session session, const UA_AddNodesRequest *request, UA_AddNodesResponse *response) {
 //TODO GET SESSION HERE	if(channel->session == UA_NULL || channel->session->application == UA_NULL)
 //		return UA_ERROR;	// TODO: Return error message
 

+ 1 - 1
src/ua_services_securechannel.c

@@ -18,7 +18,7 @@ UA_Int32 Service_OpenSecureChannel(SL_secureChannel channel,
 	return retval;
 }
 
-UA_Int32 Service_CloseSecureChannel(const UA_CloseSecureChannelRequest *request,
+UA_Int32 Service_CloseSecureChannel(UA_Session session, const UA_CloseSecureChannelRequest *request,
 		UA_CloseSecureChannelResponse *response)
 {
 	UA_Int32 retval = UA_SUCCESS;

+ 3 - 3
src/ua_services_session.c

@@ -6,7 +6,7 @@ Session sessionMockup = {
 		&appMockup
 };
 
-UA_Int32 Service_CreateSession(const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response) {
+UA_Int32 Service_CreateSession(UA_Session session, const UA_CreateSessionRequest *request, UA_CreateSessionResponse *response) {
 	UA_String_printf("CreateSession Service - endpointUrl=", &(request->endpointUrl));
 	// FIXME: create session
 
@@ -16,7 +16,7 @@ UA_Int32 Service_CreateSession(const UA_CreateSessionRequest *request, UA_Create
 	return UA_SUCCESS;
 }
 
-UA_Int32 Service_ActivateSession(const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response) {
+UA_Int32 Service_ActivateSession(UA_Session session, const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response) {
 	// FIXME: activate session
 	UA_NodeId_printf("ActivateSession - authToken=", &(request->requestHeader.authenticationToken));
 	// 321 == AnonymousIdentityToken_Encoding_DefaultBinary
@@ -28,7 +28,7 @@ UA_Int32 Service_ActivateSession(const UA_ActivateSessionRequest *request, UA_Ac
 	return UA_SUCCESS;
 }
 
-UA_Int32 Service_CloseSession(const UA_CloseSessionRequest *request, UA_CloseSessionResponse *response) {
+UA_Int32 Service_CloseSession(UA_Session session, const UA_CloseSessionRequest *request, UA_CloseSessionResponse *response) {
 	//FIXME channel->session = UA_NULL;
 	// FIXME: set response
 	return UA_SUCCESS;

+ 2 - 2
src/ua_services_view.c

@@ -1,7 +1,7 @@
 #include "ua_services.h"
 #include "ua_statuscodes.h"
 
-UA_Int32 Service_Browse(const UA_BrowseRequest *request, UA_BrowseResponse *response) {
+UA_Int32 Service_Browse(UA_Session session, const UA_BrowseRequest *request, UA_BrowseResponse *response) {
 	UA_Int32 retval = UA_SUCCESS;
 	DBG_VERBOSE(UA_NodeId_printf("BrowseService - view=",&(request->view.viewId)));
 	UA_Int32 i = 0;
@@ -11,7 +11,7 @@ UA_Int32 Service_Browse(const UA_BrowseRequest *request, UA_BrowseResponse *resp
 	return retval;
 }
 
-UA_Int32 Service_TranslateBrowsePathsToNodeIds(const UA_TranslateBrowsePathsToNodeIdsRequest *request, UA_TranslateBrowsePathsToNodeIdsResponse *response)
+UA_Int32 Service_TranslateBrowsePathsToNodeIds(UA_Session session, const UA_TranslateBrowsePathsToNodeIdsRequest *request, UA_TranslateBrowsePathsToNodeIdsResponse *response)
 {
 	UA_Int32 retval = UA_SUCCESS;
 

+ 3 - 1
src/ua_stack_session.c

@@ -22,7 +22,9 @@ UA_Boolean UA_Session_compare(UA_Session session1, UA_Session session2)
 {
 	if(session1 && session2)
 	{
-		return (UA_Guid_compare(((UA_SessionType*)session1)->sessionId.identifier,((UA_SessionType*)session2)->sessionId.identifier) == 0);
+
+		return UA_NodeId_compare(&((UA_SessionType*)session1)->sessionId,
+				&((UA_SessionType*)session2)->sessionId) == 0;
 	}
 	return UA_FALSE;
 }

+ 2 - 1
src/ua_stack_session.h

@@ -11,7 +11,7 @@
 #include "../include/opcua.h"
 #include "ua_stack_channel.h"
 
-#endif /* UA_STACK_SESSION_H_ */
+
 
 
 typedef struct UA_SessionType *UA_Session;
@@ -22,3 +22,4 @@ UA_Int32 UA_Session_getId(UA_Session session, UA_NodeId *sessionId);
 UA_Int32 UA_Session_getChannel(UA_Session session, SL_secureChannel *channel);
 
 UA_Int32 UA_Session_new(UA_Session *newSession);
+#endif /* UA_STACK_SESSION_H_ */

+ 1 - 2
src/ua_stack_session_manager.c

@@ -43,8 +43,7 @@ UA_Boolean UA_SessionManager_sessionExists(UA_Session *session)
 
 UA_Int32 UA_SessionManager_getSessionById(UA_NodeId *sessionId, UA_Session *session)
 {
-	UA_UInt32 tmpSessionId;
- 	UA_list_Element* current = sessionManager->sessions.first;
+ 	UA_list_Element* current = sessionManager->sessions->first;
 	while (current)
 	{
 		if (current->payload)

+ 1 - 1
src/ua_stack_session_manager.h

@@ -47,7 +47,7 @@ UA_Int32 UA_SessionManager_removeSession(UA_Int32 sessionId);
  * @param session the session object is returned if no error occurs
  * @return error code if all goes well UA_SUCCESS is returned
  */
-UA_Int32 UA_SessionManager_getSessionById(UA_NodeId sessionId, UA_Session *session);
+UA_Int32 UA_SessionManager_getSessionById(UA_NodeId *sessionId, UA_Session *session);
 
 /**
  * @brief

+ 3 - 2
src/ua_transport_binary_secure.c

@@ -137,12 +137,13 @@ static void init_response_header(UA_RequestHeader const * p,
 #define INVOKE_SERVICE(TYPE) \
 	UA_##TYPE##Request p; \
 	UA_##TYPE##Response r; \
-	UA_NodeId authenticationToken; \
+	UA_Session *session = UA_NULL; \
 	UA_##TYPE##Request_decodeBinary(msg, pos, &p); \
 	UA_##TYPE##Response_init(&r); \
 	init_response_header(&p.requestHeader, &r.responseHeader); \
+	UA_SessionManager_getSessionByToken(&p.requestHeader.authenticationToken, session); \
 	DBG_VERBOSE(printf("Invoke Service: %s\n", #TYPE)); \
-	Service_##TYPE(&p, &r); \
+	Service_##TYPE(*session, &p, &r); \
 	DBG_VERBOSE(printf("Finished Service: %s\n", #TYPE)); \
     *pos = 0; \
 	UA_ByteString_newMembers(&response_msg, UA_##TYPE##Response_calcSize(&r)); \