summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/lib/printnat.c
diff options
context:
space:
mode:
authorcy <cy@FreeBSD.org>2013-07-19 05:41:57 +0000
committercy <cy@FreeBSD.org>2013-07-19 05:41:57 +0000
commit672af8808c0e7c15f330b401482f9271c2eb3fa6 (patch)
tree225b5acf68c01bc6a260b386c2b2dbf4fa2839e3 /contrib/ipfilter/lib/printnat.c
parent71e82d94e82560b20789833f60056506de34de8b (diff)
downloadFreeBSD-src-672af8808c0e7c15f330b401482f9271c2eb3fa6.zip
FreeBSD-src-672af8808c0e7c15f330b401482f9271c2eb3fa6.tar.gz
As per the developers handbook (5.3.1 step 1), prepare the vendor trees for
import of new ipfilter vendor sources by flattening them. To keep the tags consistent with dist, the tags are also flattened. Approved by: glebius (Mentor)
Diffstat (limited to 'contrib/ipfilter/lib/printnat.c')
-rw-r--r--contrib/ipfilter/lib/printnat.c238
1 files changed, 0 insertions, 238 deletions
diff --git a/contrib/ipfilter/lib/printnat.c b/contrib/ipfilter/lib/printnat.c
deleted file mode 100644
index 37666a2..0000000
--- a/contrib/ipfilter/lib/printnat.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (C) 2002-2005 by Darren Reed.
- *
- * See the IPFILTER.LICENCE file for details on licencing.
- *
- * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com)
- */
-
-#include "ipf.h"
-#include "kmem.h"
-
-
-#if !defined(lint)
-static const char rcsid[] = "@(#)$Id: printnat.c,v 1.22.2.14 2007/09/06 16:40:11 darrenr Exp $";
-#endif
-
-/*
- * Print out a NAT rule
- */
-void printnat(np, opts)
-ipnat_t *np;
-int opts;
-{
- struct protoent *pr;
- int bits;
-
- pr = getprotobynumber(np->in_p);
-
- switch (np->in_redir)
- {
- case NAT_REDIRECT :
- printf("rdr");
- break;
- case NAT_MAP :
- printf("map");
- break;
- case NAT_MAPBLK :
- printf("map-block");
- break;
- case NAT_BIMAP :
- printf("bimap");
- break;
- default :
- fprintf(stderr, "unknown value for in_redir: %#x\n",
- np->in_redir);
- break;
- }
-
- if (!strcmp(np->in_ifnames[0], "-"))
- printf(" \"%s\"", np->in_ifnames[0]);
- else
- printf(" %s", np->in_ifnames[0]);
- if ((np->in_ifnames[1][0] != '\0') &&
- (strncmp(np->in_ifnames[0], np->in_ifnames[1], LIFNAMSIZ) != 0)) {
- if (!strcmp(np->in_ifnames[1], "-"))
- printf(",\"%s\"", np->in_ifnames[1]);
- else
- printf(",%s", np->in_ifnames[1]);
- }
- putchar(' ');
-
- if (np->in_flags & IPN_FILTER) {
- if (np->in_flags & IPN_NOTSRC)
- printf("! ");
- printf("from ");
- if (np->in_redir == NAT_REDIRECT) {
- printhostmask(4, (u_32_t *)&np->in_srcip,
- (u_32_t *)&np->in_srcmsk);
- } else {
- printhostmask(4, (u_32_t *)&np->in_inip,
- (u_32_t *)&np->in_inmsk);
- }
- if (np->in_scmp)
- printportcmp(np->in_p, &np->in_tuc.ftu_src);
-
- if (np->in_flags & IPN_NOTDST)
- printf(" !");
- printf(" to ");
- if (np->in_redir == NAT_REDIRECT) {
- printhostmask(4, (u_32_t *)&np->in_outip,
- (u_32_t *)&np->in_outmsk);
- } else {
- printhostmask(4, (u_32_t *)&np->in_srcip,
- (u_32_t *)&np->in_srcmsk);
- }
- if (np->in_dcmp)
- printportcmp(np->in_p, &np->in_tuc.ftu_dst);
- }
-
- if (np->in_redir == NAT_REDIRECT) {
- if (!(np->in_flags & IPN_FILTER)) {
- printf("%s", inet_ntoa(np->in_out[0].in4));
- bits = count4bits(np->in_outmsk);
- if (bits != -1)
- printf("/%d", bits);
- else
- printf("/%s", inet_ntoa(np->in_out[1].in4));
- if (np->in_flags & IPN_TCPUDP) {
- printf(" port %d", ntohs(np->in_pmin));
- if (np->in_pmax != np->in_pmin)
- printf("-%d", ntohs(np->in_pmax));
- }
- }
- printf(" -> %s", inet_ntoa(np->in_in[0].in4));
- if (np->in_flags & IPN_SPLIT)
- printf(",%s", inet_ntoa(np->in_in[1].in4));
- else if (np->in_inmsk == 0 && np->in_inip == 0)
- printf("/0");
- if (np->in_flags & IPN_TCPUDP) {
- if ((np->in_flags & IPN_FIXEDDPORT) != 0)
- printf(" port = %d", ntohs(np->in_pnext));
- else
- printf(" port %d", ntohs(np->in_pnext));
- }
- putchar(' ');
- printproto(pr, np->in_p, np);
- if (np->in_flags & IPN_ROUNDR)
- printf(" round-robin");
- if (np->in_flags & IPN_FRAG)
- printf(" frag");
- if (np->in_age[0] != 0 || np->in_age[1] != 0) {
- printf(" age %d/%d", np->in_age[0], np->in_age[1]);
- }
- if (np->in_flags & IPN_STICKY)
- printf(" sticky");
- if (np->in_mssclamp != 0)
- printf(" mssclamp %d", np->in_mssclamp);
- if (*np->in_plabel != '\0')
- printf(" proxy %.*s", (int)sizeof(np->in_plabel),
- np->in_plabel);
- if (np->in_tag.ipt_tag[0] != '\0')
- printf(" tag %-.*s", IPFTAG_LEN, np->in_tag.ipt_tag);
- printf("\n");
- if (opts & OPT_DEBUG)
- printf("\tpmax %u\n", np->in_pmax);
- } else {
- int protoprinted = 0;
-
- if (!(np->in_flags & IPN_FILTER)) {
- printf("%s/", inet_ntoa(np->in_in[0].in4));
- bits = count4bits(np->in_inmsk);
- if (bits != -1)
- printf("%d", bits);
- else
- printf("%s", inet_ntoa(np->in_in[1].in4));
- }
- printf(" -> ");
- if (np->in_flags & IPN_IPRANGE) {
- printf("range %s-", inet_ntoa(np->in_out[0].in4));
- printf("%s", inet_ntoa(np->in_out[1].in4));
- } else {
- printf("%s/", inet_ntoa(np->in_out[0].in4));
- bits = count4bits(np->in_outmsk);
- if (bits != -1)
- printf("%d", bits);
- else
- printf("%s", inet_ntoa(np->in_out[1].in4));
- }
- if (*np->in_plabel != '\0') {
- printf(" proxy port ");
- if (np->in_dcmp != 0)
- np->in_dport = htons(np->in_dport);
- if (np->in_dport != 0) {
- char *s;
-
- s = portname(np->in_p, ntohs(np->in_dport));
- if (s != NULL)
- fputs(s, stdout);
- else
- fputs("???", stdout);
- }
- printf(" %.*s/", (int)sizeof(np->in_plabel),
- np->in_plabel);
- printproto(pr, np->in_p, NULL);
- protoprinted = 1;
- } else if (np->in_redir == NAT_MAPBLK) {
- if ((np->in_pmin == 0) &&
- (np->in_flags & IPN_AUTOPORTMAP))
- printf(" ports auto");
- else
- printf(" ports %d", np->in_pmin);
- if (opts & OPT_DEBUG)
- printf("\n\tip modulous %d", np->in_pmax);
- } else if (np->in_pmin || np->in_pmax) {
- if (np->in_flags & IPN_ICMPQUERY) {
- printf(" icmpidmap ");
- } else {
- printf(" portmap ");
- }
- printproto(pr, np->in_p, np);
- protoprinted = 1;
- if (np->in_flags & IPN_AUTOPORTMAP) {
- printf(" auto");
- if (opts & OPT_DEBUG)
- printf(" [%d:%d %d %d]",
- ntohs(np->in_pmin),
- ntohs(np->in_pmax),
- np->in_ippip, np->in_ppip);
- } else {
- printf(" %d:%d", ntohs(np->in_pmin),
- ntohs(np->in_pmax));
- }
- }
-
- if (np->in_flags & IPN_FRAG)
- printf(" frag");
- if (np->in_age[0] != 0 || np->in_age[1] != 0) {
- printf(" age %d/%d", np->in_age[0], np->in_age[1]);
- }
- if (np->in_mssclamp != 0)
- printf(" mssclamp %d", np->in_mssclamp);
- if (np->in_tag.ipt_tag[0] != '\0')
- printf(" tag %s", np->in_tag.ipt_tag);
- if (!protoprinted && (np->in_flags & IPN_TCPUDP || np->in_p)) {
- putchar(' ');
- printproto(pr, np->in_p, np);
- }
- printf("\n");
- if (opts & OPT_DEBUG) {
- struct in_addr nip;
-
- nip.s_addr = htonl(np->in_nextip.s_addr);
-
- printf("\tnextip %s pnext %d\n",
- inet_ntoa(nip), np->in_pnext);
- }
- }
-
- if (opts & OPT_DEBUG) {
- printf("\tspace %lu use %u hits %lu flags %#x proto %d hv %d\n",
- np->in_space, np->in_use, np->in_hits,
- np->in_flags, np->in_p, np->in_hv);
- printf("\tifp[0] %p ifp[1] %p apr %p\n",
- np->in_ifps[0], np->in_ifps[1], np->in_apr);
- printf("\ttqehead %p/%p comment %p\n",
- np->in_tqehead[0], np->in_tqehead[1], np->in_comment);
- }
-}
OpenPOWER on IntegriCloud