summaryrefslogtreecommitdiff
path: root/lib/mpls.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mpls.h')
-rw-r--r--lib/mpls.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/mpls.h b/lib/mpls.h
index 74bd7aae3e..f89d3246ff 100644
--- a/lib/mpls.h
+++ b/lib/mpls.h
@@ -23,6 +23,7 @@
#define _QUAGGA_MPLS_H
#include <zebra.h>
+#include <vxlan.h>
#include <arpa/inet.h>
#ifdef __cplusplus
@@ -129,10 +130,32 @@ enum lsp_types_t {
ZEBRA_LSP_ISIS_SR = 5,/* IS-IS Segment Routing LSP. */
ZEBRA_LSP_SHARP = 6, /* Identifier for test protocol */
ZEBRA_LSP_SRTE = 7, /* SR-TE LSP */
+ ZEBRA_LSP_EVPN = 8, /* EVPN VNI Label */
};
/* Functions for basic label operations. */
+static inline void vni2label(vni_t vni, mpls_label_t *label)
+{
+ uint8_t *tag = (uint8_t *)label;
+
+ tag[0] = (vni >> 16) & 0xFF;
+ tag[1] = (vni >> 8) & 0xFF;
+ tag[2] = vni & 0xFF;
+}
+
+static inline vni_t label2vni(const mpls_label_t *label)
+{
+ uint8_t *tag = (uint8_t *)label;
+ vni_t vni;
+
+ vni = ((uint32_t)*tag++ << 16);
+ vni |= (uint32_t)*tag++ << 8;
+ vni |= (uint32_t)(*tag & 0xFF);
+
+ return vni;
+}
+
/* Encode a label stack entry from fields; convert to network byte-order as
* the Netlink interface expects MPLS labels to be in this format.
*/
@@ -168,8 +191,14 @@ static inline void mpls_lse_decode(mpls_lse_t lse, mpls_label_t *label,
#define MPLS_INVALID_LABEL_INDEX 0xFFFFFFFF
/* Printable string for labels (with consideration for reserved values). */
-static inline char *label2str(mpls_label_t label, char *buf, size_t len)
+static inline char *label2str(mpls_label_t label, enum lsp_types_t type,
+ char *buf, size_t len)
{
+ if (type == ZEBRA_LSP_EVPN) {
+ snprintf(buf, len, "%u", label2vni(&label));
+ return (buf);
+ }
+
switch (label) {
case MPLS_LABEL_IPV4_EXPLICIT_NULL:
strlcpy(buf, "IPv4 Explicit Null", len);
@@ -217,7 +246,7 @@ int mpls_str2label(const char *label_str, uint8_t *num_labels,
* Label to string conversion, labels in string separated by '/'.
*/
char *mpls_label2str(uint8_t num_labels, const mpls_label_t *labels, char *buf,
- int len, int pretty);
+ int len, enum lsp_types_t type, int pretty);
#ifdef __cplusplus
}