Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / cmd / ipf / lib / common / getproto.c
blob472fe148abb6aaa5044aae70386241997b7f45b8
1 /*
2 * Copyright (C) 1993-2005 by Darren Reed.
3 * See the IPFILTER.LICENCE file for details on licencing.
4 */
6 #include "ipf.h"
8 int getproto(name)
9 char *name;
11 struct protoent *p;
12 char *s;
14 for (s = name; *s != '\0'; s++)
15 if (!ISDIGIT(*s))
16 break;
17 if (*s == '\0')
18 return atoi(name);
20 #ifdef _AIX51
22 * For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5
24 if (!strcasecmp(name, "ip"))
25 return 0;
26 #endif
28 p = getprotobyname(name);
29 if (p != NULL)
30 return p->p_proto;
31 return -1;