[netfilter-cvslog] r6379 - in trunk/nfsim: . core core/ipv6
netfilter
laforge at netfilter.org
laforge at netfilter.org
Sun Jan 8 21:55:35 CET 2006
Author: laforge at netfilter.org
Date: 2006-01-08 21:55:34 +0100 (Sun, 08 Jan 2006)
New Revision: 6379
Added:
trunk/nfsim/core/ipv6/
trunk/nfsim/core/ipv6/ipv6.c
trunk/nfsim/core/ipv6/ipv6.h
Modified:
trunk/nfsim/configure
trunk/nfsim/core/Makefile
trunk/nfsim/netfilter/Makefile
trunk/nfsim/netfilter/Makefile.kbuild.in
Log:
full x_tables (ipv4 part) support.
This also adds some more ipv6 skeletons that are totally bogus and incomplete.
Modified: trunk/nfsim/configure
===================================================================
--- trunk/nfsim/configure 2006-01-08 19:58:14 UTC (rev 6378)
+++ trunk/nfsim/configure 2006-01-08 20:55:34 UTC (rev 6379)
@@ -90,15 +90,17 @@
echo "import: netfilter/core/$i" >> Makefile.import
done
# Import type-specific netfilter.c to netfilter/core/<type>.c
- echo "netfilter/core/$TYPE.c: $KERNELDIR/net/$TYPE/netfilter.c" >> Makefile.import
- echo ' @sed -f netfilter.c.sed $< > $@ && chmod a-w $@' >> Makefile.import
- echo "import: netfilter/core/$TYPE.c" >> Makefile.import
+ for typ in ipv4 ipv6; do
+ echo "netfilter/core/$typ.c: $KERNELDIR/net/$typ/netfilter.c" >> Makefile.import
+ echo ' @sed -f netfilter.c.sed $< > $@ && chmod a-w $@' >> Makefile.import
+ echo "import: netfilter/core/$typ.c" >> Makefile.import
+ done
if [ -f $KERNELDIR/net/netfilter/x_tables.c ]; then
- echo "netfilter/core/x_tables.c: $KERNELDIR/net/netfilter/x_tables.c" >> Makefile.import
- echo ' @cp $< $@ && chmod a-w $@' >> Makefile.import
- echo "import: netfilter/core/x_tables.c" >> Makefile.import
+ #echo "netfilter/core/x_tables.c: $KERNELDIR/net/netfilter/x_tables.c" >> Makefile.import
+ #echo ' @cp $< $@ && chmod a-w $@' >> Makefile.import
+ #echo "import: netfilter/core/x_tables.c" >> Makefile.import
files=$(cd $KERNELDIR/net/netfilter/; \
- find . -name '*.[ch]' ! -name '*.mod.c' ! -name 'core.c' ! -name 'nf_log.c' ! -name 'nf_queue.c' ! -name 'nf_sockopt.c' ! -name 'x_tables.c' | grep -vE '/(SCCS|RCS)/')
+ find . -name '*.[ch]' ! -name '*.mod.c' ! -name 'core.c' ! -name 'nf_log.c' ! -name 'nf_queue.c' ! -name 'nf_sockopt.c' | grep -vE '/(SCCS|RCS)/')
for f in $files; do
echo "netfilter/gen/$f":"$KERNELDIR/net/netfilter/$f" >> Makefile.import
echo ' @cp $< $@ && chmod a-w $@' >> Makefile.import
@@ -176,7 +178,7 @@
if [ -f $KERNELDIR/.config ]; then
echo Using $KERNELDIR config...
- egrep -v @@`unsupported`@@ $KERNELDIR/.config | sed 's/=m$/=y/' > .config
+ egrep -v @@`unsupported`@@ $KERNELDIR/.config > .config
else
echo Using sample config...
cp .config.sample .config
Modified: trunk/nfsim/core/Makefile
===================================================================
--- trunk/nfsim/core/Makefile 2006-01-08 19:58:14 UTC (rev 6378)
+++ trunk/nfsim/core/Makefile 2006-01-08 20:55:34 UTC (rev 6379)
@@ -1,2 +1,2 @@
-OBJS += core/utils.o core/core.o core/message.o core/$(TYPE)/$(TYPE).o core/seq_file.o core/talloc.o core/failtest.o core/field.o
+OBJS += core/utils.o core/core.o core/message.o core/$(TYPE)/$(TYPE).o core/ipv6/ipv6.o core/seq_file.o core/talloc.o core/failtest.o core/field.o
HELP_OBJS += core/tui.o core/expect.o core/log.o
Added: trunk/nfsim/core/ipv6/ipv6.c
===================================================================
--- trunk/nfsim/core/ipv6/ipv6.c 2006-01-08 19:58:14 UTC (rev 6378)
+++ trunk/nfsim/core/ipv6/ipv6.c 2006-01-08 20:55:34 UTC (rev 6379)
@@ -0,0 +1,77 @@
+
+#include "ipv6.h"
+#include "utils.h"
+#include <core.h>
+#include <field.h>
+
+#include <linux/netfilter_ipv6.h>
+
+int route(struct sk_buff *skb);
+
+LIST_HEAD(routes6);
+
+static struct notifier_block *inet6addr_chain;
+
+static void init(void)
+{
+ /* name our hooks */
+ nf_hooknames[PF_INET6][0] = "NF_IP6_PRE_ROUTING";
+ nf_hooknames[PF_INET6][1] = "NF_IP6_LOCAL_IN";
+ nf_hooknames[PF_INET6][2] = "NF_IP6_FORWARD";
+ nf_hooknames[PF_INET6][3] = "NF_IP6_LOCAL_OUT";
+ nf_hooknames[PF_INET6][4] = "NF_IP6_POST_ROUTING";
+}
+
+init_call(init);
+
+static int ip6_output2(struct sk_buff *skb)
+{
+ struct net_device *dev = skb->dst->dev;
+
+ skb->dev = dev;
+ skb->protocol = htons(ETH_P_IPV6);
+
+ return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb, NULL, skb->dev,
+ nf_send);
+}
+
+int ip6_output(struct sk_buff *skb)
+{
+ /* FIXME: fragment? */
+ return ip6_output2(skb);
+}
+
+int ip6_forward(struct sk_buff *skb)
+{
+ struct ipv6hdr *hdr = skb->nh.ipv6h;
+
+ if (!(--hdr->hop_limit)) {
+ log_route(skb, "ip6_forward: HOPLIMIT expired");
+ icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT, 0,
+ skb->dev);
+ kfree_skb(skb);
+ return 1;
+ }
+ nfsim_update_skb(skb, &skb->nh.ipv6h->hop_limit,
+ sizeof(skb->nh.ipv6h->hop_limit));
+
+ return NF_HOOK(PF_INET6, NF_IP6_FORWARD, skb, skb->dev, skb->dst->dev,
+ dst_output);
+}
+
+void ip6_route_input(struct sk_buff *skb)
+{
+
+}
+
+struct dst_entry *ip6_route_output(struct sock *sk, struct flowi *fl)
+{
+ /* FIXME */
+ return NULL;
+}
+
+void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
+ struct net_device *dev)
+{
+ /* FIXME */
+}
Added: trunk/nfsim/core/ipv6/ipv6.h
===================================================================
--- trunk/nfsim/core/ipv6/ipv6.h 2006-01-08 19:58:14 UTC (rev 6378)
+++ trunk/nfsim/core/ipv6/ipv6.h 2006-01-08 20:55:34 UTC (rev 6379)
@@ -0,0 +1,61 @@
+
+#include <protocol.h>
+
+#ifndef __HAVE_IPV6_H
+#define __HAVE_IPV6_H 1
+
+#define ICMPV6_DEST_UNREACH 1
+#define ICMPV6_PKT_TOOBIG 2
+#define ICMPV6_TIME_EXCEED 3
+#define ICMPV6_PARAMPROB 4
+
+#define ICMPV6_INFOMSG_MASK 0x80
+
+#define ICMPV6_ECHO_REQUEST 128
+#define ICMPV6_ECHO_REPLY 129
+#define ICMPV6_MGM_QUERY 130
+#define ICMPV6_MGM_REPORT 131
+#define ICMPV6_MGM_REDUCTION 132
+
+#define ICMPV6_NI_QUERY 139
+#define ICMPV6_NI_REPLY 140
+
+#define ICMPV6_MLD2_REPORT 143
+
+#define ICMPV6_DHAAD_REQUEST 144
+#define ICMPV6_DHAAD_REPLY 145
+#define ICMPV6_MOBILE_PREFIX_SOL 146
+#define ICMPV6_MOBILE_PREFIX_ADV 147
+
+/*
+ * Codes for Destination Unreachable
+ */
+#define ICMPV6_NOROUTE 0
+#define ICMPV6_ADM_PROHIBITED 1
+#define ICMPV6_NOT_NEIGHBOUR 2
+#define ICMPV6_ADDR_UNREACH 3
+#define ICMPV6_PORT_UNREACH 4
+
+/*
+ * Codes for Time Exceeded
+ */
+#define ICMPV6_EXC_HOPLIMIT 0
+#define ICMPV6_EXC_FRAGTIME 1
+
+/*
+ * Codes for Parameter Problem
+ */
+#define ICMPV6_HDR_FIELD 0
+#define ICMPV6_UNK_NEXTHDR 1
+#define ICMPV6_UNK_OPTION 2
+
+void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
+ struct net_device *dev);
+
+int ip6_forward(struct sk_buff *skb);
+int ip6_output(struct sk_buff *skb);
+
+struct dst_entry *ip6_route_output(struct sock *sk, struct flowi *fl);
+void ip6_route_input(struct sk_buff *skb);
+
+#endif /* __HAVE_IPV6_H */
Modified: trunk/nfsim/netfilter/Makefile
===================================================================
--- trunk/nfsim/netfilter/Makefile 2006-01-08 19:58:14 UTC (rev 6378)
+++ trunk/nfsim/netfilter/Makefile 2006-01-08 20:55:34 UTC (rev 6379)
@@ -2,9 +2,12 @@
all: dummy.o modules netfilter.o
-netfilter.o: $(TYPE)/$(TYPE).o $(NETFILTER_C_FILES:.c=.o)
+netfilter.o: $(TYPE)/$(TYPE).o gen/gen.o $(NETFILTER_C_FILES:.c=.o)
ld -r -o $@ $^
+gen/gen.o: gen/
+ @cd $(@D) && $(MAKE) -f ../Makefile.kbuild obj=$(@F) $(@F)
+
$(TYPE)/$(TYPE).o: $(TYPE)/
@cd $(@D) && $(MAKE) -f ../Makefile.kbuild obj=$(@F) $(@F)
Modified: trunk/nfsim/netfilter/Makefile.kbuild.in
===================================================================
--- trunk/nfsim/netfilter/Makefile.kbuild.in 2006-01-08 19:58:14 UTC (rev 6378)
+++ trunk/nfsim/netfilter/Makefile.kbuild.in 2006-01-08 20:55:34 UTC (rev 6379)
@@ -10,6 +10,9 @@
$(TYPE).o: $(obj-y) ../dummy.o
$(LD) $(LDFLAGS) -r -o $(@) $^
+gen.o: $(obj-y) ../dummy.o
+ $(LD) $(LDFLAGS) -r -o $(@) $^
+
%.o:%.c
$(COMPILE.c) $(GCOVFLAGS) -DKBUILD_MODNAME=$(@:.o=) $(OUTPUT_OPTION) $<
More information about the netfilter-cvslog
mailing list