summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 024f95e..4f892a7 100644
--- a/utils.c
+++ b/utils.c
@@ -912,3 +912,24 @@ bool fw3_attr_parse_name_type(struct blob_attr *entry, const char **name, const
return *type != NULL ? true : false;
}
+
+const char *
+fw3_protoname(void *proto)
+{
+ static char buf[sizeof("4294967295")];
+ struct fw3_protocol *p = proto;
+ struct protoent *pe;
+
+ if (!p)
+ return "?";
+
+ pe = getprotobynumber(p->protocol);
+
+ if (!pe)
+ {
+ snprintf(buf, sizeof(buf), "%u", p->protocol);
+ return buf;
+ }
+
+ return pe->p_name;
+}