mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
shell/gnrc_icmpv6_echo: print interface id in reply
If there is more than one interface, print the id of the receiving interface for convenience. ``` ping6 ff02::1 2020-02-20 18:19:38,644 # 12 bytes from fe80::d0ae:c1b:2054:58e%7: icmp_seq=0 ttl=64 rssi=-45 dBm time=4.801 ms 2020-02-20 18:19:38,652 # 12 bytes from fe80::d0ae:c1b:2054:58c%8: icmp_seq=0 ttl=64 rssi=-63 dBm time=13.422 ms (DUP!) 2020-02-20 18:19:38,661 # 12 bytes from fe80::c78:16d9:8aca:ba9a%8: icmp_seq=0 ttl=64 rssi=-44 dBm time=21.819 ms (DUP!) 2020-02-20 18:19:39,648 # 12 bytes from fe80::d0ae:c1b:2054:58e%7: icmp_seq=1 ttl=64 rssi=-44 dBm time=4.797 ms 2020-02-20 18:19:39,657 # 12 bytes from fe80::d0ae:c1b:2054:58c%8: icmp_seq=1 ttl=64 rssi=-61 dBm time=12.917 ms (DUP!) 2020-02-20 18:19:39,666 # 12 bytes from fe80::c78:16d9:8aca:ba9a%8: icmp_seq=1 ttl=64 rssi=-43 dBm time=21.679 ms (DUP!) 2020-02-20 18:19:40,657 # 12 bytes from fe80::d0ae:c1b:2054:58e%7: icmp_seq=2 ttl=64 rssi=-41 dBm time=4.795 ms ```
This commit is contained in:
parent
ea3296df62
commit
d572db83e1
@ -77,7 +77,7 @@ static void _usage(char *cmdname);
|
||||
static int _configure(int argc, char **argv, _ping_data_t *data);
|
||||
static void _pinger(_ping_data_t *data);
|
||||
static void _print_reply(_ping_data_t *data, gnrc_pktsnip_t *icmpv6,
|
||||
ipv6_addr_t *from, unsigned hoplimit, int16_t rssi);
|
||||
ipv6_addr_t *from, unsigned hoplimit, gnrc_netif_hdr_t *netif_hdr);
|
||||
static void _handle_reply(_ping_data_t *data, gnrc_pktsnip_t *pkt);
|
||||
static int _finish(_ping_data_t *data);
|
||||
|
||||
@ -322,10 +322,13 @@ error_exit:
|
||||
|
||||
static void _print_reply(_ping_data_t *data, gnrc_pktsnip_t *icmpv6,
|
||||
ipv6_addr_t *from, unsigned hoplimit,
|
||||
int16_t rssi)
|
||||
gnrc_netif_hdr_t *netif_hdr)
|
||||
{
|
||||
icmpv6_echo_t *icmpv6_hdr = icmpv6->data;
|
||||
|
||||
kernel_pid_t if_pid = netif_hdr ? netif_hdr->if_pid : KERNEL_PID_UNDEF;
|
||||
int16_t rssi = netif_hdr ? netif_hdr->rssi : 0;
|
||||
|
||||
/* discard if too short */
|
||||
if (icmpv6->size < (data->datalen + sizeof(icmpv6_echo_t))) {
|
||||
return;
|
||||
@ -364,8 +367,17 @@ static void _print_reply(_ping_data_t *data, gnrc_pktsnip_t *icmpv6,
|
||||
data->num_recv++;
|
||||
dupmsg += 7;
|
||||
}
|
||||
printf("%u bytes from %s: icmp_seq=%u ttl=%u", (unsigned)icmpv6->size,
|
||||
from_str, recv_seq, hoplimit);
|
||||
if ((GNRC_NETIF_NUMOF == 1) || (if_pid == KERNEL_PID_UNDEF) ||
|
||||
!ipv6_addr_is_link_local(from)) {
|
||||
printf("%u bytes from %s: icmp_seq=%u ttl=%u",
|
||||
(unsigned)icmpv6->size,
|
||||
from_str, recv_seq, hoplimit);
|
||||
} else {
|
||||
printf("%u bytes from %s%%%u: icmp_seq=%u ttl=%u",
|
||||
(unsigned)icmpv6->size,
|
||||
from_str, if_pid, recv_seq, hoplimit);
|
||||
|
||||
}
|
||||
if (rssi) {
|
||||
printf(" rssi=%"PRId16" dBm", rssi);
|
||||
}
|
||||
@ -392,7 +404,7 @@ static void _handle_reply(_ping_data_t *data, gnrc_pktsnip_t *pkt)
|
||||
}
|
||||
ipv6_hdr = ipv6->data;
|
||||
netif_hdr = netif ? netif->data : NULL;
|
||||
_print_reply(data, icmpv6, &ipv6_hdr->src, ipv6_hdr->hl, netif_hdr ? netif_hdr->rssi : 0);
|
||||
_print_reply(data, icmpv6, &ipv6_hdr->src, ipv6_hdr->hl, netif_hdr);
|
||||
#ifdef MODULE_GNRC_IPV6_NIB
|
||||
/* successful ping to neighbor (NIB handles case if ipv6->src is not a
|
||||
* neighbor) can be taken as upper-layer hint for reachability:
|
||||
|
Loading…
Reference in New Issue
Block a user