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