From cf83988e967405e898f85bec3da04714b1557397 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 30 Nov 2023 13:02:20 +1100 Subject: pif: Add helpers to get the name of a pif Future debugging will want to identify a specific passt interface. We make a distinction in these helpers between the name of the *type* of pif, and name of the pif itself. For the time being these are always the same thing, since we have at most instance of each type of pif. However, that might change in future. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- pif.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'pif.h') diff --git a/pif.h b/pif.h index a705f2c..ca85b34 100644 --- a/pif.h +++ b/pif.h @@ -22,6 +22,25 @@ enum pif_type { PIF_TAP, /* Namespace socket interface for splicing */ PIF_SPLICE, + + PIF_NUM_TYPES, }; +#define PIF_NAMELEN 8 + +extern const char *pif_type_str[]; + +static inline const char *pif_type(enum pif_type pt) +{ + if (pt < PIF_NUM_TYPES) + return pif_type_str[pt]; + else + return "?"; +} + +static inline const char *pif_name(uint8_t pif) +{ + return pif_type(pif); +} + #endif /* PIF_H */ -- cgit v1.2.3