Index: Build
===================================================================
RCS file: Build
diff -N Build
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Build	22 Mar 2004 01:19:58 -0000	1.4
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+source ../Config.sh
+
+pp_do "$@"
Index: Makefile
===================================================================
RCS file: /srv/CVS/eric_firmware/iptables/Makefile,v
retrieving revision 1.1.6.4
retrieving revision 1.15
diff -u -r1.1.6.4 -r1.15
--- Makefile	27 May 2003 09:53:07 -0000	1.1.6.4
+++ Makefile	4 May 2005 12:43:09 -0000	1.15
@@ -1,8 +1,11 @@
+include ../Config.mk
+
 # uncomment this to get a fully statically linked version
-# NO_SHARED_LIBS = 1
+# if using dynamic libs we ge a segfault when we use uClibc
+NO_SHARED_LIBS = 1
 
 # uncomment this to disable IPv6 support
-# DO_IPV6 = 0
+ DO_IPV6 = 0
 
 ######################################################################
 # YOU SHOULD NOT NEED TO TOUCH ANYTHING BELOW THIS LINE
@@ -12,27 +15,27 @@
 TOPLEVEL_INCLUDED=YES
 
 ifndef KERNEL_DIR
-KERNEL_DIR=/usr/src/linux
+KERNEL_DIR=$(FW_TOPDIR)/$(LINUX_KERNEL_DIR)
 endif
 IPTABLES_VERSION:=1.2.8
 OLD_IPTABLES_VERSION:=1.2.7a
 
-PREFIX:=/usr/local
-LIBDIR:=$(PREFIX)/lib
-BINDIR:=$(PREFIX)/sbin
-MANDIR:=$(PREFIX)/man
-INCDIR:=$(PREFIX)/include
+LIBDIR:=/lib
+BINDIR:=/sbin
 
 # directory for new iptables releases
 RELEASE_DIR:=/tmp
 
 # Need libc6 for this.  FIXME: Should covert to autoconf.
-ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
-DO_IPV6:=1
+#ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
+#DO_IPV6=1
+#endif
+ifeq ($(PP_BUILD_ARCH),arm)
+COPT_FLAGS:=$(FW_CFLAGS_3RDPARTY) -DNDEBUG
+else
+COPT_FLAGS:=$(FW_CFLAGS_3RDPARTY) -ffunction-sections -fdata-sections -DNDEBUG
 endif
-
-COPT_FLAGS:=-O2
-CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG
+CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I${PWD}/include-fixed -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" -D_REENTRANT #-g -DDEBUG #-pg # -DIPTC_DEBUG
 
 ifdef NO_SHARED_LIBS
 CFLAGS += -DNO_SHARED_LIBS=1
@@ -49,22 +52,22 @@
 DEPFILES = $(EXT_OBJS:%.o=%.d)
 STATIC_LIBS  = extensions/libext.a
 STATIC6_LIBS = extensions/libext6.a
-LDFLAGS      = -static
+LDFLAGS      =
 LDLIBS       =
 endif
 
 EXTRAS+=iptables iptables.o
-EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
+EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables
 
 # No longer experimental.
-EXTRAS+=iptables-save iptables-restore
-EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8
+#EXTRAS+=iptables-save iptables-restore
+#EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8
 
 ifeq ($(DO_IPV6), 1)
 EXTRAS+=ip6tables ip6tables.o
-EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables $(DESTDIR)$(MANDIR)/man8/ip6tables.8
-EXTRAS_EXP+=ip6tables-save ip6tables-restore
-EXTRA_INSTALLS_EXP+=$(DESTDIR)$(BINDIR)/ip6tables-save $(DESTDIR)$(BINDIR)/ip6tables-restore # $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-restore.8
+EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables
+#EXTRAS_EXP+=ip6tables-save ip6tables-restore
+#EXTRA_INSTALLS_EXP+=$(DESTDIR)$(BINDIR)/ip6tables-save $(DESTDIR)$(BINDIR)/ip6tables-restore # $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-restore.8
 endif
 
 # Sparc64 hack
