Skip to content

DHCP NX_DHCP_OPTION_DNS_SVR retrieve value in wrong order (endian) #365

@MiyukiDark

Description

@MiyukiDark

Describe the bug
When I use nx_dhcp_user_option_retrieve for NX_DHCP_OPTION_DNS_SVR parameter as in the documentation, the received IP address is in reverse byte order.

Running on ARM Cortex M33 with the Keil compiler
Sources included as a submodule from the current Master branch

To Reproduce
Steps to reproduce the behavior:

Code used (as is in the documentation netx-duo/netx-duo-dhcp-client/chapter3.md ), run after DHCP assigned address

/* Obtain the IP address of the DNS server.  */
	size =    sizeof(dns_ip_string);
	status =  nx_dhcp_user_option_retrieve(&DHCPClient, NX_DHCP_OPTION_DNS_SVR, dns_ip_string, &size);
	
	if (status == NX_SUCCESS)
	{
		DNS_server_address = nx_dhcp_user_option_convert(dns_ip_string);
	}

Expected behavior
DHCP is configured to provide a single DNS server address, in my case 10.6.6.1
dns_ip_string contains values [1, 6, 6, 10]
and DNS_server_address result is 0x0106060A
While expected result is 0x0A060601

Impact
It is not a big deal, but shall be either fixed in the code or in the documentation.

Additional context
It will probably be good to have a function that will be ready to decode multiple IP addresses

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Discussion

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions