xref: /titanic_51/usr/src/cmd/ipf/lib/common/printproto.c (revision ab25eeb551a4be927a4b6ae2cf8aff7ed17decb4)
1*ab25eeb5Syz155240 /*
2*ab25eeb5Syz155240  * Copyright (C) 1993-2005 by Darren Reed.
3*ab25eeb5Syz155240  *
4*ab25eeb5Syz155240  * See the IPFILTER.LICENCE file for details on licencing.
5*ab25eeb5Syz155240  */
6*ab25eeb5Syz155240 
7*ab25eeb5Syz155240 #include "ipf.h"
8*ab25eeb5Syz155240 
9*ab25eeb5Syz155240 
10*ab25eeb5Syz155240 #if !defined(lint)
11*ab25eeb5Syz155240 static const char rcsid[] = "@(#)$Id: printproto.c,v 1.1.2.1 2005/06/12 07:21:53 darrenr Exp $";
12*ab25eeb5Syz155240 #endif
13*ab25eeb5Syz155240 
14*ab25eeb5Syz155240 
15*ab25eeb5Syz155240 void printproto(pr, p, np)
16*ab25eeb5Syz155240 struct protoent *pr;
17*ab25eeb5Syz155240 int p;
18*ab25eeb5Syz155240 ipnat_t *np;
19*ab25eeb5Syz155240 {
20*ab25eeb5Syz155240 	if (np != NULL) {
21*ab25eeb5Syz155240 		if ((np->in_flags & IPN_TCPUDP) == IPN_TCPUDP)
22*ab25eeb5Syz155240 			printf("tcp/udp");
23*ab25eeb5Syz155240 		else if (np->in_flags & IPN_TCP)
24*ab25eeb5Syz155240 			printf("tcp");
25*ab25eeb5Syz155240 		else if (np->in_flags & IPN_UDP)
26*ab25eeb5Syz155240 			printf("udp");
27*ab25eeb5Syz155240 		else if (np->in_flags & IPN_ICMPQUERY)
28*ab25eeb5Syz155240 			printf("icmp");
29*ab25eeb5Syz155240 #ifdef _AIX51
30*ab25eeb5Syz155240 		/*
31*ab25eeb5Syz155240 		 * To make up for "ip = 252" and "hopopt = 0" in /etc/protocols
32*ab25eeb5Syz155240 		 */
33*ab25eeb5Syz155240 		else if (np->in_p == 0)
34*ab25eeb5Syz155240 			printf("ip");
35*ab25eeb5Syz155240 #endif
36*ab25eeb5Syz155240 		else if (pr != NULL)
37*ab25eeb5Syz155240 			printf("%s", pr->p_name);
38*ab25eeb5Syz155240 		else
39*ab25eeb5Syz155240 			printf("%d", np->in_p);
40*ab25eeb5Syz155240 	} else {
41*ab25eeb5Syz155240 #ifdef _AIX51
42*ab25eeb5Syz155240 		if (p == 0)
43*ab25eeb5Syz155240 			printf("ip");
44*ab25eeb5Syz155240 		else
45*ab25eeb5Syz155240 #endif
46*ab25eeb5Syz155240 		if (pr != NULL)
47*ab25eeb5Syz155240 			printf("%s", pr->p_name);
48*ab25eeb5Syz155240 		else
49*ab25eeb5Syz155240 			printf("%d", p);
50*ab25eeb5Syz155240 	}
51*ab25eeb5Syz155240 }
52