From c52d090e1977b10146a8f5b0a6f8a4252a55bea4 Mon Sep 17 00:00:00 2001 From: Tiejun Zhou Date: Fri, 31 Mar 2023 07:35:56 +0000 Subject: [PATCH] Update on 31 Mar 2023. Expand to see details. d91a02534 Add adu agent install unit test. b6819d250 Support random IP id 19c78054f Corrected the include order for IoT Security module. --- addons/BSD/nx_bsd.c | 7 +++++-- addons/dhcp/nx_dhcp.c | 9 ++++++++- common/inc/nx_api.h | 7 ++++++- common/inc/nx_user_sample.h | 10 +++++++++- common/src/nx_ip_create.c | 7 ++++++- common/src/nx_ip_packet_send.c | 9 ++++++++- 6 files changed, 42 insertions(+), 7 deletions(-) diff --git a/addons/BSD/nx_bsd.c b/addons/BSD/nx_bsd.c index b831d27..486399b 100644 --- a/addons/BSD/nx_bsd.c +++ b/addons/BSD/nx_bsd.c @@ -2820,7 +2820,7 @@ struct sockaddr_in peer4_address; /* FUNCTION RELEASE */ /* */ /* nx_bsd_send_internal PORTABLE C */ -/* 6.1 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2851,7 +2851,7 @@ struct sockaddr_in peer4_address; /* set_errno Sets the BSD errno */ /* nx_packet_allocate Allocate a packet */ /* nx_packet_data_append Append data to the packet */ -/* tx_mutex_get Get Mutex protction */ +/* tx_mutex_get Get Mutex protection */ /* tx_mutex_put Release Mutex protection */ /* nx_packet_release Release the packet on error */ /* nx_udp_socket_send UDP packet send */ @@ -2870,6 +2870,9 @@ struct sockaddr_in peer4_address; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */ +/* supported random IP id, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ static INT nx_bsd_send_internal(INT sockID, const CHAR *msg, INT msgLength, INT flags, diff --git a/addons/dhcp/nx_dhcp.c b/addons/dhcp/nx_dhcp.c index 965685b..91cff1f 100644 --- a/addons/dhcp/nx_dhcp.c +++ b/addons/dhcp/nx_dhcp.c @@ -6992,7 +6992,7 @@ UINT name_length; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_client_send_with_zero_source_address PORTABLE C */ -/* 6.1.12 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -7033,6 +7033,9 @@ UINT name_length; /* udp socket send and ip */ /* header add, */ /* resulting in version 6.1.12 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */ +/* supported random IP id, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ static UINT _nx_dhcp_client_send_with_zero_source_address(NX_DHCP *dhcp_ptr, UINT iface_index, NX_PACKET *packet_ptr) @@ -7159,7 +7162,11 @@ NX_IP_DRIVER driver_request; ip_header_ptr -> nx_ip_header_word_0 = (NX_IP_VERSION | socket_ptr -> nx_udp_socket_type_of_service | (0xFFFF & packet_ptr -> nx_packet_length)); /* Build the second 32-bit word of the IP header. */ +#ifdef NX_ENABLE_IP_ID_RANDOMIZATION + ip_header_ptr -> nx_ip_header_word_1 = (((ULONG)NX_RAND()) << NX_SHIFT_BY_16) | socket_ptr -> nx_udp_socket_fragment_enable; +#else ip_header_ptr -> nx_ip_header_word_1 = (ip_ptr -> nx_ip_packet_id++ << NX_SHIFT_BY_16) | socket_ptr -> nx_udp_socket_fragment_enable; +#endif /* NX_ENABLE_IP_ID_RANDOMIZATION */ /* Build the third 32-bit word of the IP header. */ ip_header_ptr -> nx_ip_header_word_2 = ((socket_ptr -> nx_udp_socket_time_to_live << NX_IP_TIME_TO_LIVE_SHIFT) | NX_IP_UDP); diff --git a/common/inc/nx_api.h b/common/inc/nx_api.h index 43760a8..f0a0a75 100644 --- a/common/inc/nx_api.h +++ b/common/inc/nx_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nx_api.h PORTABLE C */ -/* 6.2.1 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -94,6 +94,9 @@ /* 03-08-2023 Tiejun Zhou Modified comment(s), and */ /* updated product constants, */ /* resulting in version 6.2.1 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */ +/* supported random IP id, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ @@ -1517,8 +1520,10 @@ typedef struct NX_IP_STRUCT pointed to by this member should be called. */ VOID (*nx_ip_forward_packet_process)(struct NX_IP_STRUCT *, NX_PACKET *); +#ifndef NX_ENABLE_IP_ID_RANDOMIZATION /* Define the packet ID. */ ULONG nx_ip_packet_id; +#endif /* NX_ENABLE_IP_ID_RANDOMIZATION */ /* Define the default packet pool. */ struct NX_PACKET_POOL_STRUCT diff --git a/common/inc/nx_user_sample.h b/common/inc/nx_user_sample.h index f963d22..113ea33 100644 --- a/common/inc/nx_user_sample.h +++ b/common/inc/nx_user_sample.h @@ -26,7 +26,7 @@ /* PORT SPECIFIC C INFORMATION RELEASE */ /* */ /* nx_user.h PORTABLE C */ -/* 6.1.12 */ +/* 6.x */ /* */ /* AUTHOR */ /* */ @@ -52,6 +52,9 @@ /* 07-29-2022 Yuxin Zhou Modified comment(s), and */ /* added NX_ASSERT, */ /* resulting in version 6.1.12 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */ +/* supported random IP id, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ @@ -80,6 +83,11 @@ #define NX_ENABLE_IP_STATIC_ROUTING */ +/* Defined, this option enables random IP id. By default IP id is increased by one for each packet. */ +/* +#define NX_ENABLE_IP_ID_RANDOMIZATION +*/ + /* This define specifies the size of the physical packet header. The default value is 16 (based on a typical 16-byte Ethernet header). */ diff --git a/common/src/nx_ip_create.c b/common/src/nx_ip_create.c index f2c17b1..04a996b 100644 --- a/common/src/nx_ip_create.c +++ b/common/src/nx_ip_create.c @@ -36,7 +36,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_ip_create PORTABLE C */ -/* 6.1 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -83,6 +83,9 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */ +/* supported random IP id, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ UINT _nx_ip_create(NX_IP *ip_ptr, CHAR *name, ULONG ip_address, ULONG network_mask, @@ -165,7 +168,9 @@ NX_IP *tail_ptr; ip_ptr -> nx_ip_name = name; /* Set the initial IP packet ID. */ +#ifndef NX_ENABLE_IP_ID_RANDOMIZATION ip_ptr -> nx_ip_packet_id = NX_INIT_PACKET_ID; +#endif /* NX_ENABLE_IP_ID_RANDOMIZATION */ /* Setup the default packet pool for this IP instance. */ ip_ptr -> nx_ip_default_packet_pool = default_pool; diff --git a/common/src/nx_ip_packet_send.c b/common/src/nx_ip_packet_send.c index 279b006..4a44605 100644 --- a/common/src/nx_ip_packet_send.c +++ b/common/src/nx_ip_packet_send.c @@ -37,7 +37,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_ip_packet_send PORTABLE C */ -/* 6.1 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -80,6 +80,9 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */ +/* supported random IP id, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ @@ -157,7 +160,11 @@ UINT queued_count; ip_header_ptr -> nx_ip_header_word_0 = (NX_IP_VERSION | type_of_service | (0xFFFF & packet_ptr -> nx_packet_length)); /* Build the second 32-bit word of the IP header. */ +#ifdef NX_ENABLE_IP_ID_RANDOMIZATION + ip_header_ptr -> nx_ip_header_word_1 = (((ULONG)NX_RAND()) << NX_SHIFT_BY_16) | fragment; +#else ip_header_ptr -> nx_ip_header_word_1 = (ip_ptr -> nx_ip_packet_id++ << NX_SHIFT_BY_16) | fragment; +#endif /* NX_ENABLE_IP_ID_RANDOMIZATION */ /* Build the third 32-bit word of the IP header. */ ip_header_ptr -> nx_ip_header_word_2 = ((time_to_live << NX_IP_TIME_TO_LIVE_SHIFT) | protocol);