xref: /titanic_52/usr/src/cmd/ipf/lib/common/getproto.c (revision b6c3f7863936abeae522e48a13887dddeb691a45)
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