aboutsummaryrefslogtreecommitdiff
path: root/sbin/ipf/libipf/icmptypename.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/ipf/libipf/icmptypename.c')
-rw-r--r--sbin/ipf/libipf/icmptypename.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/sbin/ipf/libipf/icmptypename.c b/sbin/ipf/libipf/icmptypename.c
new file mode 100644
index 000000000000..08113853ffea
--- /dev/null
+++ b/sbin/ipf/libipf/icmptypename.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2012 by Darren Reed.
+ *
+ * See the IPFILTER.LICENCE file for details on licencing.
+ *
+ * $Id$
+ */
+#include "ipf.h"
+
+char *
+icmptypename(int family, int type)
+{
+ icmptype_t *i;
+
+ if ((type < 0) || (type > 255))
+ return (NULL);
+
+ for (i = icmptypelist; i->it_name != NULL; i++) {
+ if ((family == AF_INET) && (i->it_v4 == type))
+ return (i->it_name);
+#ifdef USE_INET6
+ if ((family == AF_INET6) && (i->it_v6 == type))
+ return (i->it_name);
+#endif
+ }
+
+ return (NULL);
+}