From b66abe8ef986698caccd08b38a991330f0791075 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 15 Oct 2009 00:28:04 +0200 Subject: Reimplements 'show ospf state' for OSPFv3 and fixes some bugs. --- proto/ospf/ospf.h | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'proto/ospf/ospf.h') diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index d85ebdc..e89769d 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -523,19 +523,57 @@ struct ospf_lsa_prefix #define METRIC_MASK 0x00FFFFFF #define OPTIONS_MASK 0x00FFFFFF -static inline unsigned lsa_rt_count(struct ospf_lsa_header *lsa) +static inline unsigned +lsa_rt_count(struct ospf_lsa_header *lsa) { return (lsa->length - sizeof(struct ospf_lsa_header) - sizeof(struct ospf_lsa_rt)) / sizeof(struct ospf_lsa_rt_link); } -static inline unsigned lsa_net_count(struct ospf_lsa_header *lsa) +static inline unsigned +lsa_net_count(struct ospf_lsa_header *lsa) { return (lsa->length - sizeof(struct ospf_lsa_header) - sizeof(struct ospf_lsa_net)) / sizeof(u32); } +#ifdef OSPFv3 + +static inline u32 * +lsa_get_ipv6_prefix(u32 *buf, ip_addr *addr, int *pxlen, u8 *pxopts, u16 *rest) +{ + u8 pxl = (*buf >> 24); + *pxopts = (*buf >> 16); + *rest = *buf; + *pxlen = pxl; + buf++; + + *addr = IPA_NONE; + + if (pxl > 0) + _I0(*addr) = *buf++; + if (pxl > 32) + _I1(*addr) = *buf++; + if (pxl > 64) + _I2(*addr) = *buf++; + if (pxl > 96) + _I3(*addr) = *buf++; + + return buf; +} + +static inline u32 * +lsa_get_ipv6_addr(u32 *buf, ip_addr *addr) +{ + *addr = *(ip_addr *) buf; + return buf + 4; +} + +#endif + + + struct ospf_lsreq_header { u32 type; -- cgit v1.2.3