diff --git a/addons/AUTO_IP/nx_auto_ip.c b/addons/auto_ip/nx_auto_ip.c similarity index 100% rename from addons/AUTO_IP/nx_auto_ip.c rename to addons/auto_ip/nx_auto_ip.c diff --git a/addons/AUTO_IP/nx_auto_ip.h b/addons/auto_ip/nx_auto_ip.h similarity index 100% rename from addons/AUTO_IP/nx_auto_ip.h rename to addons/auto_ip/nx_auto_ip.h diff --git a/addons/DHCP/nx_dhcp.c b/addons/dhcp/nx_dhcp.c similarity index 100% rename from addons/DHCP/nx_dhcp.c rename to addons/dhcp/nx_dhcp.c diff --git a/addons/DHCP/nx_dhcp.h b/addons/dhcp/nx_dhcp.h similarity index 100% rename from addons/DHCP/nx_dhcp.h rename to addons/dhcp/nx_dhcp.h diff --git a/addons/DHCP/nx_dhcp_server.c b/addons/dhcp/nx_dhcp_server.c similarity index 100% rename from addons/DHCP/nx_dhcp_server.c rename to addons/dhcp/nx_dhcp_server.c diff --git a/addons/DHCP/nx_dhcp_server.h b/addons/dhcp/nx_dhcp_server.h similarity index 100% rename from addons/DHCP/nx_dhcp_server.h rename to addons/dhcp/nx_dhcp_server.h diff --git a/addons/DNS/nx_dns.c b/addons/dns/nx_dns.c similarity index 96% rename from addons/DNS/nx_dns.c rename to addons/dns/nx_dns.c index 8cbb1ac..06e638c 100644 --- a/addons/DNS/nx_dns.c +++ b/addons/dns/nx_dns.c @@ -45,7 +45,7 @@ /* Internal DNS functions. */ static UINT _nx_dns_header_create(UCHAR *buffer_ptr, USHORT id, USHORT flags); -static UINT _nx_dns_new_packet_create(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, USHORT id, UCHAR *name, USHORT type); +static UINT _nx_dns_new_packet_create(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *name, USHORT type); static UINT _nx_dns_name_size_calculate(UCHAR *name, NX_PACKET *packet_ptr); static UINT _nx_dns_name_string_encode(UCHAR *ptr, UCHAR *name); static UINT _nx_dns_name_string_unencode(NX_PACKET *packet_ptr, UCHAR *data, UCHAR *buffer, UINT buffer_size); @@ -60,6 +60,7 @@ static VOID _nx_dns_short_to_network_convert(UCHAR *ptr, USHORT value); static UINT _nx_dns_number_to_ascii_convert(UINT number, CHAR *buffstring); static UINT _nx_dns_host_resource_data_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, UCHAR *record_buffer, UINT buffer_size, UINT *record_count, UINT lookup_type, ULONG wait_option); +static UINT _nx_dns_response_receive(NX_DNS *dns_ptr, NX_PACKET **packet_ptr, ULONG wait_option); static UINT _nx_dns_response_process(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *record_buffer, UINT buffer_size, UINT *record_count); static UINT _nx_dns_process_a_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *data_ptr, UCHAR **buffer_prepend_ptr, UCHAR **buffer_append_ptr, UINT *record_count, UINT rr_location); static UINT _nx_dns_process_aaaa_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *data_ptr, UCHAR **buffer_prepend_ptr, UCHAR **buffer_append_ptr, UINT *record_count, UINT rr_location); @@ -188,7 +189,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dns_create PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -213,8 +214,6 @@ UINT status; /* */ /* nx_udp_socket_create Create DNS UDP socket */ /* nx_udp_socket_delete Delete DNS UDP socket */ -/* nx_udp_socket_bind Bind DNS UDP socket to port */ -/* nx_udp_socket_unbind Unbind DNS UDP socket */ /* tx_mutex_create Create a ThreadX mutex */ /* */ /* CALLED BY */ @@ -228,6 +227,9 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), and */ +/* randomized the source port, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ UINT _nx_dns_create(NX_DNS *dns_ptr, NX_IP *ip_ptr, UCHAR *domain_name) @@ -273,26 +275,6 @@ UINT status; return(status); } - /* Bind the UDP socket to the DNS Client port. */ - status = nx_udp_socket_bind(&(dns_ptr -> nx_dns_socket), NX_ANY_PORT, TX_WAIT_FOREVER); - - /* Check status of socket bind. */ - if (status != NX_SUCCESS) - { - -#ifndef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL - - /* Delete the packet pool. */ - nx_packet_pool_delete(dns_ptr -> nx_dns_packet_pool_ptr); -#endif - - /* Delete the socket. */ - nx_udp_socket_delete(&(dns_ptr -> nx_dns_socket)); - - /* Return the NetX error. */ - return(status); - } - /* Create a DNS mutex for multi-thread access protection. */ status = tx_mutex_create(&dns_ptr -> nx_dns_mutex, "DNS Mutex", TX_NO_INHERIT); @@ -306,9 +288,6 @@ UINT status; nx_packet_pool_delete(dns_ptr -> nx_dns_packet_pool_ptr); #endif - /* Unbind the socket. */ - nx_udp_socket_unbind(&(dns_ptr -> nx_dns_socket)); - /* Delete the socket. */ nx_udp_socket_delete(&(dns_ptr -> nx_dns_socket)); @@ -556,7 +535,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dns_delete PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -577,7 +556,6 @@ UINT status; /* CALLS */ /* */ /* nx_udp_socket_delete Delete DNS UDP socket */ -/* nx_udp_socket_unbind Unbind DNS UDP socket */ /* tx_mutex_delete Delete DNS mutex */ /* */ /* CALLED BY */ @@ -591,6 +569,9 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), and */ +/* randomized the source port, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ UINT _nx_dns_delete(NX_DNS *dns_ptr) @@ -599,14 +580,6 @@ UINT _nx_dns_delete(NX_DNS *dns_ptr) UINT status; - /* Unbind the UDP socket. */ - status = nx_udp_socket_unbind(&dns_ptr -> nx_dns_socket); - - if (status != NX_SUCCESS) - { - /* Return the socket unbind error. */ - return status; - } /* Delete the DNS UDP socket. */ status = nx_udp_socket_delete(&dns_ptr -> nx_dns_socket); @@ -2918,7 +2891,7 @@ UINT record_count = 0; /* FUNCTION RELEASE */ /* */ /* _nx_dns_host_resource_data_by_name_get PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2952,6 +2925,8 @@ UINT record_count = 0; /* query on supplied host name */ /* tx_mutex_get Get DNS protection mutex */ /* tx_mutex_put Release DNS protection mutex */ +/* nx_udp_socket_bind Bind DNS UDP socket to port */ +/* nx_udp_socket_unbind Unbind DNS UDP socket */ /* */ /* CALLED BY */ /* */ @@ -2964,6 +2939,9 @@ UINT record_count = 0; /* 09-30-2020 Yuxin Zhou Modified comment(s), corrected*/ /* the timeout of first query, */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), and */ +/* randomized the source port, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_host_resource_data_by_name_get(NX_DNS *dns_ptr, UCHAR *host_name, @@ -3018,6 +2996,18 @@ UINT i; return(NX_DNS_NO_SERVER); } + /* Bind the UDP socket to random port for each query. */ + status = nx_udp_socket_bind(&(dns_ptr -> nx_dns_socket), NX_ANY_PORT, TX_WAIT_FOREVER); + + /* Check status. */ + if (status != TX_SUCCESS) + { + + /* Release the DNS Client lock. */ + tx_mutex_put(&dns_ptr -> nx_dns_mutex); + return(status); + } + /* Limit the timeout to NX_DNS_MAX_RETRANS_TIMEOUT. */ if (wait_option > NX_DNS_MAX_RETRANS_TIMEOUT) { @@ -3042,6 +3032,9 @@ UINT i; if (status == NX_SUCCESS) { + /* Unbind the socket. */ + nx_udp_socket_unbind(&(dns_ptr -> nx_dns_socket)); + /* Release the mutex */ tx_mutex_put(&dns_ptr -> nx_dns_mutex); @@ -3057,6 +3050,9 @@ UINT i; wait_option = NX_DNS_MAX_RETRANS_TIMEOUT; } + /* Unbind the socket. */ + nx_udp_socket_unbind(&(dns_ptr -> nx_dns_socket)); + /* Release protection. */ tx_mutex_put(&dns_ptr -> nx_dns_mutex); @@ -3070,7 +3066,7 @@ UINT i; /* FUNCTION RELEASE */ /* */ /* _nx_dns_send_query_by_address PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -3123,6 +3119,12 @@ UINT i; /* status check to improve */ /* buffer bound check, */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* improved id generation, */ +/* improved the logic of */ +/* receiving dns response, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_send_query_by_address(NX_DNS *dns_ptr, ULONG dns_server, UCHAR *ip_question, UCHAR *host_name_ptr, @@ -3133,18 +3135,11 @@ UINT status; USHORT answerCount; UCHAR *data_ptr; NX_PACKET *packet_ptr; -NX_PACKET *receive_packet_ptr; -USHORT id; +NX_PACKET *receive_packet_ptr; UINT ip_question_size; UINT name_size; UINT resource_type; UINT resource_size; -#ifdef NX_DNS_CLIENT_CLEAR_QUEUE -ULONG start_time; -ULONG current_time; -ULONG elapsed_time; -ULONG time_remaining; -#endif #ifdef NX_DNS_CACHE_ENABLE ULONG rr_ttl; #endif /* NX_DNS_CACHE_ENABLE */ @@ -3157,10 +3152,6 @@ ULONG rr_ttl; return(NX_DNS_SIZE_ERROR); } - /* Create a random DNS query ID based on the first word of an IP address (or only - word for IPv4 addresses). */ - id = (USHORT)(dns_server ^ tx_time_get()); - /* Allocate a packet. */ status = nx_packet_allocate(dns_ptr -> nx_dns_packet_pool_ptr, &packet_ptr, NX_UDP_PACKET, NX_DNS_PACKET_ALLOCATE_TIMEOUT); @@ -3173,7 +3164,7 @@ ULONG rr_ttl; } /* Create a request */ - status = _nx_dns_new_packet_create(dns_ptr, packet_ptr, id, ip_question, NX_DNS_RR_TYPE_PTR); + status = _nx_dns_new_packet_create(dns_ptr, packet_ptr, ip_question, NX_DNS_RR_TYPE_PTR); /* Check the DNS packet create status. */ if (status != NX_SUCCESS) @@ -3185,25 +3176,16 @@ ULONG rr_ttl; return(status); } - /* First clear off any 'old' DNS packets. */ - -#ifdef NX_DNS_CLIENT_CLEAR_QUEUE - /* We will use the time spent sleeping to clear broadcast DNS packets from a previous query - from the DNS receive queue. This will prevent ensure the most recent DNS response is - processed and avoid the situation of valid DNS response packets overflowing the DNS socket - queue. */ - - receive_packet_ptr = NX_NULL; - - - /* Remove all packets from the DNS Client receive queue. */ - status = NX_SUCCESS;; + from the DNS receive queue. This will prevent ensure the most recent DNS response is + processed and avoid the situation of valid DNS response packets overflowing the DNS socket + queue. */ +#ifdef NX_DNS_CLIENT_CLEAR_QUEUE do { /* Is there any packets on the queue? */ - status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), &receive_packet_ptr, 1 ); + status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), &receive_packet_ptr, NX_NO_WAIT); /* Yes, we received a packet on the DNS port! */ if (status == NX_SUCCESS) @@ -3214,15 +3196,12 @@ ULONG rr_ttl; } /* Keep checking till the queue becomes empty. */ - - } while(status == NX_SUCCESS); - -#endif + } while(status == NX_SUCCESS); +#endif /* NX_DNS_CLIENT_CLEAR_QUEUE */ /* Send the DNS packet out. */ status = nx_udp_socket_send(&dns_ptr -> nx_dns_socket, packet_ptr, dns_server, NX_DNS_PORT); - /* Check the completion of the send. */ if (status != NX_SUCCESS) { @@ -3233,69 +3212,8 @@ ULONG rr_ttl; return status; } -#ifdef NX_DNS_CLIENT_CLEAR_QUEUE - - /* Initialize the value. */ - elapsed_time = 0; - time_remaining = wait_option; - - /* If waiting for the DNS 'sleep' interval, check for packets arriving on the queue. */ - while(time_remaining > 0) - { - - start_time = tx_time_get(); - - /* Check if some of these packet are intended for other hosts. */ - status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), &receive_packet_ptr, time_remaining); - - /* Determine if this one is for us. */ - if (status == NX_SUCCESS) - { - - /* Check the ID from the Client query matches the ID in the received DNS packet. */ - if (_nx_dns_network_to_short_convert(receive_packet_ptr -> nx_packet_prepend_ptr + NX_DNS_ID_OFFSET) == id) - { - /* They do. We can stop receiving packets and process this one. */ - break; - } - else - { - /* They do not. Discard the packet! */ - nx_packet_release(receive_packet_ptr); - } - } - - /* Get the current time. */ - current_time = tx_time_get(); - - /* Has the time wrapped? */ - if (current_time >= start_time) - { - /* No, simply subtract to get the elapsed time. */ - elapsed_time = current_time - start_time; - } - else - { - /* Yes it has. Time has rolled over the 32-bit boundary. */ - elapsed_time = (((ULONG) 0xFFFFFFFF) - start_time) + current_time; - } - - /* Update the time remaining by subtracting the elapsed time. */ - if (time_remaining > elapsed_time) - { - time_remaining -= elapsed_time; - } - else - { - time_remaining = 0; - } - } - -#else - - /* Otherwise, wait for a DNS response UDP packet. */ - status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), &receive_packet_ptr, wait_option); -#endif + /* Wait for a DNS response. */ + status = _nx_dns_response_receive(dns_ptr, &receive_packet_ptr, wait_option); /* Check status. */ if (status == NX_SUCCESS) @@ -3320,7 +3238,7 @@ ULONG rr_ttl; } /* Packet is long enough. Check the IDs in the DNS header match. */ - if (_nx_dns_network_to_short_convert(receive_packet_ptr -> nx_packet_prepend_ptr + NX_DNS_ID_OFFSET) != id) + if (_nx_dns_network_to_short_convert(receive_packet_ptr -> nx_packet_prepend_ptr + NX_DNS_ID_OFFSET) != dns_ptr -> nx_dns_transmit_id) { /* No; Release the packet. */ @@ -3553,7 +3471,7 @@ ULONG rr_ttl; /* FUNCTION RELEASE */ /* */ /* _nx_dns_send_query_get_rdata_by_name PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -3583,7 +3501,7 @@ ULONG rr_ttl; /* _nx_dns_new_packet_create Create new DNS packet */ /* nx_packet_release Release packet */ /* nx_udp_socket_send Send DNS UDP packet */ -/* nx_udp_socket_receive Receive DNS UDP packet */ +/* _nx_dns_response_receive Receive DNS response */ /* _nx_dns_response_process Process the DNS respondse */ /* */ /* CALLED BY */ @@ -3598,6 +3516,11 @@ ULONG rr_ttl; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* improved the logic of */ +/* receiving dns response, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_send_query_get_rdata_by_name(NX_DNS *dns_ptr, ULONG dns_server_address, @@ -3608,17 +3531,7 @@ static UINT _nx_dns_send_query_get_rdata_by_name(NX_DNS *dns_ptr, ULONG dns_serv UINT status; NX_PACKET *packet_ptr; NX_PACKET *receive_packet_ptr; -USHORT id; -#ifdef NX_DNS_CLIENT_CLEAR_QUEUE -ULONG start_time; -ULONG current_time; -ULONG elapsed_time; -ULONG time_remaining; -#endif - /* Generate a random ID based on host name. */ - id = (USHORT)((ALIGN_TYPE) host_name ^ tx_time_get()); - /* Allocate a packet. */ status = nx_packet_allocate(dns_ptr -> nx_dns_packet_pool_ptr, &packet_ptr, NX_UDP_PACKET, NX_DNS_PACKET_ALLOCATE_TIMEOUT); @@ -3631,7 +3544,7 @@ ULONG time_remaining; } /* Create a request */ - status = _nx_dns_new_packet_create(dns_ptr, packet_ptr, id, host_name, (USHORT)dns_record_type); + status = _nx_dns_new_packet_create(dns_ptr, packet_ptr, host_name, (USHORT)dns_record_type); /* Check the DNS packet create status. */ if (status != NX_SUCCESS) @@ -3643,21 +3556,16 @@ ULONG time_remaining; return(status); } - /* First clear off any 'old' DNS packets. */ -#ifdef NX_DNS_CLIENT_CLEAR_QUEUE - - /* Initialize the value */ - receive_packet_ptr = NX_NULL; - - /* Remove all packets from the DNS Client receive queue. */ - status = NX_SUCCESS;; + /* We will use the time spent sleeping to clear broadcast DNS packets from a previous query + from the DNS receive queue. This will prevent ensure the most recent DNS response is + processed and avoid the situation of valid DNS response packets overflowing the DNS socket + queue. */ +#ifdef NX_DNS_CLIENT_CLEAR_QUEUE do { - start_time = tx_time_get(); - /* Is there any packets on the queue? */ - status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), &receive_packet_ptr, 1 ); + status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), &receive_packet_ptr, NX_NO_WAIT); /* Yes, we received a packet on the DNS port! */ if (status == NX_SUCCESS) @@ -3668,9 +3576,8 @@ ULONG time_remaining; } /* Keep checking till the queue becomes empty. */ - - } while(status == NX_SUCCESS); -#endif + } while(status == NX_SUCCESS); +#endif /* NX_DNS_CLIENT_CLEAR_QUEUE */ /* Send the DNS packet out. */ status = nx_udp_socket_send(&dns_ptr -> nx_dns_socket, packet_ptr, dns_server_address, NX_DNS_PORT); @@ -3685,71 +3592,8 @@ ULONG time_remaining; return status; } -#ifdef NX_DNS_CLIENT_CLEAR_QUEUE - - /* Initialize the value. */ - elapsed_time = 0; - time_remaining = wait_option; - - /* If waiting for the DNS 'sleep' interval, check for packets arriving on the queue. */ - while(time_remaining > 0) - { - - start_time = tx_time_get(); - - /* Check if some of these packet are intended for other hosts. */ - status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), &receive_packet_ptr, time_remaining); - - /* Determine if this one is for us. */ - if (status == NX_SUCCESS) - { - - /* Check the IDs in the DNS header match. */ - if (_nx_dns_network_to_short_convert(receive_packet_ptr -> nx_packet_prepend_ptr + NX_DNS_ID_OFFSET) == id) - { - - /* They do. We can stop receiving packets and process this one. */ - break; - } - else - { - - /* They do not. Discard the packet! */ - nx_packet_release(receive_packet_ptr); - } - } - - /* Get the current time. */ - current_time = tx_time_get(); - - /* Has the time wrapped? */ - if (current_time >= start_time) - { - /* No, simply subtract to get the elapsed time. */ - elapsed_time = current_time - start_time; - } - else - { - - /* Yes it has. Time has rolled over the 32-bit boundary. */ - elapsed_time = (((ULONG) 0xFFFFFFFF) - start_time) + current_time; - } - - /* Update the time remaining with the elapsed time. */ - if (time_remaining > elapsed_time) - { - time_remaining -= elapsed_time; - } - else - time_remaining = 0; - - } - -#else - - /* Otherwise, wait for a DNS response UDP packet. */ - status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), &receive_packet_ptr, wait_option); -#endif + /* Wait for a DNS response. */ + status = _nx_dns_response_receive(dns_ptr, &receive_packet_ptr, wait_option); /* Check status. */ if (status == NX_SUCCESS) @@ -3771,6 +3615,127 @@ ULONG time_remaining; return(status); } +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nx_dns_response_receive PORTABLE C */ +/* 6.1.4 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function receives dns response. */ +/* */ +/* INPUT */ +/* */ +/* dns_ptr Pointer to DNS instance */ +/* packet_ptr Pointer to UDP packet pointer */ +/* wait_option Timeout value */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* tx_time_get Get the system time */ +/* nx_udp_socket_receive Receive DNS UDP packet */ +/* nx_packet_release Release packet */ +/* */ +/* CALLED BY */ +/* */ +/* _nx_dns_send_query_get_rdata_by_name Get the resource data by name */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 02-02-2021 Yuxin Zhou Initial Version 6.1.4 */ +/* */ +/**************************************************************************/ +static UINT _nx_dns_response_receive(NX_DNS *dns_ptr, NX_PACKET **packet_ptr, ULONG wait_option) +{ + +UINT status; +ULONG start_time; +ULONG current_time; +ULONG elapsed_time; +ULONG time_remaining; + + + /* Initialize the value. */ + start_time = tx_time_get(); + elapsed_time = 0; + time_remaining = wait_option; + + do + { + + /* Receive udp packet. */ + status = nx_udp_socket_receive(&(dns_ptr -> nx_dns_socket), packet_ptr, time_remaining); + + /* Determine if this one is for us. */ + if (status == NX_SUCCESS) + { + + /* Check the IDs in the DNS header match. */ + if (((*packet_ptr) -> nx_packet_length >= sizeof(USHORT)) && + (_nx_dns_network_to_short_convert((*packet_ptr) -> nx_packet_prepend_ptr + NX_DNS_ID_OFFSET) == dns_ptr -> nx_dns_transmit_id)) + { + + /* They do. We can stop receiving packets and process this one. */ + break; + } + else + { + + /* They do not. Discard the packet! */ + nx_packet_release((*packet_ptr)); + + /* Continue to receive next packet. */ + if (time_remaining == 0) + { + continue; + } + } + } + + /* Get the current time. */ + current_time = tx_time_get(); + + /* Has the time wrapped? */ + if (current_time >= start_time) + { + + /* No, simply subtract to get the elapsed time. */ + elapsed_time = current_time - start_time; + } + else + { + + /* Yes it has. Time has rolled over the 32-bit boundary. */ + elapsed_time = (((ULONG) 0xFFFFFFFF) - start_time) + current_time; + } + + /* Update the time remaining with the elapsed time. */ + if (time_remaining > elapsed_time) + { + time_remaining -= elapsed_time; + } + else + { + time_remaining = 0; + } + + } while(time_remaining > 0); + + /* Return completion status. */ + return(status); +} + /**************************************************************************/ /* */ @@ -4085,7 +4050,7 @@ UINT name_size; /* FUNCTION RELEASE */ /* */ /* _nx_dns_process_a_type PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4134,6 +4099,9 @@ UINT name_size; /* updated resource get APIs to*/ /* improve buffer bound check, */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_process_a_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *data_ptr, @@ -4222,7 +4190,7 @@ ULONG rr_ttl; /* Get data address and check if it is valid. */ data_ptr = _nx_dns_resource_data_address_get(data_ptr, packet_ptr); - if (!data_ptr) + if ((!data_ptr) || ((data_ptr + sizeof(ULONG)) > packet_ptr -> nx_packet_append_ptr)) { /* Return! */ @@ -4335,7 +4303,12 @@ ULONG rr_ttl; continue; } - if((memcmp(ns_entry -> nx_dns_ns_hostname_ptr, &temp_string_buffer[0], name_size)) == 0) + /* The nx_dns_ns_hostname_ptr is set internally with null termination. */ + status = _nx_utility_string_length_check((CHAR *)(ns_entry -> nx_dns_ns_hostname_ptr), &data_length, name_size); + + if((status == NX_SUCCESS) && + (data_length == name_size) && + ((memcmp(ns_entry -> nx_dns_ns_hostname_ptr, &temp_string_buffer[0], name_size)) == 0)) { /* This A type record contains the IPv4 address for the NS entry. */ @@ -4354,7 +4327,7 @@ ULONG rr_ttl; /* Get data address and check if it is valid. */ data_ptr = _nx_dns_resource_data_address_get(data_ptr, packet_ptr); - if (!data_ptr) + if ((!data_ptr) || ((data_ptr + sizeof(ULONG)) > packet_ptr -> nx_packet_append_ptr)) { /* Return! */ @@ -4421,7 +4394,12 @@ ULONG rr_ttl; continue; } - if((memcmp(mx_entry -> nx_dns_mx_hostname_ptr, &temp_string_buffer[0], name_size)) == 0) + /* The nx_dns_mx_hostname_ptr is set internally with null termination. */ + status = _nx_utility_string_length_check((CHAR *)(mx_entry -> nx_dns_mx_hostname_ptr), &data_length, name_size); + + if((status == NX_SUCCESS) && + (data_length == name_size) && + ((memcmp(mx_entry -> nx_dns_mx_hostname_ptr, &temp_string_buffer[0], name_size)) == 0)) { /* This A type record contains the IPv4 address for the MX entry. */ @@ -4440,7 +4418,7 @@ ULONG rr_ttl; /* Get data address and check if it is valid. */ data_ptr = _nx_dns_resource_data_address_get(data_ptr, packet_ptr); - if (!data_ptr) + if ((!data_ptr) || ((data_ptr + sizeof(ULONG)) > packet_ptr -> nx_packet_append_ptr)) { /* Return! */ @@ -4506,7 +4484,12 @@ ULONG rr_ttl; continue; } - if((memcmp(srv_entry -> nx_dns_srv_hostname_ptr, &temp_string_buffer[0], name_size)) == 0) + /* The nx_dns_srv_hostname_ptr is set internally with null termination. */ + status = _nx_utility_string_length_check((CHAR *)(srv_entry -> nx_dns_srv_hostname_ptr), &data_length, name_size); + + if((status == NX_SUCCESS) && + (data_length == name_size) && + ((memcmp(srv_entry -> nx_dns_srv_hostname_ptr, &temp_string_buffer[0], name_size)) == 0)) { /* This A type record contains the IPv4 address for the MX entry. */ @@ -4525,7 +4508,7 @@ ULONG rr_ttl; /* Get data address and check if it is valid. */ data_ptr = _nx_dns_resource_data_address_get(data_ptr, packet_ptr); - if (!data_ptr) + if ((!data_ptr) || ((data_ptr + sizeof(ULONG)) > packet_ptr -> nx_packet_append_ptr)) { /* Return! */ @@ -4563,7 +4546,7 @@ ULONG rr_ttl; /* FUNCTION RELEASE */ /* */ /* _nx_dns_process_aaaa_type PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4609,6 +4592,9 @@ ULONG rr_ttl; /* updated resource get APIs to*/ /* improve buffer bound check, */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_process_aaaa_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, @@ -4705,7 +4691,7 @@ ULONG rr_ttl; /* Update the pointer to the ipv6 address. */ data_ptr = _nx_dns_resource_data_address_get(data_ptr, packet_ptr); - if (!data_ptr) + if ((!data_ptr) || ((data_ptr + (4 * sizeof(ULONG))) > packet_ptr -> nx_packet_append_ptr)) { /* Return! */ @@ -4980,7 +4966,7 @@ ULONG rr_ttl; /* FUNCTION RELEASE */ /* */ /* _nx_dns_process_txt_type PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5023,6 +5009,9 @@ ULONG rr_ttl; /* updated resource get APIs to*/ /* improve buffer bound check, */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_process_txt_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *data_ptr, @@ -5096,7 +5085,7 @@ ULONG rr_ttl; text_data_length = (UINT) (*data_ptr++); /* Judge the resource data buffer space. */ - if(text_data_length > buffer_size - 1) + if ((text_data_length > buffer_size - 1) || ((data_ptr + text_data_length) > packet_ptr -> nx_packet_append_ptr)) { /* Return error, and release the packet in repsonse*/ @@ -5211,10 +5200,11 @@ ULONG rr_ttl; /* updated resource get APIs to*/ /* improve buffer bound check, */ /* resulting in version 6.1 */ -/* 12-31-2020 Yuxin Zhou Updated input parameter of the*/ -/* API to get the real size of */ -/* resource name, resulting in */ -/* version 6.1.3 */ +/* 12-31-2020 Yuxin Zhou Modified comment(s), updated */ +/* input parameter of the API */ +/* to get the real size of */ +/* resource name, */ +/* resulting in version 6.1.3 */ /* */ /**************************************************************************/ static UINT _nx_dns_process_ns_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *data_ptr, @@ -5371,7 +5361,7 @@ ULONG rr_ttl; /* FUNCTION RELEASE */ /* */ /* _nx_dns_process_mx_type PORTABLE C */ -/* 6.1.3 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5419,10 +5409,14 @@ ULONG rr_ttl; /* updated resource get APIs to*/ /* improve buffer bound check, */ /* resulting in version 6.1 */ -/* 12-31-2020 Yuxin Zhou Updated input parameter of the*/ -/* API to get the real size of */ -/* resource name, resulting in */ -/* version 6.1.3 */ +/* 12-31-2020 Yuxin Zhou Modified comment(s), updated */ +/* input parameter of the API */ +/* to get the real size of */ +/* resource name, */ +/* resulting in version 6.1.3 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_process_mx_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *data_ptr, @@ -5487,7 +5481,7 @@ UINT size; /* Update the pointer to point at the resource data. */ data_ptr = _nx_dns_resource_data_address_get(data_ptr, packet_ptr); - if (!data_ptr) + if ((!data_ptr) || ((data_ptr + sizeof(USHORT)) >= packet_ptr -> nx_packet_append_ptr)) { /* Return! */ @@ -5606,7 +5600,7 @@ UINT size; /* FUNCTION RELEASE */ /* */ /* _nx_dns_process_srv_type PORTABLE C */ -/* 6.1.3 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5654,10 +5648,14 @@ UINT size; /* updated resource get APIs to*/ /* improve buffer bound check, */ /* resulting in version 6.1 */ -/* 12-31-2020 Yuxin Zhou Updated input parameter of the*/ -/* API to get the real size of */ -/* resource name, resulting in */ -/* version 6.1.3 */ +/* 12-31-2020 Yuxin Zhou Modified comment(s), updated */ +/* input parameter of the API */ +/* to get the real size of */ +/* resource name, */ +/* resulting in version 6.1.3 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_process_srv_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *data_ptr, UCHAR **buffer_prepend_ptr, @@ -5723,7 +5721,9 @@ UINT size; /* Update the pointer to point at the resource data. */ data_ptr = _nx_dns_resource_data_address_get(data_ptr, packet_ptr); - if (!data_ptr) + + /* Plus 6 for 2 bytes priority, 2 bytes weight and 2 bytes port. */ + if ((!data_ptr) || ((data_ptr + 6) >= packet_ptr -> nx_packet_append_ptr)) { /* Return! */ @@ -5858,7 +5858,7 @@ UINT size; /* FUNCTION RELEASE */ /* */ /* _nx_dns_process_soa_type PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5905,6 +5905,9 @@ UINT size; /* updated resource get APIs to*/ /* improve buffer bound check, */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_process_soa_type(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *data_ptr, @@ -6039,7 +6042,8 @@ ULONG rr_ttl; /* Get name size */ name_size = _nx_dns_name_size_calculate(data_ptr, packet_ptr); - if (!name_size) + /* 20 bytes for 4 bytes serial, 4 bytes refresh, 4 bytes retry, 4 bytes expire and 4 bytes minmum. */ + if ((!name_size) || ((data_ptr + name_size + 20) > packet_ptr -> nx_packet_append_ptr)) { /* Return! */ return(NX_DNS_MALFORMED_PACKET); @@ -6290,7 +6294,7 @@ UINT _nx_dns_host_by_address_get(NX_DNS *dns_ptr, ULONG dns_address, UCHAR *hos /* FUNCTION RELEASE */ /* */ /* _nx_dns_host_by_address_get_internal PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6319,6 +6323,8 @@ UINT _nx_dns_host_by_address_get(NX_DNS *dns_ptr, ULONG dns_address, UCHAR *hos /* query packet */ /* tx_mutex_get Get DNS protection mutex */ /* tx_mutex_put Release DNS protection mutex */ +/* nx_udp_socket_bind Bind DNS UDP socket to port */ +/* nx_udp_socket_unbind Unbind DNS UDP socket */ /* */ /* CALLED BY */ /* */ @@ -6333,6 +6339,9 @@ UINT _nx_dns_host_by_address_get(NX_DNS *dns_ptr, ULONG dns_address, UCHAR *hos /* the timeout of first query, */ /* verified memcpy use cases, */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), and */ +/* randomized the source port, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_host_by_address_get_internal(NX_DNS *dns_ptr, ULONG host_address, UCHAR *host_name_ptr, @@ -6421,6 +6430,18 @@ UINT length, index; } #endif /*NX_DNS_CACHE_ENABLE. */ + /* Bind the UDP socket to random port for each query. */ + status = nx_udp_socket_bind(&(dns_ptr -> nx_dns_socket), NX_ANY_PORT, TX_WAIT_FOREVER); + + /* Check status. */ + if (status != TX_SUCCESS) + { + + /* Release the DNS Client lock. */ + tx_mutex_put(&dns_ptr -> nx_dns_mutex); + return(status); + } + /* Limit the timeout to NX_DNS_MAX_RETRANS_TIMEOUT. */ if (wait_option > NX_DNS_MAX_RETRANS_TIMEOUT) { @@ -6445,6 +6466,9 @@ UINT length, index; if (status == NX_SUCCESS) { + /* Unbind the socket. */ + nx_udp_socket_unbind(&(dns_ptr -> nx_dns_socket)); + /* Release the mutex */ tx_mutex_put(&dns_ptr -> nx_dns_mutex); @@ -6460,6 +6484,9 @@ UINT length, index; wait_option = NX_DNS_MAX_RETRANS_TIMEOUT; } + /* Unbind the socket. */ + nx_udp_socket_unbind(&(dns_ptr -> nx_dns_socket)); + /* Release protection. */ tx_mutex_put(&(dns_ptr -> nx_dns_mutex)); @@ -6473,7 +6500,7 @@ UINT length, index; /* FUNCTION RELEASE */ /* */ /* _nx_dns_new_packet_create PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6487,7 +6514,6 @@ UINT length, index; /* */ /* dns_ptr Pointer to DNS instance */ /* packet_ptr Packet allocated for message */ -/* id DNS Client Identification */ /* name Question e.g. host name */ /* type DNS message type e.g. A, AAAA */ /* */ @@ -6515,12 +6541,18 @@ UINT length, index; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), and */ +/* improved id generation, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ -static UINT _nx_dns_new_packet_create(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, USHORT id, UCHAR *name, USHORT type) +static UINT _nx_dns_new_packet_create(NX_DNS *dns_ptr, NX_PACKET *packet_ptr, UCHAR *name, USHORT type) { +USHORT id; +UINT size; -UINT size; + /* Generate a random ID based on name. */ + id = (USHORT)NX_RAND(); /* Add the DNS header. */ size = _nx_dns_header_create(packet_ptr -> nx_packet_append_ptr, id, NX_DNS_QUERY_FLAGS); @@ -6826,7 +6858,7 @@ UINT count = 1; /* FUNCTION RELEASE */ /* */ /* _nx_dns_name_string_unencode PORTABLE C */ -/* 6.1.3 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6868,6 +6900,9 @@ UINT count = 1; /* infinite loop in name */ /* compression, resulting in */ /* version 6.1.3 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_name_string_unencode(NX_PACKET *packet_ptr, UCHAR *data, UCHAR *buffer, UINT buffer_size) @@ -6887,9 +6922,19 @@ UINT pointer_count = 0; /* As long as there is space in the buffer and we haven't found a zero terminating label */ - while (*character != '\0') + while (1) { + if (character >= packet_ptr -> nx_packet_append_ptr) + { + return(0); + } + + if (*character == '\0') + { + break; + } + /* Check the buffer size. */ if (buffer_size > length) { @@ -6905,6 +6950,11 @@ UINT pointer_count = 0; while ((buffer_size > length) && (label_size > 0)) { + if ((character >= packet_ptr -> nx_packet_append_ptr) || (*character == '\0')) + { + return(0); + } + *buffer++ = *character++; length++; label_size--; @@ -6918,6 +6968,10 @@ UINT pointer_count = 0; { /* Message compression. */ + if (character >= packet_ptr -> nx_packet_append_ptr) + { + return(0); + } /* Get the offset. */ offset = ((label_size & NX_DNS_LABEL_MAX) << 8) + *character; @@ -7085,7 +7139,7 @@ UINT size = 0; /* FUNCTION RELEASE */ /* */ /* _nx_dns_resource_name_real_size_calculate PORTABLE C */ -/* 6.1.3 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -7125,6 +7179,9 @@ UINT size = 0; /* infinite loop in name */ /* compression, resulting in */ /* version 6.1.3 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* packet length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_dns_resource_name_real_size_calculate(UCHAR *data, UINT start, UINT data_length) @@ -7134,13 +7191,24 @@ UCHAR *character = data + start; UINT length = 0; UINT offset; UINT pointer_count = 0; +UINT labelSize; /* As long as there is space in the buffer and we haven't found a zero terminating label */ - while (*character != '\0') + while (1) { - UINT labelSize = *character++; + if (character >= (data + data_length)) + { + return(0); + } + + if (*character == '\0') + { + break; + } + + labelSize = *character++; /* Is this a compression pointer or a count. */ if (labelSize <= NX_DNS_LABEL_MAX) @@ -7149,6 +7217,12 @@ UINT pointer_count = 0; /* Simple count, check for space and copy the label. */ while (labelSize > 0) { + + if (character >= (data + data_length)) + { + return(0); + } + character++; length++; labelSize--; @@ -7160,6 +7234,11 @@ UINT pointer_count = 0; else if ((labelSize & NX_DNS_COMPRESS_MASK) == NX_DNS_COMPRESS_VALUE) { + if (character >= (data + data_length)) + { + return(0); + } + /* Get the offset. */ offset = ((labelSize & NX_DNS_LABEL_MAX) << 8) + *character; diff --git a/addons/DNS/nx_dns.h b/addons/dns/nx_dns.h similarity index 100% rename from addons/DNS/nx_dns.h rename to addons/dns/nx_dns.h diff --git a/addons/FTP/nx_ftp.h b/addons/ftp/nx_ftp.h similarity index 100% rename from addons/FTP/nx_ftp.h rename to addons/ftp/nx_ftp.h diff --git a/addons/FTP/nx_ftp_client.c b/addons/ftp/nx_ftp_client.c similarity index 100% rename from addons/FTP/nx_ftp_client.c rename to addons/ftp/nx_ftp_client.c diff --git a/addons/FTP/nx_ftp_client.h b/addons/ftp/nx_ftp_client.h similarity index 100% rename from addons/FTP/nx_ftp_client.h rename to addons/ftp/nx_ftp_client.h diff --git a/addons/FTP/nx_ftp_server.c b/addons/ftp/nx_ftp_server.c similarity index 100% rename from addons/FTP/nx_ftp_server.c rename to addons/ftp/nx_ftp_server.c diff --git a/addons/FTP/nx_ftp_server.h b/addons/ftp/nx_ftp_server.h similarity index 100% rename from addons/FTP/nx_ftp_server.h rename to addons/ftp/nx_ftp_server.h diff --git a/addons/HTTP/nx_http.h b/addons/http/nx_http.h similarity index 100% rename from addons/HTTP/nx_http.h rename to addons/http/nx_http.h diff --git a/addons/HTTP/nx_http_client.c b/addons/http/nx_http_client.c similarity index 100% rename from addons/HTTP/nx_http_client.c rename to addons/http/nx_http_client.c diff --git a/addons/HTTP/nx_http_client.h b/addons/http/nx_http_client.h similarity index 100% rename from addons/HTTP/nx_http_client.h rename to addons/http/nx_http_client.h diff --git a/addons/HTTP/nx_http_server.c b/addons/http/nx_http_server.c similarity index 100% rename from addons/HTTP/nx_http_server.c rename to addons/http/nx_http_server.c diff --git a/addons/HTTP/nx_http_server.h b/addons/http/nx_http_server.h similarity index 100% rename from addons/HTTP/nx_http_server.h rename to addons/http/nx_http_server.h diff --git a/addons/POP3/nx_pop3.h b/addons/pop3/nx_pop3.h similarity index 100% rename from addons/POP3/nx_pop3.h rename to addons/pop3/nx_pop3.h diff --git a/addons/POP3/nx_pop3_client.c b/addons/pop3/nx_pop3_client.c similarity index 99% rename from addons/POP3/nx_pop3_client.c rename to addons/pop3/nx_pop3_client.c index fb231c3..6eaa6de 100644 --- a/addons/POP3/nx_pop3_client.c +++ b/addons/pop3/nx_pop3_client.c @@ -2018,7 +2018,7 @@ UINT pid_index; /* FUNCTION RELEASE */ /* */ /* _nx_pop3_parse_response PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2064,6 +2064,9 @@ UINT pid_index; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* buffer length verification, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ void _nx_pop3_parse_response(CHAR *buffer, UINT argument_index, UINT buffer_length, CHAR *argument, UINT argument_length, @@ -2132,7 +2135,7 @@ UINT argument_char_count; } /* Are we at the end of the buffer? */ - if (i == buffer_length) + if ((i == buffer_length) && (buffer_length >= 2)) { /* Yes, is there a line terminator? */ diff --git a/addons/POP3/nx_pop3_client.h b/addons/pop3/nx_pop3_client.h similarity index 100% rename from addons/POP3/nx_pop3_client.h rename to addons/pop3/nx_pop3_client.h diff --git a/addons/PPP/nx_ppp.c b/addons/ppp/nx_ppp.c similarity index 100% rename from addons/PPP/nx_ppp.c rename to addons/ppp/nx_ppp.c diff --git a/addons/PPP/nx_ppp.h b/addons/ppp/nx_ppp.h similarity index 100% rename from addons/PPP/nx_ppp.h rename to addons/ppp/nx_ppp.h diff --git a/addons/PPPoE/nx_pppoe_client.c b/addons/pppoe/nx_pppoe_client.c similarity index 100% rename from addons/PPPoE/nx_pppoe_client.c rename to addons/pppoe/nx_pppoe_client.c diff --git a/addons/PPPoE/nx_pppoe_client.h b/addons/pppoe/nx_pppoe_client.h similarity index 100% rename from addons/PPPoE/nx_pppoe_client.h rename to addons/pppoe/nx_pppoe_client.h diff --git a/addons/PPPoE/nx_pppoe_server.c b/addons/pppoe/nx_pppoe_server.c similarity index 98% rename from addons/PPPoE/nx_pppoe_server.c rename to addons/pppoe/nx_pppoe_server.c index 9736aba..71f4ad5 100644 --- a/addons/PPPoE/nx_pppoe_server.c +++ b/addons/pppoe/nx_pppoe_server.c @@ -2787,7 +2787,7 @@ NX_PPPOE_CLIENT_SESSION *client_session_ptr = NX_NULL; /* FUNCTION RELEASE */ /* */ /* _nx_pppoe_server_discovery_send PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2831,6 +2831,9 @@ NX_PPPOE_CLIENT_SESSION *client_session_ptr = NX_NULL; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), */ +/* fixed the compiler errors, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_pppoe_server_discovery_send(NX_PPPOE_SERVER *pppoe_server_ptr, NX_PPPOE_CLIENT_SESSION *client_session_ptr, UINT code) @@ -2916,7 +2919,7 @@ UCHAR *service_name_ptr; { /* Get the service name. */ - if (_nx_utility_string_length_check((const char *)(service_name_ptr), &tag_length, NX_MAX_STRING_LENGTH)) + if (_nx_utility_string_length_check((char *)(service_name_ptr), &tag_length, NX_MAX_STRING_LENGTH)) { nx_packet_release(packet_ptr); return(NX_PPPOE_SERVER_SERVICE_NAME_ERROR); @@ -3054,7 +3057,7 @@ UCHAR *service_name_ptr; { /* Calculate the Generic-Error string length. */ - if (_nx_utility_string_length_check((const char *)(client_session_ptr -> nx_pppoe_generic_error), &tag_length, NX_MAX_STRING_LENGTH)) + if (_nx_utility_string_length_check((char *)(client_session_ptr -> nx_pppoe_generic_error), &tag_length, NX_MAX_STRING_LENGTH)) { nx_packet_release(packet_ptr); return(NX_SIZE_ERROR); @@ -3178,7 +3181,7 @@ NX_IP_DRIVER driver_request; /* FUNCTION RELEASE */ /* */ /* _nx_pppoe_server_tag_process PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -3217,6 +3220,10 @@ NX_IP_DRIVER driver_request; /* packet length verification, */ /* verified memcpy use cases, */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), improved */ +/* string length verification, */ +/* fixed the compiler errors, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ static UINT _nx_pppoe_server_tag_process(NX_PPPOE_SERVER *pppoe_server_ptr, NX_PPPOE_CLIENT_SESSION *client_session_ptr, UINT code, UCHAR *tag_ptr, ULONG length) @@ -3228,9 +3235,9 @@ UINT tag_index = 0; UINT tag_service_name_count = 0; UINT tag_service_name_valid = NX_FALSE; UINT service_name_index = 0; +UINT service_name_length; #ifdef NX_PPPOE_SERVER_SESSION_CONTROL_ENABLE UCHAR *service_name_ptr; -UINT service_name_length; #endif /* Initialize the value. */ @@ -3300,11 +3307,21 @@ UINT service_name_length; while (service_name_index < pppoe_server_ptr -> nx_pppoe_service_name_count) { + /* Get the length of service name. */ + if (_nx_utility_string_length_check((char *)(pppoe_server_ptr -> nx_pppoe_service_name[service_name_index]), + &service_name_length, tag_length)) + { + service_name_index++; + continue; + } + /* Compare the same service name with PPPoE Service Name. */ - if (!memcmp(tag_ptr + tag_index, (pppoe_server_ptr -> nx_pppoe_service_name[service_name_index]), tag_length)) + if ((service_name_length == tag_length) && + (!memcmp(tag_ptr + tag_index, (pppoe_server_ptr -> nx_pppoe_service_name[service_name_index]), tag_length))) { tag_service_name_valid = NX_TRUE; client_session_ptr -> nx_pppoe_service_name = pppoe_server_ptr -> nx_pppoe_service_name[service_name_index]; + client_session_ptr -> nx_pppoe_service_name_length = service_name_length; break; } service_name_index ++; @@ -3334,7 +3351,7 @@ UINT service_name_length; { /* Get the service name. */ - if (_nx_utility_string_length_check((const char *)(service_name_ptr), &service_name_length, NX_MAX_STRING_LENGTH)) + if (_nx_utility_string_length_check((char *)(service_name_ptr), &service_name_length, NX_MAX_STRING_LENGTH)) { return(NX_PPPOE_SERVER_SERVICE_NAME_ERROR); } @@ -3344,7 +3361,7 @@ UINT service_name_length; { tag_service_name_valid = NX_TRUE; } - else if ((tag_length != 0) && (service_name_length != 0)) + else if ((tag_length != 0) && (tag_length == service_name_length)) { /* Compare the service name. */ @@ -3380,8 +3397,17 @@ UINT service_name_length; while (service_name_index < pppoe_server_ptr -> nx_pppoe_service_name_count) { + /* Get the length of service name. */ + if (_nx_utility_string_length_check((char *)(pppoe_server_ptr -> nx_pppoe_service_name[service_name_index]), + &service_name_length, tag_length)) + { + service_name_index++; + continue; + } + /* Find the same service name. */ - if (!memcmp(tag_ptr + tag_index, (pppoe_server_ptr -> nx_pppoe_service_name[service_name_index]), tag_length)) + if ((service_name_length == tag_length) && + (!memcmp(tag_ptr + tag_index, (pppoe_server_ptr -> nx_pppoe_service_name[service_name_index]), tag_length))) { /* Update the information. */ @@ -3400,7 +3426,8 @@ UINT service_name_length; if (pppoe_server_ptr -> nx_pppoe_ac_name) { /* Check the access concentrator name. */ - if (memcmp(tag_ptr + tag_index, (pppoe_server_ptr -> nx_pppoe_ac_name), tag_length)) + if ((pppoe_server_ptr -> nx_pppoe_ac_name_length != tag_length) || + (memcmp(tag_ptr + tag_index, (pppoe_server_ptr -> nx_pppoe_ac_name), tag_length))) { return(NX_PPPOE_SERVER_AC_NAME_ERROR); @@ -3409,7 +3436,8 @@ UINT service_name_length; else { /* If user does not separately set Access Concentrator name, will use PPPoE server name as Access Concentrator name.*/ - if (memcmp(tag_ptr + tag_index, (pppoe_server_ptr -> nx_pppoe_name), tag_length)) + if ((pppoe_server_ptr -> nx_pppoe_name_length != tag_length) || + (memcmp(tag_ptr + tag_index, (pppoe_server_ptr -> nx_pppoe_name), tag_length))) { return(NX_PPPOE_SERVER_AC_NAME_ERROR); @@ -3957,7 +3985,7 @@ NX_PACKET *current_packet; /* FUNCTION RELEASE */ /* */ /* PppInitInd PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -3978,7 +4006,7 @@ NX_PACKET *current_packet; /* */ /* CALLS */ /* */ -/* nx_pppoe_server_service_name_set Set the service name */ +/* _nx_pppoe_server_service_name_set Set the service name */ /* */ /* CALLED BY */ /* */ @@ -3991,6 +4019,9 @@ NX_PACKET *current_packet; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), */ +/* fixed the compiler errors, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ VOID PppInitInd(UINT length, UCHAR *aData) @@ -4006,7 +4037,7 @@ VOID PppInitInd(UINT length, UCHAR *aData) { /* Clean the default service name. */ - nx_pppoe_server_service_name_set(_nx_pppoe_server_created_ptr, NX_NULL, 0); + _nx_pppoe_server_service_name_set(_nx_pppoe_server_created_ptr, NX_NULL, 0); } else { @@ -4015,7 +4046,7 @@ VOID PppInitInd(UINT length, UCHAR *aData) nx_pppoe_service_name[0] = aData; /* Set the default service name. */ - nx_pppoe_server_service_name_set(_nx_pppoe_server_created_ptr, nx_pppoe_service_name, 1); + _nx_pppoe_server_service_name_set(_nx_pppoe_server_created_ptr, nx_pppoe_service_name, 1); } } @@ -4212,7 +4243,7 @@ NX_PPPOE_CLIENT_SESSION *client_session_ptr; /* FUNCTION RELEASE */ /* */ /* PppCloseInd PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4232,7 +4263,7 @@ NX_PPPOE_CLIENT_SESSION *client_session_ptr; /* */ /* CALLS */ /* */ -/* nx_pppoe_server_session_terminate Terminate the PPPoE Session */ +/* _nx_pppoe_server_session_terminate Terminate the PPPoE Session */ /* */ /* CALLED BY */ /* */ @@ -4245,6 +4276,9 @@ NX_PPPOE_CLIENT_SESSION *client_session_ptr; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), */ +/* fixed the compiler errors, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ VOID PppCloseInd(UINT interfaceHandle, UCHAR *causeCode) @@ -4275,7 +4309,7 @@ VOID PppCloseInd(UINT interfaceHandle, UCHAR *causeCode) _nx_pppoe_server_created_ptr -> nx_pppoe_client_session[interfaceHandle].nx_pppoe_generic_error = causeCode; /* Send PADT to terminate the session. */ - nx_pppoe_server_session_terminate(_nx_pppoe_server_created_ptr, interfaceHandle); + _nx_pppoe_server_session_terminate(_nx_pppoe_server_created_ptr, interfaceHandle); /* Release the IP internal mutex. */ tx_mutex_put(&(_nx_pppoe_server_created_ptr -> nx_pppoe_ip_ptr -> nx_ip_protection)); @@ -4351,7 +4385,7 @@ VOID PppCloseCnf(UINT interfaceHandle) /* FUNCTION RELEASE */ /* */ /* PppTransmitDataCnf PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4385,6 +4419,9 @@ VOID PppCloseCnf(UINT interfaceHandle) /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), */ +/* fixed the compiler errors, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ VOID PppTransmitDataCnf(UINT interfaceHandle, UCHAR *data_ptr, UINT packet_id) @@ -4392,6 +4429,8 @@ VOID PppTransmitDataCnf(UINT interfaceHandle, UCHAR *data_ptr, UINT packet_id) NX_PACKET *packet_ptr; + NX_PARAMETER_NOT_USED(data_ptr); + /* Check to see if PPPoE instance is created. */ if ((_nx_pppoe_server_created_ptr == NX_NULL) || (_nx_pppoe_server_created_ptr -> nx_pppoe_id != NX_PPPOE_SERVER_ID)) @@ -4432,7 +4471,7 @@ NX_PACKET *packet_ptr; /* FUNCTION RELEASE */ /* */ /* PppReceiveDataInd PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4451,7 +4490,7 @@ NX_PACKET *packet_ptr; /* */ /* CALLS */ /* */ -/* nx_pppoe_server_session_send Send PPPoE session data */ +/* _nx_pppoe_server_session_send Send PPPoE session data */ /* */ /* CALLED BY */ /* */ @@ -4464,6 +4503,9 @@ NX_PACKET *packet_ptr; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), */ +/* fixed the compiler errors, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ VOID PppReceiveDataInd(UINT interfaceHandle, UINT data_length, UCHAR *data_ptr) @@ -4488,6 +4530,6 @@ VOID PppReceiveDataInd(UINT interfaceHandle, UINT data_length, UCHAR *data_ptr) return; /* Send data. */ - nx_pppoe_server_session_send(_nx_pppoe_server_created_ptr, interfaceHandle, data_ptr, data_length); + _nx_pppoe_server_session_send(_nx_pppoe_server_created_ptr, interfaceHandle, data_ptr, data_length); } #endif diff --git a/addons/PPPoE/nx_pppoe_server.h b/addons/pppoe/nx_pppoe_server.h similarity index 99% rename from addons/PPPoE/nx_pppoe_server.h rename to addons/pppoe/nx_pppoe_server.h index 859aa66..6587b23 100644 --- a/addons/PPPoE/nx_pppoe_server.h +++ b/addons/pppoe/nx_pppoe_server.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nx_pppoe_server.h PORTABLE C */ -/* 6.1 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -44,6 +44,9 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), */ +/* fixed the compiler errors, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ @@ -315,16 +318,6 @@ UINT nx_pppoe_server_session_terminate(NX_PPPOE_SERVER *pppoe_server_ptr, UIN UINT nx_pppoe_server_session_get(NX_PPPOE_SERVER *pppoe_server_ptr, UINT session_index, ULONG *client_mac_msw, ULONG *client_mac_lsw, ULONG *session_id); VOID _nx_pppoe_server_packet_deferred_receive(NX_PACKET *packet_ptr); -#ifdef NX_PPPOE_SERVER_SESSION_CONTROL_ENABLE -VOID PppInitInd(UINT length, UCHAR *aData); -VOID PppDiscoverCnf(UINT length, UCHAR *aData, UINT interfaceHandle); -VOID PppOpenCnf(UCHAR accept, UINT interfaceHandle); -VOID PppCloseInd(UINT interfaceHandle, UCHAR *causeCode); -VOID PppCloseCnf(UINT interfaceHandle); -VOID PppTransmitDataCnf(UINT interfaceHandle, UCHAR *aData, UINT packet_id); -VOID PppReceiveDataInd(UINT interfaceHandle, UINT length, UCHAR *aData); -#endif - #else UINT _nxe_pppoe_server_create(NX_PPPOE_SERVER *pppoe_server_ptr, UCHAR *name, NX_IP *ip_ptr, UINT interface_index, @@ -369,6 +362,16 @@ VOID _nx_pppoe_server_packet_deferred_receive(NX_PACKET *packet_ptr); #endif /* NX_PPPOE_SERVER_SOURCE_CODE */ +#ifdef NX_PPPOE_SERVER_SESSION_CONTROL_ENABLE +VOID PppInitInd(UINT length, UCHAR *aData); +VOID PppDiscoverCnf(UINT length, UCHAR *aData, UINT interfaceHandle); +VOID PppOpenCnf(UCHAR accept, UINT interfaceHandle); +VOID PppCloseInd(UINT interfaceHandle, UCHAR *causeCode); +VOID PppCloseCnf(UINT interfaceHandle); +VOID PppTransmitDataCnf(UINT interfaceHandle, UCHAR *aData, UINT packet_id); +VOID PppReceiveDataInd(UINT interfaceHandle, UINT length, UCHAR *aData); +#endif + /* Determine if a C++ compiler is being used. If so, complete the standard C conditional started above. */ #ifdef __cplusplus diff --git a/addons/SMTP/nx_smtp_client.c b/addons/smtp/nx_smtp_client.c similarity index 100% rename from addons/SMTP/nx_smtp_client.c rename to addons/smtp/nx_smtp_client.c diff --git a/addons/SMTP/nx_smtp_client.h b/addons/smtp/nx_smtp_client.h similarity index 100% rename from addons/SMTP/nx_smtp_client.h rename to addons/smtp/nx_smtp_client.h diff --git a/addons/SNMP/nx_des.c b/addons/snmp/nx_des.c similarity index 100% rename from addons/SNMP/nx_des.c rename to addons/snmp/nx_des.c diff --git a/addons/SNMP/nx_des.h b/addons/snmp/nx_des.h similarity index 100% rename from addons/SNMP/nx_des.h rename to addons/snmp/nx_des.h diff --git a/addons/SNMP/nx_sha1.c b/addons/snmp/nx_sha1.c similarity index 100% rename from addons/SNMP/nx_sha1.c rename to addons/snmp/nx_sha1.c diff --git a/addons/SNMP/nx_sha1.h b/addons/snmp/nx_sha1.h similarity index 100% rename from addons/SNMP/nx_sha1.h rename to addons/snmp/nx_sha1.h diff --git a/addons/SNMP/nx_snmp.c b/addons/snmp/nx_snmp.c similarity index 100% rename from addons/SNMP/nx_snmp.c rename to addons/snmp/nx_snmp.c diff --git a/addons/SNMP/nx_snmp.h b/addons/snmp/nx_snmp.h similarity index 100% rename from addons/SNMP/nx_snmp.h rename to addons/snmp/nx_snmp.h diff --git a/addons/SNTP/nx_sntp.h b/addons/sntp/nx_sntp.h similarity index 100% rename from addons/SNTP/nx_sntp.h rename to addons/sntp/nx_sntp.h diff --git a/addons/SNTP/nx_sntp_client.c b/addons/sntp/nx_sntp_client.c similarity index 100% rename from addons/SNTP/nx_sntp_client.c rename to addons/sntp/nx_sntp_client.c diff --git a/addons/SNTP/nx_sntp_client.h b/addons/sntp/nx_sntp_client.h similarity index 100% rename from addons/SNTP/nx_sntp_client.h rename to addons/sntp/nx_sntp_client.h diff --git a/addons/TELNET/nx_telnet.h b/addons/telnet/nx_telnet.h similarity index 100% rename from addons/TELNET/nx_telnet.h rename to addons/telnet/nx_telnet.h diff --git a/addons/TELNET/nx_telnet_client.c b/addons/telnet/nx_telnet_client.c similarity index 100% rename from addons/TELNET/nx_telnet_client.c rename to addons/telnet/nx_telnet_client.c diff --git a/addons/TELNET/nx_telnet_client.h b/addons/telnet/nx_telnet_client.h similarity index 100% rename from addons/TELNET/nx_telnet_client.h rename to addons/telnet/nx_telnet_client.h diff --git a/addons/TELNET/nx_telnet_server.c b/addons/telnet/nx_telnet_server.c similarity index 100% rename from addons/TELNET/nx_telnet_server.c rename to addons/telnet/nx_telnet_server.c diff --git a/addons/TELNET/nx_telnet_server.h b/addons/telnet/nx_telnet_server.h similarity index 100% rename from addons/TELNET/nx_telnet_server.h rename to addons/telnet/nx_telnet_server.h diff --git a/addons/TFTP/nx_tftp.h b/addons/tftp/nx_tftp.h similarity index 100% rename from addons/TFTP/nx_tftp.h rename to addons/tftp/nx_tftp.h diff --git a/addons/TFTP/nx_tftp_client.c b/addons/tftp/nx_tftp_client.c similarity index 100% rename from addons/TFTP/nx_tftp_client.c rename to addons/tftp/nx_tftp_client.c diff --git a/addons/TFTP/nx_tftp_client.h b/addons/tftp/nx_tftp_client.h similarity index 100% rename from addons/TFTP/nx_tftp_client.h rename to addons/tftp/nx_tftp_client.h diff --git a/addons/TFTP/nx_tftp_server.c b/addons/tftp/nx_tftp_server.c similarity index 100% rename from addons/TFTP/nx_tftp_server.c rename to addons/tftp/nx_tftp_server.c diff --git a/addons/TFTP/nx_tftp_server.h b/addons/tftp/nx_tftp_server.h similarity index 100% rename from addons/TFTP/nx_tftp_server.h rename to addons/tftp/nx_tftp_server.h diff --git a/common/inc/nx_api.h b/common/inc/nx_api.h index 14e2576..9ad7bff 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.1.3 */ +/* 6.1.4 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -57,6 +57,9 @@ /* string to unsigned integer, */ /* updated product constants, */ /* resulting in version 6.1.3 */ +/* 02-02-2021 Yuxin Zhou Modified comment(s), and */ +/* updated product constants, */ +/* resulting in version 6.1.4 */ /* */ /**************************************************************************/ @@ -365,7 +368,7 @@ VOID _nx_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, ULONG #define AZURE_RTOS_NETX #define NETX_MAJOR_VERSION 6 #define NETX_MINOR_VERSION 1 -#define NETX_PATCH_VERSION 3 +#define NETX_PATCH_VERSION 4 /* The following symbols are defined for backward compatibility reasons.*/ #define EL_PRODUCT_NETX diff --git a/samples/demo_netx_pppoe_server.c b/samples/demo_netx_pppoe_server.c index cfa6688..16eb746 100644 --- a/samples/demo_netx_pppoe_server.c +++ b/samples/demo_netx_pppoe_server.c @@ -371,6 +371,8 @@ void ppp_server_packet_send(NX_PACKET *packet_ptr) UINT interfaceHandle = 0; #ifdef NX_PPPOE_SERVER_SESSION_CONTROL_ENABLE +NX_PACKET *temp_packet = packet_ptr; + while(packet_ptr) { @@ -380,6 +382,8 @@ UINT interfaceHandle = 0; /* Move to the next packet structure. */ packet_ptr = packet_ptr -> nx_packet_next; } + + nx_packet_transmit_release(temp_packet); #else /* Directly Call PPPoE send function to send out the data through PPPoE module. */ nx_pppoe_server_session_packet_send(&pppoe_server, interfaceHandle, packet_ptr);