summaryrefslogtreecommitdiff
path: root/proto/bfd/config.Y
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2013-09-10 12:09:36 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2013-09-10 12:09:36 +0200
commitbf139664aa2ae9956b520ba4813bb6e03bf1a3e8 (patch)
tree33381e1e2214b32fcb169def039a891b0db58509 /proto/bfd/config.Y
parentbff9ce5130d16af2fd802d42bdb2bff00980c9ae (diff)
Initial BFD commit, work in progress.
Diffstat (limited to 'proto/bfd/config.Y')
-rw-r--r--proto/bfd/config.Y113
1 files changed, 113 insertions, 0 deletions
diff --git a/proto/bfd/config.Y b/proto/bfd/config.Y
new file mode 100644
index 00000000..a5414d4e
--- /dev/null
+++ b/proto/bfd/config.Y
@@ -0,0 +1,113 @@
+/*
+ * BIRD -- Router Advertisement Configuration
+ *
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+CF_HDR
+
+#include "proto/bfd/bfd.h"
+
+CF_DEFINES
+
+#define BFD_CFG ((struct bfd_config *) this_proto)
+#define BFD_SESSION this_bfd_session
+#define BFD_NEIGHBOR this_bfd_neighbor
+
+static struct bfd_session_config *this_bfd_session;
+static struct bfd_neighbor *this_bfd_neighbor;
+
+
+CF_DECLS
+
+CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, MULTIHOP, PASSIVE,
+ NEIGHBOR)
+
+%type <iface> bfd_neigh_iface
+%type <a> bfd_neigh_local
+
+CF_GRAMMAR
+
+CF_ADDTO(proto, bfd_proto)
+
+bfd_proto_start: proto_start BFD
+{
+ this_proto = proto_config_new(&proto_bfd, sizeof(struct bfd_config), $1);
+ init_list(&BFD_CFG->neighbors);
+};
+
+bfd_proto_item:
+ proto_item
+ | bfd_neighbor
+ ;
+
+bfd_proto_opts:
+ /* empty */
+ | bfd_proto_opts bfd_proto_item ';'
+ ;
+
+bfd_proto:
+ bfd_proto_start proto_name '{' bfd_proto_opts '}';
+
+
+bfd_session_start:
+{
+ this_bfd_session = cfg_allocz(sizeof(struct bfd_session_config));
+
+ BFD_SESSION->min_rx_int = BFD_DEFAULT_MIN_RX_INT;
+ BFD_SESSION->min_tx_int = BFD_DEFAULT_MIN_TX_INT;
+ BFD_SESSION->idle_tx_int = BFD_DEFAULT_IDLE_TX_INT;
+ BFD_SESSION->multiplier = BFD_DEFAULT_MULTIPLIER;
+};
+
+bfd_session_item:
+ INTERVAL expr_us { BFD_SESSION->min_rx_int = BFD_SESSION->min_tx_int = $2; }
+ | MIN RX INTERVAL expr_us { BFD_SESSION->min_rx_int = $4; }
+ | MIN TX INTERVAL expr_us { BFD_SESSION->min_tx_int = $4; }
+ | IDLE TX INTERVAL expr_us { BFD_SESSION->idle_tx_int = $4; }
+ | MULTIPLIER expr { BFD_SESSION->multiplier = $2; }
+ | MULTIHOP bool { BFD_SESSION->multihop = $2; }
+ | PASSIVE bool { BFD_SESSION->passive = $2; }
+ ;
+
+bfd_session_opts:
+ /* empty */
+ | bfd_session_opts bfd_session_item ';'
+ ;
+
+bfd_session_opt_list:
+ /* empty */
+ | '{' bfd_session_opts '}'
+ ;
+
+bfd_session:
+ bfd_session_start bfd_session_opt_list;
+
+
+bfd_neigh_iface:
+ /* empty */ { $$ = NULL; }
+ | '%' SYM { $$ = if_get_by_name($2->name); }
+ | DEV TEXT { $$ = if_get_by_name($2); }
+ ;
+
+bfd_neigh_local:
+ /* empty */ { $$ = IPA_NONE; }
+ | LOCAL ipa { $$ = $2; }
+ ;
+
+bfd_neighbor: NEIGHBOR ipa bfd_neigh_iface bfd_neigh_local bfd_session
+{
+ this_bfd_neighbor = cfg_allocz(sizeof(struct bfd_neighbor));
+ add_tail(&BFD_CFG->neighbors, NODE this_bfd_neighbor);
+
+ BFD_NEIGHBOR->addr = $2;
+ BFD_NEIGHBOR->local = $4;
+ BFD_NEIGHBOR->iface = $3;
+ BFD_NEIGHBOR->opts = BFD_SESSION;
+};
+
+
+CF_CODE
+
+CF_END