@@ -84,7 +87,7 @@
 endif
 
 .PHONY: default
-default: print-extensions all
+default: fixincludes print-extensions all
 
 .PHONY: print-extensions
 print-extensions:
Index: Rules.make
===================================================================
RCS file: /srv/CVS/eric_firmware/iptables/Rules.make,v
retrieving revision 1.1.6.1
retrieving revision 1.3
diff -u -r1.1.6.1 -r1.3
--- Rules.make	28 Jan 2002 09:20:30 -0000	1.1.6.1
+++ Rules.make	4 Nov 2003 08:45:22 -0000	1.3
@@ -1,6 +1,17 @@
 #! /usr/bin/make
 
-all: $(SHARED_LIBS) $(EXTRAS)
+all: fixincludes $(SHARED_LIBS) $(EXTRAS)
+
+.PHONY: fixincludes
+fixincludes:
+	mkdir -p include-fixed/linux/netfilter_ipv4
+	mkdir -p include-fixed/linux/netfilter_ipv6
+	sed -e 's,^extern __inline__,static __inline__,' \
+		< $(KERNEL_DIR)/include/linux/netfilter_ipv4/ip_tables.h \
+		> include-fixed/linux/netfilter_ipv4/ip_tables.h
+	sed -e 's,^extern __inline__,static __inline__,' \
+		< $(KERNEL_DIR)/include/linux/netfilter_ipv6/ip6_tables.h \
+		> include-fixed/linux/netfilter_ipv6/ip6_tables.h
 
 experimental: $(EXTRAS_EXP)
 
@@ -8,10 +19,11 @@
 clean: $(EXTRA_CLEANS)
 	rm -f $(SHARED_LIBS) $(EXTRAS) $(EXTRAS_EXP) $(SHARED_LIBS:%.so=%_sh.o)
 	rm -f extensions/initext.c extensions/initext6.c
+	rm -rf include-fixed
 	@find . -name '*.[ao]' -o -name '*.so' | xargs rm -f
 
 install: all $(EXTRA_INSTALLS)
-	@if [ -f /usr/local/bin/iptables -a "$(BINDIR)" = "/usr/local/sbin" ];\
+	#@if [ -f /usr/local/bin/iptables -a "$(BINDIR)" = "/usr/local/sbin" ];\
 	then echo 'Erasing iptables from old location (now /usr/local/sbin).';\
 	rm -f /usr/local/bin/iptables;\
 	fi
Index: ip6tables.c
===================================================================
RCS file: /srv/CVS/eric_firmware/iptables/ip6tables.c,v
retrieving revision 1.1.6.4
retrieving revision 1.2
diff -u -r1.1.6.4 -r1.2
--- ip6tables.c	27 May 2003 09:53:07 -0000	1.1.6.4
+++ ip6tables.c	4 Nov 2003 08:45:22 -0000	1.2
@@ -148,14 +148,6 @@
  * magic number of -1 */
 int line = -1;
 
-#ifndef __OPTIMIZE__
-struct ip6t_entry_target *
-ip6t_get_target(struct ip6t_entry *e)
-{
-	return (void *)e + e->target_offset;
-}
-#endif
-
 static struct option *opts = original_opts;
 static unsigned int global_option_offset = 0;
 
Index: iptables.c
===================================================================
RCS file: /srv/CVS/eric_firmware/iptables/iptables.c,v
retrieving revision 1.1.6.4
retrieving revision 1.2
diff -u -r1.1.6.4 -r1.2
--- iptables.c	27 May 2003 09:53:07 -0000	1.1.6.4
+++ iptables.c	4 Nov 2003 08:45:22 -0000	1.2
@@ -147,14 +147,6 @@
  * magic number of -1 */
 int line = -1;
 
-#ifndef __OPTIMIZE__
-struct ipt_entry_target *
-ipt_get_target(struct ipt_entry *e)
-{
-	return (void *)e + e->target_offset;
-}
-#endif
-
 static struct option *opts = original_opts;
 static unsigned int global_option_offset = 0;
 
