Skip to content

Commit 129b757

Browse files
maxd-nordicrlubos
authored andcommitted
lib: nrf_cloud: invert ports as late as possible
Updated handling of ports with led to confusing log messages with byte-inversed values. Signed-off-by: Maximilian Deubel <[email protected]>
1 parent 61a41ff commit 129b757

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,10 @@ Libraries for networking
10371037
* :ref:`lib_nrf_cloud` library:
10381038

10391039
* Added the :c:func:`nrf_cloud_obj_location_request_create_timestamped` function to make location requests for past cellular or Wi-Fi scans.
1040-
* Updated by refactoring the folder structure of the library to separate the different backend implementations.
1040+
* Updated:
1041+
1042+
* By refactoring the folder structure of the library to separate the different backend implementations.
1043+
* Handling of ports, which led to confusing log messages with byte-inversed values.
10411044

10421045
* :ref:`lib_downloader` library:
10431046

subsys/net/lib/nrf_cloud/coap/src/nrf_cloud_coap_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ int nrf_cloud_coap_transport_connect(struct nrf_cloud_coap_client *const client)
773773
client->authenticated = false;
774774

775775
const char *const host_name = CONFIG_NRF_CLOUD_COAP_SERVER_HOSTNAME;
776-
uint16_t port = htons(CONFIG_NRF_CLOUD_COAP_SERVER_PORT);
776+
uint16_t port = CONFIG_NRF_CLOUD_COAP_SERVER_PORT;
777777

778778
struct zsock_addrinfo hints = {
779779
.ai_socktype = SOCK_DGRAM

subsys/net/lib/nrf_cloud/common/src/nrf_cloud_dns.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ static int nrf_cloud_try_addresses(const char *const host_name, uint16_t port,
4040

4141
switch (sa->sa_family) {
4242
case AF_INET6:
43-
((struct sockaddr_in6 *)sa)->sin6_port = port;
43+
((struct sockaddr_in6 *)sa)->sin6_port = htons(port);
4444
break;
4545
case AF_INET:
46-
((struct sockaddr_in *)sa)->sin_port = port;
46+
((struct sockaddr_in *)sa)->sin_port = htons(port);
4747
break;
4848
}
4949

@@ -87,14 +87,14 @@ int nrf_cloud_connect_host(const char *hostname, uint16_t port, struct zsock_add
8787

8888
#if defined(CONFIG_NRF_CLOUD_STATIC_IPV4)
8989
static struct sockaddr_in static_addr;
90-
uint16_t static_port = htons(CONFIG_NRF_CLOUD_PORT);
90+
uint16_t static_port = CONFIG_NRF_CLOUD_PORT;
9191

9292
LOG_DBG("Trying static IPv4 address: %s, port: %d", CONFIG_NRF_CLOUD_STATIC_IPV4_ADDR,
9393
port);
9494

9595
zsock_inet_pton(AF_INET, CONFIG_NRF_CLOUD_STATIC_IPV4_ADDR, &(static_addr.sin_addr));
9696
static_addr.sin_family = AF_INET;
97-
static_addr.sin_port = static_port;
97+
static_addr.sin_port = htons(static_port);
9898

9999
sock = connect_cb((struct sockaddr *)&static_addr);
100100

subsys/net/lib/nrf_cloud/mqtt/src/nrf_cloud_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ int nct_connect(void)
934934
{
935935
int err = 0;
936936
const char *const host_name = NRF_CLOUD_HOSTNAME;
937-
uint16_t port = htons(NRF_CLOUD_PORT);
937+
uint16_t port = NRF_CLOUD_PORT;
938938
struct zsock_addrinfo hints = {.ai_socktype = SOCK_STREAM};
939939
int sock = nrf_cloud_connect_host(host_name, port, &hints, &nct_connect_host_cb);
940940

0 commit comments

Comments
 (0)