ipnat.c (5e985db5) | ipnat.c (ab25eeb5) |
---|---|
1/* 2 * Copyright (C) 1993-2001 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com) 7 * | 1/* 2 * Copyright (C) 1993-2001 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com) 7 * |
8 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. | 8 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
9 * Use is subject to license terms. 10 */ 11 12#pragma ident "%Z%%M% %I% %E% SMI" 13 14#include <stdio.h> 15#include <string.h> 16#include <fcntl.h> --- 27 unchanged lines hidden (view full) --- 44#if __FreeBSD_version >= 300000 45# include <net/if_var.h> 46#endif 47#include <netdb.h> 48#include <arpa/nameser.h> 49#include <arpa/inet.h> 50#include <resolv.h> 51#include <ctype.h> | 9 * Use is subject to license terms. 10 */ 11 12#pragma ident "%Z%%M% %I% %E% SMI" 13 14#include <stdio.h> 15#include <string.h> 16#include <fcntl.h> --- 27 unchanged lines hidden (view full) --- 44#if __FreeBSD_version >= 300000 45# include <net/if_var.h> 46#endif 47#include <netdb.h> 48#include <arpa/nameser.h> 49#include <arpa/inet.h> 50#include <resolv.h> 51#include <ctype.h> |
52#include <nlist.h> | 52#if defined(linux) 53# include <linux/a.out.h> 54#else 55# include <nlist.h> 56#endif |
53#include "ipf.h" | 57#include "ipf.h" |
54#include "ipl.h" | 58#include "netinet/ipl.h" |
55#include "kmem.h" 56 57#ifdef __hpux 58# define nlist nlist64 59#endif 60 61#if defined(sun) && !SOLARIS2 62# define STRERROR(x) sys_errlist[x] 63extern char *sys_errlist[]; 64#else 65# define STRERROR(x) strerror(x) 66#endif 67 68#if !defined(lint) 69static const char sccsid[] ="@(#)ipnat.c 1.9 6/5/96 (C) 1993 Darren Reed"; | 59#include "kmem.h" 60 61#ifdef __hpux 62# define nlist nlist64 63#endif 64 65#if defined(sun) && !SOLARIS2 66# define STRERROR(x) sys_errlist[x] 67extern char *sys_errlist[]; 68#else 69# define STRERROR(x) strerror(x) 70#endif 71 72#if !defined(lint) 73static const char sccsid[] ="@(#)ipnat.c 1.9 6/5/96 (C) 1993 Darren Reed"; |
70static const char rcsid[] = "@(#)$Id: ipnat.c,v 1.20 2003/07/01 16:30:27 darrenr Exp $"; | 74static const char rcsid[] = "@(#)$Id: ipnat.c,v 1.24.2.2 2005/05/10 21:19:30 darrenr Exp $"; |
71#endif 72 73 74#if SOLARIS 75#define bzero(a,b) memset(a,0,b) 76#endif 77int use_inet6 = 0; 78char thishost[MAXHOSTNAMELEN]; --- 6 unchanged lines hidden (view full) --- 85void showhostmap __P((natstat_t *nsp)); 86void natstat_dead __P((natstat_t *, char *)); 87 88int opts; 89 90void usage(name) 91char *name; 92{ | 75#endif 76 77 78#if SOLARIS 79#define bzero(a,b) memset(a,0,b) 80#endif 81int use_inet6 = 0; 82char thishost[MAXHOSTNAMELEN]; --- 6 unchanged lines hidden (view full) --- 89void showhostmap __P((natstat_t *nsp)); 90void natstat_dead __P((natstat_t *, char *)); 91 92int opts; 93 94void usage(name) 95char *name; 96{ |
93 fprintf(stderr, "Usage: %s [-CdFhlnrsv] [-f filename]\n", name); | 97 fprintf(stderr, "Usage: %s [-CFhlnrRsv] [-f filename]\n", name); |
94 exit(1); 95} 96 97 98int main(argc, argv) 99int argc; 100char *argv[]; 101{ --- 5 unchanged lines hidden (view full) --- 107 fd = -1; 108 opts = 0; 109 nsp = &ns; 110 file = NULL; 111 core = NULL; 112 kernel = NULL; 113 mode = O_RDWR; 114 | 98 exit(1); 99} 100 101 102int main(argc, argv) 103int argc; 104char *argv[]; 105{ --- 5 unchanged lines hidden (view full) --- 111 fd = -1; 112 opts = 0; 113 nsp = &ns; 114 file = NULL; 115 core = NULL; 116 kernel = NULL; 117 mode = O_RDWR; 118 |
115 while ((c = getopt(argc, argv, "CdFf:hlM:N:nrsv")) != -1) | 119 while ((c = getopt(argc, argv, "CdFf:hlM:N:nrRsv")) != -1) |
116 switch (c) 117 { 118 case 'C' : 119 opts |= OPT_CLEAR; 120 break; 121 case 'd' : 122 opts |= OPT_DEBUG; 123 break; --- 15 unchanged lines hidden (view full) --- 139 break; 140 case 'N' : 141 kernel = optarg; 142 break; 143 case 'n' : 144 opts |= OPT_DONOTHING; 145 mode = O_RDONLY; 146 break; | 120 switch (c) 121 { 122 case 'C' : 123 opts |= OPT_CLEAR; 124 break; 125 case 'd' : 126 opts |= OPT_DEBUG; 127 break; --- 15 unchanged lines hidden (view full) --- 143 break; 144 case 'N' : 145 kernel = optarg; 146 break; 147 case 'n' : 148 opts |= OPT_DONOTHING; 149 mode = O_RDONLY; 150 break; |
151 case 'R' : 152 opts |= OPT_NORESOLVE; 153 break; |
|
147 case 'r' : 148 opts |= OPT_REMOVE; 149 break; 150 case 's' : 151 opts |= OPT_STAT; 152 mode = O_RDONLY; 153 break; 154 case 'v' : --- 153 unchanged lines hidden (view full) --- 308 printf("List of active MAP/Redirect filters:\n"); 309 while (nsp->ns_list) { 310 if (kmemcpy((char *)&ipn, (long)nsp->ns_list, 311 sizeof(ipn))) { 312 perror("kmemcpy"); 313 break; 314 } 315 if (opts & OPT_HITS) | 154 case 'r' : 155 opts |= OPT_REMOVE; 156 break; 157 case 's' : 158 opts |= OPT_STAT; 159 mode = O_RDONLY; 160 break; 161 case 'v' : --- 153 unchanged lines hidden (view full) --- 315 printf("List of active MAP/Redirect filters:\n"); 316 while (nsp->ns_list) { 317 if (kmemcpy((char *)&ipn, (long)nsp->ns_list, 318 sizeof(ipn))) { 319 perror("kmemcpy"); 320 break; 321 } 322 if (opts & OPT_HITS) |
316 printf("%d ", ipn.in_hits); | 323 printf("%lu ", ipn.in_hits); |
317 printnat(&ipn, opts & (OPT_DEBUG|OPT_VERBOSE)); 318 nsp->ns_list = ipn.in_next; 319 } 320 321 printf("\nList of active sessions:\n"); 322 323 for (np = nsp->ns_instances; np; np = nat.nat_next) { 324 if (kmemcpy((char *)&nat, (long)np, sizeof(nat))) 325 break; 326 printactivenat(&nat, opts); | 324 printnat(&ipn, opts & (OPT_DEBUG|OPT_VERBOSE)); 325 nsp->ns_list = ipn.in_next; 326 } 327 328 printf("\nList of active sessions:\n"); 329 330 for (np = nsp->ns_instances; np; np = nat.nat_next) { 331 if (kmemcpy((char *)&nat, (long)np, sizeof(nat))) 332 break; 333 printactivenat(&nat, opts); |
334 if (nat.nat_aps) 335 printaps(nat.nat_aps, opts); |
|
327 } 328 329 if (opts & OPT_VERBOSE) 330 showhostmap(nsp); 331 } 332} 333 334 --- 65 unchanged lines hidden --- | 336 } 337 338 if (opts & OPT_VERBOSE) 339 showhostmap(nsp); 340 } 341} 342 343 --- 65 unchanged lines hidden --- |