diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-03-22 15:00:07 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-03-22 18:16:49 +0100 |
commit | 1e37e35c3ea88672c677ea7ac63fe0b9df609b0c (patch) | |
tree | 8400d1b28ae6d4d0146ad1573c7ebd3653152ace /lib/unaligned.h | |
parent | ead7b8f498ddefc0b7373cbba78f9a7ba1dddaa9 (diff) |
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.
Diffstat (limited to 'lib/unaligned.h')
-rw-r--r-- | lib/unaligned.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/unaligned.h b/lib/unaligned.h index 4e841f3a..0da1fdb4 100644 --- a/lib/unaligned.h +++ b/lib/unaligned.h @@ -29,6 +29,13 @@ get_u16(const void *p) } 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) { u32 x; @@ -53,6 +60,13 @@ put_u16(void *p, u16 x) } 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) { x = htonl(x); |