Merge pull request #14028 from miri64/gnrc_pktdump/fix/opt-deps

gnrc_pktdump: fix dependencies
This commit is contained in:
Leandro Lanzieri 2020-05-08 08:53:31 +02:00 committed by GitHub
commit 2d1d13d452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 42 deletions

View File

@ -47,86 +47,93 @@ static char _stack[GNRC_PKTDUMP_STACKSIZE];
static void _dump_snip(gnrc_pktsnip_t *pkt) static void _dump_snip(gnrc_pktsnip_t *pkt)
{ {
size_t hdr_len = pkt->size; size_t hdr_len = 0;
switch (pkt->type) { switch (pkt->type) {
case GNRC_NETTYPE_UNDEF:
printf("NETTYPE_UNDEF (%i)\n", pkt->type);
od_hex_dump(pkt->data, pkt->size, OD_WIDTH_DEFAULT);
break;
#ifdef MODULE_GNRC_NETIF
case GNRC_NETTYPE_NETIF: case GNRC_NETTYPE_NETIF:
printf("NETTYPE_NETIF (%i)\n", pkt->type); printf("NETTYPE_NETIF (%i)\n", pkt->type);
if (IS_USED(MODULE_GNRC_NETIF_HDR)) {
gnrc_netif_hdr_print(pkt->data); gnrc_netif_hdr_print(pkt->data);
hdr_len = pkt->size;
}
break; break;
#endif case GNRC_NETTYPE_UNDEF:
#ifdef MODULE_GNRC_SIXLOWPAN printf("NETTYPE_UNDEF (%i)\n", pkt->type);
break;
#if IS_USED(MODULE_GNRC_NETTYPE_SIXLOWPAN)
case GNRC_NETTYPE_SIXLOWPAN: case GNRC_NETTYPE_SIXLOWPAN:
printf("NETTYPE_SIXLOWPAN (%i)\n", pkt->type); printf("NETTYPE_SIXLOWPAN (%i)\n", pkt->type);
if (IS_USED(MODULE_SIXLOWPAN)) {
sixlowpan_print(pkt->data, pkt->size); sixlowpan_print(pkt->data, pkt->size);
hdr_len = pkt->size;
}
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_SIXLOWPAN) */
#ifdef MODULE_GNRC_IPV6 #if IS_USED(MODULE_GNRC_NETTYPE_IPV6)
case GNRC_NETTYPE_IPV6: case GNRC_NETTYPE_IPV6:
printf("NETTYPE_IPV6 (%i)\n", pkt->type); printf("NETTYPE_IPV6 (%i)\n", pkt->type);
if (IS_USED(MODULE_IPV6_HDR)) {
ipv6_hdr_print(pkt->data); ipv6_hdr_print(pkt->data);
hdr_len = sizeof(ipv6_hdr_t); hdr_len = sizeof(ipv6_hdr_t);
}
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_IPV6) */
#ifdef MODULE_GNRC_IPV6_EXT #if IS_USED(MODULE_GNRC_NETTYPE_IPV6_EXT)
case GNRC_NETTYPE_IPV6_EXT: case GNRC_NETTYPE_IPV6_EXT:
printf("NETTYPE_IPV6_EXT (%i)\n", pkt->type); printf("NETTYPE_IPV6_EXT (%i)\n", pkt->type);
od_hex_dump(pkt->data, pkt->size, OD_WIDTH_DEFAULT);
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_IPV6_EXT) */
#ifdef MODULE_GNRC_ICMPV6 #if IS_USED(MODULE_GNRC_NETTYPE_ICMPV6)
case GNRC_NETTYPE_ICMPV6: case GNRC_NETTYPE_ICMPV6:
printf("NETTYPE_ICMPV6 (%i)\n", pkt->type); printf("NETTYPE_ICMPV6 (%i)\n", pkt->type);
if (IS_USED(MODULE_ICMPV6)) {
icmpv6_hdr_print(pkt->data); icmpv6_hdr_print(pkt->data);
hdr_len = sizeof(icmpv6_hdr_t); hdr_len = sizeof(icmpv6_hdr_t);
}
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_ICMPV6) */
#ifdef MODULE_GNRC_TCP #if IS_USED(MODULE_GNRC_NETTYPE_TCP)
case GNRC_NETTYPE_TCP: case GNRC_NETTYPE_TCP:
printf("NETTYPE_TCP (%i)\n", pkt->type); printf("NETTYPE_TCP (%i)\n", pkt->type);
if (IS_USED(MODULE_TCP)) {
tcp_hdr_print(pkt->data); tcp_hdr_print(pkt->data);
hdr_len = sizeof(tcp_hdr_t); hdr_len = sizeof(tcp_hdr_t);
}
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_TCP) */
#ifdef MODULE_GNRC_UDP #if IS_USED(MODULE_GNRC_NETTYPE_UDP)
case GNRC_NETTYPE_UDP: case GNRC_NETTYPE_UDP:
printf("NETTYPE_UDP (%i)\n", pkt->type); printf("NETTYPE_UDP (%i)\n", pkt->type);
if (IS_USED(MODULE_UDP)) {
udp_hdr_print(pkt->data); udp_hdr_print(pkt->data);
hdr_len = sizeof(udp_hdr_t); hdr_len = sizeof(udp_hdr_t);
}
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_UDP) */
#ifdef MODULE_CCN_LITE_UTILS #if IS_USED(MODULE_GNRC_NETTYPE_CCN)
case GNRC_NETTYPE_CCN_CHUNK: case GNRC_NETTYPE_CCN_CHUNK:
printf("GNRC_NETTYPE_CCN_CHUNK (%i)\n", pkt->type); printf("GNRC_NETTYPE_CCN_CHUNK (%i)\n", pkt->type);
printf("Content is: %.*s\n", (int)pkt->size, (char*)pkt->data); printf("Content is: %.*s\n", (int)pkt->size, (char*)pkt->data);
hdr_len = pkt->size;
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_CCN) */
#ifdef MODULE_NDN_RIOT #if IS_USED(MODULE_GNRC_NETTYPE_NDN)
case GNRC_NETTYPE_NDN: case GNRC_NETTYPE_NDN:
printf("NETTYPE_NDN (%i)\n", pkt->type); printf("NETTYPE_NDN (%i)\n", pkt->type);
od_hex_dump(pkt->data, pkt->size, OD_WIDTH_DEFAULT);
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_NDN) */
#ifdef MODULE_GNRC_LORAWAN #if IS_USED(MODULE_GNRC_NETTYPE_LORAWAN)
case GNRC_NETTYPE_LORAWAN: case GNRC_NETTYPE_LORAWAN:
printf("NETTYPE_LORAWAN (%i)\n", pkt->type); printf("NETTYPE_LORAWAN (%i)\n", pkt->type);
od_hex_dump(pkt->data, pkt->size, OD_WIDTH_DEFAULT);
break; break;
#endif #endif /* IS_USED(MODULE_GNRC_NETTYPE_LORAWAN) */
#ifdef TEST_SUITES #ifdef TEST_SUITES
case GNRC_NETTYPE_TEST: case GNRC_NETTYPE_TEST:
printf("NETTYPE_TEST (%i)\n", pkt->type); printf("NETTYPE_TEST (%i)\n", pkt->type);
od_hex_dump(pkt->data, pkt->size, OD_WIDTH_DEFAULT);
break; break;
#endif #endif
default: default:
printf("NETTYPE_UNKNOWN (%i)\n", pkt->type); printf("NETTYPE_UNKNOWN (%i)\n", pkt->type);
od_hex_dump(pkt->data, pkt->size, OD_WIDTH_DEFAULT);
break; break;
} }
if (hdr_len < pkt->size) { if (hdr_len < pkt->size) {

View File

@ -80,7 +80,7 @@ def testfunc(child):
child.expect("pktdump dumping Ethernet packet with empty payload") child.expect("pktdump dumping Ethernet packet with empty payload")
child.expect("PKTDUMP: data received:") child.expect("PKTDUMP: data received:")
child.expect(r"~~ SNIP 0 - size: 0 byte, type: NETTYPE_UNDEF \(0\)") child.expect(r"~~ SNIP 0 - size: 0 byte, type: NETTYPE_UNDEF \(0\)")
child.expect(r"00000000~~ SNIP 1 - size: \d+ byte, type: NETTYPE_NETIF \(-1\)") child.expect(r"~~ SNIP 1 - size: \d+ byte, type: NETTYPE_NETIF \(-1\)")
child.expect(r"if_pid: (\d+) rssi: -?\d+ lqi: \d+") child.expect(r"if_pid: (\d+) rssi: -?\d+ lqi: \d+")
assert 0 < int(child.match.group(1)) assert 0 < int(child.match.group(1))
child.expect("flags: 0x0") child.expect("flags: 0x0")
@ -91,7 +91,7 @@ def testfunc(child):
child.expect(r"pktdump dumping IEEE 802\.15\.4 packet with empty payload") child.expect(r"pktdump dumping IEEE 802\.15\.4 packet with empty payload")
child.expect("PKTDUMP: data received:") child.expect("PKTDUMP: data received:")
child.expect(r"~~ SNIP 0 - size: 0 byte, type: NETTYPE_UNDEF \(0\)") child.expect(r"~~ SNIP 0 - size: 0 byte, type: NETTYPE_UNDEF \(0\)")
child.expect(r"00000000~~ SNIP 1 - size: \d+ byte, type: NETTYPE_NETIF \(-1\)") child.expect(r"~~ SNIP 1 - size: \d+ byte, type: NETTYPE_NETIF \(-1\)")
child.expect(r"if_pid: (\d+) rssi: -?\d+ lqi: \d+") child.expect(r"if_pid: (\d+) rssi: -?\d+ lqi: \d+")
assert 0 < int(child.match.group(1)) assert 0 < int(child.match.group(1))
child.expect("flags: 0x0") child.expect("flags: 0x0")