diff options
Diffstat (limited to 'lib/tunnel_encaps.c')
-rw-r--r-- | lib/tunnel_encaps.c | 41 |
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); |