Index: extensions/Makefile
===================================================================
RCS file: /srv/CVS/eric_firmware/iptables/extensions/Makefile,v
retrieving revision 1.1.6.4
retrieving revision 1.8
diff -u -r1.1.6.4 -r1.8
--- extensions/Makefile	27 May 2003 09:53:07 -0000	1.1.6.4
+++ extensions/Makefile	4 May 2005 12:43:09 -0000	1.8
@@ -1,12 +1,14 @@
 #! /usr/bin/make
 
-# WARNING:
-# only add extensions here that are either present in the kernel, or whose
-# header files are present in the include/linux directory of this iptables
-# package (HW)
-#
-PF_EXT_SLIB:=ah conntrack dscp ecn esp helper icmp iplimit length limit mac mark multiport owner physdev pkttype rpc standard state tcp tcpmss tos ttl udp unclean DNAT DSCP ECN LOG MARK MASQUERADE MIRROR REDIRECT REJECT SAME SNAT TARPIT TCPMSS TOS TTL ULOG
-PF6_EXT_SLIB:=eui64 hl icmpv6 length limit mac mark multiport owner standard tcp udp HL LOG MARK
+ifeq ($(PP_BUILD_ARCH),arm)
+PF_EXT_SLIB:=standard mac mark tcp udp REDIRECT
+else
+PF_EXT_SLIB:=standard mac mark tcp udp FASTNAT MARK REDIRECT
+endif
+PF6_EXT_SLIB:=standard
+
+# The following may not be present, but compile them anyway.
+PF_EXT_SLIB+=
 
 # Optionals
 PF_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))
