Skip to content

Commit 3684736

Browse files
fix to use DNS struct
1 parent 4dcaef3 commit 3684736

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

examples/mqttnet.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,13 @@ static int NetConnect(void *context, const char* host, word16 port,
419419
"Use TLS %d", host, port, timeout_ms, mqttCtx->use_tls);
420420
}
421421
#ifndef WOLFMQTT_NO_NETX_DNS
422+
if (sock->dnsPtr == NULL) {
423+
PRINTF("DNS pointer was NULL and needs set, sock->dnsPtr");
424+
return MQTT_CODE_ERROR_NETWORK;
425+
}
426+
422427
/* Convert hostname to IP address using NETX DUO DNS */
423-
status = nxd_dns_host_by_name_get(sock->ipPtr, (UCHAR *)host,
428+
status = nxd_dns_host_by_name_get(sock->dnsPtr, (UCHAR *)host,
424429
&ipAddress, timeout_ms);
425430
if (status != NX_SUCCESS) {
426431
PRINTF("DNS lookup failed: %d", status);

examples/mqttnet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ typedef struct _SocketContext {
5757
void* websocket_ctx;
5858
#endif
5959
#ifdef HAVE_NETX
60+
#ifndef WOLFMQTT_NO_NETX_DNS
61+
NX_IP_DNS_STRUCT *dnsPtr;
62+
#endif
6063
NX_IP *ipPtr;
6164
NX_PACKET *nxPacket;
6265
ULONG nxOffset;

0 commit comments

Comments
 (0)