mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-30 00:41:17 +01:00
shell_commands/gnrc_icmpv6_echo: use netif pointer
... instead of numeric network interface identifier
This commit is contained in:
parent
47fdebc938
commit
6ad3c8d223
@ -67,7 +67,7 @@ typedef struct {
|
||||
BITFIELD(cktab, CKTAB_SIZE);
|
||||
uint32_t timeout;
|
||||
uint32_t interval;
|
||||
kernel_pid_t iface;
|
||||
gnrc_netif_t *netif;
|
||||
uint16_t id;
|
||||
uint8_t hoplimit;
|
||||
uint8_t pattern;
|
||||
@ -171,21 +171,23 @@ static int _configure(int argc, char **argv, _ping_data_t *data)
|
||||
for (int i = 1; i < argc; i++) {
|
||||
char *arg = argv[i];
|
||||
if (arg[0] != '-') {
|
||||
int iface;
|
||||
|
||||
data->hostname = arg;
|
||||
#ifdef MODULE_SOCK_DNS
|
||||
if (sock_dns_query(data->hostname, &data->host, AF_INET6) == 0) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
data->iface = ipv6_addr_split_iface(data->hostname);
|
||||
if (data->iface < KERNEL_PID_UNDEF) {
|
||||
#if GNRC_NETIF_NUMOF == 1
|
||||
gnrc_netif_t *netif = gnrc_netif_iter(NULL);
|
||||
if (netif != NULL) {
|
||||
data->iface = netif->pid;
|
||||
}
|
||||
#endif
|
||||
iface = ipv6_addr_split_iface(data->hostname);
|
||||
if (iface > KERNEL_PID_UNDEF) {
|
||||
data->netif = gnrc_netif_get_by_pid(iface);
|
||||
}
|
||||
#if GNRC_NETIF_NUMOF == 1
|
||||
else {
|
||||
data->netif = gnrc_netif_iter(NULL);
|
||||
}
|
||||
#endif
|
||||
if (ipv6_addr_from_str(&data->host, data->hostname) == NULL) {
|
||||
break;
|
||||
}
|
||||
@ -295,7 +297,7 @@ static void _pinger(_ping_data_t *data)
|
||||
ipv6 = pkt->data;
|
||||
/* if data->hoplimit is unset (i.e. 0) gnrc_ipv6 will select hop limit */
|
||||
ipv6->hl = data->hoplimit;
|
||||
if (data->iface > KERNEL_PID_UNDEF) {
|
||||
if (data->netif != NULL) {
|
||||
gnrc_netif_hdr_t *netif;
|
||||
|
||||
tmp = gnrc_netif_hdr_build(NULL, 0, NULL, 0);
|
||||
@ -304,7 +306,7 @@ static void _pinger(_ping_data_t *data)
|
||||
goto error_exit;
|
||||
}
|
||||
netif = tmp->data;
|
||||
netif->if_pid = data->iface;
|
||||
netif->if_pid = data->netif->pid;
|
||||
LL_PREPEND(pkt, tmp);
|
||||
}
|
||||
if (data->datalen >= sizeof(uint32_t)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user