From 1e37e35c3ea88672c677ea7ac63fe0b9df609b0c Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Wed, 22 Mar 2017 15:00:07 +0100 Subject: BGP: Support for MPLS labels and VPN SAFI Basic support for SAFI 4 and 128 (MPLS labeled IP and VPN) for IPv4 and IPv6. Should work for route reflector, but does not properly handle originating routes with next hop self. Based on patches from Jan Matejka. --- lib/net.h | 8 ++++++++ lib/unaligned.h | 14 ++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'lib') diff --git a/lib/net.h b/lib/net.h index 16a18479..ff889e99 100644 --- a/lib/net.h +++ b/lib/net.h @@ -35,6 +35,8 @@ #define NB_MPLS (1 << NET_MPLS) #define NB_IP (NB_IP4 | NB_IP6) +#define NB_VPN (NB_VPN4 | NB_VPN6) +#define NB_FLOW (NB_FLOW4 | NB_FLOW6) #define NB_ANY 0xffffffff @@ -481,6 +483,12 @@ static inline void net_normalize_ip4(net_addr_ip4 *n) static inline void net_normalize_ip6(net_addr_ip6 *n) { n->prefix = ip6_and(n->prefix, ip6_mkmask(n->pxlen)); } +static inline void net_normalize_vpn4(net_addr_vpn4 *n) +{ net_normalize_ip4((net_addr_ip4 *) n); } + +static inline void net_normalize_vpn6(net_addr_vpn6 *n) +{ net_normalize_ip6((net_addr_ip6 *) n); } + void net_normalize(net_addr *N); diff --git a/lib/unaligned.h b/lib/unaligned.h index 4e841f3a..0da1fdb4 100644 --- a/lib/unaligned.h +++ b/lib/unaligned.h @@ -28,6 +28,13 @@ get_u16(const void *p) return ntohs(x); } +static inline u32 +get_u24(const void *P) +{ + const byte *p = P; + return (p[0] << 16) + (p[1] << 8) + p[2]; +} + static inline u32 get_u32(const void *p) { @@ -52,6 +59,13 @@ put_u16(void *p, u16 x) memcpy(p, &x, 2); } +static inline void +put_u24(void *p, u32 x) +{ + x = htonl(x); + memcpy(p, ((char *) &x) + 1, 3); +} + static inline void put_u32(void *p, u32 x) { -- cgit v1.2.3