Pārlūkot izejas kodu

free,alloc memory

FlorianPalm 11 gadi atpakaļ
vecāks
revīzija
ebbdf1921c

+ 4 - 4
OPCUAServer/src/opcua_connectionHelper.h

@@ -26,7 +26,7 @@ enum connectionState
 	connectionState_ESTABLISHED,
 
 };
-typedef struct buffer_t
+typedef struct
 {
 	UInt32 recvBufferSize;
 	UInt32 sendBufferSize;
@@ -40,8 +40,8 @@ struct TL_connection
 {
 	Int32 socket;
 	UInt32 connectionState;
-	TL_buffer clientConf;
-	TL_buffer serverConf;
+	TL_buffer remoteConf;
+	TL_buffer localConf;
 	UA_String endpointURL;
 };
 
@@ -67,7 +67,7 @@ struct SS_connection
 
 };
 
-typedef struct UA_connection_t
+typedef struct
 {
 	struct TL_connection transportLayer;
 	struct SL_connection secureLayer;

+ 2 - 2
OPCUAServer/src/opcua_memory.c

@@ -8,11 +8,11 @@
 
 void *opcua_malloc(size_t size)
 {
-	malloc(size);
+	return malloc(size);
 }
 
 
-void free(void *pointer)
+void opcua_free(void *pointer)
 {
 	free(pointer);
 }

+ 1 - 1
OPCUAServer/src/opcua_secureChannelLayer.c

@@ -42,7 +42,7 @@ Int32 SL_secureChannel_ResponseHeader_form(UA_connection *connection, T_Response
  */
 Int32 SL_secureChannel_Response_form(UA_connection *connection, SL_Response *response)
 {
-	response->ServerProtocolVersion = 0; //TODO must be set
+	response->ServerProtocolVersion = connection->transportLayer//TODO must be set
 	response->SecurityToken.ChannelId = connection->secureLayer.UInt32_secureChannelId;
 	response->SecurityToken.CreatedAt = connection->secureLayer.requestedAt;
 	response->SecurityToken.TokenId = connection->secureLayer.tokenId; //TODO  must be generated;

+ 20 - 20
OPCUAServer/src/opcua_transportLayer.c

@@ -14,7 +14,7 @@ void TL_sendACK(UA_connection *connection)
 	//get memory for message
 	//
 	//build message
-	//connection->transportLayer.serverConf.maxChunkCount;
+	//connection->transportLayer.localConf.maxChunkCount;
 
 	//call send function
 
@@ -31,16 +31,16 @@ void TL_open(UA_connection *connection, AD_RawMessage *rawMessage)
 		{
 			//process the connection values received by the client
 			TL_processHELMessage(&tmpConnection,rawMessage);
-			connection->transportLayer.serverConf.protocolVersion = TL_SERVER_PROTOCOL_VERSION;
+			connection->transportLayer.localConf.protocolVersion = TL_SERVER_PROTOCOL_VERSION;
 
-			connection->transportLayer.serverConf.recvBufferSize =
-					tmpConnection.transportLayer.serverConf.recvBufferSize;
+			connection->transportLayer.localConf.recvBufferSize =
+					tmpConnection.transportLayer.localConf.recvBufferSize;
 
-			connection->transportLayer.serverConf.sendBufferSize =
-					tmpConnection.transportLayer.serverConf.sendBufferSize;
+			connection->transportLayer.localConf.sendBufferSize =
+					tmpConnection.transportLayer.localConf.sendBufferSize;
 
-			connection->transportLayer.serverConf.maxMessageSize = TL_SERVER_MAX_MESSAGE_SIZE;
-			connection->transportLayer.serverConf.maxChunkCount = TL_SERVER_MAX_CHUNK_COUNT;
+			connection->transportLayer.localConf.maxMessageSize = TL_SERVER_MAX_MESSAGE_SIZE;
+			connection->transportLayer.localConf.maxChunkCount = TL_SERVER_MAX_CHUNK_COUNT;
 
 		    TL_sendACK(connection);
 			connection->transportLayer.connectionState = connectionState_ESTABLISHED;
@@ -66,7 +66,7 @@ Int32 TL_checkMessage(UA_connection *connection, AD_RawMessage *TL_messsage)
 
 	Int32 messageLen = decodeUInt32(TL_messsage->message, &position);
 	if (messageLen == TL_messsage->length &&
-		messageLen < (connection->transportLayer.serverConf.maxMessageSize))
+		messageLen < (connection->transportLayer.localConf.maxMessageSize))
 	{
 		return 1;
 	}
@@ -74,7 +74,7 @@ Int32 TL_checkMessage(UA_connection *connection, AD_RawMessage *TL_messsage)
 }
 void TL_receive(UA_connection *connection, AD_RawMessage *TL_message)
 {
-	UInt32 bufferSize = connection->transportLayer.serverConf.recvBufferSize = 8192;
+	UInt32 bufferSize = connection->transportLayer.localConf.recvBufferSize = 8192;
 	UInt32 length = 0;
 
 	AD_RawMessage tmpRawMessage;
@@ -252,11 +252,11 @@ void TL_processHELMessage_test()
 
 	TL_processHELMessage(&con, &rawMessage);
 
-	if(con.transportLayer.clientConf.protocolVersion == 0 &&
-	   con.transportLayer.clientConf.recvBufferSize == 65536 &&
-	   con.transportLayer.clientConf.sendBufferSize == 65536 &&
-	   con.transportLayer.clientConf.maxMessageSize == 16777216 &&
-	   con.transportLayer.clientConf.maxChunkCount == 5000)
+	if(con.transportLayer.remoteConf.protocolVersion == 0 &&
+	   con.transportLayer.remoteConf.recvBufferSize == 65536 &&
+	   con.transportLayer.remoteConf.sendBufferSize == 65536 &&
+	   con.transportLayer.remoteConf.maxMessageSize == 16777216 &&
+	   con.transportLayer.remoteConf.maxChunkCount == 5000)
 	{
 		printf(" - passed \n");
 	}
@@ -277,22 +277,22 @@ void TL_processHELMessage(UA_connection *connection, AD_RawMessage *rawMessage)
 	UInt32 pos = TL_HEADER_LENGTH;
 	struct TL_header tmpHeader;
 
-	connection->transportLayer.clientConf.protocolVersion =
+	connection->transportLayer.remoteConf.protocolVersion =
 			decodeUInt32(rawMessage->message,&pos);
 	pos = pos + sizeof(UInt32);
 
-	connection->transportLayer.clientConf.recvBufferSize =
+	connection->transportLayer.remoteConf.recvBufferSize =
 			decodeUInt32(rawMessage->message,&pos);
 	pos = pos +  sizeof(UInt32);
 
-	connection->transportLayer.clientConf.sendBufferSize =
+	connection->transportLayer.remoteConf.sendBufferSize =
 			decodeUInt32(rawMessage->message,&pos);
 	pos = pos +  sizeof(UInt32);
-	connection->transportLayer.clientConf.maxMessageSize =
+	connection->transportLayer.remoteConf.maxMessageSize =
 			decodeUInt32(rawMessage->message,&pos);
 	pos = pos +  sizeof(UInt32);
 
-	connection->transportLayer.clientConf.maxChunkCount =
+	connection->transportLayer.remoteConf.maxChunkCount =
 			decodeUInt32(rawMessage->message,&pos);
 	pos = pos +  sizeof(UInt32);