Browse Source

One ConnectionConfig per connection; Deduplicate HEL/ACK negotiation

Julius Pfrommer 5 years ago
parent
commit
f6eae36ebe

+ 14 - 18
arch/ua_network_tcp.c

@@ -26,7 +26,7 @@
 static UA_StatusCode
 connection_getsendbuffer(UA_Connection *connection,
                          size_t length, UA_ByteString *buf) {
-    if(length > connection->remoteConf.recvBufferSize)
+    if(length > connection->config.sendBufferSize)
         return UA_STATUSCODE_BADCOMMUNICATIONERROR;
     return UA_ByteString_allocBuffer(buf, length);
 }
@@ -111,7 +111,7 @@ connection_recv(UA_Connection *connection, UA_ByteString *response,
     }
 
     response->data = (UA_Byte*)
-        UA_malloc(connection->localConf.recvBufferSize);
+        UA_malloc(connection->config.recvBufferSize);
     if(!response->data) {
         response->length = 0;
         return UA_STATUSCODE_BADOUTOFMEMORY; /* not enough memory retry */
@@ -119,7 +119,7 @@ connection_recv(UA_Connection *connection, UA_ByteString *response,
 
     /* Get the received packet(s) */
     ssize_t ret = UA_recv(connection->sockfd, (char*)response->data,
-                       connection->localConf.recvBufferSize, 0);
+                          connection->config.recvBufferSize, 0);
 
     /* The remote side closed the connection */
     if(ret == 0) {
@@ -159,7 +159,6 @@ typedef struct ConnectionEntry {
 
 typedef struct {
     UA_Logger logger;
-    UA_ConnectionConfig conf;
     UA_UInt16 port;
     UA_SOCKET serverSockets[FD_SETSIZE];
     UA_UInt16 serverSocketsSize;
@@ -183,8 +182,8 @@ ServerNetworkLayerTCP_close(UA_Connection *connection) {
 }
 
 static UA_StatusCode
-ServerNetworkLayerTCP_add(ServerNetworkLayerTCP *layer, UA_Int32 newsockfd,
-                          struct sockaddr_storage *remote) {
+ServerNetworkLayerTCP_add(UA_ServerNetworkLayer *nl, ServerNetworkLayerTCP *layer,
+                          UA_Int32 newsockfd, struct sockaddr_storage *remote) {
     /* Set nonblocking */
     UA_socket_set_nonblocking(newsockfd);//TODO: check return value
 
@@ -213,7 +212,7 @@ ServerNetworkLayerTCP_add(ServerNetworkLayerTCP *layer, UA_Int32 newsockfd,
     } else {
         UA_LOG_SOCKET_ERRNO_WRAP(UA_LOG_WARNING(layer->logger, UA_LOGCATEGORY_NETWORK,
                                                 "Connection %i | New connection over TCP, "
-                                                        "getnameinfo failed with error: %s",
+                                                "getnameinfo failed with error: %s",
                                                 (int)newsockfd, errno_str));
     }
 #else
@@ -232,8 +231,7 @@ ServerNetworkLayerTCP_add(ServerNetworkLayerTCP *layer, UA_Int32 newsockfd,
     memset(c, 0, sizeof(UA_Connection));
     c->sockfd = newsockfd;
     c->handle = layer;
-    c->localConf = layer->conf;
-    c->remoteConf = layer->conf;
+    c->config = nl->localConnectionConfig;
     c->send = connection_write;
     c->close = ServerNetworkLayerTCP_close;
     c->free = ServerNetworkLayerTCP_freeConnection;
@@ -425,7 +423,7 @@ ServerNetworkLayerTCP_listen(UA_ServerNetworkLayer *nl, UA_Server *server,
                     "Connection %i | New TCP connection on server socket %i",
                     (int)newsockfd, layer->serverSockets[i]);
 
-        ServerNetworkLayerTCP_add(layer, (UA_Int32)newsockfd, &remote);
+        ServerNetworkLayerTCP_add(nl, layer, (UA_Int32)newsockfd, &remote);
     }
 
     /* Read from established sockets */
@@ -516,7 +514,7 @@ ServerNetworkLayerTCP_deleteMembers(UA_ServerNetworkLayer *nl) {
 }
 
 UA_ServerNetworkLayer
-UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt16 port, UA_Logger logger) {
+UA_ServerNetworkLayerTCP(UA_ConnectionConfig config, UA_UInt16 port, UA_Logger logger) {
     UA_ServerNetworkLayer nl;
     memset(&nl, 0, sizeof(UA_ServerNetworkLayer));
     ServerNetworkLayerTCP *layer = (ServerNetworkLayerTCP*)
@@ -525,10 +523,10 @@ UA_ServerNetworkLayerTCP(UA_ConnectionConfig conf, UA_UInt16 port, UA_Logger log
         return nl;
 
     layer->logger = (logger != NULL ? logger : UA_Log_Stdout);
-    layer->conf = conf;
     layer->port = port;
 
     nl.handle = layer;
+    nl.localConnectionConfig = config;
     nl.start = ServerNetworkLayerTCP_start;
     nl.listen = ServerNetworkLayerTCP_listen;
     nl.stop = ServerNetworkLayerTCP_stop;
@@ -721,15 +719,14 @@ UA_StatusCode UA_ClientConnectionTCP_poll(UA_Client *client, void *data) {
 
 }
 
-UA_Connection UA_ClientConnectionTCP_init(UA_ConnectionConfig conf,
+UA_Connection UA_ClientConnectionTCP_init(UA_ConnectionConfig config,
 		const char *endpointUrl, const UA_UInt32 timeout,
                 UA_Logger logger) {
     UA_Connection connection;
     memset(&connection, 0, sizeof(UA_Connection));
 
     connection.state = UA_CONNECTION_OPENING;
-    connection.localConf = conf;
-    connection.remoteConf = conf;
+    connection.config = config;
     connection.send = connection_write;
     connection.recv = connection_recv;
     connection.close = ClientNetworkLayerTCP_close;
@@ -781,7 +778,7 @@ UA_Connection UA_ClientConnectionTCP_init(UA_ConnectionConfig conf,
 }
 
 UA_Connection
-UA_ClientConnectionTCP(UA_ConnectionConfig conf,
+UA_ClientConnectionTCP(UA_ConnectionConfig config,
                        const char *endpointUrl, const UA_UInt32 timeout,
                        UA_Logger logger) {
 
@@ -794,8 +791,7 @@ UA_ClientConnectionTCP(UA_ConnectionConfig conf,
     UA_Connection connection;
     memset(&connection, 0, sizeof(UA_Connection));
     connection.state = UA_CONNECTION_CLOSED;
-    connection.localConf = conf;
-    connection.remoteConf = conf;
+    connection.config = config;
     connection.send = connection_write;
     connection.recv = connection_recv;
     connection.close = ClientNetworkLayerTCP_close;

+ 9 - 7
include/ua_plugin_network.h

@@ -42,10 +42,10 @@ typedef struct UA_ServerNetworkLayer UA_ServerNetworkLayer;
 
 typedef struct {
     UA_UInt32 protocolVersion;
-    UA_UInt32 sendBufferSize;
     UA_UInt32 recvBufferSize;
-    UA_UInt32 maxMessageSize;
-    UA_UInt32 maxChunkCount;
+    UA_UInt32 sendBufferSize;
+    UA_UInt32 maxMessageSize; /* Indicated by the remote side (0 = unbounded) */
+    UA_UInt32 maxChunkCount;  /* Indicated by the remote side (0 = unbounded) */
 } UA_ConnectionConfig;
 
 typedef enum {
@@ -60,8 +60,7 @@ typedef enum {
 
 struct UA_Connection {
     UA_ConnectionState state;
-    UA_ConnectionConfig localConf;
-    UA_ConnectionConfig remoteConf;
+    UA_ConnectionConfig config;
     UA_SecureChannel *channel;       /* The securechannel that is attached to
                                       * this connection */
     UA_SOCKET sockfd;                 /* Most connectivity solutions run on
@@ -150,8 +149,11 @@ UA_Server_removeConnection(UA_Server *server, UA_Connection *connection);
 
 struct UA_ServerNetworkLayer {
     void *handle; /* Internal data */
+
     UA_String discoveryUrl;
 
+    UA_ConnectionConfig localConnectionConfig;
+
     /* Start listening on the networklayer.
      *
      * @param nl The network layer
@@ -191,12 +193,12 @@ struct UA_ServerNetworkLayer {
  * The client has only a single connection used for sending and receiving binary
  * messages. */
 
-/* @param localConf the connection config for this client
+/* @param config the connection config for this client
  * @param endpointUrl to where to connect
  * @param timeout in ms until the connection try times out if remote not reachable
  * @param logger the logger to use */
 typedef UA_Connection
-(*UA_ConnectClientConnection)(UA_ConnectionConfig localConf, const char *endpointUrl,
+(*UA_ConnectClientConnection)(UA_ConnectionConfig config, const char *endpointUrl,
                               const UA_UInt32 timeout, UA_Logger logger);
 
 _UA_END_DECLS

+ 7 - 20
src/client/ua_client_connect.c

@@ -75,27 +75,18 @@ processACKResponse(void *application, UA_Connection *connection, UA_ByteString *
         return UA_STATUSCODE_BADTCPMESSAGETYPEINVALID;
     }
 
+    /* Decode the ACK message */
     retval |= UA_TcpAcknowledgeMessage_decodeBinary(chunk, &offset, &ackMessage);
     if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_INFO(client->config.logger, UA_LOGCATEGORY_NETWORK,
                     "Decoding ACK message failed");
         return retval;
     }
-
-    /* Store remote connection settings and adjust local configuration to not
-     * exceed the limits */
     UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_NETWORK, "Received ACK message");
-    connection->remoteConf.maxChunkCount = ackMessage.maxChunkCount; /* may be zero -> unlimited */
-    connection->remoteConf.maxMessageSize = ackMessage.maxMessageSize; /* may be zero -> unlimited */
-    connection->remoteConf.protocolVersion = ackMessage.protocolVersion;
-    connection->remoteConf.sendBufferSize = ackMessage.sendBufferSize;
-    connection->remoteConf.recvBufferSize = ackMessage.receiveBufferSize;
-    if(connection->remoteConf.recvBufferSize < connection->localConf.sendBufferSize)
-        connection->localConf.sendBufferSize = connection->remoteConf.recvBufferSize;
-    if(connection->remoteConf.sendBufferSize < connection->localConf.recvBufferSize)
-        connection->localConf.recvBufferSize = connection->remoteConf.sendBufferSize;
-    connection->state = UA_CONNECTION_ESTABLISHED;
-    return UA_STATUSCODE_GOOD;
+
+    /* Process the ACK message */
+    return UA_Connection_processHELACK(connection, &client->config.localConnectionConfig,
+                                       (const UA_ConnectionConfig*)&ackMessage);
 }
 
 static UA_StatusCode
@@ -110,11 +101,7 @@ HelAckHandshake(UA_Client *client) {
     /* Prepare the HEL message and encode at offset 8 */
     UA_TcpHelloMessage hello;
     UA_String_copy(&client->endpointUrl, &hello.endpointUrl); /* must be less than 4096 bytes */
-    hello.maxChunkCount = conn->localConf.maxChunkCount;
-    hello.maxMessageSize = conn->localConf.maxMessageSize;
-    hello.protocolVersion = conn->localConf.protocolVersion;
-    hello.receiveBufferSize = conn->localConf.recvBufferSize;
-    hello.sendBufferSize = conn->localConf.sendBufferSize;
+    memcpy(&hello, &client->config.localConnectionConfig, sizeof(UA_ConnectionConfig)); /* same struct layout */
 
     UA_Byte *bufPos = &message.data[8]; /* skip the header */
     const UA_Byte *bufEnd = &message.data[message.length];
@@ -604,7 +591,7 @@ UA_Client_connectInternal(UA_Client *client, const char *endpointUrl,
         return retval;
 
     /* Open a TCP connection */
-    client->connection.localConf = client->config.localConnectionConfig;
+    client->connection.config = client->config.localConnectionConfig;
     retval = HelAckHandshake(client);
     if(retval != UA_STATUSCODE_GOOD)
         goto cleanup;

+ 7 - 23
src/client/ua_client_connect_async.c

@@ -68,25 +68,13 @@ processACKResponseAsync(void *application, UA_Connection *connection,
                      "Decoding ACK message failed");
         return client->connectStatus;
     }
+    UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_NETWORK, "Received ACK message");
 
-    /* Store remote connection settings and adjust local configuration to not
-     * exceed the limits */
-    UA_LOG_DEBUG(client->config.logger, UA_LOGCATEGORY_NETWORK,
-                 "Received ACK message");
-    connection->remoteConf.maxChunkCount = ackMessage.maxChunkCount; /* may be zero -> unlimited */
-    connection->remoteConf.maxMessageSize = ackMessage.maxMessageSize; /* may be zero -> unlimited */
-    connection->remoteConf.protocolVersion = ackMessage.protocolVersion;
-    connection->remoteConf.sendBufferSize = ackMessage.sendBufferSize;
-    connection->remoteConf.recvBufferSize = ackMessage.receiveBufferSize;
-    if (connection->remoteConf.recvBufferSize
-            < connection->localConf.sendBufferSize)
-        connection->localConf.sendBufferSize =
-                connection->remoteConf.recvBufferSize;
-    if (connection->remoteConf.sendBufferSize
-            < connection->localConf.recvBufferSize)
-        connection->localConf.recvBufferSize =
-                connection->remoteConf.sendBufferSize;
-    connection->state = UA_CONNECTION_ESTABLISHED;
+    client->connectStatus =
+        UA_Connection_processHELACK(connection, &client->config.localConnectionConfig,
+                                    (const UA_ConnectionConfig*)&ackMessage);
+    if(client->connectStatus != UA_STATUSCODE_GOOD)
+        return client->connectStatus;
 
     client->state = UA_CLIENTSTATE_CONNECTED;
 
@@ -110,11 +98,7 @@ sendHELMessage(UA_Client *client) {
     /* Prepare the HEL message and encode at offset 8 */
     UA_TcpHelloMessage hello;
     UA_String_copy(&client->endpointUrl, &hello.endpointUrl); /* must be less than 4096 bytes */
-    hello.maxChunkCount = conn->localConf.maxChunkCount;
-    hello.maxMessageSize = conn->localConf.maxMessageSize;
-    hello.protocolVersion = conn->localConf.protocolVersion;
-    hello.receiveBufferSize = conn->localConf.recvBufferSize;
-    hello.sendBufferSize = conn->localConf.sendBufferSize;
+    memcpy(&hello, &client->config.localConnectionConfig, sizeof(UA_ConnectionConfig)); /* same struct layout */
 
     UA_Byte *bufPos = &message.data[8]; /* skip the header */
     const UA_Byte *bufEnd = &message.data[message.length];

+ 19 - 23
src/server/ua_server_binary.c

@@ -278,35 +278,32 @@ processHEL(UA_Server *server, UA_Connection *connection,
     if(retval != UA_STATUSCODE_GOOD)
         return retval;
 
-    /* Parameterize the connection */
-    connection->remoteConf.maxChunkCount = helloMessage.maxChunkCount; /* zero -> unlimited */
-    connection->remoteConf.maxMessageSize = helloMessage.maxMessageSize; /* zero -> unlimited */
-    connection->remoteConf.protocolVersion = helloMessage.protocolVersion;
-    connection->remoteConf.recvBufferSize = helloMessage.receiveBufferSize;
-    if(connection->localConf.sendBufferSize > helloMessage.receiveBufferSize)
-        connection->localConf.sendBufferSize = helloMessage.receiveBufferSize;
-    connection->remoteConf.sendBufferSize = helloMessage.sendBufferSize;
-    if(connection->localConf.recvBufferSize > helloMessage.sendBufferSize)
-        connection->localConf.recvBufferSize = helloMessage.sendBufferSize;
+    /* Currently not checked */
     UA_String_deleteMembers(&helloMessage.endpointUrl);
 
-    if(connection->remoteConf.recvBufferSize == 0) {
+    /* TODO: Use the config of the exact NetworkLayer */
+    if(server->config.networkLayersSize == 0)
+        return UA_STATUSCODE_BADOUTOFMEMORY;
+    const UA_ConnectionConfig *localConfig = &server->config.networkLayers[0].localConnectionConfig;
+
+    /* Parameterize the connection */
+    UA_ConnectionConfig remoteConfig;
+    remoteConfig.protocolVersion = helloMessage.protocolVersion;
+    remoteConfig.sendBufferSize = helloMessage.sendBufferSize;
+    remoteConfig.recvBufferSize = helloMessage.receiveBufferSize;
+    remoteConfig.maxMessageSize = helloMessage.maxMessageSize;
+    remoteConfig.maxChunkCount = helloMessage.maxChunkCount;
+    retval = UA_Connection_processHELACK(connection, localConfig, &remoteConfig);
+    if(retval != UA_STATUSCODE_GOOD) {
         UA_LOG_INFO(server->config.logger, UA_LOGCATEGORY_NETWORK,
-                    "Connection %i | Remote end indicated a receive buffer size of 0. "
-                    "Not able to send any messages.",
+                    "Connection %i | Error during the HEL/ACK handshake",
                     connection->sockfd);
-        return UA_STATUSCODE_BADINTERNALERROR;
+        return retval;
     }
 
-    connection->state = UA_CONNECTION_ESTABLISHED;
-
     /* Build acknowledge response */
     UA_TcpAcknowledgeMessage ackMessage;
-    ackMessage.protocolVersion = connection->localConf.protocolVersion;
-    ackMessage.receiveBufferSize = connection->localConf.recvBufferSize;
-    ackMessage.sendBufferSize = connection->localConf.sendBufferSize;
-    ackMessage.maxMessageSize = connection->localConf.maxMessageSize;
-    ackMessage.maxChunkCount = connection->localConf.maxChunkCount;
+    memcpy(&ackMessage, localConfig, sizeof(UA_TcpAcknowledgeMessage)); /* Same struct layout.. */
     UA_TcpMessageHeader ackHeader;
     ackHeader.messageTypeAndChunkType = UA_MESSAGETYPE_ACK + UA_CHUNKTYPE_FINAL;
     ackHeader.messageSize = 8 + 20; /* ackHeader + ackMessage */
@@ -314,8 +311,7 @@ processHEL(UA_Server *server, UA_Connection *connection,
     /* Get the send buffer from the network layer */
     UA_ByteString ack_msg;
     UA_ByteString_init(&ack_msg);
-    retval = connection->getSendBuffer(connection, connection->localConf.sendBufferSize,
-                                       &ack_msg);
+    retval = connection->getSendBuffer(connection, connection->config.sendBufferSize, &ack_msg);
     if(retval != UA_STATUSCODE_GOOD)
         return retval;
 

+ 1 - 1
src/server/ua_services_session.c

@@ -144,7 +144,7 @@ Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
     /* Fill the session information */
     newSession->maxResponseMessageSize = request->maxResponseMessageSize;
     newSession->maxRequestMessageSize =
-        channel->connection->localConf.maxMessageSize;
+        channel->connection->config.maxMessageSize;
     response->responseHeader.serviceResult |=
         UA_ApplicationDescription_copy(&request->clientDescription,
                                        &newSession->clientDescription);

+ 32 - 1
src/ua_connection.c

@@ -22,6 +22,37 @@ void UA_Connection_deleteMembers(UA_Connection *connection) {
     UA_ByteString_deleteMembers(&connection->incompleteMessage);
 }
 
+UA_StatusCode
+UA_Connection_processHELACK(UA_Connection *connection,
+                            const UA_ConnectionConfig *localConfig,
+                            const UA_ConnectionConfig *remoteConfig) {
+    connection->config = *remoteConfig;
+
+    /* The lowest common version is used by both sides */
+    if(connection->config.protocolVersion > localConfig->protocolVersion)
+        connection->config.protocolVersion = localConfig->protocolVersion;
+
+    /* Can we receive the max send size? */
+    if(connection->config.sendBufferSize > localConfig->recvBufferSize)
+        connection->config.sendBufferSize = localConfig->recvBufferSize;
+
+    /* Can we send the max receive size? */
+    if(connection->config.recvBufferSize > localConfig->sendBufferSize)
+        connection->config.recvBufferSize = localConfig->sendBufferSize;
+
+    /* Chunks of at least 8192 bytes must be permissible.
+     * See Part 6, Clause 6.7.1 */
+    if(connection->config.recvBufferSize < 8192 ||
+       connection->config.sendBufferSize < 8192 ||
+       (connection->config.maxMessageSize != 0 &&
+        connection->config.maxMessageSize < 8192))
+        return UA_STATUSCODE_BADINTERNALERROR;
+
+    connection->state = UA_CONNECTION_ESTABLISHED;
+
+    return UA_STATUSCODE_GOOD;
+}
+
 /* Hides somme errors before sending them to a client according to the
  * standard. */
 static void
@@ -127,7 +158,7 @@ processChunk(UA_Connection *connection, void *application,
     UA_UInt32_decodeBinary(&temp, &temp_offset, &chunk_length);
 
     /* The message size is not allowed */
-    if(chunk_length < 16 || chunk_length > connection->localConf.recvBufferSize)
+    if(chunk_length < 16 || chunk_length > connection->config.recvBufferSize)
         return UA_STATUSCODE_BADTCPMESSAGETOOLARGE;
 
     /* Wait for the next packet to process the complete chunk */

+ 7 - 0
src/ua_connection_internal.h

@@ -18,6 +18,13 @@ extern "C" {
 #include "ua_plugin_network.h"
 #include "ua_transport_generated.h"
 
+/* Process the remote configuration in the HEL/ACK handshake. The connection
+ * config is initialized with the local settings. */
+UA_StatusCode
+UA_Connection_processHELACK(UA_Connection *connection,
+                            const UA_ConnectionConfig *localConfig,
+                            const UA_ConnectionConfig *remoteConfig);
+
 /* The application can be the client or the server */
 typedef UA_StatusCode (*UA_Connection_processChunk)(void *application,
                                                     UA_Connection *connection,

+ 10 - 16
src/ua_securechannel.c

@@ -345,7 +345,7 @@ UA_SecureChannel_sendAsymmetricOPNMessage(UA_SecureChannel *channel, UA_UInt32 r
     /* Allocate the message buffer */
     UA_ByteString buf = UA_BYTESTRING_NULL;
     UA_StatusCode retval =
-        connection->getSendBuffer(connection, connection->localConf.sendBufferSize, &buf);
+        connection->getSendBuffer(connection, connection->config.sendBufferSize, &buf);
     if(retval != UA_STATUSCODE_GOOD)
         return retval;
 
@@ -531,11 +531,11 @@ sendSymmetricChunk(UA_MessageContext *mc) {
     size_t bodyLength = (uintptr_t)buf_body_end - (uintptr_t)buf_body_start;
     mc->messageSizeSoFar += bodyLength;
     mc->chunksSoFar++;
-    if(mc->messageSizeSoFar > connection->remoteConf.maxMessageSize &&
-       connection->remoteConf.maxMessageSize != 0)
+    if(mc->messageSizeSoFar > connection->config.maxMessageSize &&
+       connection->config.maxMessageSize != 0)
         res = UA_STATUSCODE_BADRESPONSETOOLARGE;
-    if(mc->chunksSoFar > connection->remoteConf.maxChunkCount &&
-       connection->remoteConf.maxChunkCount != 0)
+    if(mc->chunksSoFar > connection->config.maxChunkCount &&
+       connection->config.maxChunkCount != 0)
         res = UA_STATUSCODE_BADRESPONSETOOLARGE;
     if(res != UA_STATUSCODE_GOOD) {
         connection->releaseSendBuffer(channel->connection, &mc->messageBuffer);
@@ -644,7 +644,7 @@ sendSymmetricEncodingCallback(void *data, UA_Byte **buf_pos, const UA_Byte **buf
 
     /* Set a new buffer for the next chunk */
     UA_Connection *connection = mc->channel->connection;
-    retval = connection->getSendBuffer(connection, connection->localConf.sendBufferSize,
+    retval = connection->getSendBuffer(connection, connection->config.sendBufferSize,
                                        &mc->messageBuffer);
     if(retval != UA_STATUSCODE_GOOD)
         return retval;
@@ -675,13 +675,9 @@ UA_MessageContext_begin(UA_MessageContext *mc, UA_SecureChannel *channel,
     mc->messageBuffer = UA_BYTESTRING_NULL;
     mc->messageType = messageType;
 
-    /* Minimum required size */
-    if(connection->localConf.sendBufferSize <= UA_SECURE_MESSAGE_HEADER_LENGTH)
-        return UA_STATUSCODE_BADRESPONSETOOLARGE;
-
     /* Allocate the message buffer */
     UA_StatusCode retval =
-        connection->getSendBuffer(connection, connection->localConf.sendBufferSize,
+        connection->getSendBuffer(connection, connection->config.sendBufferSize,
                                   &mc->messageBuffer);
     if(retval != UA_STATUSCODE_GOOD)
         return retval;
@@ -787,12 +783,10 @@ addChunkPayload(UA_SecureChannel *channel, UA_UInt32 requestId,
     }
 
     /* Test against the connection settings */
-    const UA_ConnectionConfig *config = &channel->connection->localConf;
-    if(config->maxChunkCount > 0 &&
-       config->maxChunkCount <= latest->chunkPayloadsSize)
+    const UA_ConnectionConfig *config = &channel->connection->config;
+    if(config->maxChunkCount > 0 && config->maxChunkCount <= latest->chunkPayloadsSize)
         return UA_STATUSCODE_BADRESPONSETOOLARGE;
-    if(config->maxMessageSize > 0 &&
-       config->maxMessageSize < latest->messageSize + chunkPayload->length)
+    if(config->maxMessageSize > 0 && config->maxMessageSize < latest->messageSize + chunkPayload->length)
         return UA_STATUSCODE_BADRESPONSETOOLARGE;
 
     /* Create a new chunk entry */

+ 1 - 2
tests/testing-plugins/testing_networklayers.c

@@ -56,8 +56,7 @@ UA_Connection createDummyConnection(size_t sendBufferSize,
 
     UA_Connection c;
     c.state = UA_CONNECTION_ESTABLISHED;
-    c.localConf = UA_ConnectionConfig_default;
-    c.remoteConf = UA_ConnectionConfig_default;
+    c.config = UA_ConnectionConfig_default;
     c.channel = NULL;
     c.sockfd = 0;
     c.handle = NULL;