freebsd-dev/sbin/ipf/libipf/getproto.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
490 B
C
Raw Normal View History

/* $FreeBSD$ */
/*
* Copyright (C) 2012 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* $Id$
*/
#include "ipf.h"
#include <ctype.h>
int getproto(char *name);
int
getproto(char *name)
{
struct protoent *p;
char *s;
for (s = name; *s != '\0'; s++)
if (!ISDIGIT(*s))
break;
if (*s == '\0')
return (atoi(name));
if (!strcasecmp(name, "ip"))
return (0);
p = getprotobyname(name);
if (p != NULL)
return (p->p_proto);
return (-1);
}