summaryrefslogtreecommitdiff
path: root/lib/ipv6.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-08-25 16:42:14 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2009-08-25 16:42:14 +0200
commitb49e6f5a65d437cb7e7bdefe8397e0f550496012 (patch)
tree21e0f77023119de17ea8ab6ab7871b1026db92e6 /lib/ipv6.c
parentc3226991a061415fa83b757cbff678111c586e58 (diff)
Temporary OSPFv3 development commit
Diffstat (limited to 'lib/ipv6.c')
-rw-r--r--lib/ipv6.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/ipv6.c b/lib/ipv6.c
index 88c54eb6..3334b976 100644
--- a/lib/ipv6.c
+++ b/lib/ipv6.c
@@ -136,6 +136,60 @@ ipv6_compare(ip_addr X, ip_addr Y)
return 0;
}
+/* From Linux include/net/ipv6.h */
+#define NEXTHDR_HOP 0 /* Hop-by-hop option header. */
+#define NEXTHDR_ROUTING 43 /* Routing header. */
+#define NEXTHDR_FRAGMENT 44 /* Fragmentation/reassembly header. */
+#define NEXTHDR_DEST 60 /* Destination options header. */
+#define NEXTHDR_NONE 59 /* No next header */
+
+#define NEXTHDR_ESP 50 /* Encapsulating security payload. */
+#define NEXTHDR_AUTH 51 /* Authentication header. */
+
+
+byte *
+ipv6_skip_header(byte *pkt, int *len)
+{
+ int l = *len;
+ int q;
+ u8 nh;
+
+ if (l < 40 || (*pkt & 0xf0) != 0x60)
+ return NULL;
+
+ /* Skip IPv6 header */
+ nh = pkt[6];
+ pkt += 40;
+
+ while ()
+ {
+ switch (nw)
+ {
+ case NEXTHDR_FRAGMENT:
+
+ case NEXTHDR_HOP:
+ case NEXTHDR_ROUTING:
+ case NEXTHDR_DEST:
+
+ case NEXTHDR_AUTH:
+ break;
+
+ case NEXTHDR_NONE:
+ return NULL;
+
+ default:
+ return pkt;
+ }
+ }
+
+ q = (*pkt & 0x0f) * 4;
+ if (q > l)
+ return NULL;
+ *len -= q;
+ return pkt + q;
+}
+
+
/*
* Conversion of IPv6 address to presentation format and vice versa.
* Heavily inspired by routines written by Paul Vixie for the BIND project