blob: 6c52cd3b767790137ff9741259a45c582a57949e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* $FreeBSD$ */
/*
* Copyright (C) 2012 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* $Id$
*/
#include "ipf.h"
#include <ctype.h>
int getproto(name)
char *name;
{
struct protoent *p;
char *s;
for (s = name; *s != '\0'; s++)
if (!ISDIGIT(*s))
break;
if (*s == '\0')
return atoi(name);
#ifdef _AIX51
/*
* For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5
* The IANA has doubled up on the definition of 0 - it is now also
* used for IPv6 hop-opts, so we can no longer rely on /etc/protocols
* providing the correct name->number mapping
*/
#endif
if (!strcasecmp(name, "ip"))
return 0;
p = getprotobyname(name);
if (p != NULL)
return p->p_proto;
return -1;
}
|