xref: /titanic_52/usr/src/cmd/ipf/lib/common/getproto.c (revision 7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fe)
1 #include "ipf.h"
2 
3 int getproto(name)
4 char *name;
5 {
6 	struct protoent *p;
7 	char *s;
8 
9 	for (s = name; *s != '\0'; s++)
10 		if (!isdigit(*s))
11 			break;
12 	if (*s == '\0')
13 		return atoi(name);
14 
15 	p = getprotobyname(name);
16 	if (p != NULL)
17 		return p->p_proto;
18 	return -1;
19 }
20