]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ipfilter/lib/printproto.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ipfilter / lib / printproto.c
1 /*
2  * Copyright (C) 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.2 2006/06/16 17:21:14 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 }