getproto.c revision 153881
1/* $FreeBSD: head/contrib/ipfilter/lib/getproto.c 153881 2005-12-30 11:52:26Z guido $ */ 2 3#include "ipf.h" 4 5int getproto(name) 6char *name; 7{ 8 struct protoent *p; 9 char *s; 10 11 for (s = name; *s != '\0'; s++) 12 if (!ISDIGIT(*s)) 13 break; 14 if (*s == '\0') 15 return atoi(name); 16 17#ifdef _AIX51 18 /* 19 * For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5 20 */ 21 if (!strcasecmp(name, "ip")) 22 return 0; 23#endif 24 25 p = getprotobyname(name); 26 if (p != NULL) 27 return p->p_proto; 28 return -1; 29} 30