xref: /onnv-gate/usr/src/cmd/ipf/lib/common/getproto.c (revision 2393:76e0289ce525)
1*2393Syz155240 /*
2*2393Syz155240  * Copyright (C) 1993-2005  by Darren Reed.
3*2393Syz155240  * See the IPFILTER.LICENCE file for details on licencing.
4*2393Syz155240  */
5*2393Syz155240 
60Sstevel@tonic-gate #include "ipf.h"
70Sstevel@tonic-gate 
getproto(name)80Sstevel@tonic-gate int getproto(name)
90Sstevel@tonic-gate char *name;
100Sstevel@tonic-gate {
110Sstevel@tonic-gate 	struct protoent *p;
120Sstevel@tonic-gate 	char *s;
130Sstevel@tonic-gate 
140Sstevel@tonic-gate 	for (s = name; *s != '\0'; s++)
15*2393Syz155240 		if (!ISDIGIT(*s))
160Sstevel@tonic-gate 			break;
170Sstevel@tonic-gate 	if (*s == '\0')
180Sstevel@tonic-gate 		return atoi(name);
190Sstevel@tonic-gate 
20*2393Syz155240 #ifdef _AIX51
21*2393Syz155240 	/*
22*2393Syz155240 	 * For some bogus reason, "ip" is 252 in /etc/protocols on AIX 5
23*2393Syz155240 	 */
24*2393Syz155240 	if (!strcasecmp(name, "ip"))
25*2393Syz155240 		return 0;
26*2393Syz155240 #endif
27*2393Syz155240 
280Sstevel@tonic-gate 	p = getprotobyname(name);
290Sstevel@tonic-gate 	if (p != NULL)
300Sstevel@tonic-gate 		return p->p_proto;
310Sstevel@tonic-gate 	return -1;
320Sstevel@tonic-gate }
33