]> git.proxmox.com Git - mirror_frr.git/blobdiff - bfdd/bfd.h
Merge pull request #5126 from qlyoung/fix-grpc-build
[mirror_frr.git] / bfdd / bfd.h
index e08a1ff724e8bec4ec5bafde7a3dd4b432b0a39f..cdec78d1226066ceb130c38f3cd5942628fbff20 100644 (file)
 #define BFDD_JSON_CONV_OPTIONS (0)
 #endif
 
-DECLARE_MGROUP(BFDD);
-DECLARE_MTYPE(BFDD_TMP);
-DECLARE_MTYPE(BFDD_CONFIG);
-DECLARE_MTYPE(BFDD_LABEL);
-DECLARE_MTYPE(BFDD_CONTROL);
-DECLARE_MTYPE(BFDD_SESSION_OBSERVER);
-DECLARE_MTYPE(BFDD_NOTIFICATION);
+DECLARE_MGROUP(BFDD)
+DECLARE_MTYPE(BFDD_CONTROL)
+DECLARE_MTYPE(BFDD_NOTIFICATION)
 
 struct bfd_timers {
        uint32_t desired_min_tx;
@@ -128,6 +124,12 @@ struct bfd_echo_pkt {
                        flags |= (val & 0x3) << 6;                             \
        }
 #define BFD_GETSTATE(flags) ((flags >> 6) & 0x3)
+#define BFD_SETCBIT(flags, val)                                                \
+       {                                                                      \
+               if ((val))                                                     \
+                       flags |= val;                                          \
+       }
+#define BFD_GETCBIT(flags) (flags & BFD_FBIT)
 #define BFD_ECHO_VERSION 1
 #define BFD_ECHO_PKT_LEN sizeof(struct bfd_echo_pkt)
 
@@ -167,6 +169,7 @@ enum bfd_session_flags {
                                                 */
        BFD_SESS_FLAG_SHUTDOWN = 1 << 7,        /* disable BGP peer function */
        BFD_SESS_FLAG_CONFIG = 1 << 8,  /* Session configured with bfd NB API */
+       BFD_SESS_FLAG_CBIT = 1 << 9,    /* CBIT is set */
 };
 
 #define BFD_SET_FLAG(field, flag) (field |= flag)
@@ -209,6 +212,7 @@ struct bfd_session {
        uint8_t detect_mult;
        uint8_t remote_detect_mult;
        uint8_t mh_ttl;
+       uint8_t remote_cbit;
 
        /* Timers */
        struct bfd_timers timers;
@@ -248,11 +252,7 @@ struct bfd_session {
        struct bfd_timers remote_timers;
 
        uint64_t refcount; /* number of pointers referencing this. */
-
-       /* VTY context data. */
-       QOBJ_FIELDS;
 };
-DECLARE_QOBJ_TYPE(bfd_session);
 
 struct peer_label {
        TAILQ_ENTRY(peer_label) pl_entry;
@@ -379,15 +379,19 @@ int control_accept(struct thread *t);
  *
  * Daemon specific code.
  */
-struct bfd_global {
+struct bfd_vrf_global {
        int bg_shop;
        int bg_mhop;
        int bg_shop6;
        int bg_mhop6;
        int bg_echo;
        int bg_echov6;
+       struct vrf *vrf;
+
        struct thread *bg_ev[6];
+};
 
+struct bfd_global {
        int bg_csock;
        struct thread *bg_csockev;
        struct bcslist bg_bcslist;
@@ -395,6 +399,8 @@ struct bfd_global {
        struct pllist bg_pllist;
 
        struct obslist bg_obslist;
+
+       struct zebra_privs_t bfdd_privs;
 };
 extern struct bfd_global bglobal;
 extern struct bfd_diag_str_list diag_list[];
@@ -459,14 +465,14 @@ int bp_set_tosv6(int sd, uint8_t value);
 int bp_set_tos(int sd, uint8_t value);
 int bp_bind_dev(int sd, const char *dev);
 
-int bp_udp_shop(void);
-int bp_udp_mhop(void);
-int bp_udp6_shop(void);
-int bp_udp6_mhop(void);
+int bp_udp_shop(vrf_id_t vrf_id);
+int bp_udp_mhop(vrf_id_t vrf_id);
+int bp_udp6_shop(vrf_id_t vrf_id);
+int bp_udp6_mhop(vrf_id_t vrf_id);
 int bp_peer_socket(const struct bfd_session *bs);
 int bp_peer_socketv6(const struct bfd_session *bs);
-int bp_echo_socket(void);
-int bp_echov6_socket(void);
+int bp_echo_socket(vrf_id_t vrf_id);
+int bp_echov6_socket(vrf_id_t vrf_id);
 
 void ptm_bfd_snd(struct bfd_session *bfd, int fbit);
 void ptm_bfd_echo_snd(struct bfd_session *bfd);
@@ -505,9 +511,9 @@ void bfd_echo_xmttimer_assign(struct bfd_session *bs, bfd_ev_cb cb);
 int bfd_session_enable(struct bfd_session *bs);
 void bfd_session_disable(struct bfd_session *bs);
 struct bfd_session *ptm_bfd_sess_new(struct bfd_peer_cfg *bpc);
-int ptm_bfd_ses_del(struct bfd_peer_cfg *bpc);
-void ptm_bfd_ses_dn(struct bfd_session *bfd, uint8_t diag);
-void ptm_bfd_ses_up(struct bfd_session *bfd);
+int ptm_bfd_sess_del(struct bfd_peer_cfg *bpc);
+void ptm_bfd_sess_dn(struct bfd_session *bfd, uint8_t diag);
+void ptm_bfd_sess_up(struct bfd_session *bfd);
 void ptm_bfd_echo_stop(struct bfd_session *bfd);
 void ptm_bfd_echo_start(struct bfd_session *bfd);
 void ptm_bfd_xmt_TO(struct bfd_session *bfd, int fbit);
@@ -536,9 +542,22 @@ void bs_observer_del(struct bfd_session_observer *bso);
 
 void bs_to_bpc(struct bfd_session *bs, struct bfd_peer_cfg *bpc);
 
+void gen_bfd_key(struct bfd_key *key, struct sockaddr_any *peer,
+                struct sockaddr_any *local, bool mhop, const char *ifname,
+                const char *vrfname);
+struct bfd_session *bfd_session_new(void);
+struct bfd_session *bs_registrate(struct bfd_session *bs);
+void bfd_session_free(struct bfd_session *bs);
+const struct bfd_session *bfd_session_next(const struct bfd_session *bs,
+                                          bool mhop);
+void bfd_sessions_remove_manual(void);
+
 /* BFD hash data structures interface */
 void bfd_initialize(void);
 void bfd_shutdown(void);
+void bfd_vrf_init(void);
+void bfd_vrf_terminate(void);
+struct bfd_vrf_global *bfd_vrf_look_by_session(struct bfd_session *bfd);
 struct bfd_session *bfd_id_lookup(uint32_t id);
 struct bfd_session *bfd_key_lookup(struct bfd_key key);
 
@@ -571,12 +590,56 @@ extern struct in6_addr zero_addr;
 void bfdd_vty_init(void);
 
 
+/*
+ * bfdd_cli.c
+ *
+ * BFD daemon CLI implementation.
+ */
+void bfdd_cli_init(void);
+
+void bfd_cli_show_header(struct vty *vty, struct lyd_node *dnode,
+                        bool show_defaults);
+void bfd_cli_show_header_end(struct vty *vty, struct lyd_node *dnode);
+void bfd_cli_show_single_hop_peer(struct vty *vty,
+                                 struct lyd_node *dnode,
+                                 bool show_defaults);
+void bfd_cli_show_multi_hop_peer(struct vty *vty,
+                                struct lyd_node *dnode,
+                                bool show_defaults);
+void bfd_cli_show_peer_end(struct vty *vty, struct lyd_node *dnode);
+void bfd_cli_show_mult(struct vty *vty, struct lyd_node *dnode,
+                      bool show_defaults);
+void bfd_cli_show_tx(struct vty *vty, struct lyd_node *dnode,
+                    bool show_defaults);
+void bfd_cli_show_rx(struct vty *vty, struct lyd_node *dnode,
+                    bool show_defaults);
+void bfd_cli_show_shutdown(struct vty *vty, struct lyd_node *dnode,
+                          bool show_defaults);
+void bfd_cli_show_echo(struct vty *vty, struct lyd_node *dnode,
+                          bool show_defaults);
+void bfd_cli_show_echo_interval(struct vty *vty, struct lyd_node *dnode,
+                               bool show_defaults);
+
+
 /*
  * ptm_adapter.c
  */
 void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv);
 void bfdd_zclient_stop(void);
+void bfdd_zclient_unregister(vrf_id_t vrf_id);
+void bfdd_zclient_register(vrf_id_t vrf_id);
+void bfdd_sessions_enable_vrf(struct vrf *vrf);
+void bfdd_sessions_disable_vrf(struct vrf *vrf);
+void bfd_session_update_vrf_name(struct bfd_session *bs, struct vrf *vrf);
 
 int ptm_bfd_notify(struct bfd_session *bs);
 
+
+/*
+ * bfdd_northbound.c
+ *
+ * BFD northbound callbacks.
+ */
+extern const struct frr_yang_module_info frr_bfdd_info;
+
 #endif /* _BFD_H_ */