Index: extensions/libipt_FASTNAT.c
===================================================================
RCS file: extensions/libipt_FASTNAT.c
diff -N extensions/libipt_FASTNAT.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ extensions/libipt_FASTNAT.c	21 Apr 2005 11:59:36 -0000	1.5
@@ -0,0 +1,192 @@
+#include <stdio.h>
+#include <netdb.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <iptables.h>
+#include <sys/types.h>
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv4/ipt_FASTNAT.h>
+
+/* Function which prints out usage message. */
+static void
+help(void)
+{
+    printf("FASTNAT v%s options:\n"
+	   " --to-source <ipaddr>         Address to map source to.\n"
+	   " --to-destination <ipaddr>    Address to map destination to.\n"
+	   " --to-sport <port>            Port to map source to.\n"
+	   " --to-dport <port>            Port to map destination to.\n\n",
+	   IPTABLES_VERSION);
+}
+
+static struct option opts[] = {
+    { "to-source", 1, 0, '1' },
+    { "to-destination", 1, 0, '2' },
+    { "to-sport", 1, 0, '3' },
+    { "to-dport", 1, 0, '4' },
+    { 0 }
+};
+
+/* Initialize the target. */
+static void
+init(struct ipt_entry_target *t, unsigned int *nfcache)
+{
+    struct ipt_fastnat_info *info = (struct ipt_fastnat_info *)t->data;
+
+    memset(info, 0, sizeof(*info));
+
+    /* Can't cache this */
+    *nfcache |= NFC_UNKNOWN;
+}
+
+/* Function which parses command options; returns true if it ate an option */
+static int
+parse(int c, char **argv, int invert, unsigned int *flags,
+      const struct ipt_entry *entry,
+      struct ipt_entry_target **target)
+{
+    struct ipt_fastnat_info *info = (struct ipt_fastnat_info *)(*target)->data;
+    struct in_addr * ip;
+    u_int port;
+
+    switch (c) {
+      case '1':
+	  if (check_inverse(optarg, &invert, NULL, 0)) {
+	      exit_error(PARAMETER_PROBLEM,
+			 "Unexpected `!' after --to-source");
+	  }
+
+	  ip = dotted_to_addr(optarg);
+	  if (!ip) {
+	      exit_error(PARAMETER_PROBLEM, "Bad IP address `%s'\n", optarg);
+	  }
+
+	  info->type |= IPT_FASTNAT_SRC_ADDR;
+	  memcpy(&info->saddr, ip, sizeof(info->saddr));
+	  *flags |= IPT_FASTNAT_SRC_ADDR;
+	  return 1;
+
+      case '2':
+	  if (check_inverse(optarg, &invert, NULL, 0)) {
+	      exit_error(PARAMETER_PROBLEM,
+			 "Unexpected `!' after --to-destination");
+	  }
+
+	  ip = dotted_to_addr(optarg);
+	  if (!ip) {
+	      exit_error(PARAMETER_PROBLEM, "Bad IP address `%s'\n", optarg);
+	  }
+
+	  info->type |= IPT_FASTNAT_DST_ADDR;
+	  memcpy(&info->daddr, ip, sizeof(info->daddr));
+	  *flags |= IPT_FASTNAT_DST_ADDR;
+	  return 1;
+
+      case '3':
+	  if (check_inverse(optarg, &invert, NULL, 0)) {
+	      exit_error(PARAMETER_PROBLEM,
+			 "Unexpected `!' after --to-sport");
+	  }
+
+	  if (string_to_number(optarg, 0, 65535, &port) == -1) {
+	      exit_error(PARAMETER_PROBLEM, "Bad port number `%s'\n", optarg);
+	  }
+
+	  info->type |= IPT_FASTNAT_SRC_PORT;
+	  info->sport = port;
+	  *flags |= IPT_FASTNAT_SRC_PORT;
+	  return 1;
+
+      case '4':
+	  if (check_inverse(optarg, &invert, NULL, 0)) {
+	      exit_error(PARAMETER_PROBLEM,
+			 "Unexpected `!' after --to-dport");
+	  }
+
+	  if (string_to_number(optarg, 0, 65535, &port) == -1) {
+	      exit_error(PARAMETER_PROBLEM, "Bad port number `%s'\n", optarg);
+	  }
+
+	  info->type |= IPT_FASTNAT_DST_PORT;
+	  info->dport = port;
+	  *flags |= IPT_FASTNAT_DST_PORT;
+	  return 1;
+
+      default:
+	  return 0;
+    }
+}
+
+/* Final check */
+static void final_check(unsigned int flags)
+{
+    if (!flags) {
+	exit_error(PARAMETER_PROBLEM,
+		   "You must specify one of --to-source, --to-sport, --to-destination and --to-dport.");
+    }
+}
+
+/* Prints out the targinfo. */
+static void
+print(const struct ipt_ip *ip,
+      const struct ipt_entry_target *target,
+      int numeric)
+{
+    struct ipt_fastnat_info *info = (struct ipt_fastnat_info *)target->data;
+
+    printf("FASTNAT ");
+    if (info->type & IPT_FASTNAT_SRC_ADDR) {
+	printf("source to %s ", addr_to_dotted(&info->saddr));
+    }
+    if (info->type & IPT_FASTNAT_SRC_PORT) {
+	printf("source port to %hu ", info->sport);
+    }
+    if (info->type & IPT_FASTNAT_DST_ADDR) {
+	printf("destination to %s ", addr_to_dotted(&info->daddr));
+    }
+    if (info->type & IPT_FASTNAT_DST_PORT) {
+	printf("destination port to %hu ", info->dport);
+    }
+}
+
+/* Saves the union ipt_targinfo in parsable form to stdout. */
+static void
+save(const struct ipt_ip *ip, const struct ipt_entry_target *target)
+{
+    struct ipt_fastnat_info *info = (struct ipt_fastnat_info *)target->data;
+
+    if (info->type & IPT_FASTNAT_SRC_ADDR) {
+	printf("--to-source %s ", addr_to_dotted(&info->saddr));
+    }
+    if (info->type & IPT_FASTNAT_SRC_PORT) {
+	printf("--to-sport %hu ", info->sport);
+    }
+    if (info->type & IPT_FASTNAT_DST_ADDR) {
+	printf("--to-destination %s ", addr_to_dotted(&info->daddr));
+    }
+    if (info->type & IPT_FASTNAT_DST_PORT) {
+	printf("--to-dport %hu ", info->dport);
+    }
+}
+
+static
+struct iptables_target fastnat
+= { NULL,
+    "FASTNAT",
+    IPTABLES_VERSION,
+    IPT_ALIGN(sizeof(struct ipt_fastnat_info)),
+    IPT_ALIGN(sizeof(struct ipt_fastnat_info)),
+    &help,
+    &init,
+    &parse,
+    &final_check,
+    &print,
+    &save,
+    opts
+};
+
+void _init(void)
+{
+    register_target(&fastnat);
+}
Index: extensions/libipt_MARK.c
===================================================================
RCS file: /srv/CVS/eric_firmware/iptables/extensions/libipt_MARK.c,v
retrieving revision 1.1.6.2
retrieving revision 1.2
diff -u -r1.1.6.2 -r1.2
--- extensions/libipt_MARK.c	7 Nov 2002 07:57:57 -0000	1.1.6.2
+++ extensions/libipt_MARK.c	21 Apr 2005 11:59:36 -0000	1.2
@@ -19,7 +19,7 @@
 {
 	printf(
 "MARK target v%s options:\n"
-"  --set-mark value                   Set nfmark value\n"
+"  --set-mark value[/mask]         Set nfmark value with optional mask\n"
 "\n",
 IPTABLES_VERSION);
 }
