2005-04-25 18:20:15 +00:00
|
|
|
/* $FreeBSD$ */
|
2005-04-25 17:31:50 +00:00
|
|
|
|
2007-06-04 02:54:36 +00:00
|
|
|
/*
|
2013-08-11 14:28:45 +00:00
|
|
|
* Copyright (C) 2012 by Darren Reed.
|
|
|
|
*
|
|
|
|
* See the IPFILTER.LICENCE file for details on licencing.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*/
|
2007-06-04 02:54:36 +00:00
|
|
|
|
2005-04-25 17:31:50 +00:00
|
|
|
#include "ipf.h"
|
2013-08-11 14:28:45 +00:00
|
|
|
#include <ctype.h>
|
2005-04-25 17:31:50 +00:00
|
|
|
|
2021-12-20 17:07:20 +00:00
|
|
|
int getproto(char *name);
|
|
|
|
|
|
|
|
int
|
|
|
|
getproto(char *name)
|
2005-04-25 17:31:50 +00:00
|
|
|
{
|
|
|
|
struct protoent *p;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
for (s = name; *s != '\0'; s++)
|
|
|
|
if (!ISDIGIT(*s))
|
|
|
|
break;
|
|
|
|
if (*s == '\0')
|
2022-01-04 02:49:18 +00:00
|
|
|
return (atoi(name));
|
2005-04-25 17:31:50 +00:00
|
|
|
|
2005-12-30 11:52:26 +00:00
|
|
|
if (!strcasecmp(name, "ip"))
|
2022-01-04 02:49:18 +00:00
|
|
|
return (0);
|
2005-12-30 11:52:26 +00:00
|
|
|
|
2005-04-25 17:31:50 +00:00
|
|
|
p = getprotobyname(name);
|
|
|
|
if (p != NULL)
|
2022-01-04 02:49:18 +00:00
|
|
|
return (p->p_proto);
|
|
|
|
return (-1);
|
2005-04-25 17:31:50 +00:00
|
|
|
}
|