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>2020-09-13 18:05:34 +0200
commitcdf197d153921f098bc8f026d629f9a72f688f40 (patch)
tree82ee87d203948cadacf4bb9a3fe274b746c1fc7a
parent87264e5c5ba36fcfadfbcdd53b4e681cd995dbe3 (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);