浏览代码

minor bugfixes in use of ptrs and struct-definitions

Leon Urbas 11 年之前
父节点
当前提交
dfcf4314fd
共有 5 个文件被更改,包括 15 次插入9 次删除
  1. 3 0
      include/opcua_basictypes.h
  2. 4 3
      src/UA_stackInternalTypes.c
  3. 1 1
      src/UA_stackInternalTypes.h
  4. 2 2
      src/opcua_basictypes.c
  5. 5 3
      src/opcua_secureLayer.c

+ 3 - 0
include/opcua_basictypes.h

@@ -201,6 +201,9 @@ typedef struct T_UA_LocalizedText
 }
 UA_LocalizedText;
 UA_TYPE_METHOD_PROTOTYPES (UA_LocalizedText)
+void UA_ByteString_printf(char* label, UA_ByteString* string);
+void UA_ByteString_printx(char* label, UA_ByteString* string);
+void UA_ByteString_printx_hex(char* label, UA_ByteString* string);
 
 /* GuidType - Part: 6, Chapter: 5.2.2.6 Page: 17 */
 typedef struct T_UA_Guid

+ 4 - 3
src/UA_stackInternalTypes.c

@@ -197,13 +197,14 @@ UA_Int32 UA_SecureConversationMessageHeader_deleteMembers(UA_SecureConversationM
 	return retval;
 }
 
+//TODO: I assume that requestId belongs to the sequence header, not to the AAS. Need to check
 UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_calcSize(UA_AsymmetricAlgorithmSecurityHeader const * ptr) {
 	if(ptr==UA_NULL){return sizeof(UA_AsymmetricAlgorithmSecurityHeader);}
 	return 0
 	 + UA_ByteString_calcSize(&(ptr->securityPolicyUri))
 	 + UA_ByteString_calcSize(&(ptr->senderCertificate))
 	 + UA_ByteString_calcSize(&(ptr->receiverCertificateThumbprint))
-	 + sizeof(UA_UInt32) // requestId
+	 // + sizeof(UA_UInt32) // requestId
 	;
 }
 
@@ -212,7 +213,7 @@ UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_encode(UA_AsymmetricAlgorithmSecur
 	retval |= UA_ByteString_encode(&(src->securityPolicyUri),pos,dst);
 	retval |= UA_ByteString_encode(&(src->senderCertificate),pos,dst);
 	retval |= UA_ByteString_encode(&(src->receiverCertificateThumbprint),pos,dst);
-	retval |= UA_UInt32_encode(&(src->requestId),pos,dst);
+	// retval |= UA_UInt32_encode(&(src->requestId),pos,dst);
 	return retval;
 }
 
@@ -221,7 +222,7 @@ UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_decode(char const * src, UA_Int32*
 	retval |= UA_ByteString_decode(src,pos,&(dst->securityPolicyUri));
 	retval |= UA_ByteString_decode(src,pos,&(dst->senderCertificate));
 	retval |= UA_ByteString_decode(src,pos,&(dst->receiverCertificateThumbprint));
-	retval |= UA_UInt32_decode(src,pos,&(dst->requestId));
+	// retval |= UA_UInt32_decode(src,pos,&(dst->requestId));
 	return retval;
 }
 

+ 1 - 1
src/UA_stackInternalTypes.h

@@ -109,7 +109,7 @@ typedef struct T_UA_AsymmetricAlgorithmSecurityHeader {
 	UA_ByteString securityPolicyUri;
 	UA_ByteString senderCertificate;
 	UA_ByteString receiverCertificateThumbprint;
-	UA_UInt32 requestId;
+	// UA_UInt32 requestId;
 } UA_AsymmetricAlgorithmSecurityHeader;
 UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_calcSize(UA_AsymmetricAlgorithmSecurityHeader const * ptr);
 UA_Int32 UA_AsymmetricAlgorithmSecurityHeader_encode(UA_AsymmetricAlgorithmSecurityHeader const * src, UA_Int32* pos, char* dst);

+ 2 - 2
src/opcua_basictypes.c

@@ -428,10 +428,10 @@ UA_Int32 UA_ByteString_compare(UA_ByteString *string1, UA_ByteString *string2) {
 void UA_ByteString_printf(char* label, UA_ByteString* string) {
 	UA_String_printf(label, (UA_String*) string);
 }
-void UA_ByteString_printx(char* label, UA_String* string) {
+void UA_ByteString_printx(char* label, UA_ByteString* string) {
 	UA_String_printx(label, (UA_String*) string);
 }
-void UA_ByteString_printx_hex(char* label, UA_String* string) {
+void UA_ByteString_printx_hex(char* label, UA_ByteString* string) {
 	UA_String_printx_hex(label, (UA_String*) string);
 }
 

+ 5 - 3
src/opcua_secureLayer.c

@@ -272,7 +272,7 @@ UA_Int32 SL_openSecureChannel(UA_connection *connection,
 	//encode header
 	printf("SL_openSecureChannel - encoding response header \n");
 
-	UA_ResponseHeader_encode(&responseHeader, &pos, &response.data);
+	UA_ResponseHeader_encode(&responseHeader, &pos, response.data);
 	printf("SL_openSecureChannel - response header encoded \n");
 
 	//encode message
@@ -470,7 +470,7 @@ void SL_receive(UA_connection *connection, UA_ByteString *serviceMessage) {
 	UA_SecureConversationMessageHeader secureConvHeader;
 	UA_AsymmetricAlgorithmSecurityHeader asymAlgSecHeader;
 	UA_SequenceHeader sequenceHeader;
-	UA_Int32 packetType = 0;
+	// UA_Int32 packetType = 0;
 	UA_Int32 pos = 0;
 	UA_Int32 iTmp;
 	//TODO Error Handling, length checking
@@ -507,13 +507,14 @@ void SL_receive(UA_connection *connection, UA_ByteString *serviceMessage) {
 				}
 
 			//FIXME: destroy decodeAASHeader (to prevent memleak)
+			// UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(&asymAlgSecHeader);
 			}
 			else
 			{
 				//TODO invalid securechannelId
 			}
 
-			UA_SequenceHeader_decode(&secureChannelPacket.data, &pos, &sequenceHeader);
+			UA_SequenceHeader_decode(secureChannelPacket.data, &pos, &sequenceHeader);
 			printf("SL_receive - SequenceHeader.RequestId=%d\n",
 					sequenceHeader.requestId);
 			printf("SL_receive - SequenceHeader.SequenceNr=%d\n",
@@ -527,6 +528,7 @@ void SL_receive(UA_connection *connection, UA_ByteString *serviceMessage) {
 			//SL_decrypt(&secureChannelPacket);
 			message.data = &secureChannelPacket.data[pos];
 			message.length = secureChannelPacket.length - pos;
+			UA_ByteString_printx("SL_receive - message=",&message);
 
 			SL_processMessage(connection, message);