Release 6.1.8

This commit is contained in:
Yuxin Zhou 2021-07-28 07:24:17 +00:00
parent 6edc016bce
commit ddfb7fc423
11 changed files with 465 additions and 302 deletions

View File

@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
# Set up the project
project(netx
VERSION 6.0.0
LANGUAGES C ASM
)
@ -26,7 +25,11 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)
# Pick up the port specific stuff first
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN})
if(DEFINED NETX_CUSTOM_PORT)
add_subdirectory(${NETX_CUSTOM_PORT} netx_port)
else()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN})
endif()
# Then the common files
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common)

View File

@ -44,6 +44,7 @@ static UINT _nx_dhcp_extract_information(NX_DHCP *dhcp_ptr, NX_DHCP_INTER
static UINT _nx_dhcp_get_option_value(UCHAR *bootp_message, UINT option, ULONG *value, UINT length);
static UINT _nx_dhcp_add_option_value(UCHAR *bootp_message, UINT option, UINT size, ULONG value, UINT *index);
static UINT _nx_dhcp_add_option_string(UCHAR *bootp_message, UINT option, UINT size, UCHAR *value, UINT *index);
static UINT _nx_dhcp_add_option_parameter_request(NX_DHCP *dhcp_ptr, UCHAR *bootp_message, UINT *index);
static ULONG _nx_dhcp_update_timeout(ULONG timeout);
static ULONG _nx_dhcp_update_renewal_timeout(ULONG timeout);
static UCHAR *_nx_dhcp_search_buffer(UCHAR *option_message, UINT option, UINT length);
@ -70,8 +71,8 @@ static VOID _nx_dhcp_ip_conflict(NX_IP *ip_ptr, UINT interface_index, ULO
/* Define the Request string that specifies which options are to be added
to the DHCP Client discover request to the server. Additional options
(found in nx_dhcp.h) may be added after the last option. */
to the DHCP Client discover request to the server. Additional options
(found in nx_dhcp.h) may be added by calling nx_dhcp_user_option_request(). */
UCHAR _nx_dhcp_request_parameters[] = { NX_DHCP_OPTION_SUBNET_MASK,
NX_DHCP_OPTION_GATEWAYS,
@ -154,7 +155,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_create PORTABLE C */
/* 6.1 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -204,6 +205,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 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), and */
/* improved the code, */
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
UINT _nx_dhcp_create(NX_DHCP *dhcp_ptr, NX_IP *ip_ptr, CHAR *name_ptr)
@ -384,7 +388,7 @@ UINT label_length = 0;
/* Determine if the semaphore creation was successful. */
if (status != NX_SUCCESS)
if (status != TX_SUCCESS)
{
/* Delete the UDP socket. */
@ -403,7 +407,7 @@ UINT label_length = 0;
status = tx_mutex_create(&(dhcp_ptr -> nx_dhcp_mutex), "NetX DHCP Client", TX_NO_INHERIT);
/* Determine if the semaphore creation was successful. */
if (status != NX_SUCCESS)
if (status != TX_SUCCESS)
{
/* Delete the UDP socket. */
@ -428,7 +432,7 @@ UINT label_length = 0;
/* Determine if the thread creation was successful. */
if (status != NX_SUCCESS)
if (status != TX_SUCCESS)
{
/* Delete the mutex. */
@ -4313,6 +4317,153 @@ UINT status;
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nxe_dhcp_user_option_request PORTABLE C */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function checks for errors in the DHCP user option function */
/* call. */
/* */
/* INPUT */
/* */
/* dhcp_ptr Pointer to DHCP instance */
/* option_code Option code */
/* */
/* OUTPUT */
/* */
/* status Completion status */
/* NX_PTR_ERROR Invalid pointer input */
/* */
/* CALLS */
/* */
/* _nx_dhcp_user_option_request Actual DHCP user option */
/* request function call */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 08-02-2021 Yuxin Zhou Initial Version 6.1.8 */
/* */
/**************************************************************************/
UINT _nxe_dhcp_user_option_request(NX_DHCP *dhcp_ptr, UINT option_code)
{
UINT status;
/* Check for invalid input pointer. */
if ((dhcp_ptr == NX_NULL) || (dhcp_ptr -> nx_dhcp_id != NX_DHCP_ID))
return(NX_PTR_ERROR);
/* Check for appropriate caller. */
NX_THREADS_ONLY_CALLER_CHECKING
/* Call actual DHCP interface user option request service. */
status = _nx_dhcp_user_option_request(dhcp_ptr, option_code);
/* Return status. */
return(status);
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_user_option_request PORTABLE C */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function requests the additional user option. */
/* */
/* INPUT */
/* */
/* dhcp_ptr Pointer to DHCP instance */
/* option_code Option code */
/* */
/* OUTPUT */
/* */
/* status Completion status */
/* */
/* CALLS */
/* */
/* tx_mutex_get Get the DHCP mutex */
/* tx_mutex_put Release the DHCP mutex */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 08-02-2021 Yuxin Zhou Initial Version 6.1.8 */
/* */
/**************************************************************************/
UINT _nx_dhcp_user_option_request(NX_DHCP *dhcp_ptr, UINT option_code)
{
UINT i;
/* Obtain DHCP Client protection mutex. */
tx_mutex_get(&(dhcp_ptr -> nx_dhcp_mutex), TX_WAIT_FOREVER);
/* Check if the default option array already has it. */
for (i = 0; i < NX_DHCP_REQUEST_PARAMETER_SIZE; i++)
{
if (_nx_dhcp_request_parameters[i] == option_code)
{
tx_mutex_put(&(dhcp_ptr -> nx_dhcp_mutex));
return(NX_DUPLICATED_ENTRY);
}
}
/* Check if the user option array already has it. */
for (i = 0; i < dhcp_ptr -> nx_dhcp_user_request_parameter_size; i++)
{
if (dhcp_ptr -> nx_dhcp_user_request_parameter[i] == option_code)
{
tx_mutex_put(&(dhcp_ptr -> nx_dhcp_mutex));
return(NX_DUPLICATED_ENTRY);
}
}
/* Check if there is space to add option. */
if (dhcp_ptr -> nx_dhcp_user_request_parameter_size >= NX_DHCP_CLIENT_MAX_USER_REQUEST_PARAMETER)
{
tx_mutex_put(&(dhcp_ptr -> nx_dhcp_mutex));
return(NX_NO_MORE_ENTRIES);
}
/* Add the option. */
dhcp_ptr -> nx_dhcp_user_request_parameter[dhcp_ptr -> nx_dhcp_user_request_parameter_size++] = (UCHAR)option_code;
/* Release the DHCP mutex. */
tx_mutex_put(&(dhcp_ptr -> nx_dhcp_mutex));
/* Return success. */
return(NX_SUCCESS);
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
@ -6400,7 +6551,7 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_send_request_internal PORTABLE C */
/* 6.1 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -6430,6 +6581,7 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* _nx_dhcp_add_option_value Add an option to the request */
/* _nx_dhcp_add_option_string Add an option string to the */
/* request */
/* _nx_dhcp_add_option_parameter_request Add a parameter request option*/
/* nx_udp_socket_interface_send Send packet out on interface */
/* _nx_dhcp_client_send_with_zero_source_address */
/* Send broadcast packet with */
@ -6455,6 +6607,10 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), supported*/
/* adding additional request */
/* option in parameter request,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
static UINT _nx_dhcp_send_request_internal(NX_DHCP *dhcp_ptr, NX_DHCP_INTERFACE_RECORD *interface_record, UINT dhcp_message_type)
@ -6619,8 +6775,8 @@ UINT name_length;
(UCHAR *) dhcp_ptr -> nx_dhcp_name, &index);
}
/* Add an option request for DHCP parameters (gateway, subnet mask, etc.). */
_nx_dhcp_add_option_string(buffer, NX_DHCP_OPTION_DHCP_PARAMETERS, NX_DHCP_REQUEST_PARAMETER_SIZE, _nx_dhcp_request_parameters, &index);
/* Add parameter request option. */
_nx_dhcp_add_option_parameter_request(dhcp_ptr, buffer, &index);
#ifdef NX_DHCP_CLIENT_SEND_MAX_DHCP_MESSAGE_OPTION
@ -6690,9 +6846,9 @@ UINT name_length;
_nx_dhcp_store_data(buffer + NX_BOOTP_OFFSET_CLIENT_IP, 4, interface_record -> nx_dhcp_ip_address);
}
/* Add the request for the DHCP parameters (gateway, subnet mask, etc.) if not renewing. */
_nx_dhcp_add_option_string(buffer, NX_DHCP_OPTION_DHCP_PARAMETERS, NX_DHCP_REQUEST_PARAMETER_SIZE, _nx_dhcp_request_parameters, &index);
/* Add parameter request option. */
_nx_dhcp_add_option_parameter_request(dhcp_ptr, buffer, &index);
#ifdef NX_DHCP_CLIENT_SEND_MAX_DHCP_MESSAGE_OPTION
/* Add an option to specify the maximum length DHCP message that DHCP Client is willing to accept.
@ -6751,8 +6907,8 @@ UINT name_length;
_nx_dhcp_add_option_string(buffer, NX_DHCP_OPTION_HOST_NAME, name_length, (UCHAR *) dhcp_ptr -> nx_dhcp_name, &index);
}
/* Add an option request for DHCP parameters (gateway, subnet mask, etc.). */
_nx_dhcp_add_option_string(buffer, NX_DHCP_OPTION_DHCP_PARAMETERS, 1, &(interface_record -> nx_dhcp_user_option), &index);
/* Add parameter request option. */
_nx_dhcp_add_option_parameter_request(dhcp_ptr, buffer, &index);
/* Increment the number of Inform messages sent. */
interface_record -> nx_dhcp_informs_sent++;
@ -7073,6 +7229,7 @@ NX_IP_DRIVER driver_request;
return(NX_NOT_SUCCESSFUL);
}
}
#endif /* NX_ENABLE_IP_PACKET_FILTER */
/* Build the driver request. */
@ -7853,6 +8010,74 @@ static UINT _nx_dhcp_add_option_string(UCHAR *bootp_message, UINT option, UINT
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_dhcp_add_option_parameter_request PORTABLE C */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This routine adds a DHCP parameter request option to the BootP */
/* message in supplied buffer. Adding the option includes adding the */
/* option code, length and option value. */
/* */
/* INPUT */
/* */
/* dhcp_ptr Pointer to DHCP instance */
/* bootp_message Pointer to message buffer */
/* index Index to write data */
/* */
/* OUTPUT */
/* */
/* status Completion status */
/* */
/* CALLS */
/* */
/* _nx_dhcp_move_string Store option string */
/* */
/* CALLED BY */
/* */
/* _nx_dhcp_send_request_internal Internal DHCP message send */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 08-02-2021 Yuxin Zhou Initial Version 6.1.8 */
/* */
/**************************************************************************/
static UINT _nx_dhcp_add_option_parameter_request(NX_DHCP *dhcp_ptr, UCHAR *bootp_message, UINT *index)
{
/* Store the option. */
*(bootp_message + (*index)) = NX_DHCP_OPTION_DHCP_PARAMETERS;
(*index) ++;
/* Store the option size. */
*(bootp_message + (*index)) = (UCHAR)(NX_DHCP_REQUEST_PARAMETER_SIZE + dhcp_ptr -> nx_dhcp_user_request_parameter_size);
(*index) ++;
/* Store the option value. */
_nx_dhcp_move_string(bootp_message + (*index), _nx_dhcp_request_parameters, NX_DHCP_REQUEST_PARAMETER_SIZE);
(*index) += (UINT)NX_DHCP_REQUEST_PARAMETER_SIZE;
/* Check if there are additional user options. */
if (dhcp_ptr -> nx_dhcp_user_request_parameter_size)
{
_nx_dhcp_move_string(bootp_message + (*index), dhcp_ptr -> nx_dhcp_user_request_parameter, dhcp_ptr -> nx_dhcp_user_request_parameter_size);
(*index) += (UCHAR)dhcp_ptr -> nx_dhcp_user_request_parameter_size;
}
/* Return a successful completion. */
return(NX_SUCCESS);
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */

View File

@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nx_dhcp.h PORTABLE C */
/* 6.1 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -45,6 +45,10 @@
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), supported*/
/* adding additional request */
/* option in parameter request,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
@ -129,6 +133,13 @@ extern "C" {
#endif
/* Define the max number of user request parameter.
Subnet mask, gateway and dns server options are added in _nx_dhcp_request_parameters arrary by default. */
#ifndef NX_DHCP_CLIENT_MAX_USER_REQUEST_PARAMETER
#define NX_DHCP_CLIENT_MAX_USER_REQUEST_PARAMETER 4
#endif /* NX_DHCP_CLIENT_MAX_USER_REQUEST_PARAMETER */
/* Define the size of DHCP options buffer. */
/* A DHCP client must be prepared to receive DHCP messages with an 'options' field of
at least length 312 octets. RFC 2131; Section 2. Protocol Summary. */
@ -466,6 +477,10 @@ typedef struct NX_DHCP_STRUCT
NX_DHCP_INTERFACE_RECORD
nx_dhcp_interface_record[NX_DHCP_CLIENT_MAX_RECORDS];
/* Record of DHCP Client state on specific interface */
UCHAR nx_dhcp_user_request_parameter[NX_DHCP_CLIENT_MAX_USER_REQUEST_PARAMETER];
/* User request parameter */
UINT nx_dhcp_user_request_parameter_size;
/* User request parameter size */
#ifdef NX_DHCP_CLIENT_SEND_MAX_DHCP_MESSAGE_OPTION
ULONG nx_dhcp_max_dhcp_message_size;
@ -525,6 +540,7 @@ typedef struct NX_DHCP_STRUCT
#define nx_dhcp_stop _nx_dhcp_stop
#define nx_dhcp_server_address_get _nx_dhcp_server_address_get
#define nx_dhcp_state_change_notify _nx_dhcp_state_change_notify
#define nx_dhcp_user_option_request _nx_dhcp_user_option_request
#define nx_dhcp_user_option_retrieve _nx_dhcp_user_option_retrieve
#define nx_dhcp_user_option_convert _nx_dhcp_user_option_convert
#define nx_dhcp_user_option_add_callback_set _nx_dhcp_user_option_add_callback_set
@ -572,6 +588,7 @@ typedef struct NX_DHCP_STRUCT
#define nx_dhcp_stop _nxe_dhcp_stop
#define nx_dhcp_server_address_get _nxe_dhcp_server_address_get
#define nx_dhcp_state_change_notify _nxe_dhcp_state_change_notify
#define nx_dhcp_user_option_request _nxe_dhcp_user_option_request
#define nx_dhcp_user_option_retrieve _nxe_dhcp_user_option_retrieve
#define nx_dhcp_user_option_convert _nxe_dhcp_user_option_convert
#define nx_dhcp_user_option_add_callback_set _nxe_dhcp_user_option_add_callback_set
@ -619,6 +636,7 @@ UINT nx_dhcp_start(NX_DHCP *dhcp_ptr);
UINT nx_dhcp_stop(NX_DHCP *dhcp_ptr);
UINT nx_dhcp_server_address_get(NX_DHCP *dhcp_ptr, ULONG *server_address);
UINT nx_dhcp_state_change_notify(NX_DHCP *dhcp_ptr, VOID (*dhcp_state_change_notify)(NX_DHCP *dhcp_ptr, UCHAR new_state));
UINT nx_dhcp_user_option_request(NX_DHCP *dhcp_ptr, UINT option_code);
UINT nx_dhcp_user_option_retrieve(NX_DHCP *dhcp_ptr, UINT request_option, UCHAR *destination_ptr, UINT *destination_size);
ULONG nx_dhcp_user_option_convert(UCHAR *source_ptr);
UINT nx_dhcp_user_option_add_callback_set(NX_DHCP *dhcp_ptr, UINT (*dhcp_user_option_add)(NX_DHCP *dhcp_ptr, UINT iface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length));
@ -678,6 +696,8 @@ UINT _nxe_dhcp_server_address_get(NX_DHCP *dhcp_ptr, ULONG *server_addres
UINT _nx_dhcp_server_address_get(NX_DHCP *dhcp_ptr, ULONG *server_address);
UINT _nxe_dhcp_state_change_notify(NX_DHCP *dhcp_ptr, VOID (*dhcp_state_change_notify)(NX_DHCP *dhcp_ptr, UCHAR new_state));
UINT _nx_dhcp_state_change_notify(NX_DHCP *dhcp_ptr, VOID (*dhcp_state_change_notify)(NX_DHCP *dhcp_ptr, UCHAR new_state));
UINT _nxe_dhcp_user_option_request(NX_DHCP *dhcp_ptr, UINT option_code);
UINT _nx_dhcp_user_option_request(NX_DHCP *dhcp_ptr, UINT option_code);
UINT _nxe_dhcp_user_option_retrieve(NX_DHCP *dhcp_ptr, UINT request_option, UCHAR *destination_ptr, UINT *destination_size);
UINT _nx_dhcp_user_option_retrieve(NX_DHCP *dhcp_ptr, UINT request_option, UCHAR *destination_ptr, UINT *destination_size);
ULONG _nxe_dhcp_user_option_convert(UCHAR *source_ptr);

View File

@ -80,7 +80,7 @@ NX_CALLER_CHECKING_EXTERNS
#define NX_FTP_CODE_NO_SPACE "552" /* Requested file action aborted, no space. */
#define NX_FTP_CODE_BAD_NAME "553" /* Requested action not taken, File name not allowed. */
static VOID _nx_ftp_server_number_to_ascii(UCHAR *buffer_ptr, UINT buffer_size, UINT number);
static VOID _nx_ftp_server_number_to_ascii(UCHAR *buffer_ptr, UINT buffer_size, UINT number, UCHAR pad);
/**************************************************************************/
/* */
@ -1355,7 +1355,7 @@ ULONG events;
/* FUNCTION RELEASE */
/* */
/* _nx_ftp_server_command_process PORTABLE C */
/* 6.1.3 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -1429,6 +1429,9 @@ ULONG events;
/* 12-31-2020 Yuxin Zhou Modified comment(s), improved */
/* packet length verification, */
/* resulting in version 6.1.3 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), */
/* corrected the pad character,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
VOID _nx_ftp_server_command_process(NX_FTP_SERVER *ftp_server_ptr)
@ -3364,17 +3367,17 @@ ULONG block_size;
memcpy(&buffer_ptr[1], "rw-rw-rw-", 9); /* Use case of memcpy is verified. */
}
memcpy(&buffer_ptr[10], " 1 owner group ", 16); /* Use case of memcpy is verified. */
_nx_ftp_server_number_to_ascii(&buffer_ptr[26], 10, size);
_nx_ftp_server_number_to_ascii(&buffer_ptr[26], 10, size, ' ');
buffer_ptr[36] = ' ';
buffer_ptr[37] = (UCHAR)months[month - 1][0];
buffer_ptr[38] = (UCHAR)months[month - 1][1];
buffer_ptr[39] = (UCHAR)months[month - 1][2];
buffer_ptr[40] = ' ';
_nx_ftp_server_number_to_ascii(&buffer_ptr[41], 2, day);
_nx_ftp_server_number_to_ascii(&buffer_ptr[41], 2, day, '0');
buffer_ptr[43] = ' ';
_nx_ftp_server_number_to_ascii(&buffer_ptr[44], 2, hour);
_nx_ftp_server_number_to_ascii(&buffer_ptr[44], 2, hour, '0');
buffer_ptr[46] = ':';
_nx_ftp_server_number_to_ascii(&buffer_ptr[47], 2, minute);
_nx_ftp_server_number_to_ascii(&buffer_ptr[47], 2, minute, '0');
buffer_ptr[49] = ' ';
memcpy(&buffer_ptr[50], filename, length); /* Use case of memcpy is verified. */
length += 50;
@ -5791,7 +5794,7 @@ NX_PACKET *last_packet;
/* FUNCTION RELEASE */
/* */
/* _nx_ftp_server_number_to_ascii PORTABLE C */
/* 6.1.7 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -5830,9 +5833,12 @@ NX_PACKET *last_packet;
/* 06-02-2021 Yuxin Zhou Modified comment(s), and */
/* corrected the size check, */
/* resulting in version 6.1.7 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), */
/* corrected the pad character,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
static VOID _nx_ftp_server_number_to_ascii(UCHAR *buffer_ptr, UINT buffer_size, UINT number)
static VOID _nx_ftp_server_number_to_ascii(UCHAR *buffer_ptr, UINT buffer_size, UINT number, UCHAR pad)
{
UINT digit;
UINT size;
@ -5840,8 +5846,8 @@ UINT size;
/* Initialize counters. */
size = 1;
/* Initialize buffer with spaces. */
memset(buffer_ptr, ' ', buffer_size);
/* Initialize buffer with pad character. */
memset(buffer_ptr, pad, buffer_size);
/* Loop to convert the number to ASCII. */
while (size <= buffer_size)

View File

@ -5326,105 +5326,6 @@ CHAR *buffer_ptr;
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_number_convert PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function converts a number into an ASCII string. */
/* */
/* INPUT */
/* */
/* number Unsigned integer number */
/* string Destination string */
/* */
/* OUTPUT */
/* */
/* Size Number of bytes in string */
/* (0 implies an error) */
/* */
/* CALLS */
/* */
/* None */
/* */
/* CALLED BY */
/* */
/* _nx_http_server_get_process Process GET request */
/* _nx_http_server_response_send Send response to client */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
UINT _nx_http_server_number_convert(UINT number, CHAR *string)
{
UINT j;
UINT digit;
UINT size;
/* Initialize counters. */
size = 0;
/* Loop to convert the number to ASCII. */
while (size < 10)
{
/* Shift the current digits over one. */
for (j = size; j != 0; j--)
{
/* Move each digit over one place. */
string[j] = string[j-1];
}
/* Compute the next decimal digit. */
digit = number % 10;
/* Update the input number. */
number = number / 10;
/* Store the new digit in ASCII form. */
string[0] = (CHAR) (digit + 0x30);
/* Increment the size. */
size++;
/* Determine if the number is now zero. */
if (number == 0)
break;
}
/* Make the string NULL terminated. */
string[size] = (CHAR) NX_NULL;
/* Determine if there is an overflow error. */
if (number)
{
/* Error, return bad values to user. */
size = 0;
string[0] = '0';
}
/* Return size to caller. */
return(size);
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
@ -7747,7 +7648,7 @@ UCHAR ch;
/* FUNCTION RELEASE */
/* */
/* _nx_http_server_generate_response_header PORTABLE C */
/* 6.1 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -7782,7 +7683,7 @@ UCHAR ch;
/* nx_packet_data_append */
/* memcmp */
/* _nx_utility_string_length_check */
/* _nx_http_server_number_convert */
/* _nx_utility_uint_to_string */
/* _nx_http_server_date_to_string */
/* nx_packet_release */
/* */
@ -7801,6 +7702,10 @@ UCHAR ch;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), */
/* improved the logic of */
/* converting number to string,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
UINT _nx_http_server_generate_response_header(NX_HTTP_SERVER *server_ptr, NX_PACKET **packet_pptr, CHAR *status_code,
@ -7884,7 +7789,7 @@ CHAR status_code_not_modified;
{
/* Convert the content_length to ASCII representation. */
temp = _nx_http_server_number_convert(content_length, temp_string);
temp = _nx_utility_uint_to_string(content_length, 10, temp_string, sizeof(temp_string));
/* Place the "Content-Length" field in the header. */
status += nx_packet_data_append(packet_ptr, "Content-Length: ", 16,
@ -7948,7 +7853,7 @@ CHAR status_code_not_modified;
server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER);
/* Convert the max-age to ASCII representation. */
temp = _nx_http_server_number_convert(max_age, temp_string);
temp = _nx_utility_uint_to_string(max_age, 10, temp_string, sizeof(temp_string));
status += nx_packet_data_append(packet_ptr, temp_string, temp,
server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER);

View File

@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nx_http_server.h PORTABLE C */
/* 6.1.6 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -49,6 +49,10 @@
/* improved the logic of */
/* parsing base64, */
/* resulting in version 6.1.6 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), and */
/* improved the logic of */
/* converting number to string,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
@ -577,7 +581,6 @@ UINT _nx_http_server_basic_authenticate(NX_HTTP_SERVER *server_ptr, NX_PA
UINT _nx_http_server_retrieve_basic_authorization(NX_PACKET *packet_ptr, CHAR *authorization_request_ptr);
UINT _nx_http_server_retrieve_resource(NX_PACKET *packet_ptr, CHAR *destination, UINT max_size);
UINT _nx_http_server_calculate_content_offset(NX_PACKET *packet_ptr);
UINT _nx_http_server_number_convert(UINT number, CHAR *string);
UINT _nx_http_server_type_get(NX_HTTP_SERVER *server_ptr, CHAR *name, CHAR *http_type_string);
UINT _nx_http_server_type_get_extended(NX_HTTP_SERVER *server_ptr, CHAR *name, UINT name_length, CHAR *http_type_string, UINT http_type_string_max_size);

View File

@ -2201,7 +2201,7 @@ NX_PACKET *packet_ptr;
/* FUNCTION RELEASE */
/* */
/* _nx_ppp_lcp_state_machine_update PORTABLE C */
/* 6.1.2 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -2248,6 +2248,9 @@ NX_PACKET *packet_ptr;
/* improved packet length */
/* verification, */
/* resulting in version 6.1.2 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), fixed */
/* the logic of retransmission,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
void _nx_ppp_lcp_state_machine_update(NX_PPP *ppp_ptr, NX_PACKET *packet_ptr)
@ -2792,9 +2795,6 @@ UINT status;
/* Yes, the peer can accept larger messages than the default. */
(ppp_ptr -> nx_ppp_interface_ptr) -> nx_interface_ip_mtu_size = ppp_ptr -> nx_ppp_mru;
}
/* Disable the LCP timeout. */
ppp_ptr -> nx_ppp_timeout = 0;
}
/* Send configuration reply. */

View File

@ -12924,7 +12924,7 @@ UINT _nx_snmp_utility_error_info_set(UCHAR *buffer_ptr, UINT error_code, UINT e
/* FUNCTION RELEASE */
/* */
/* _nx_snmp_utility_object_id_get PORTABLE C */
/* 6.1 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -12947,7 +12947,7 @@ UINT _nx_snmp_utility_error_info_set(UCHAR *buffer_ptr, UINT error_code, UINT e
/* */
/* CALLS */
/* */
/* None */
/* _nx_utility_uint_to_string Convert number to ASCII */
/* */
/* CALLED BY */
/* */
@ -12963,6 +12963,10 @@ UINT _nx_snmp_utility_error_info_set(UCHAR *buffer_ptr, UINT error_code, UINT e
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), */
/* improved the logic of */
/* converting number to string,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
UINT _nx_snmp_utility_object_id_get(UCHAR *buffer_ptr, UCHAR *object_string, INT buffer_length)
@ -13234,48 +13238,23 @@ UINT string_length;
value = value + temp;
}
/* Loop to convert value into ASCII. */
size = 0;
do
/* Convert value into ASCII. */
size = _nx_utility_uint_to_string(value, 10, (CHAR *)object_string, NX_SNMP_MAX_OCTET_STRING + 1 - string_length);
if (size == 0)
{
/* Shift the current digits over one. */
for (i = size; i != 0; i--)
{
/* Move each digit over one place. */
object_string[i] = object_string[i-1];
}
/* Compute the next decimal digit. */
byte = (UCHAR) (value % 10);
/* Update the input number. */
value = value / 10;
/* Store the new digit in ASCII form. */
object_string[0] = (UCHAR)(byte + 0x30);
/* Increment the size. */
size++;
/* Increment the string length. */
string_length++;
/* Determine if the length is too long. */
if (string_length >= NX_SNMP_MAX_OCTET_STRING)
{
/* String is too long. */
/* String is too long. */
/* Null-terminate the string. */
*object_string = NX_NULL;
/* Null-terminate the string. */
*object_string = NX_NULL;
/* Return the length. */
return(length);
}
} while ((size < 10) && (value));
/* Return the length. */
return(length);
}
/* Adjust the object string length. */
string_length += size;
/* Adjust the object string. */
object_string = object_string + size;

View File

@ -69,8 +69,6 @@ extern volatile ULONG _tx_thread_system_state;
TX_EVENT_FLAGS_GROUP nx_sntp_client_events;
static UINT _nx_sntp_client_number_to_ascii(CHAR *buffer_ptr, UINT buffer_size, UINT number);
/* Define internal time variables for offsets between
receipt of SNTP packet and application to
SNTP Client local time. */
@ -3657,7 +3655,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_sntp_client_get_local_time_extended PORTABLE C */
/* 6.1 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -3683,8 +3681,8 @@ UINT status;
/* CALLS */
/* */
/* _nx_sntp_client_utility_fraction_to_usecs */
/* Convert NTP fraction to usecs */
/* _nx_sntp_client_number_to_ascii Converts number to ascii text */
/* Convert NTP fraction to usecs */
/* _nx_utility_uint_to_string Converts number to ascii text */
/* */
/* CALLED BY */
/* */
@ -3698,6 +3696,10 @@ UINT status;
/* 09-30-2020 Yuxin Zhou Modified comment(s), and */
/* verified memmove use cases, */
/* resulting in version 6.1 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), */
/* improved the logic of */
/* converting number to string,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
UINT _nx_sntp_client_get_local_time_extended(NX_SNTP_CLIENT *client_ptr, ULONG *seconds, ULONG *fraction, CHAR *buffer, UINT buffer_size)
@ -3731,8 +3733,8 @@ UINT length = 0;
buffer[offset++] = 'e';
buffer[offset++] = ':';
buffer[offset++] = ' ';
length = _nx_sntp_client_number_to_ascii(&buffer[offset], buffer_size - offset,
client_ptr->nx_sntp_client_local_ntp_time.seconds);
length = _nx_utility_uint_to_string(client_ptr -> nx_sntp_client_local_ntp_time.seconds,
10, &buffer[offset], buffer_size - offset);
if (length == 0)
{
return(NX_SIZE_ERROR);
@ -3743,7 +3745,7 @@ UINT length = 0;
return(NX_SIZE_ERROR);
}
buffer[offset++] = '.';
length = _nx_sntp_client_number_to_ascii(&buffer[offset], 6, usecs);
length = _nx_utility_uint_to_string(usecs, 10, &buffer[offset], buffer_size - offset);
if (length == 0)
{
return(NX_SIZE_ERROR);
@ -3756,6 +3758,8 @@ UINT length = 0;
memmove(&buffer[offset + (6 - length)], &buffer[offset], length); /* Use case of memmove is verified. */
memset(&buffer[offset], '0', (6 - length));
}
offset += 6;
buffer[offset++] = ' ';
buffer[offset++] = 's';
buffer[offset++] = 'e';
@ -4343,7 +4347,7 @@ UINT status;
/* FUNCTION RELEASE */
/* */
/* _nx_sntp_client_utility_display_date_time PORTABLE C */
/* 6.1 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -4372,8 +4376,8 @@ UINT status;
/* */
/* CALLS */
/* _nx_sntp_client_utility_convert_seconds_to_date */
/* Converts seconds to year, month */
/* _nx_sntp_client_number_to_ascii Converts number to ascii text */
/* Converts seconds to year, month */
/* _nx_utility_uint_to_string Converts number to ascii text */
/* */
/* CALLED BY */
/* */
@ -4386,6 +4390,10 @@ UINT status;
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), */
/* improved the logic of */
/* converting number to string,*/
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
UINT _nx_sntp_client_utility_display_date_time(NX_SNTP_CLIENT *client_ptr, CHAR *buffer, UINT length)
@ -4438,48 +4446,48 @@ const CHAR *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
offset = 4;
/* Write in the rest of the data as numeric from the Date Time objext. */
return_length = _nx_sntp_client_number_to_ascii(&buffer[offset], length - offset, DisplayTime.day);
return_length = _nx_utility_uint_to_string(DisplayTime.day, 10, &buffer[offset], length - offset);
offset += return_length;
if ((return_length == 0) || ((length - offset) < 2))
{
return NX_SNTP_ERROR_CONVERTING_DATETIME;
}
offset += return_length;
buffer[offset++] = ',';
buffer[offset++] = ' ';
return_length = _nx_sntp_client_number_to_ascii(&buffer[offset], length - offset, DisplayTime.year);
return_length = _nx_utility_uint_to_string(DisplayTime.year, 10, &buffer[offset], length - offset);
offset += return_length;
if ((return_length == 0) || ((length - offset) < 1))
{
return NX_SNTP_ERROR_CONVERTING_DATETIME;
}
offset += return_length;
buffer[offset++] = ' ';
return_length = _nx_sntp_client_number_to_ascii(&buffer[offset], length - offset, DisplayTime.hour);
return_length = _nx_utility_uint_to_string(DisplayTime.hour, 10, &buffer[offset], length - offset);
offset += return_length;
if ((return_length == 0) || ((length - offset) < 1))
{
return NX_SNTP_ERROR_CONVERTING_DATETIME;
}
offset += return_length;
buffer[offset++] = ':';
return_length = _nx_sntp_client_number_to_ascii(&buffer[offset], length - offset, DisplayTime.minute);
return_length = _nx_utility_uint_to_string(DisplayTime.minute, 10, &buffer[offset], length - offset);
offset += return_length;
if ((return_length == 0) || ((length - offset) < 1))
{
return NX_SNTP_ERROR_CONVERTING_DATETIME;
}
offset += return_length;
buffer[offset++] = ':';
return_length = _nx_sntp_client_number_to_ascii(&buffer[offset], length - offset, DisplayTime.second);
return_length = _nx_utility_uint_to_string(DisplayTime.second, 10, &buffer[offset], length - offset);
offset += return_length;
if ((return_length == 0) || ((length - offset) < 1))
{
return NX_SNTP_ERROR_CONVERTING_DATETIME;
}
offset += return_length;
buffer[offset++] = '.';
return_length = _nx_sntp_client_number_to_ascii(&buffer[offset], length - offset, DisplayTime.millisecond);
return_length = _nx_utility_uint_to_string(DisplayTime.millisecond, 10, &buffer[offset], length - offset);
offset += return_length;
if ((return_length == 0) || ((length - offset) < 5))
{
return NX_SNTP_ERROR_CONVERTING_DATETIME;
}
offset += return_length;
buffer[offset++] = ' ';
buffer[offset++] = 'U';
buffer[offset++] = 'T';
@ -5907,105 +5915,4 @@ UINT carry;
/* Ok to add operands!*/
return NX_SUCCESS;
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_sntp_client_number_to_ascii PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function converts a number to ascii text. */
/* */
/* INPUT */
/* */
/* buffer_ptr Pointer to output string buffer */
/* buffer_size Size of output buffer */
/* number Number to convert to ASCII */
/* */
/* OUTPUT */
/* */
/* size Size of converted string */
/* */
/* CALLS */
/* */
/* None */
/* */
/* CALLED BY */
/* */
/* _nx_sntp_client_utility_display_date_time */
/* Convert an NTP time */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
static UINT _nx_sntp_client_number_to_ascii(CHAR *buffer_ptr, UINT buffer_size, UINT number)
{
UINT i;
UINT digit;
UINT size;
/* Initialize counters. */
size = 0;
/* Loop to convert the number to ASCII. */
while (size < buffer_size)
{
/* Shift the current digits over one. */
for (i = size; i != 0; i--)
{
/* Move each digit over one place. */
buffer_ptr[i] = buffer_ptr[i - 1];
}
/* Compute the next decimal digit. */
digit = (number % 10);
/* Update the input number. */
number = (number / 10);
/* Store the new digit in ASCII form. */
if (digit < 10)
{
buffer_ptr[0] = (CHAR)(digit + '0');
}
else
{
buffer_ptr[0] = (CHAR)((digit - 10) + 'a');
}
/* Increment the size. */
size++;
/* Determine if the number is now zero. */
if (number == 0)
break;
}
/* Determine if there is an overflow error. */
if (number)
{
/* Error, return bad values to user. */
return(0);
}
/* Return size to caller. */
return(size);
}

View File

@ -26,7 +26,7 @@
/* APPLICATION INTERFACE DEFINITION RELEASE */
/* */
/* nx_api.h PORTABLE C */
/* 6.1.7 */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
@ -69,6 +69,10 @@
/* 06-02-2021 Yuxin Zhou Modified comment(s), and */
/* updated product constants, */
/* resulting in version 6.1.7 */
/* 08-02-2021 Yuxin Zhou Modified comment(s), and */
/* added function to convert */
/* unsigned integer to string, */
/* resulting in version 6.1.8 */
/* */
/**************************************************************************/
@ -377,7 +381,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 7
#define NETX_PATCH_VERSION 8
/* The following symbols are defined for backward compatibility reasons.*/
#define EL_PRODUCT_NETX
@ -2386,6 +2390,7 @@ VOID _nx_ip_driver_link_status_event(NX_IP *ip_ptr, UINT interface_index);
/* Utility functions. */
UINT _nx_utility_string_length_check(CHAR *input_string, UINT *string_length, UINT max_string_length);
UINT _nx_utility_string_to_uint(CHAR *input_string, UINT string_length, UINT *number);
UINT _nx_utility_uint_to_string(UINT number, UINT base, CHAR *string_buffer, UINT string_buffer_size);
UINT _nx_utility_base64_encode(UCHAR *name, UINT name_size, UCHAR *base64name, UINT base64name_size, UINT *bytes_copied);
UINT _nx_utility_base64_decode(UCHAR *base64name, UINT base64name_size, UCHAR *name, UINT name_size, UINT *bytes_copied);

View File

@ -202,6 +202,116 @@ UINT i;
return(NX_SUCCESS);
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_utility_uint_to_string PORTABLE C */
/* 6.1.8 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function converts the unsigned integer to string. */
/* */
/* INPUT */
/* */
/* number Input number */
/* base Base of the conversion */
/* 8 for OCT */
/* 10 for DEC */
/* 16 for HEX */
/* string_buffer Pointer to string buffer */
/* string_buffer_size Size of string buffer */
/* */
/* OUTPUT */
/* */
/* size The size of output string */
/* */
/* CALLS */
/* */
/* None */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 08-02-2021 Yuxin Zhou Initial Version 6.1.8 */
/* */
/**************************************************************************/
UINT _nx_utility_uint_to_string(UINT number, UINT base, CHAR *string_buffer, UINT string_buffer_size)
{
UINT i;
UINT digit;
UINT size;
/* Check for invalid input pointers. */
if ((string_buffer == NX_NULL) || (string_buffer_size == 0))
{
return(0);
}
/* Initialize. */
i = 0;
size = 0;
/* Loop to convert the number to ASCII. Minus 1 to put NULL terminal. */
while (size < string_buffer_size - 1)
{
/* Shift the current digits over one. */
for (i = size; i != 0; i--)
{
/* Move each digit over one place. */
string_buffer[i] = string_buffer[i-1];
}
/* Compute the next decimal digit. */
digit = number % base;
/* Update the input number. */
number = number / base;
/* Store the new digit in ASCII form. */
if (digit < 10)
{
string_buffer[0] = (CHAR) (digit + '0');
}
else
{
string_buffer[0] = (CHAR) (digit + 'a' - 0xa);
}
/* Increment the size. */
size++;
/* Determine if the number is now zero. */
if (number == 0)
break;
}
/* Determine if there is an overflow error. */
if (number)
{
/* Error, return bad values to user. */
size = 0;
}
/* Make the string NULL terminated. */
string_buffer[size] = (CHAR) NX_NULL;
/* Return size to caller. */
return(size);
}
/**************************************************************************/
/* */
/* FUNCTION RELEASE */