summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/tools/ipftest.c
diff options
context:
space:
mode:
authorguido <guido@FreeBSD.org>2005-12-30 11:52:26 +0000
committerguido <guido@FreeBSD.org>2005-12-30 11:52:26 +0000
commit7ee09247502caaf9063c5d6ba733231a70de09ef (patch)
tree9209f38a8bc3af0186363bc8bbfe05d79337f8d4 /contrib/ipfilter/tools/ipftest.c
parent3cc29e6ebff10906cf1f84a6cc2d518dcecf219c (diff)
downloadFreeBSD-src-7ee09247502caaf9063c5d6ba733231a70de09ef.zip
FreeBSD-src-7ee09247502caaf9063c5d6ba733231a70de09ef.tar.gz
Resolve conflicts (and believe me...you don't want to know).
Diffstat (limited to 'contrib/ipfilter/tools/ipftest.c')
-rw-r--r--contrib/ipfilter/tools/ipftest.c68
1 files changed, 48 insertions, 20 deletions
diff --git a/contrib/ipfilter/tools/ipftest.c b/contrib/ipfilter/tools/ipftest.c
index 6dbf21f..bbc8bbf 100644
--- a/contrib/ipfilter/tools/ipftest.c
+++ b/contrib/ipfilter/tools/ipftest.c
@@ -12,7 +12,7 @@
#if !defined(lint)
static const char sccsid[] = "@(#)ipt.c 1.19 6/3/96 (C) 1993-2000 Darren Reed";
-static const char rcsid[] = "@(#)Id: ipftest.c,v 1.44.2.3 2005/02/01 02:41:24 darrenr Exp";
+static const char rcsid[] = "@(#)$Id: ipftest.c,v 1.44.2.7 2005/12/07 08:29:19 darrenr Exp $";
#endif
extern char *optarg;
@@ -22,13 +22,15 @@ extern struct ifnet *get_unit __P((char *, int));
extern void init_ifp __P((void));
extern ipnat_t *natparse __P((char *, int));
extern int fr_running;
+extern hostmap_t **maptable;
ipfmutex_t ipl_mutex, ipf_authmx, ipf_rw, ipf_stinsert;
ipfmutex_t ipf_nat_new, ipf_natio, ipf_timeoutlock;
-ipfrwlock_t ipf_mutex, ipf_global, ipf_ipidfrag, ip_poolrw;
+ipfrwlock_t ipf_mutex, ipf_global, ipf_ipidfrag, ip_poolrw, ipf_frcache;
ipfrwlock_t ipf_frag, ipf_state, ipf_nat, ipf_natfrag, ipf_auth;
int opts = OPT_DONOTHING;
int use_inet6 = 0;
+int docksum = 0;
int pfil_delayed_copy = 0;
int main __P((int, char *[]));
int loadrules __P((char *, int));
@@ -77,6 +79,7 @@ char *argv[];
{
char *datain, *iface, *ifname, *logout;
int fd, i, dir, c, loaded, dump, hlen;
+ struct in_addr sip;
struct ifnet *ifp;
struct ipread *r;
mb_t mb, *m;
@@ -90,21 +93,23 @@ char *argv[];
r = &iptext;
iface = NULL;
logout = NULL;
- ifname = "anon0";
datain = NULL;
+ sip.s_addr = 0;
+ ifname = "anon0";
MUTEX_INIT(&ipf_rw, "ipf rw mutex");
MUTEX_INIT(&ipf_timeoutlock, "ipf timeout lock");
RWLOCK_INIT(&ipf_global, "ipf filter load/unload mutex");
RWLOCK_INIT(&ipf_mutex, "ipf filter rwlock");
RWLOCK_INIT(&ipf_ipidfrag, "ipf IP NAT-Frag rwlock");
+ RWLOCK_INIT(&ipf_frcache, "ipf filter cache");
initparse();
if (fr_initialise() == -1)
abort();
fr_running = 1;
- while ((c = getopt(argc, argv, "6bdDF:i:I:l:N:P:or:RT:vxX")) != -1)
+ while ((c = getopt(argc, argv, "6bCdDF:i:I:l:N:P:or:RS:T:vxX")) != -1)
switch (c)
{
case '6' :
@@ -121,6 +126,9 @@ char *argv[];
case 'd' :
opts |= OPT_DEBUG;
break;
+ case 'C' :
+ docksum = 1;
+ break;
case 'D' :
dump = 1;
break;
@@ -147,21 +155,6 @@ char *argv[];
case 'l' :
logout = optarg;
break;
- case 'o' :
- opts |= OPT_SAVEOUT;
- break;
- case 'r' :
- if (ipf_parsefile(-1, ipf_addrule, iocfunctions,
- optarg) == -1)
- return -1;
- loaded = 1;
- break;
- case 'R' :
- opts |= OPT_NORESOLVE;
- break;
- case 'v' :
- opts |= OPT_VERBOSE;
- break;
case 'N' :
if (ipnat_parsefile(-1, ipnat_addrule, ipnattestioctl,
optarg) == -1)
@@ -169,14 +162,32 @@ char *argv[];
loaded = 1;
opts |= OPT_NAT;
break;
+ case 'o' :
+ opts |= OPT_SAVEOUT;
+ break;
case 'P' :
if (ippool_parsefile(-1, optarg, ipooltestioctl) == -1)
return -1;
loaded = 1;
break;
+ case 'r' :
+ if (ipf_parsefile(-1, ipf_addrule, iocfunctions,
+ optarg) == -1)
+ return -1;
+ loaded = 1;
+ break;
+ case 'S' :
+ sip.s_addr = inet_addr(optarg);
+ break;
+ case 'R' :
+ opts |= OPT_NORESOLVE;
+ break;
case 'T' :
ipf_dotuning(-1, optarg, ipftestioctl);
break;
+ case 'v' :
+ opts |= OPT_VERBOSE;
+ break;
case 'x' :
opts |= OPT_HEX;
break;
@@ -207,9 +218,11 @@ char *argv[];
if (!use_inet6) {
ip->ip_off = ntohs(ip->ip_off);
ip->ip_len = ntohs(ip->ip_len);
- if (r->r_flags & R_DO_CKSUM)
+ if ((r->r_flags & R_DO_CKSUM) || docksum)
fixv4sums(m, ip);
hlen = IP_HL(ip) << 2;
+ if (sip.s_addr)
+ dir = !(sip.s_addr == ip->ip_src.s_addr);
}
#ifdef USE_INET6
else
@@ -283,6 +296,9 @@ char *argv[];
}
m = &mb;
}
+
+ if (i != 0)
+ fprintf(stderr, "readip failed: %d\n", i);
(*r->r_close)();
if (logout != NULL) {
@@ -617,6 +633,8 @@ void dumpnat()
{
ipnat_t *ipn;
nat_t *nat;
+ hostmap_t *hm;
+ int i;
printf("List of active MAP/Redirect filters:\n");
for (ipn = nat_list; ipn != NULL; ipn = ipn->in_next)
@@ -627,6 +645,12 @@ void dumpnat()
if (nat->nat_aps)
printaps(nat->nat_aps, opts);
}
+
+ printf("\nHostmap table:\n");
+ for (i = 0; i < ipf_hostmap_sz; i++) {
+ for (hm = maptable[i]; hm != NULL; hm = hm->hm_next)
+ printhostmap(hm, i);
+ }
}
@@ -764,6 +788,10 @@ ip_t *ip;
hdr = csump;
csump += offsetof(udphdr_t, uh_sum);
break;
+ case IPPROTO_ICMP :
+ hdr = csump;
+ csump += offsetof(icmphdr_t, icmp_cksum);
+ break;
default :
csump = NULL;
hdr = NULL;
OpenPOWER on IntegriCloud