|
@@ -219,9 +219,13 @@ getServicePointers(UA_UInt32 requestTypeId, const UA_DataType **requestType,
|
|
|
|
|
|
|
|
|
|
|
|
-static void processHEL(UA_Connection *connection, const UA_ByteString *msg, size_t *offset) {
|
|
|
+static void
|
|
|
+processHEL(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg, size_t *offset) {
|
|
|
UA_TcpHelloMessage helloMessage;
|
|
|
if(UA_TcpHelloMessage_decodeBinary(msg, offset, &helloMessage) != UA_STATUSCODE_GOOD) {
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Could not decode the HEL message. Closing the connection.",
|
|
|
+ connection->sockfd);
|
|
|
connection->close(connection);
|
|
|
return;
|
|
|
}
|
|
@@ -299,6 +303,9 @@ processOPN(UA_Server *server, UA_Connection *connection,
|
|
|
UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(&asymHeader);
|
|
|
UA_NodeId_deleteMembers(&requestType);
|
|
|
UA_OpenSecureChannelRequest_deleteMembers(&r);
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Could not decode the OPN message. Closing the connection.",
|
|
|
+ connection->sockfd);
|
|
|
connection->close(connection);
|
|
|
return;
|
|
|
}
|
|
@@ -314,6 +321,9 @@ processOPN(UA_Server *server, UA_Connection *connection,
|
|
|
if(!channel) {
|
|
|
UA_OpenSecureChannelResponse_deleteMembers(&p);
|
|
|
UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(&asymHeader);
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Could not open a SecureChannel. "
|
|
|
+ "Closing the connection.", connection->sockfd);
|
|
|
connection->close(connection);
|
|
|
return;
|
|
|
}
|
|
@@ -328,6 +338,9 @@ processOPN(UA_Server *server, UA_Connection *connection,
|
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
|
UA_OpenSecureChannelResponse_deleteMembers(&p);
|
|
|
UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(&asymHeader);
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Could not obtain a buffer to answer the OPN message. "
|
|
|
+ "Closing the connection.", connection->sockfd);
|
|
|
connection->close(connection);
|
|
|
return;
|
|
|
}
|
|
@@ -343,6 +356,9 @@ processOPN(UA_Server *server, UA_Connection *connection,
|
|
|
retval |= UA_OpenSecureChannelResponse_encodeBinary(&p, &bufPos, &bufEnd);
|
|
|
|
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Could not encode the OPN message. "
|
|
|
+ "Closing the connection.", connection->sockfd);
|
|
|
connection->releaseSendBuffer(connection, &resp_msg);
|
|
|
UA_OpenSecureChannelResponse_deleteMembers(&p);
|
|
|
UA_AsymmetricAlgorithmSecurityHeader_deleteMembers(&asymHeader);
|
|
@@ -537,13 +553,17 @@ processMSG(UA_Server *server, UA_SecureChannel *channel,
|
|
|
static void processERR(UA_Server *server, UA_Connection *connection, const UA_ByteString *msg, size_t *offset) {
|
|
|
UA_TcpErrorMessage errorMessage;
|
|
|
if (UA_TcpErrorMessage_decodeBinary(msg, offset, &errorMessage) != UA_STATUSCODE_GOOD) {
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Could not decide the ERR message. "
|
|
|
+ "Closing the connection.", connection->sockfd);
|
|
|
connection->close(connection);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
UA_LOG_ERROR(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
- "Client replied with an error message: %s %.*s",
|
|
|
- UA_StatusCode_name(errorMessage.error), errorMessage.reason.length, errorMessage.reason.data);
|
|
|
+ "Connection %i | Client replied with an error message: %s %.*s",
|
|
|
+ connection->sockfd, UA_StatusCode_name(errorMessage.error),
|
|
|
+ errorMessage.reason.length, errorMessage.reason.data);
|
|
|
|
|
|
UA_TcpErrorMessage_deleteMembers(&errorMessage);
|
|
|
}
|
|
@@ -599,9 +619,13 @@ processBinaryMessage(UA_Server *server, UA_Connection *connection,
|
|
|
connection->releaseRecvBuffer(connection, message);
|
|
|
else
|
|
|
UA_ByteString_deleteMembers(message);
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Failed to complete a chunk. "
|
|
|
+ "Closing the connection.", connection->sockfd);
|
|
|
+ connection->close(connection);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
UA_SecureChannel *channel = connection->channel;
|
|
|
if(channel) {
|
|
|
|
|
@@ -616,6 +640,9 @@ processBinaryMessage(UA_Server *server, UA_Connection *connection,
|
|
|
UA_TcpMessageHeader tcpMessageHeader;
|
|
|
retval = UA_TcpMessageHeader_decodeBinary(message, &offset, &tcpMessageHeader);
|
|
|
if(retval != UA_STATUSCODE_GOOD) {
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Could not decode the TCP message header. "
|
|
|
+ "Closing the connection.", connection->sockfd);
|
|
|
connection->close(connection);
|
|
|
return;
|
|
|
}
|
|
@@ -630,15 +657,20 @@ processBinaryMessage(UA_Server *server, UA_Connection *connection,
|
|
|
case UA_MESSAGETYPE_HEL:
|
|
|
UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
"Connection %i | Process HEL message", connection->sockfd);
|
|
|
- processHEL(connection, message, &offset);
|
|
|
+ processHEL(server, connection, message, &offset);
|
|
|
break;
|
|
|
case UA_MESSAGETYPE_OPN: {
|
|
|
UA_LOG_TRACE(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
"Connection %i | Process OPN message", connection->sockfd);
|
|
|
UA_UInt32 channelId = 0;
|
|
|
retval = UA_UInt32_decodeBinary(message, &offset, &channelId);
|
|
|
- if(retval != UA_STATUSCODE_GOOD)
|
|
|
+ if(retval != UA_STATUSCODE_GOOD) {
|
|
|
+ UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
|
|
|
+ "Connection %i | Could not decode the channel ID for an OPN call. "
|
|
|
+ "Closing the connection.", connection->sockfd);
|
|
|
connection->close(connection);
|
|
|
+ break;
|
|
|
+ }
|
|
|
UA_ByteString offsetMessage;
|
|
|
offsetMessage.data = message->data + 12;
|
|
|
offsetMessage.length = message->length - 12;
|