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