summaryrefslogtreecommitdiff
path: root/usr/src/cmd/ipf
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2020-05-24 15:47:03 +0300
committerToomas Soome <tsoome@me.com>2021-02-25 00:03:54 +0200
commit64410b34750c079390ce58d7e159fcff545d09b0 (patch)
tree2ce1edc0dd8f94127538047135143caf18111438 /usr/src/cmd/ipf
parentcfc9ef1dcc5d6a18778b3b10d738d19df873d1a3 (diff)
downloadillumos-gate-64410b34750c079390ce58d7e159fcff545d09b0.tar.gz
13543 ipf: symbol 'thishost' is multiply-defined
Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/cmd/ipf')
-rw-r--r--usr/src/cmd/ipf/tools/ipnat.c135
1 files changed, 60 insertions, 75 deletions
diff --git a/usr/src/cmd/ipf/tools/ipnat.c b/usr/src/cmd/ipf/tools/ipnat.c
index 941765eb43..2c201f3a96 100644
--- a/usr/src/cmd/ipf/tools/ipnat.c
+++ b/usr/src/cmd/ipf/tools/ipnat.c
@@ -27,14 +27,14 @@
#include <unistd.h>
#include <stddef.h>
#include <sys/file.h>
-#define _KERNEL
+#define _KERNEL
#include <sys/uio.h>
#undef _KERNEL
#include <sys/socket.h>
#include <sys/ioctl.h>
#if defined(sun) && (defined(__svr4__) || defined(__SVR4))
-# include <sys/ioccom.h>
-# include <sys/sysmacros.h>
+#include <sys/ioccom.h>
+#include <sys/sysmacros.h>
#endif
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -42,7 +42,7 @@
#include <netinet/tcp.h>
#include <net/if.h>
#if __FreeBSD_version >= 300000
-# include <net/if_var.h>
+#include <net/if_var.h>
#endif
#include <netdb.h>
#include <arpa/nameser.h>
@@ -50,9 +50,9 @@
#include <resolv.h>
#include <ctype.h>
#if defined(linux)
-# include <linux/a.out.h>
+#include <linux/a.out.h>
#else
-# include <nlist.h>
+#include <nlist.h>
#endif
#include "ipf.h"
#include "netinet/ipl.h"
@@ -60,34 +60,25 @@
#include "ipfzone.h"
#ifdef __hpux
-# define nlist nlist64
+#define nlist nlist64
#endif
#if defined(sun) && !SOLARIS2
-# define STRERROR(x) sys_errlist[x]
+#define STRERROR(x) sys_errlist[x]
extern char *sys_errlist[];
#else
-# define STRERROR(x) strerror(x)
+#define STRERROR(x) strerror(x)
#endif
-#if !defined(lint)
-static const char sccsid[] ="@(#)ipnat.c 1.9 6/5/96 (C) 1993 Darren Reed";
-static const char rcsid[] = "@(#)$Id: ipnat.c,v 1.24.2.2 2005/05/10 21:19:30 darrenr Exp $";
-#endif
-
-
-#ifdef SOLARIS
-#define bzero(a,b) memset(a,0,b)
-#endif
int use_inet6 = 0;
-char thishost[MAXHOSTNAMELEN];
+extern char thishost[MAXHOSTNAMELEN];
extern char *optarg;
void dostats __P((int, natstat_t *, int, int));
void flushtable __P((int, int));
void usage __P((char *));
-int main __P((int, char*[]));
+int main __P((int, char *[]));
void showhostmap __P((natstat_t *nsp));
void natstat_dead __P((natstat_t *, char *));
void dostats_live __P((int, natstat_t *, int));
@@ -95,8 +86,8 @@ void showhostmap_live __P((int, natstat_t *));
int opts;
-void usage(name)
-char *name;
+void
+usage(char *name)
{
fprintf(stderr, "Usage: %s [-CdFhlnrRsv] [-f filename]", name);
fprintf(stderr, " [-G|-z zonename]\n");
@@ -104,9 +95,8 @@ char *name;
}
-int main(argc, argv)
-int argc;
-char *argv[];
+int
+main(int argc, char *argv[])
{
char *file, *core, *kernel;
natstat_t ns, *nsp;
@@ -122,8 +112,7 @@ char *argv[];
mode = O_RDWR;
while ((c = getopt(argc, argv, "CdFf:G:hlM:N:nrRsvz:")) != -1)
- switch (c)
- {
+ switch (c) {
case 'C' :
opts |= OPT_CLEAR;
break;
@@ -140,7 +129,7 @@ char *argv[];
setzonename_global(optarg);
break;
case 'h' :
- opts |=OPT_HITS;
+ opts |= OPT_HITS;
break;
case 'l' :
opts |= OPT_LIST;
@@ -183,7 +172,7 @@ char *argv[];
(void) setreuid(getuid(), getuid());
}
- bzero((char *)&ns, sizeof(ns));
+ bzero((char *)&ns, sizeof (ns));
if ((opts & OPT_DONOTHING) == 0) {
if (checkrev(IPL_NAME) == -1) {
@@ -201,7 +190,7 @@ char *argv[];
if (((fd = open(IPNAT_NAME, mode)) == -1) &&
((fd = open(IPNAT_NAME, O_RDONLY)) == -1)) {
(void) fprintf(stderr, "%s: open: %s\n", IPNAT_NAME,
- STRERROR(errno));
+ STRERROR(errno));
exit(1);
}
@@ -210,9 +199,9 @@ char *argv[];
exit(1);
}
- bzero((char *)&obj, sizeof(obj));
+ bzero((char *)&obj, sizeof (obj));
obj.ipfo_rev = IPFILTER_VERSION;
- obj.ipfo_size = sizeof(*nsp);
+ obj.ipfo_size = sizeof (*nsp);
obj.ipfo_type = IPFOBJ_NATSTAT;
obj.ipfo_ptr = (void *)nsp;
if (ioctl(fd, SIOCGNATS, &obj) == -1) {
@@ -238,7 +227,7 @@ char *argv[];
}
if (opts & (OPT_LIST|OPT_STAT))
dostats(fd, nsp, opts, 1);
- return 0;
+ return (0);
}
@@ -246,9 +235,8 @@ char *argv[];
* Read NAT statistic information in using a symbol table and memory file
* rather than doing ioctl's.
*/
-void natstat_dead(nsp, kernel)
-natstat_t *nsp;
-char *kernel;
+void
+natstat_dead(natstat_t *nsp, char *kernel)
{
struct nlist nat_nlist[10] = {
{ "nat_table" }, /* 0 */
@@ -274,35 +262,34 @@ char *kernel;
* for us, before returning it to userland, so here we must copy each
* one in individually.
*/
- kmemcpy((char *)&tables, nat_nlist[0].n_value, sizeof(tables));
+ kmemcpy((char *)&tables, nat_nlist[0].n_value, sizeof (tables));
nsp->ns_table[0] = tables[0];
nsp->ns_table[1] = tables[1];
kmemcpy((char *)&nsp->ns_list, nat_nlist[1].n_value,
- sizeof(nsp->ns_list));
+ sizeof (nsp->ns_list));
kmemcpy((char *)&nsp->ns_maptable, nat_nlist[2].n_value,
- sizeof(nsp->ns_maptable));
+ sizeof (nsp->ns_maptable));
kmemcpy((char *)&nsp->ns_nattab_sz, nat_nlist[3].n_value,
- sizeof(nsp->ns_nattab_sz));
+ sizeof (nsp->ns_nattab_sz));
kmemcpy((char *)&nsp->ns_rultab_sz, nat_nlist[4].n_value,
- sizeof(nsp->ns_rultab_sz));
+ sizeof (nsp->ns_rultab_sz));
kmemcpy((char *)&nsp->ns_rdrtab_sz, nat_nlist[5].n_value,
- sizeof(nsp->ns_rdrtab_sz));
+ sizeof (nsp->ns_rdrtab_sz));
kmemcpy((char *)&nsp->ns_hostmap_sz, nat_nlist[6].n_value,
- sizeof(nsp->ns_hostmap_sz));
+ sizeof (nsp->ns_hostmap_sz));
kmemcpy((char *)&nsp->ns_instances, nat_nlist[7].n_value,
- sizeof(nsp->ns_instances));
+ sizeof (nsp->ns_instances));
kmemcpy((char *)&nsp->ns_apslist, nat_nlist[8].n_value,
- sizeof(nsp->ns_apslist));
+ sizeof (nsp->ns_apslist));
}
/*
* Display NAT statistics.
*/
-void dostats(fd, nsp, opts, alive)
-natstat_t *nsp;
-int fd, opts, alive;
+void
+dostats(int fd, natstat_t *nsp, int opts, int alive)
{
nat_t *np, nat;
ipnat_t ipn;
@@ -312,17 +299,17 @@ int fd, opts, alive;
*/
if (opts & OPT_STAT) {
printf("mapped\tin\t%lu\tout\t%lu\n",
- nsp->ns_mapped[0], nsp->ns_mapped[1]);
+ nsp->ns_mapped[0], nsp->ns_mapped[1]);
printf("added\t%lu\texpired\t%lu\n",
- nsp->ns_added, nsp->ns_expire);
+ nsp->ns_added, nsp->ns_expire);
printf("no memory\t%lu\tbad nat\t%lu\n",
- nsp->ns_memfail, nsp->ns_badnat);
+ nsp->ns_memfail, nsp->ns_badnat);
printf("inuse\t%lu\norphans\t%u\nrules\t%lu\n",
- nsp->ns_inuse, nsp->ns_orphans, nsp->ns_rules);
+ nsp->ns_inuse, nsp->ns_orphans, nsp->ns_rules);
printf("wilds\t%u\n", nsp->ns_wilds);
if (opts & OPT_VERBOSE)
printf("table %p list %p\n",
- nsp->ns_table, nsp->ns_list);
+ nsp->ns_table, nsp->ns_list);
}
/*
@@ -336,7 +323,7 @@ int fd, opts, alive;
printf("List of active MAP/Redirect filters:\n");
while (nsp->ns_list) {
if (kmemcpy((char *)&ipn, (long)nsp->ns_list,
- sizeof(ipn))) {
+ sizeof (ipn))) {
perror("kmemcpy");
break;
}
@@ -349,7 +336,7 @@ int fd, opts, alive;
printf("\nList of active sessions:\n");
for (np = nsp->ns_instances; np; np = nat.nat_next) {
- if (kmemcpy((char *)&nat, (long)np, sizeof(nat)))
+ if (kmemcpy((char *)&nat, (long)np, sizeof (nat)))
break;
printactivenat(&nat, opts, 0);
if (nat.nat_aps)
@@ -365,22 +352,22 @@ int fd, opts, alive;
/*
* Display the active host mapping table.
*/
-void showhostmap(nsp)
-natstat_t *nsp;
+void
+showhostmap(natstat_t *nsp)
{
hostmap_t hm, *hmp, **maptable;
- u_int hv;
+ uint_t hv;
printf("\nList of active host mappings:\n");
- maptable = (hostmap_t **)malloc(sizeof(hostmap_t *) *
- nsp->ns_hostmap_sz);
+ maptable = (hostmap_t **)malloc(sizeof (hostmap_t *) *
+ nsp->ns_hostmap_sz);
if (maptable == NULL) {
perror("malloc");
exit(1);
}
- if (kmemcpy((char *)maptable, (u_long)nsp->ns_maptable,
- sizeof(hostmap_t *) * nsp->ns_hostmap_sz)) {
+ if (kmemcpy((char *)maptable, (ulong_t)nsp->ns_maptable,
+ sizeof (hostmap_t *) * nsp->ns_hostmap_sz)) {
perror("kmemcpy (maptable)");
return;
}
@@ -389,7 +376,7 @@ natstat_t *nsp;
hmp = maptable[hv];
while (hmp) {
- if (kmemcpy((char *)&hm, (u_long)hmp, sizeof(hm))) {
+ if (kmemcpy((char *)&hm, (ulong_t)hmp, sizeof (hm))) {
perror("kmemcpy (hostmap)");
return;
}
@@ -406,8 +393,8 @@ natstat_t *nsp;
* Issue an ioctl to flush either the NAT rules table or the active mapping
* table or both.
*/
-void flushtable(fd, opts)
-int fd, opts;
+void
+flushtable(int fd, int opts)
{
int n = 0;
@@ -431,19 +418,18 @@ int fd, opts;
/*
* Display NAT statistics.
*/
-void dostats_live(fd, nsp, opts)
-natstat_t *nsp;
-int fd, opts;
+void
+dostats_live(int fd, natstat_t *nsp, int opts)
{
ipfgeniter_t iter;
ipfobj_t obj;
ipnat_t ipn;
nat_t nat;
- bzero((char *)&obj, sizeof(obj));
+ bzero((char *)&obj, sizeof (obj));
obj.ipfo_rev = IPFILTER_VERSION;
obj.ipfo_type = IPFOBJ_GENITER;
- obj.ipfo_size = sizeof(iter);
+ obj.ipfo_size = sizeof (iter);
obj.ipfo_ptr = &iter;
iter.igi_type = IPFGENITER_IPNAT;
@@ -485,18 +471,17 @@ int fd, opts;
/*
* Display the active host mapping table.
*/
-void showhostmap_live(fd, nsp)
-int fd;
-natstat_t *nsp;
+void
+showhostmap_live(int fd, natstat_t *nsp)
{
hostmap_t hm, *hmp;
ipfgeniter_t iter;
ipfobj_t obj;
- bzero((char *)&obj, sizeof(obj));
+ bzero((char *)&obj, sizeof (obj));
obj.ipfo_rev = IPFILTER_VERSION;
obj.ipfo_type = IPFOBJ_GENITER;
- obj.ipfo_size = sizeof(iter);
+ obj.ipfo_size = sizeof (iter);
obj.ipfo_ptr = &iter;
iter.igi_type = IPFGENITER_HOSTMAP;