Skip to content

Commit bb1f7f9

Browse files
authored
Fixed issues with websocket changes and updated tests (#345)
* Restored ECC_CIPHERSUITE ifdef code. * Remove unused variables. * Replaced faulty comparisons with ifdefs. * Fixed regression tests.
1 parent f9ecbd7 commit bb1f7f9

14 files changed

+35
-2
lines changed

addons/websocket/nx_websocket_client.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,14 @@ UINT nx_websocket_client_packet_allocate(NX_WEBSOCKET_CLIENT *client_ptr, NX_PA
265265
UINT nx_websocket_client_connect(NX_WEBSOCKET_CLIENT *client_ptr, NX_TCP_SOCKET *socket_ptr,
266266
UCHAR *host, UINT host_length,
267267
UCHAR *uri_path, UINT uri_path_length,
268-
UCHAR *protocol, UINT protocol_length,UINT wait_option);
268+
UCHAR *protocol, UINT protocol_length,
269+
UCHAR *bearer, UINT bearer_length, UINT wait_option);
269270
#ifdef NX_SECURE_ENABLE
270271
UINT nx_websocket_client_secure_connect(NX_WEBSOCKET_CLIENT *client_ptr, NX_SECURE_TLS_SESSION *tls_session,
271272
UCHAR *host, UINT host_length,
272273
UCHAR *uri_path, UINT uri_path_length,
273-
UCHAR *protocol, UINT protocol_length,UINT wait_option);
274+
UCHAR *protocol, UINT protocol_length,
275+
UCHAR *bearer, UINT bearer_length, UINT wait_option);
274276
#endif /* NX_SECURE_ENABLE */
275277
UINT nx_websocket_client_disconnect(NX_WEBSOCKET_CLIENT *client_ptr, UINT wait_option);
276278
UINT nx_websocket_client_send(NX_WEBSOCKET_CLIENT *client_ptr, NX_PACKET *packet_ptr, UINT code, UINT is_final, UINT wait_option);

common/src/nx_ip_packet_receive.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ UCHAR version_byte;
101101
packet_ptr -> nx_packet_address.nx_packet_interface_ptr = &(ip_ptr -> nx_ip_interface[0]);
102102
}
103103

104+
#ifndef NX_DISABLE_IPV4
104105
/* GHSA-pf5q-r6q5-6j2f:
105106
This is an IPv4 packet. Therefore the header length must be at least 20 bytes.
106107
Validate the payload size before accessing the IP header. */
@@ -113,6 +114,7 @@ UCHAR version_byte;
113114

114115
return;
115116
}
117+
#endif
116118

117119
/* It's assumed that the IP link driver has positioned the top pointer in the
118120
packet to the start of the IP address... so that's where we will start. */

test/regression/websocket_test/netx_websocket_16_bit_payload_length_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void thread_server_entry(ULONG thread_input);
4747
#define TEST_HOST_NAME "1.2.3.4"
4848
#define TEST_URI_PATH "/test"
4949
#define TEST_PROTOCOL "test"
50+
#define TEST_BEARER ""
5051

5152
static UCHAR server_switch_101[] =
5253
{
@@ -322,6 +323,7 @@ UINT code;
322323
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
323324
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
324325
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
326+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
325327
NX_WAIT_FOREVER);
326328

327329
if (status)

test/regression/websocket_test/netx_websocket_connect_test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static void thread_server_entry(ULONG thread_input);
7171
#define TEST_HOST_NAME "1.2.3.4"
7272
#define TEST_URI_PATH "/test"
7373
#define TEST_PROTOCOL "test"
74+
#define TEST_BEARER ""
7475

7576
static UCHAR bad_server_switch_101[] =
7677
{
@@ -314,6 +315,7 @@ UINT code;
314315
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
315316
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
316317
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
318+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
317319
NX_WAIT_FOREVER);
318320

319321
/* The first time is to test whether the bad response from server will be checked and found */
@@ -325,6 +327,7 @@ UINT code;
325327
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
326328
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
327329
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
330+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
328331
NX_WAIT_FOREVER);
329332
if (status || client_websocket.nx_websocket_client_mutex.tx_mutex_ownership_count != 0)
330333
SET_ERROR_COUNTER(&error_counter, __FILE__, __LINE__);
@@ -348,6 +351,7 @@ UINT code;
348351
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
349352
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
350353
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
354+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
351355
NX_WAIT_FOREVER);
352356
if (status || client_websocket.nx_websocket_client_mutex.tx_mutex_ownership_count != 0)
353357
SET_ERROR_COUNTER(&error_counter, __FILE__, __LINE__);

test/regression/websocket_test/netx_websocket_delete_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static void thread_server_entry(ULONG thread_input);
4848
#define TEST_HOST_NAME "1.2.3.4"
4949
#define TEST_URI_PATH "/test"
5050
#define TEST_PROTOCOL "test"
51+
#define TEST_BEARER ""
5152

