From 62d3f846e6340ce7ad8d44714b7c480abb92f2f7 Mon Sep 17 00:00:00 2001 From: Lorenzo Cogotti Date: Fri, 15 Oct 2021 12:04:42 +0200 Subject: [PATCH] [lonetix/bgp] Add quick access functions for BGP UPDATE fields --- lonetix/include/df/bgp/bgp.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lonetix/include/df/bgp/bgp.h b/lonetix/include/df/bgp/bgp.h index a25c278..54838ea 100755 --- a/lonetix/include/df/bgp/bgp.h +++ b/lonetix/include/df/bgp/bgp.h @@ -559,6 +559,23 @@ typedef ALIGNED(1, struct) { Uint8 attrs[FLEX_ARRAY]; } Bgpattrseg; +FORCE_INLINE Bgpwithdrawnseg *BGP_WITHDRAWN(const Bgpupdate *msg) +{ + return (Bgpwithdrawnseg *) msg->data; +} + +FORCE_INLINE Bgpattrseg *BGP_ATTRIBUTES(const Bgpupdate *msg) +{ + const Bgpwithdrawnseg *w = BGP_WITHDRAWN(msg); + return (Bgpattrseg *) (w->nlri + BE16(w->len)); +} + +FORCE_INLINE void *BGP_ANNOUNCEMENTS(const Bgpupdate *msg) +{ + const Bgpattrseg *tpa = BGP_ATTRIBUTES(msg); + return (void *) (tpa->attrs + BE16(tpa->len)); +} + // NOTE: NLRI segment is handled with no struct /// Attribute length has an additional byte.