44bc301921
Reported by: jrtc27 Fixes: 2582ae5740181e0d2bab10003d66ae91c9b56329 MFC after: 1 month
36 lines
490 B
C
36 lines
490 B
C
/* $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);
|
|
}
|