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.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pif.c (limited to 'pif.c') diff --git a/pif.c b/pif.c new file mode 100644 index 0000000..ebf01cc --- /dev/null +++ b/pif.c @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright Red Hat + * Author: David Gibson + * + * Passt/pasta interface types and IDs + */ + +#include +#include + +#include "util.h" +#include "pif.h" + +const char *pif_type_str[] = { + [PIF_NONE] = "", + [PIF_HOST] = "HOST", + [PIF_TAP] = "TAP", + [PIF_SPLICE] = "SPLICE", +}; +static_assert(ARRAY_SIZE(pif_type_str) == PIF_NUM_TYPES, + "pif_type_str[] doesn't match enum pif_type"); -- cgit v1.2.3