xref: /titanic_41/usr/src/cmd/ipf/lib/common/getproto.c (revision 9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bb)
1 /*
2  * Copyright (C) 1993-2005  by Darren Reed.
3  * See the IPFILTER.LICENCE file for details on licencing.
4  */
5 
6 #include "ipf.h"
7 
8 int getproto(name)
9 char *name;
10 {
11 	struct protoent *p;
12 	char *s;
13 
14 	for (s = name; *s != '\0'; s++)
15 		if (!ISDIGIT(*s))
16 			break;
17 	if (*s == '\0')
18 		return atoi(name);
19 
20 #ifdef _AIX51
21 	/*
22 	 * For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5
23 	 */
24 	if (!strcasecmp(name, "ip"))
25 		return 0;
26 #endif
27 
28 	p = getprotobyname(name);
29 	if (p != NULL)
30 		return p->p_proto;
31 	return -1;
32 }
33