Przeglądaj źródła

Session without UA-prefix

Julius Pfrommer 11 lat temu
rodzic
commit
ae8491f991

+ 2 - 2
src/ua_application.h

@@ -5,9 +5,9 @@
 #include "ua_namespace.h"
 #include "ua_indexedList.h"
 
-typedef struct UA_Application_T {
+typedef struct Application_T {
 	UA_ApplicationDescription *description;
 	UA_indexedList_List *namespaces; // each entry is a namespace
-} UA_Application;
+} Application;
 
 #endif

+ 3 - 3
src/ua_services_attribute.c

@@ -26,7 +26,7 @@ enum UA_AttributeId {
 	UA_ATTRIBUTEID_USEREXECUTABLE = 22
 };
 
-static UA_DataValue * service_read_node(UA_Application *app, const UA_ReadValueId *id) {
+static UA_DataValue * service_read_node(Application *app, const UA_ReadValueId *id) {
 	UA_DataValue *v;
 	UA_alloc((void **) &v, sizeof(UA_DataValue));
 	
@@ -152,13 +152,13 @@ static UA_DataValue * service_read_node(UA_Application *app, const UA_ReadValueI
 }
 
 UA_Int32 Service_Read(SL_Channel *channel, const UA_ReadRequest *request, UA_ReadResponse *response ) {
-	if(channel->application == UA_NULL) return UA_ERROR; // TODO: Return error message
+	if(channel->session == UA_NULL || channel->session->application == UA_NULL) return UA_ERROR; // TODO: Return error message
 
 	int readsize = request->nodesToReadSize > 0 ? request->nodesToReadSize : 0;
 	response->resultsSize = readsize;
 	UA_alloc((void **)&response->results, sizeof(void *)*readsize);
 	for(int i=0;i<readsize;i++) {
-		response->results[i] = service_read_node(channel->application, request->nodesToRead[i]);
+		response->results[i] = service_read_node(channel->session->application, request->nodesToRead[i]);
 	}
 	response->diagnosticInfosSize = -1;
 	return UA_SUCCESS;

+ 1 - 1
src/ua_transport.c

@@ -23,7 +23,7 @@ UA_Int32 UA_MessageType_encodeBinary(UA_MessageType const * src, UA_Int32* pos,
 UA_Int32 UA_MessageType_decodeBinary(UA_ByteString const * src, UA_Int32* pos, UA_MessageType* dst){
 	UA_Int32 retval = UA_SUCCESS;
 	UA_Byte tmpBuf[3];
-	retval |= UA_Byte_decodeBinary(src,pos,&(tmpBuf[0]));//messageType to Byte representation
+	retval |= UA_Byte_decodeBinary(src,pos,&(tmpBuf[0])); //messageType to Byte representation
 	retval |= UA_Byte_decodeBinary(src,pos,&(tmpBuf[1]));
 	retval |= UA_Byte_decodeBinary(src,pos,&(tmpBuf[2]));
 	*dst = (UA_MessageType)((UA_Int32)(tmpBuf[0]<<16) + (UA_Int32)(tmpBuf[1]<<8) + (UA_Int32)(tmpBuf[2]));

+ 4 - 13
src/ua_transport.h

@@ -1,8 +1,8 @@
 #ifndef OPCUA_STACKINTERNALTYPES_H_
 #define OPCUA_STACKINTERNALTYPES_H_
 
-#include "ua_application.h"
 #include "opcua.h"
+#include "ua_application.h"
 
 static const UA_Int32 SL_HEADER_LENGTH = 0;
 
@@ -14,11 +14,10 @@ enum connectionState {
 };
 
 typedef struct Session_T {
-	UA_Int32 dummy;
-	UA_Application *application;
-} UA_Session;
+	UA_Int32 sessionId;
+	Application *application;
+} Session;
 
-/* Enums */
 typedef enum {
 	UA_SECURITYTOKEN_ISSUE = 0,
 	UA_SECURITYTOKEN_RENEW = 1
@@ -30,14 +29,6 @@ typedef enum {
 	UA_SECURITYMODE_SIGNANDENCRYPT = 2
 } SecurityMode;
 
-/* Structures */
-typedef struct SL_Response_T {
-	UA_UInt32 serverProtocolVersion;
-	UA_ChannelSecurityToken securityToken;
-	UA_String serverNonce;
-} SL_Response;
-UA_TYPE_METHOD_PROTOTYPES(SL_Response)
-
 /* MessageType */
 typedef UA_Int32 UA_MessageType;
 enum UA_MessageType

+ 1 - 4
src/ua_transport_binary_secure.h

@@ -4,7 +4,6 @@
 #include "ua_transport.h"
 #include "ua_transport_binary.h"
 #include "ua_transport_binary_secure.h"
-#include "ua_application.h"
 
 typedef struct {
 	UA_UInt32 secureChannelId;
@@ -16,7 +15,7 @@ typedef struct {
 typedef struct SL_Channel_T {
 	UA_String secureChannelId;
 	TL_connection* tlConnection;
-	UA_Session *session; // equals UA_Null iff no session is active
+	Session *session; // equals UA_Null iff no session is active
 	UA_AsymmetricAlgorithmSecurityHeader remoteAsymAlgSettings;
 	UA_AsymmetricAlgorithmSecurityHeader localAsymAlgSettings;
 	UA_SequenceHeader sequenceHeader;
@@ -25,8 +24,6 @@ typedef struct SL_Channel_T {
 	UA_ByteString localNonce;
 	UA_UInt32 connectionState;
 	SL_ChannelSecurityToken securityToken;
-
-	UA_Application *application;
 } SL_Channel;
 
 UA_Int32 SL_initConnectionObject(SL_Channel *connection);