From 8f7af2e42cb32fed5eadc0153d32a297b1894a18 Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Thu, 20 Feb 2025 10:08:03 +0100 Subject: [PATCH] lib: Add a function to convert SR Policy Headend Behaviors into string This commit adds a function to convert SR Policy Headend Behaviors into string format for printing. Signed-off-by: Carmine Scarpitta --- lib/srv6.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/srv6.h b/lib/srv6.h index 24b387ec4e..b25241adfa 100644 --- a/lib/srv6.h +++ b/lib/srv6.h @@ -345,6 +345,24 @@ struct srv6_sid_ctx { ifindex_t ifindex; }; +static inline const char *srv6_headend_behavior2str(enum srv6_headend_behavior behavior) +{ + switch (behavior) { + case SRV6_HEADEND_BEHAVIOR_H_INSERT: + return "H.Insert"; + case SRV6_HEADEND_BEHAVIOR_H_ENCAPS: + return "H.Encaps"; + case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_RED: + return "H.Encaps.Red"; + case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_L2: + return "H.Encaps.L2"; + case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_L2_RED: + return "H.Encaps.L2.Red"; + } + + return "unknown"; +} + static inline const char *seg6_mode2str(enum seg6_mode_t mode) { switch (mode) { -- 2.39.5