NetBSD/dist/ipf/lib/getproto.c

30 lines
468 B
C
Raw Normal View History

2006-04-04 20:17:18 +04:00
/* $NetBSD: getproto.c,v 1.3 2006/04/04 16:17:18 martti Exp $ */
2004-03-28 12:55:20 +04:00
#include "ipf.h"
int getproto(name)
char *name;
{
struct protoent *p;
char *s;
for (s = name; *s != '\0'; s++)
if (!ISDIGIT(*s))
2004-03-28 12:55:20 +04:00
break;
if (*s == '\0')
return atoi(name);
2006-04-04 20:17:18 +04:00
#ifdef _AIX51
/*
* For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5
*/
if (!strcasecmp(name, "ip"))
return 0;
#endif
2004-03-28 12:55:20 +04:00
p = getprotobyname(name);
if (p != NULL)
return p->p_proto;
return -1;
}