xref: /netbsd-src/external/bsd/ipf/dist/lib/icmptypename.c (revision 13885a665959c62f13a82b3caedf986eaa17aa31)
1 /*	$NetBSD: icmptypename.c,v 1.2 2012/07/22 14:27:36 darrenr Exp $	*/
2 
3 /*
4  * Copyright (C) 2012 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  *
8  * Id: icmptypename.c,v 1.1.1.2 2012/07/22 13:44:38 darrenr Exp $
9  */
10 #include "ipf.h"
11 
icmptypename(family,type)12 char *icmptypename(family, type)
13 	int family, type;
14 {
15 	icmptype_t *i;
16 
17 	if ((type < 0) || (type > 255))
18 		return NULL;
19 
20 	for (i = icmptypelist; i->it_name != NULL; i++) {
21 		if ((family == AF_INET) && (i->it_v4 == type))
22 			return i->it_name;
23 #ifdef USE_INET6
24 		if ((family == AF_INET6) && (i->it_v6 == type))
25 			return i->it_name;
26 #endif
27 	}
28 
29 	return NULL;
30 }
31