summaryrefslogtreecommitdiffstats
path: root/bgpd/bgpd.h
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgpd.h')
-rw-r--r--bgpd/bgpd.h83
1 files changed, 76 insertions, 7 deletions
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index afe06635..20b8424f 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -59,6 +59,7 @@ struct bgp_master
#define BGP_OPT_NO_FIB (1 << 0)
#define BGP_OPT_MULTIPLE_INSTANCE (1 << 1)
#define BGP_OPT_CONFIG_CISCO (1 << 2)
+#define BGP_OPT_IMPORT_CHECK (1 << 3)
};
/* BGP instance structure. */
@@ -70,6 +71,9 @@ struct bgp
/* Name of this BGP instance. */
char *name;
+ /* Reference count to allow peer_delete to finish after bgp_delete */
+ int lock;
+
/* Self peer. */
struct peer *peer_self;
@@ -817,13 +821,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 *);
@@ -838,10 +861,58 @@ 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_free (struct bgp *);
+
+/* BGP flag manipulation. */
+static inline void
+bgp_flag_set (struct bgp *bgp, int flag)
+{
+ SET_FLAG (bgp->flags, flag);
+}
-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 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);
+}
+
+static inline int
+bgp_config_check (const struct bgp *bgp, int config)
+{
+ return CHECK_FLAG (bgp->config, config);
+}
+
+static inline void
+bgp_lock(struct bgp *bgp)
+{
+ ++bgp->lock;
+}
+
+static inline void
+bgp_unlock(struct bgp *bgp)
+{
+ if (--bgp->lock == 0)
+ bgp_free (bgp);
+}
extern int bgp_router_id_set (struct bgp *, struct in_addr *);
@@ -946,6 +1017,4 @@ extern int peer_maximum_prefix_unset (struct peer *, afi_t, safi_t);
extern int peer_clear (struct peer *);
extern int peer_clear_soft (struct peer *, afi_t, safi_t, enum bgp_clear_type);
-extern void peer_nsf_stop (struct peer *);
-
#endif /* _QUAGGA_BGPD_H */