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