getproto.c revision 153881
1145519Sdarrenr/* $FreeBSD: head/contrib/ipfilter/lib/getproto.c 153881 2005-12-30 11:52:26Z guido $ */ 2145510Sdarrenr 3145510Sdarrenr#include "ipf.h" 4145510Sdarrenr 5145510Sdarrenrint getproto(name) 6145510Sdarrenrchar *name; 7145510Sdarrenr{ 8145510Sdarrenr struct protoent *p; 9145510Sdarrenr char *s; 10145510Sdarrenr 11145510Sdarrenr for (s = name; *s != '\0'; s++) 12145510Sdarrenr if (!ISDIGIT(*s)) 13145510Sdarrenr break; 14145510Sdarrenr if (*s == '\0') 15145510Sdarrenr return atoi(name); 16145510Sdarrenr 17153881Sguido#ifdef _AIX51 18153881Sguido /* 19153881Sguido * For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5 20153881Sguido */ 21153881Sguido if (!strcasecmp(name, "ip")) 22153881Sguido return 0; 23153881Sguido#endif 24153881Sguido 25145510Sdarrenr p = getprotobyname(name); 26145510Sdarrenr if (p != NULL) 27145510Sdarrenr return p->p_proto; 28145510Sdarrenr return -1; 29145510Sdarrenr} 30