NetBSD/dist/ipf/lib/printproto.c

57 lines
1.2 KiB
C
Raw Normal View History

/* $NetBSD: printproto.c,v 1.1.1.3 2008/05/20 06:45:04 darrenr Exp $ */
2006-04-04 20:08:18 +04:00
/*
2007-04-15 00:17:19 +04:00
* Copyright (C) 2005 by Darren Reed.
2006-04-04 20:08:18 +04:00
*
* See the IPFILTER.LICENCE file for details on licencing.
*/
#include "ipf.h"
#if !defined(lint)
static const char rcsid[] = "@(#)Id: printproto.c,v 1.1.2.3 2007/10/27 16:03:39 darrenr Exp";
2006-04-04 20:08:18 +04:00
#endif
void printproto(pr, p, np)
struct protoent *pr;
int p;
ipnat_t *np;
{
if (np != NULL) {
if ((np->in_flags & IPN_TCPUDP) == IPN_TCPUDP)
printf("tcp/udp");
else if (np->in_flags & IPN_TCP)
printf("tcp");
else if (np->in_flags & IPN_UDP)
printf("udp");
else if (np->in_flags & IPN_ICMPQUERY)
printf("icmp");
#ifdef _AIX51
/*
* To make up for "ip = 252" and "hopopt = 0" in /etc/protocols
* The IANA has doubled up on the definition of 0 - it is now
* also used for IPv6 hop-opts, so we can no longer rely on
* /etc/protocols providing the correct name->number mapping
2006-04-04 20:08:18 +04:00
*/
#endif
2006-04-04 20:08:18 +04:00
else if (np->in_p == 0)
printf("ip");
else if (pr != NULL)
printf("%s", pr->p_name);
else
printf("%d", np->in_p);
} else {
#ifdef _AIX51
if (p == 0)
printf("ip");
else
#endif
if (pr != NULL)
printf("%s", pr->p_name);
else
printf("%d", p);
}
}