1/*	$FreeBSD$	*/
2
3/*
4 * Copyright (C) 2012 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 *
8 * $Id$
9 */
10
11#include "ipf.h"
12#include <ctype.h>
13
14int getproto(name)
15	char *name;
16{
17	struct protoent *p;
18	char *s;
19
20	for (s = name; *s != '\0'; s++)
21		if (!ISDIGIT(*s))
22			break;
23	if (*s == '\0')
24		return atoi(name);
25
26	if (!strcasecmp(name, "ip"))
27		return 0;
28
29	p = getprotobyname(name);
30	if (p != NULL)
31		return p->p_proto;
32	return -1;
33}
34