Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / getproto.c
blob1d09b73dc4f30c72d26bc196a94c314d1223bd66
1 /* $NetBSD: getproto.c,v 1.4 2007/04/14 20:34:24 martin Exp $ */
3 /*
4 * Copyright (C) 2002-2005 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 *
8 * Id: getproto.c,v 1.2.2.4 2007/10/27 16:03:38 darrenr Exp
9 */
11 #include "ipf.h"
13 int getproto(name)
14 char *name;
16 struct protoent *p;
17 char *s;
19 for (s = name; *s != '\0'; s++)
20 if (!ISDIGIT(*s))
21 break;
22 if (*s == '\0')
23 return atoi(name);
25 #ifdef _AIX51
27 * For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5
28 * The IANA has doubled up on the definition of 0 - it is now also
29 * used for IPv6 hop-opts, so we can no longer rely on /etc/protocols
30 * providing the correct name->number mapping
32 #endif
33 if (!strcasecmp(name, "ip"))
34 return 0;
36 p = getprotobyname(name);
37 if (p != NULL)
38 return p->p_proto;
39 return -1;