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-05-08 18:52:55 +0200
commit2ad421b12eb94c06a3eb41740b48bb1a6d0d4f27 (patch)
tree51ca842548b2338a9cd8c0e207c1d6f442ae3a7c
parentffcdbe0b6c9bb500393251183ebe19d3170c46b8 (diff)
Wireguard: 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);