summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-09-29 22:10:53 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2021-01-12 23:34:17 +0100
commit190b70e7ea3127e3c2b2769f7440076a6caa1cbb (patch)
treeb847e7f9b6d2f18e397cac025cbfa5b27c1fc893
parentb04f434f693e49c65197c2c1bcee2d5fd66f12d2 (diff)
TunnelEncaps: Add tunnel type names
-rw-r--r--lib/tunnel_encaps.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/lib/tunnel_encaps.c b/lib/tunnel_encaps.c
index 421c0c83..aa3e6b29 100644
--- a/lib/tunnel_encaps.c
+++ b/lib/tunnel_encaps.c
@@ -176,6 +176,43 @@ int decode_tunnel_encap(const eattr *e, struct tunnel_encap *encap, struct pool
return 0;
}
+struct {
+ int type;
+ const char *name;
+} tunnel_types[] = {
+ {0, "Reserved"},
+ {1, "L2TPv3 over IP"},
+ {2, "GRE"},
+ {3, "Transmit tunnel endpoint"},
+ {4, "IPsec in Tunnel-mode"},
+ {5, "IP in IP tunnel with IPsec Transport Mode"},
+ {6, "MPLS-in-IP tunnel with IPsec Transport Mode"},
+ {7, "IP in IP"},
+ {8, "VXLAN"},
+ {9, "NVGRE"},
+ {10, "MPLS"},
+ {11, "MPLS in GRE"},
+ {12, "VXLAN GPE"},
+ {13, "MPLS in UDP"},
+ {14, "IPv6 Tunnel"},
+ {15, "SR TE Policy Type"},
+ {16, "Bare"},
+ {17, "SR Tunnel"},
+};
+
+const uint num_tunnel_types = sizeof(tunnel_types)/sizeof(tunnel_types[0]);
+
+static const char *
+lookup_name(int type)
+{
+ for (uint i = 0; i < num_tunnel_types; i++) {
+ if (tunnel_types[i].type == type)
+ return tunnel_types[i].name;
+ }
+
+ return "Unassigned";
+}
+
int format_tunnel_encap(const eattr *a, byte *buf, uint size)
{
byte *pos = buf;
@@ -192,7 +229,9 @@ int format_tunnel_encap(const eattr *a, byte *buf, uint size)
return pos - buf;
}
- l = bsnprintf(pos, size, "type: %d", encap.type);
+ const char *name = lookup_name(encap.type);
+
+ l = bsnprintf(pos, size, "type: %s(%d)", name, encap.type);
if (l < 0)
return pos - buf;
ADVANCE(pos, size, l);