diff options
Diffstat (limited to 'bgpd/bgpd.h')
-rw-r--r-- | bgpd/bgpd.h | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index afe06635..f699dc35 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -817,13 +817,32 @@ extern struct peer_group *peer_group_lookup (struct bgp *, const char *); extern struct peer_group *peer_group_get (struct bgp *, const char *); extern struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *, int *); -extern struct peer *peer_lock (struct peer *); -extern struct peer *peer_unlock (struct peer *); +extern void peer_free (struct peer *peer); extern int peer_sort (struct peer *peer); extern int peer_active (struct peer *); extern int peer_active_nego (struct peer *); extern struct peer *peer_create_accept (struct bgp *); extern char *peer_uptime (time_t, char *, size_t); + +static inline struct peer * +peer_lock (struct peer *peer) +{ + assert (peer && (peer->lock >= 0)); + assert (peer->status != Deleted); + + peer->lock++; + return peer; +} + +static inline void +peer_unlock (struct peer *peer) +{ + assert (peer && (peer->lock > 0)); + + if (--peer->lock == 0) + peer_free (peer); +} + extern int bgp_config_write (struct vty *); extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *); @@ -837,11 +856,46 @@ extern int bgp_option_unset (int); extern int bgp_option_check (int); extern int bgp_get (struct bgp **, as_t *, const char *); -extern int bgp_delete (struct bgp *); +extern void bgp_delete (struct bgp *); +extern void bgp_free (struct bgp *); + +/* BGP flag manipulation. */ +static inline void +bgp_flag_set (struct bgp *bgp, int flag) +{ + SET_FLAG (bgp->flags, flag); +} + +static inline void +bgp_flag_unset (struct bgp *bgp, int flag) +{ + UNSET_FLAG (bgp->flags, flag); +} + +static inline int +bgp_flag_check (const struct bgp *bgp, int flag) +{ + return CHECK_FLAG (bgp->flags, flag); +} + +/* Internal function to set BGP structure configureation flag. */ +static inline void +bgp_config_set (struct bgp *bgp, int config) +{ + SET_FLAG (bgp->config, config); +} + +static inline void +bgp_config_unset (struct bgp *bgp, int config) +{ + UNSET_FLAG (bgp->config, config); +} -extern int bgp_flag_set (struct bgp *, int); -extern int bgp_flag_unset (struct bgp *, int); -extern int bgp_flag_check (struct bgp *, int); +static inline int +bgp_config_check (const struct bgp *bgp, int config) +{ + return CHECK_FLAG (bgp->config, config); +} extern int bgp_router_id_set (struct bgp *, struct in_addr *); |