diff options
Diffstat (limited to 'bgpd/bgp_common.h')
-rw-r--r-- | bgpd/bgp_common.h | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/bgpd/bgp_common.h b/bgpd/bgp_common.h index a2722ed1..703b2ab2 100644 --- a/bgpd/bgp_common.h +++ b/bgpd/bgp_common.h @@ -23,6 +23,8 @@ #define _QUAGGA_BGP_COMMON_H #include <stdint.h> +#include <sys/socket.h> + #include "bgpd/bgp.h" #include "qafi_safi.h" #include "lib/zassert.h" @@ -54,6 +56,22 @@ typedef struct bgp_connection* bgp_connection ; typedef struct bgp_open_state* bgp_open_state ; /*============================================================================== + * Some BGP capabilities and messages have RFC and pre-RFC forms. + * + * Sometimes see both, or send RFC and/or pre-RFC forms, or track what form(s) + * are being used. + */ +typedef enum bgp_form bgp_form_t ; + +enum bgp_form +{ + bgp_form_none = 0, + bgp_form_pre = 1, + bgp_form_rfc = 2, + bgp_form_both = 3 /* _rfc and _pre are bits ! */ +} ; + +/*============================================================================== * Both session and connection require these */ @@ -206,7 +224,7 @@ extern qafx_num_t qafx_num(qafx_bit_t bit) ; /*============================================================================== - * Conversions for qafx_num => qAFI and qSAFI + * Conversions for qafx_num => qAFI, qSAFI, iAFI, iSAFI and pAF */ /*------------------------------------------------------------------------------ @@ -281,6 +299,24 @@ get_iSAFI(qafx_num_t num) return iSAFI_map[num] ; } ; +/*------------------------------------------------------------------------------ + * Convert qafx_num_t to AF_xxx (pAF_t) + * + * Maps qafx_num_other to iSAFI_Reserved. + * + * NB: it is a mistake to try to map qafx_num_undef (FATAL unless NDEBUG). + */ + +extern const pAF_t pAF_map[] ; + +Inline pAF_t +get_pAF(qafx_num_t num) +{ + dassert((num >= qafx_num_min) && (num <= qafx_num_max)) ; + + return pAF_map[num] ; +} ; + /*============================================================================== * Conversions for iAFI/iSAFI => qafx_num_t * and qAFI/qSAFI => qafx_num_t @@ -302,6 +338,12 @@ extern qafx_bit_t qafx_bit_from_qAFI_qSAFI(qAFI_t afi, qSAFI_t safi) ; /*============================================================================== + * + */ + + + +/*============================================================================== * Buffer sucking * * @@ -344,6 +386,15 @@ suck_start(sucker sr) return sr->start ; } ; +Inline ptr_t +suck_step(sucker sr, unsigned length) +{ + ptr_t ptr = sr->ptr ; + sr->ptr += length ; + dassert(sr->ptr <= sr->end) ; + return ptr ; +} ; + Inline void suck_push(sucker sr, unsigned length, sucker sv) { |