From b23c5e0ff4e9071b2568bf2f7d437bc13273d17d Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 14 May 1999 18:03:09 +0000 Subject: Added ip_skip_header() and modified OSPF to use it. --- lib/ipv4.c | 15 +++++++++++++++ lib/ipv4.h | 3 +++ 2 files changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/ipv4.c b/lib/ipv4.c index 186b36a..943e2c8 100644 --- a/lib/ipv4.c +++ b/lib/ipv4.c @@ -94,3 +94,18 @@ ip_pton(char *a, ip_addr *o) *o = ipa_from_u32(ia); return 1; } + +byte * +ipv4_skip_header(byte *pkt, int *len) +{ + int l = *len; + int q; + + if (l < 20 || (*pkt & 0xf0) != 0x40) + return NULL; + q = (*pkt & 0x0f) * 4; + if (q < l) + return NULL; + *len -= q; + return pkt + q; +} diff --git a/lib/ipv4.h b/lib/ipv4.h index a672036..87e0874 100644 --- a/lib/ipv4.h +++ b/lib/ipv4.h @@ -58,8 +58,11 @@ typedef u32 ip_addr; #define ipa_to_u32(x) _I(x) #define ipa_compare(x,y) ipv4_compare(_I(x),_I(y)) +#define ip_skip_header(x, y) ipv4_skip_header(x, y) + int ipv4_classify(u32); u32 ipv4_class_mask(u32); +byte *ipv4_skip_header(byte *, int *); static inline unsigned ipv4_hash(u32 a) { -- cgit v1.2.3