summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2023-04-12 00:14:53 -0700
committerGuy Harris <gharris@sonic.net>2023-04-12 00:14:53 -0700
commit7a8e7f79c4398e984cf1756159f2b4eef0cd3657 (patch)
treef5cac78a0896fcb3d7487acab1965ba1936b5ca3
parent52f602dbea16954e2b5fcea6fed42407d6909e01 (diff)
downloadtcpdump-7a8e7f79c4398e984cf1756159f2b4eef0cd3657.tar.gz
nhrp: handle draft-detienne-dmvpn-01, improve indication decoding.
Handle the I-D draft-detienne-dmvpn-01 traffic indication packet. Print the error code in an error indication symbolically if it's a known code. Print the address fields in the mandatory part of the header for error and traffic indication packets.
-rw-r--r--print-nhrp.c37
-rw-r--r--tests/nhrp-trace.out2
2 files changed, 34 insertions, 5 deletions
diff --git a/print-nhrp.c b/print-nhrp.c
index 1e63f01b..bc462b74 100644
--- a/print-nhrp.c
+++ b/print-nhrp.c
@@ -20,6 +20,7 @@
/*
* RFC 2332 NBMA Next Hop Resolution Protocol (NHRP)
+ * I-D draft-detienne-dmvpn-01 (expired)
*/
#ifdef HAVE_CONFIG_H
@@ -45,6 +46,7 @@
#define NHRP_PKT_PURGE_REQUEST 5
#define NHRP_PKT_PURGE_REPLY 6
#define NHRP_PKT_ERROR_INDICATION 7
+#define NHRP_PKT_TRAFFIC_INDICATION 8 /* draft-detienne-dmvpn-01 */
static const struct tok pkt_types[] = {
{ NHRP_PKT_RESOLUTION_REQUEST, "res request" },
@@ -54,6 +56,7 @@ static const struct tok pkt_types[] = {
{ NHRP_PKT_PURGE_REQUEST, "purge request" },
{ NHRP_PKT_PURGE_REPLY, "purge reply" },
{ NHRP_PKT_ERROR_INDICATION, "error indication" },
+ { NHRP_PKT_TRAFFIC_INDICATION, "traffic indication" },
{ 0, NULL }
};
@@ -82,8 +85,9 @@ struct nhrp_fixed_header {
*
* The mandatory header part formats are similar for
* all NHRP packets; the only difference is that NHRP_PKT_ERROR_INDICATION
- * has a 16-bit error code and a 16-bit error packet offset rather
- * than a 32-bit request ID.
+ * has a 16-bit error code and a 16-bit error packet offset, and
+ * NHRP_PKT_TRAFFIC_INDICATION has a 16-bit traffic code and a 16-bit unused
+ * field, rather than a 32-bit request ID.
*/
struct nhrp_mand_header {
nd_uint8_t spl; /* src proto len */
@@ -95,9 +99,31 @@ struct nhrp_mand_header {
nd_uint16_t code;
nd_uint16_t offset;
} err;
+ struct { /* error code */
+ nd_uint16_t traffic_code;
+ nd_uint16_t unused;
+ } tind;
} u;
};
+static const struct tok err_code_types[] = {
+ { 1, "unrecognized extension" },
+ { 3, "NHRP loop detected" },
+ { 6, "protocol address unreachable" },
+ { 7, "protocol error" },
+ { 8, "NHRP SDU size exceeded" },
+ { 9, "invalid extension" },
+ { 10, "invalid NHRP resolution reply received" },
+ { 11, "authentication failure" },
+ { 15, "hop count exceeded" },
+ { 0, NULL }
+};
+
+static const struct tok traffic_code_types[] = {
+ { 0, "NHRP traffic redirect/indirection" },
+ { 0, NULL }
+};
+
#define NHRP_FIXED_HEADER_LEN 20
struct nhrp_cie {
@@ -232,8 +258,11 @@ nhrp_print(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT(", id %u", GET_BE_U_4(mand_hdr->u.id));
break;
case NHRP_PKT_ERROR_INDICATION:
- ND_PRINT(", error %u", GET_BE_U_2(mand_hdr->u.err.code));
- return;
+ ND_PRINT(", error <%s>", tok2str(err_code_types, "unknown-err-code-%u", GET_BE_U_2(mand_hdr->u.err.code)));
+ break;
+ case NHRP_PKT_TRAFFIC_INDICATION:
+ ND_PRINT(", code <%s>", tok2str(traffic_code_types, "unknown-traffic-code-%u", GET_BE_U_2(mand_hdr->u.tind.traffic_code)));
+ break;
}
shtl = GET_U_1(fixed_hdr->shtl);
diff --git a/tests/nhrp-trace.out b/tests/nhrp-trace.out
index 632164a9..2ed256e7 100644
--- a/tests/nhrp-trace.out
+++ b/tests/nhrp-trace.out
@@ -1,6 +1,6 @@
1 07:11:37.354029 IP (tos 0xc0, ttl 255, id 22, offset 0, flags [none], proto GRE (47), length 126)
192.168.200.1 > 192.168.200.3: GREv0, Flags [key present], key=0x3e8, length 106
- NHRP: unknown-op-type-0008, hopcnt 255, src nbma 192.168.200.1, 10.255.255.1 -> 10.255.255.3
+ NHRP: traffic indication, code <NHRP traffic redirect/indirection>, hopcnt 255, src nbma 192.168.200.1, 10.255.255.1 -> 10.255.255.3
2 07:11:37.366110 IP (tos 0xc0, ttl 255, id 14, offset 0, flags [none], proto GRE (47), length 114)
192.168.200.3 > 192.168.200.1: GREv0, Flags [key present], key=0x3e8, length 94
NHRP: res request, id 5, hopcnt 255, src nbma 192.168.200.3, 10.255.255.3 -> 10.255.255.2 (code 0, pl 0, mtu 1514, htime 7200, pref 0)