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