diff options
| author | Tiejun Zhou <[email protected]> | 2023-03-31 07:36:05 +0000 |
|---|---|---|
| committer | Tiejun Zhou <[email protected]> | 2023-03-31 07:36:05 +0000 |
| commit | ee528a27ed44983183b2437320d60bd700834063 (patch) | |
| tree | c960a8ab1ef03c41dae5cd9092619a43505197eb | |
| parent | 1ebdfa52e92ace193c6c6b354c65befbf1bd1871 (diff) | |
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.
| -rw-r--r-- | addons/BSD/nxd_bsd.c | 13 | ||||
| -rw-r--r-- | addons/azure_iot/nx_azure_iot.c | 6 | ||||
| -rw-r--r-- | addons/dhcp/nxd_dhcp_client.c | 9 | ||||
| -rw-r--r-- | common/inc/nx_api.h | 7 | ||||
| -rw-r--r-- | common/inc/nx_user_sample.h | 10 | ||||
| -rw-r--r-- | common/src/nx_ip_create.c | 7 | ||||
| -rw-r--r-- | common/src/nx_ip_header_add.c | 13 | ||||
| -rw-r--r-- | common/src/nx_ipv6_fragment_process.c | 9 |
8 files changed, 62 insertions, 12 deletions
diff --git a/addons/BSD/nxd_bsd.c b/addons/BSD/nxd_bsd.c index 4681eb19..c14740fe 100644 --- a/addons/BSD/nxd_bsd.c +++ b/addons/BSD/nxd_bsd.c @@ -3072,7 +3072,7 @@ struct sockaddr_in6 peer6_address; /* FUNCTION RELEASE */ /* */ /* nx_bsd_send_internal PORTABLE C */ -/* 6.1 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -3103,7 +3103,7 @@ struct sockaddr_in6 peer6_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 */ @@ -3128,6 +3128,9 @@ struct sockaddr_in6 peer6_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, @@ -3382,8 +3385,14 @@ ULONG data_sent = (ULONG)msgLength; (*(packet_ptr -> nx_packet_prepend_ptr + 5) == 0)) { +#ifdef NX_ENABLE_IP_ID_RANDOMIZATION + ULONG rand_id = (ULONG)NX_RAND(); + *(packet_ptr -> nx_packet_prepend_ptr + 4) = (UCHAR)((rand_id & 0xFFFF) >> 8); + *(packet_ptr -> nx_packet_prepend_ptr + 5) = (UCHAR)(rand_id & 0xFF); +#else *(packet_ptr -> nx_packet_prepend_ptr + 4) = (UCHAR)(((nx_bsd_default_ip -> nx_ip_packet_id) & 0xFFFF) >> 8); *(packet_ptr -> nx_packet_prepend_ptr + 5) = (UCHAR)((nx_bsd_default_ip -> nx_ip_packet_id) & 0xFF); +#endif /* NX_ENABLE_IP_ID_RANDOMIZATION */ } /* Clear the checksum field. */ diff --git a/addons/azure_iot/nx_azure_iot.c b/addons/azure_iot/nx_azure_iot.c index 6eb889a8..1a3a34c0 100644 --- a/addons/azure_iot/nx_azure_iot.c +++ b/addons/azure_iot/nx_azure_iot.c @@ -12,15 +12,13 @@ #include <stdio.h> #include <stdarg.h> +#include "nx_azure_iot.h" +#include "azure/core/internal/az_log_internal.h" #ifndef NX_AZURE_DISABLE_IOT_SECURITY_MODULE #include "nx_azure_iot_security_module.h" #endif /* NX_AZURE_DISABLE_IOT_SECURITY_MODULE */ -#include "nx_azure_iot.h" - -#include "azure/core/internal/az_log_internal.h" - #ifndef NX_AZURE_IOT_WAIT_OPTION #define NX_AZURE_IOT_WAIT_OPTION NX_WAIT_FOREVER #endif /* NX_AZURE_IOT_WAIT_OPTION */ diff --git a/addons/dhcp/nxd_dhcp_client.c b/addons/dhcp/nxd_dhcp_client.c index e7131477..e79851f5 100644 --- a/addons/dhcp/nxd_dhcp_client.c +++ b/addons/dhcp/nxd_dhcp_client.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 */ @@ -7039,6 +7039,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) @@ -7177,7 +7180,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 8a102381..dba70712 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 */ @@ -100,6 +100,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 */ /* */ /**************************************************************************/ @@ -2582,8 +2585,10 @@ typedef struct NX_IP_STRUCT #endif #endif /* !NX_DISABLE_IPV4 */ +#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 f7bab5f1..2bc43017 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.11 */ +/* 6.x */ /* */ /* AUTHOR */ /* */ @@ -52,6 +52,9 @@ /* resulting in version 6.1.8 */ /* 04-25-2022 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1.11 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */ +/* supported random IP id, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ @@ -126,6 +129,11 @@ #define NX_IP_ROUTING_TABLE_SIZE 8 */ +/* 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 maximum number of multicast groups that can be joined. The default value is 7. */ /* diff --git a/common/src/nx_ip_create.c b/common/src/nx_ip_create.c index 2c63a1e3..e4d82e8d 100644 --- a/common/src/nx_ip_create.c +++ b/common/src/nx_ip_create.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_ip_create PORTABLE C */ -/* 6.1 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -82,6 +82,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, @@ -195,7 +198,9 @@ TX_THREAD *current_thread; 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_header_add.c b/common/src/nx_ip_header_add.c index a638aac8..1f401fbc 100644 --- a/common/src/nx_ip_header_add.c +++ b/common/src/nx_ip_header_add.c @@ -39,7 +39,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_ip_header_add PORTABLE C */ -/* 6.1.8 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -83,6 +83,9 @@ /* 08-02-2021 Yuxin Zhou Modified comment(s), and */ /* supported TCP/IP offload, */ /* resulting in version 6.1.8 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), */ +/* supported random IP id, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ UINT _nx_ip_header_add(NX_IP *ip_ptr, NX_PACKET *packet_ptr, ULONG source_ip, ULONG destination_ip, @@ -96,6 +99,10 @@ UINT compute_checksum = 1; #endif /* defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) || defined(NX_IPSEC_ENABLE) */ ULONG val; +#ifdef NX_ENABLE_IP_ID_RANDOMIZATION + NX_PARAMETER_NOT_USED(ip_ptr); +#endif /* NX_ENABLE_IP_ID_RANDOMIZATION */ + #ifndef NX_DISABLE_IGMPV2 /* Check IGMPv2 protocol. */ if ((protocol == NX_IP_IGMP) && (ip_ptr -> nx_ip_igmp_router_version == NX_IGMP_HOST_VERSION_2)) @@ -152,7 +159,11 @@ ULONG val; } /* 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); diff --git a/common/src/nx_ipv6_fragment_process.c b/common/src/nx_ipv6_fragment_process.c index abc781ac..57e6e71e 100644 --- a/common/src/nx_ipv6_fragment_process.c +++ b/common/src/nx_ipv6_fragment_process.c @@ -39,7 +39,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_ipv6_fragment_process PORTABLE C */ -/* 6.1 */ +/* 6.x */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -84,6 +84,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 */ /* */ /**************************************************************************/ VOID _nx_ipv6_fragment_process(struct NX_IP_DRIVER_STRUCT *driver_req_ptr, UINT mtu) @@ -125,7 +128,11 @@ NX_PACKET_POOL *pool_ptr; /* Source_packet points a packet (or a chain of packets) that already has IP header constructed. The prepend pointer should point to the IPv6 header. */ +#ifdef NX_ENABLE_IP_ID_RANDOMIZATION + packet_id = (ULONG)NX_RAND(); +#else packet_id = ip_ptr -> nx_ip_packet_id++; +#endif /* NX_ENABLE_IP_ID_RANDOMIZATION */ /* Byte swap packet_id */ NX_CHANGE_ULONG_ENDIAN(packet_id); |