@@ -46,10 +46,17 @@
 		= (struct ipt_mark_target_info *)(*target)->data;
 
 	switch (c) {
+		char *end;
 	case '1':
-		if (string_to_number(optarg, 0, 0xffffffff, 
-				     (unsigned int *)&markinfo->mark))
+		markinfo->mark = strtoul(optarg, &end, 0);
+		if (*end == '/') {
+			markinfo->mask = strtoul(end+1, &end, 0);
+		} else {
+			markinfo->mask = 0xffffffff;
+		}
+		if (*end != '\0' || end == optarg) {
 			exit_error(PARAMETER_PROBLEM, "Bad MARK value `%s'", optarg);
+		}
 		if (*flags)
 			exit_error(PARAMETER_PROBLEM,
 			           "MARK target: Can't specify --set-mark twice");
@@ -72,9 +79,12 @@
 }
 
 static void
-print_mark(unsigned long mark, int numeric)
+print_mark(unsigned long mark, unsigned long mask, int numeric)
 {
-	printf("0x%lx ", mark);
+	if(mask != 0xffffffff)
+		printf("0x%lx/0x%lx ", mark, mask);
+	else
+		printf("0x%lx ", mark);
 }
 
 /* Prints out the targinfo. */
@@ -86,7 +96,7 @@
 	const struct ipt_mark_target_info *markinfo =
 		(const struct ipt_mark_target_info *)target->data;
 	printf("MARK set ");
-	print_mark(markinfo->mark, numeric);
+	print_mark(markinfo->mark, markinfo->mask, numeric);
 }
 
 /* Saves the union ipt_targinfo in parsable form to stdout. */
@@ -96,7 +106,8 @@
 	const struct ipt_mark_target_info *markinfo =
 		(const struct ipt_mark_target_info *)target->data;
 
-	printf("--set-mark 0x%lx ", markinfo->mark);
+	printf("--set-mark ");
+	print_mark(markinfo->mark, markinfo->mask, 0);
 }
 
 static
Index: libiptc/libiptc.c
===================================================================
RCS file: /srv/CVS/eric_firmware/iptables/libiptc/libiptc.c,v
retrieving revision 1.1.6.3
retrieving revision 1.2
diff -u -r1.1.6.3 -r1.2
--- libiptc/libiptc.c	7 Nov 2002 07:57:58 -0000	1.1.6.3
+++ libiptc/libiptc.c	4 Nov 2003 08:45:22 -0000	1.2
@@ -15,14 +15,6 @@
 #define IPT_LIB_DIR "/usr/local/lib/iptables"
 #endif
 
-#ifndef __OPTIMIZE__
-STRUCT_ENTRY_TARGET *
-GET_TARGET(STRUCT_ENTRY *e)
-{
-	return (void *)e + e->target_offset;
-}
-#endif
-
 static int sockfd = -1;
 static void *iptc_fn = NULL;
 
