blob: f5bfc8e316dba2372bf9f0ba9678b50a9ec821f4 (
plain) (
blame)
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
|
/* $FreeBSD: src/contrib/ipfilter/lib/getproto.c,v 1.4.10.1.6.1 2010/12/21 17:09:25 kensmith Exp $ */
/*
* Copyright (C) 2002-2005 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* $Id: getproto.c,v 1.2.2.3 2006/06/16 17:21:00 darrenr Exp $
*/
#include "ipf.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
*/
if (!strcasecmp(name, "ip"))
return 0;
#endif
p = getprotobyname(name);
if (p != NULL)
return p->p_proto;
return -1;
}
|