From edc95679cd7a37c14f0f155b03ba6bd4523769fa Mon Sep 17 00:00:00 2001 From: M Aiman Ismail Date: Tue, 30 Jun 2020 21:38:54 +0200 Subject: [PATCH] cord_ep: allow not specify netif if only one interface exist --- sys/shell/commands/sc_cord_ep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/shell/commands/sc_cord_ep.c b/sys/shell/commands/sc_cord_ep.c index e2abdfdb03..0e32adce28 100644 --- a/sys/shell/commands/sc_cord_ep.c +++ b/sys/shell/commands/sc_cord_ep.c @@ -32,8 +32,12 @@ static int make_sock_ep(sock_udp_ep_t *ep, const char *addr) if (sock_udp_str2ep(ep, addr) < 0) { return -1; } + /* if netif not specified in addr */ + if ((ep->netif == SOCK_ADDR_ANY_NETIF) && (gnrc_netif_numof() == 1)) { + /* assign the single interface found in gnrc_netif_numof() */ + ep->netif = (uint16_t)gnrc_netif_iter(NULL)->pid; + } ep->family = AF_INET6; - ep->netif = SOCK_ADDR_ANY_NETIF; if (ep->port == 0) { ep->port = COAP_PORT; }