mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/paho-mqtt: add support for DNS
This commit is contained in:
parent
2a5bc04a16
commit
3206ac80cf
@ -22,6 +22,7 @@
|
||||
#ifdef MODULE_IPV4_ADDR
|
||||
#include "net/ipv4/addr.h"
|
||||
#endif
|
||||
#include "net/dns.h"
|
||||
#include "net/sock/tcp.h"
|
||||
#include "paho_mqtt.h"
|
||||
#include "MQTTClient.h"
|
||||
@ -121,6 +122,12 @@ int NetworkConnect(Network *n, char *addr_ip, int port)
|
||||
int ret =-1;
|
||||
sock_tcp_ep_t remote = SOCK_IPV4_EP_ANY;
|
||||
|
||||
ret = dns_query(addr_ip, &remote.addr, AF_UNSPEC);
|
||||
if (ret > 0) {
|
||||
remote.port = port;
|
||||
remote.family = ret == 4 ? AF_INET : AF_INET6;
|
||||
}
|
||||
|
||||
if (IS_USED(MODULE_IPV4_ADDR) && (remote.port == 0) &&
|
||||
ipv4_addr_from_str((ipv4_addr_t *)&remote.addr, addr_ip)) {
|
||||
remote.port = port;
|
||||
|
Loading…
Reference in New Issue
Block a user