]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ipfilter/lib/getproto.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ipfilter / lib / getproto.c
1 /*      $FreeBSD$       */
2
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.3 2006/06/16 17:21:00 darrenr Exp $ 
9  */     
10
11 #include "ipf.h"
12
13 int getproto(name)
14 char *name;
15 {
16         struct protoent *p;
17         char *s;
18
19         for (s = name; *s != '\0'; s++)
20                 if (!ISDIGIT(*s))
21                         break;
22         if (*s == '\0')
23                 return atoi(name);
24
25 #ifdef _AIX51
26         /*
27          * For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5
28          */
29         if (!strcasecmp(name, "ip"))
30                 return 0;
31 #endif
32
33         p = getprotobyname(name);
34         if (p != NULL)
35                 return p->p_proto;
36         return -1;
37 }