Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/paho-mqtt: add support for gnrc #17004

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
fixup! pkg/paho-mqtt: add support for gnrc
  • Loading branch information
vera committed Dec 16, 2021
commit ad3b13e8d7f8fdac9eea73263d9066326196355a
13 changes: 3 additions & 10 deletions pkg/paho-mqtt/contrib/riot_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#define ENABLE_DEBUG 0
#include "debug.h"

#define IP_MAX_LEN_ADDRESS (39) /*IPv6 max length */

#ifndef TSRB_MAX_SIZE
#define TSRB_MAX_SIZE (1024)
#endif
Expand Down Expand Up @@ -127,19 +125,14 @@ int NetworkConnect(Network *n, char *addr_ip, int port)
{
int ret =-1;
sock_tcp_ep_t remote = SOCK_IPV4_EP_ANY;
char _local_ip[IP_MAX_LEN_ADDRESS];

strncpy(_local_ip, addr_ip, sizeof(_local_ip));
if (IS_USED(MODULE_IPV4_ADDR) &&
ipv4_addr_from_str((ipv4_addr_t *)&remote.addr, _local_ip)) {
ipv4_addr_from_str((ipv4_addr_t *)&remote.addr, addr_ip)) {
remote.port = port;
}
else if (IS_USED(MODULE_IPV6_ADDR)) {
/* ipvN_addr_from_str modifies input buffer */
strncpy(_local_ip, addr_ip, sizeof(_local_ip));

if (IS_USED(MODULE_GNRC)) {
char *iface = ipv6_addr_split_iface(_local_ip);
char *iface = ipv6_addr_split_iface(addr_ip);
if ((!iface) && (gnrc_netif_numof() == 1)) {
remote.netif = gnrc_netif_iter(NULL)->pid;
}
Expand All @@ -148,7 +141,7 @@ int NetworkConnect(Network *n, char *addr_ip, int port)
}
}

if (ipv6_addr_from_str((ipv6_addr_t *)&remote.addr, _local_ip)) {
if (ipv6_addr_from_str((ipv6_addr_t *)&remote.addr, addr_ip)) {
remote.port = port;
remote.family = AF_INET6;
}
Expand Down