141edb306SCy Schubert /* $FreeBSD$ */ 241edb306SCy Schubert 341edb306SCy Schubert /* 441edb306SCy Schubert * Copyright (C) 2012 by Darren Reed. 541edb306SCy Schubert * 641edb306SCy Schubert * See the IPFILTER.LICENCE file for details on licencing. 741edb306SCy Schubert * 841edb306SCy Schubert * $Id$ 941edb306SCy Schubert */ 1041edb306SCy Schubert 1141edb306SCy Schubert #include "ipf.h" 1241edb306SCy Schubert #include <ctype.h> 1341edb306SCy Schubert 14efeb8bffSCy Schubert int getproto(char *name); 15efeb8bffSCy Schubert 16efeb8bffSCy Schubert int 17efeb8bffSCy Schubert getproto(char *name) 1841edb306SCy Schubert { 1941edb306SCy Schubert struct protoent *p; 2041edb306SCy Schubert char *s; 2141edb306SCy Schubert 2241edb306SCy Schubert for (s = name; *s != '\0'; s++) 2341edb306SCy Schubert if (!ISDIGIT(*s)) 2441edb306SCy Schubert break; 2541edb306SCy Schubert if (*s == '\0') 26*2582ae57SCy Schubert return(atoi(name)); 2741edb306SCy Schubert 2841edb306SCy Schubert if (!strcasecmp(name, "ip")) 29*2582ae57SCy Schubert return(0); 3041edb306SCy Schubert 3141edb306SCy Schubert p = getprotobyname(name); 3241edb306SCy Schubert if (p != NULL) 33*2582ae57SCy Schubert return(p->p_proto); 34*2582ae57SCy Schubert return(-1); 3541edb306SCy Schubert } 36