1 /* $NetBSD: printproto.c,v 1.2 2012/07/22 14:27:37 darrenr Exp $ */ 2 3 /* 4 * Copyright (C) 2012 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 */ 8 9 #include "ipf.h" 10 11 12 #if !defined(lint) 13 static const char rcsid[] = "@(#)Id: printproto.c,v 1.1.1.2 2012/07/22 13:44:42 darrenr Exp $"; 14 #endif 15 16 17 void 18 printproto(pr, p, np) 19 struct protoent *pr; 20 int p; 21 ipnat_t *np; 22 { 23 if (np != NULL) { 24 if ((np->in_flags & IPN_TCPUDP) == IPN_TCPUDP) 25 PRINTF("tcp/udp"); 26 else if (np->in_flags & IPN_TCP) 27 PRINTF("tcp"); 28 else if (np->in_flags & IPN_UDP) 29 PRINTF("udp"); 30 else if (np->in_flags & IPN_ICMPQUERY) 31 PRINTF("icmp"); 32 #ifdef _AIX51 33 /* 34 * To make up for "ip = 252" and "hopopt = 0" in /etc/protocols 35 * The IANA has doubled up on the definition of 0 - it is now 36 * also used for IPv6 hop-opts, so we can no longer rely on 37 * /etc/protocols providing the correct name->number mapping. 38 */ 39 #endif 40 else if (np->in_pr[0] == 0) 41 PRINTF("ip"); 42 else if (pr != NULL) 43 PRINTF("%s", pr->p_name); 44 else 45 PRINTF("%d", np->in_pr[0]); 46 } else { 47 #ifdef _AIX51 48 if (p == 0) 49 PRINTF("ip"); 50 else 51 #endif 52 if (pr != NULL) 53 PRINTF("%s", pr->p_name); 54 else 55 PRINTF("%d", p); 56 } 57 } 58