diff options
author | darrenr <darrenr@FreeBSD.org> | 2007-10-18 21:42:51 +0000 |
---|---|---|
committer | darrenr <darrenr@FreeBSD.org> | 2007-10-18 21:42:51 +0000 |
commit | 71e82d94e82560b20789833f60056506de34de8b (patch) | |
tree | da6aaa7272c76c9c4cad931122fd1f4e4db237a5 /contrib/ipfilter/l4check | |
parent | e2e28d4361fc9bdb67694eedaf349bdc7ca088a3 (diff) | |
download | FreeBSD-src-71e82d94e82560b20789833f60056506de34de8b.zip FreeBSD-src-71e82d94e82560b20789833f60056506de34de8b.tar.gz |
Import IPFilter 4.1.28
Diffstat (limited to 'contrib/ipfilter/l4check')
-rw-r--r-- | contrib/ipfilter/l4check/Makefile | 2 | ||||
-rw-r--r-- | contrib/ipfilter/l4check/l4check.c | 43 |
2 files changed, 31 insertions, 14 deletions
diff --git a/contrib/ipfilter/l4check/Makefile b/contrib/ipfilter/l4check/Makefile index e7366b6..e2bb9f8 100644 --- a/contrib/ipfilter/l4check/Makefile +++ b/contrib/ipfilter/l4check/Makefile @@ -4,7 +4,7 @@ all: l4check l4check: l4check.c - $(CC) -g -I.. $(CFLAGS) $(LIBS) l4check.c -o $@ + $(CC) -g -I.. -Wall $(CFLAGS) $(LIBS) l4check.c -o $@ clean: /bin/rm -f l4check diff --git a/contrib/ipfilter/l4check/l4check.c b/contrib/ipfilter/l4check/l4check.c index 3fecb80..a096fff 100644 --- a/contrib/ipfilter/l4check/l4check.c +++ b/contrib/ipfilter/l4check/l4check.c @@ -25,6 +25,7 @@ #include "ip_compat.h" #include "ip_fil.h" #include "ip_nat.h" +#include "ipl.h" #include "ipf.h" @@ -96,13 +97,21 @@ char *dst, *src; void addnat(l4) l4cfg_t *l4; { + ipnat_t *ipn = &l4->l4_nat; - printf("Add NAT rule for %s/%#x,%u -> ", inet_ntoa(ipn->in_out[0]), + printf("Add NAT rule for %s/%#x,%u -> ", inet_ntoa(ipn->in_out[0].in4), ipn->in_outmsk, ntohs(ipn->in_pmin)); - printf("%s,%u\n", inet_ntoa(ipn->in_in[0]), ntohs(ipn->in_pnext)); + printf("%s,%u\n", inet_ntoa(ipn->in_in[0].in4), ntohs(ipn->in_pnext)); if (!(opts & OPT_DONOTHING)) { - if (ioctl(natfd, SIOCADNAT, &ipn) == -1) + ipfobj_t obj; + + bzero(&obj, sizeof(obj)); + obj.ipfo_rev = IPFILTER_VERSION; + obj.ipfo_size = sizeof(*ipn); + obj.ipfo_ptr = ipn; + + if (ioctl(natfd, SIOCADNAT, &obj) == -1) perror("ioctl(SIOCADNAT)"); } } @@ -114,9 +123,16 @@ l4cfg_t *l4; ipnat_t *ipn = &l4->l4_nat; printf("Remove NAT rule for %s/%#x,%u -> ", - inet_ntoa(ipn->in_out[0]), ipn->in_outmsk, ipn->in_pmin); - printf("%s,%u\n", inet_ntoa(ipn->in_in[0]), ipn->in_pnext); + inet_ntoa(ipn->in_out[0].in4), ipn->in_outmsk, ipn->in_pmin); + printf("%s,%u\n", inet_ntoa(ipn->in_in[0].in4), ipn->in_pnext); if (!(opts & OPT_DONOTHING)) { + ipfobj_t obj; + + bzero(&obj, sizeof(obj)); + obj.ipfo_rev = IPFILTER_VERSION; + obj.ipfo_size = sizeof(*ipn); + obj.ipfo_ptr = ipn; + if (ioctl(natfd, SIOCRMNAT, &ipn) == -1) perror("ioctl(SIOCRMNAT)"); } @@ -176,7 +192,6 @@ l4cfg_t *l4; void writefd(l4) l4cfg_t *l4; { - char buf[80], *ptr; int n, i, fd; fd = l4->l4_fd; @@ -408,7 +423,6 @@ u_short *portp; struct servent *sp; struct hostent *hp; char *host, *port; - struct in_addr ip; host = str; port = strchr(host, ','); @@ -553,7 +567,8 @@ char *filename; break; } - strncpy(ipn->in_ifname, s, sizeof(ipn->in_ifname)); + strncpy(ipn->in_ifnames[0], s, LIFNAMSIZ); + strncpy(ipn->in_ifnames[1], s, LIFNAMSIZ); if (!gethostport(t, num, &ipn->in_outip, &ipn->in_pmin)) { errtxt = line; @@ -565,11 +580,11 @@ char *filename; if (opts & OPT_VERBOSE) fprintf(stderr, "Interface %s %s/%#x port %u\n", - ipn->in_ifname, - inet_ntoa(ipn->in_out[0]), + ipn->in_ifnames[0], + inet_ntoa(ipn->in_out[0].in4), ipn->in_outmsk, ipn->in_pmin); } else if (!strcasecmp(t, "remote")) { - if (!*ipn->in_ifname) { + if (!*ipn->in_ifnames[0]) { fprintf(stderr, "%d: ifname not set prior to remote\n", num); @@ -604,7 +619,7 @@ char *filename; break; } bcopy((char *)&template, (char *)l4, sizeof(*l4)); - l4->l4_sin.sin_addr = ipn->in_in[0]; + l4->l4_sin.sin_addr = ipn->in_in[0].in4; l4->l4_sin.sin_port = ipn->in_pnext; l4->l4_next = l4list; l4list = l4; @@ -791,7 +806,7 @@ char *argv[]; } if (!(opts & OPT_DONOTHING)) { - natfd = open(IPL_NAT, O_RDWR); + natfd = open(IPNAT_NAME, O_RDWR); if (natfd == -1) { perror("open(IPL_NAT)"); exit(1); @@ -802,4 +817,6 @@ char *argv[]; fprintf(stderr, "Starting...\n"); while (runconfig() == 0) ; + + exit(1); } |