/*
* Copyright (C) 1993-2001 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com)
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <strings.h>
#else
#include <sys/byteorder.h>
#endif
#include <stdlib.h>
#include <unistd.h>
#include <stddef.h>
#define _KERNEL
# include <sys/sysmacros.h>
#endif
#include <netinet/in_systm.h>
#if __FreeBSD_version >= 300000
#endif
#include <netdb.h>
#include <resolv.h>
#include <ctype.h>
#if defined(linux)
#else
# include <nlist.h>
#endif
#include "ipf.h"
#include "kmem.h"
#include "ipfzone.h"
#ifdef __hpux
#endif
extern char *sys_errlist[];
#else
#endif
#if !defined(lint)
#endif
#if SOLARIS
#endif
int use_inet6 = 0;
extern char *optarg;
void flushtable __P((int, int));
int opts;
char *name;
{
exit(1);
}
int argc;
char *argv[];
{
fd = -1;
opts = 0;
switch (c)
{
case 'C' :
break;
case 'd' :
break;
case 'f' :
break;
case 'F' :
break;
case 'G' :
break;
case 'h' :
break;
case 'l' :
break;
case 'M' :
break;
case 'N' :
break;
case 'n' :
opts |= OPT_DONOTHING;
break;
case 'R' :
opts |= OPT_NORESOLVE;
break;
case 'r' :
opts |= OPT_REMOVE;
break;
case 's' :
break;
case 'v' :
opts |= OPT_VERBOSE;
break;
case 'z' :
break;
default :
}
initparse();
}
if ((opts & OPT_DONOTHING) == 0) {
exit(1);
}
}
#ifdef notdef
exit(1);
#endif
exit(1);
}
exit(1);
}
perror("ioctl(SIOCGNATS)");
exit(1);
}
exit(1);
exit(0);
}
if (file) {
}
return 0;
}
/*
* Read NAT statistic information in using a symbol table and memory file
* rather than doing ioctl's.
*/
char *kernel;
{
{ "nat_table" }, /* 0 */
{ "nat_list" },
{ "maptable" },
{ "ipf_nattable_sz" },
{ "ipf_natrules_sz" },
{ "ipf_rdrrules_sz" }, /* 5 */
{ "ipf_hostmap_sz" },
{ "nat_instances" },
{ "ap_sess_list" },
{ NULL }
};
return;
}
/*
* Normally the ioctl copies all of these values into the structure
* for us, before returning it to userland, so here we must copy each
* one in individually.
*/
sizeof(nsp->ns_maptable));
sizeof(nsp->ns_nattab_sz));
sizeof(nsp->ns_rultab_sz));
sizeof(nsp->ns_rdrtab_sz));
sizeof(nsp->ns_hostmap_sz));
sizeof(nsp->ns_instances));
sizeof(nsp->ns_apslist));
}
/*
* Display NAT statistics.
*/
{
/*
* Show statistics ?
*/
printf("mapped\tin\t%lu\tout\t%lu\n",
printf("added\t%lu\texpired\t%lu\n",
printf("no memory\t%lu\tbad nat\t%lu\n",
printf("inuse\t%lu\norphans\t%u\nrules\t%lu\n",
if (opts & OPT_VERBOSE)
printf("table %p list %p\n",
}
/*
* Show list of NAT rules and NAT sessions ?
*/
if (alive) {
return;
}
sizeof(ipn))) {
perror("kmemcpy");
break;
}
}
printf("\nList of active sessions:\n");
break;
}
if (opts & OPT_VERBOSE)
}
}
/*
* Display the active host mapping table.
*/
{
printf("\nList of active host mappings:\n");
nsp->ns_hostmap_sz);
perror("malloc");
exit(1);
}
perror("kmemcpy (maptable)");
return;
}
while (hmp) {
perror("kmemcpy (hostmap)");
return;
}
}
}
}
/*
* Issue an ioctl to flush either the NAT rules table or the active mapping
* table or both.
*/
{
int n = 0;
n = FLUSH_TABLE_ALL;
perror("ioctl(SIOCFLNAT)");
else
printf("%d entries flushed from NAT table\n", n);
}
n = FLUSH_LIST;
perror("ioctl(SIOCCNATL)");
else
printf("%d entries flushed from NAT list\n", n);
}
}
/*
* Display NAT statistics.
*/
{
/*
* Show list of NAT rules and NAT sessions ?
*/
break;
}
printf("\nList of active sessions:\n");
break;
}
if (opts & OPT_VERBOSE)
}
/*
* Display the active host mapping table.
*/
int fd;
{
printf("\nList of active host mappings:\n");
break;
printhostmap(&hm, 0);
}
}