]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ipfilter/lib/printproto.c
MFC 4cd1807c7d2a67b633dd0c0bfde15091543a2514:
[FreeBSD/FreeBSD.git] / contrib / ipfilter / lib / printproto.c
1 /*
2  * Copyright (C) 2012 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$";
12 #endif
13
14
15 void
16 printproto(pr, p, np)
17         struct protoent *pr;
18         int p;
19         ipnat_t *np;
20 {
21         if (np != NULL) {
22                 if ((np->in_flags & IPN_TCPUDP) == IPN_TCPUDP)
23                         PRINTF("tcp/udp");
24                 else if (np->in_flags & IPN_TCP)
25                         PRINTF("tcp");
26                 else if (np->in_flags & IPN_UDP)
27                         PRINTF("udp");
28                 else if (np->in_flags & IPN_ICMPQUERY)
29                         PRINTF("icmp");
30                 else if (np->in_pr[0] == 0)
31                         PRINTF("ip");
32                 else if (pr != NULL)
33                         PRINTF("%s", pr->p_name);
34                 else
35                         PRINTF("%d", np->in_pr[0]);
36         } else {
37                 if (pr != NULL)
38                         PRINTF("%s", pr->p_name);
39                 else
40                         PRINTF("%d", p);
41         }
42 }