getproto.c revision 145519
1/*	$FreeBSD: head/contrib/ipfilter/lib/getproto.c 145519 2005-04-25 18:20:15Z darrenr $	*/
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	p = getprotobyname(name);
18	if (p != NULL)
19		return p->p_proto;
20	return -1;
21}
22