5253
static UCHAR server_switch_101[] =
5354
{
@@ -226,6 +227,7 @@ UINT code;
226227
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
227228
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
228229
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
230+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
229231
NX_WAIT_FOREVER);
230232

231233
if (status)

test/regression/websocket_test/netx_websocket_disconnect_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static void thread_server_entry(ULONG thread_input);
4848
#define TEST_HOST_NAME "1.2.3.4"
4949
#define TEST_URI_PATH "/test"
5050
#define TEST_PROTOCOL "test"
51+
#define TEST_BEARER ""
5152

5253
static UCHAR server_switch_101[] =
5354
{
@@ -229,6 +230,7 @@ UINT code;
229230
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
230231
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
231232
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
233+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
232234
NX_WAIT_FOREVER);
233235

234236
if (status)

test/regression/websocket_test/netx_websocket_fin_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void thread_server_entry(ULONG thread_input);
4747
#define TEST_HOST_NAME "1.2.3.4"
4848
#define TEST_URI_PATH "/test"
4949
#define TEST_PROTOCOL "test"
50+
#define TEST_BEARER ""
5051

5152
static UCHAR server_switch_101[] =
5253
{
@@ -233,6 +234,7 @@ UINT code;
233234
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
234235
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
235236
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
237+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
236238
NX_WAIT_FOREVER);
237239

238240
if(status)

test/regression/websocket_test/netx_websocket_mask_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static void thread_server_entry(ULONG thread_input);
4949
#define TEST_HOST_NAME "1.2.3.4"
5050
#define TEST_URI_PATH "/test"
5151
#define TEST_PROTOCOL "test"
52+
#define TEST_BEARER ""
5253

5354
static UCHAR server_switch_101[] =
5455
{
@@ -235,6 +236,7 @@ UINT code;
235236
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
236237
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
237238
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
239+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
238240
NX_WAIT_FOREVER);
239241

240242
if(status)

test/regression/websocket_test/netx_websocket_multi_instance_test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static void thread_server_entry(ULONG thread_input);
4848
#define TEST_HOST_NAME "1.2.3.4"
4949
#define TEST_URI_PATH "/test"
5050
#define TEST_PROTOCOL "test"
51+
#define TEST_BEARER ""
5152

5253
static UCHAR server_switch_101[] =
5354
{
@@ -293,6 +294,7 @@ UINT code;
293294
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
294295
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
295296
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
297+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
296298
NX_WAIT_FOREVER);
297299

298300
if (status || client_websocket.nx_websocket_client_mutex.tx_mutex_ownership_count != 0)
@@ -486,6 +488,7 @@ UINT code;
486488
TEST1_HOST_NAME, sizeof(TEST1_HOST_NAME) - 1,
487489
(UCHAR *)TEST1_URI_PATH, sizeof(TEST1_URI_PATH) - 1,
488490
(UCHAR *)TEST1_PROTOCOL, sizeof(TEST1_PROTOCOL) - 1,
491+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
489492
NX_WAIT_FOREVER);
490493

491494
if (status || client1_websocket.nx_websocket_client_mutex.tx_mutex_ownership_count != 0)

test/regression/websocket_test/netx_websocket_non_block_test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static void thread_server_entry(ULONG thread_input);
7474
#define TEST_HOST_NAME "1.2.3.4"
7575
#define TEST_URI_PATH "/test"
7676
#define TEST_PROTOCOL "test"
77+
#define TEST_BEARER ""
7778

7879
static UCHAR server_switch_101[] =
7980
{
@@ -325,6 +326,7 @@ UINT code;
325326
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
326327
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
327328
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
329+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
328330
NX_NO_WAIT); /* Set 0 to do non-blocking test */
329331
if (status != NX_IN_PROGRESS || client_websocket.nx_websocket_client_mutex.tx_mutex_ownership_count != 0)
330332
SET_ERROR_COUNTER(&error_counter, __FILE__, __LINE__);
@@ -376,6 +378,7 @@ UINT code;
376378
TEST_HOST_NAME, sizeof(TEST_HOST_NAME) - 1,
377379
(UCHAR *)TEST_URI_PATH, sizeof(TEST_URI_PATH) - 1,
378380
(UCHAR *)TEST_PROTOCOL, sizeof(TEST_PROTOCOL) - 1,
381+
(UCHAR *)TEST_BEARER, sizeof(TEST_BEARER) -1,
379382
NX_NO_WAIT);
380383
if (status != NX_IN_PROGRESS || client_websocket.nx_websocket_client_mutex.tx_mutex_ownership_count != 0)
381384
SET_ERROR_COUNTER(&error_counter, __FILE__, __LINE__);

0 commit comments

Comments
 (0)