summaryrefslogtreecommitdiff
path: root/proto/bfd/config.Y
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2013-11-19 22:33:48 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2013-11-19 22:33:48 +0100
commit1ec522538fb81a56b068c087d0a842faf7aa7869 (patch)
tree84dc0555c224120da8772b1714e7e4f1dfa66aa5 /proto/bfd/config.Y
parent0e175f9f0fd872e95225355dbdeca49cd35ec0fd (diff)
BFD protocol, ready for release.
Supports OSPF and BGP and also statically configured sessions.
Diffstat (limited to 'proto/bfd/config.Y')
-rw-r--r--proto/bfd/config.Y82
1 files changed, 52 insertions, 30 deletions
diff --git a/proto/bfd/config.Y b/proto/bfd/config.Y
index f1193d70..1bf8764f 100644
--- a/proto/bfd/config.Y
+++ b/proto/bfd/config.Y
@@ -12,20 +12,21 @@ CF_HDR
CF_DEFINES
#define BFD_CFG ((struct bfd_config *) this_proto)
-#define BFD_SESSION this_bfd_session
+#define BFD_IFACE ((struct bfd_iface_config *) this_ipatt)
#define BFD_NEIGHBOR this_bfd_neighbor
-static struct bfd_session_config *this_bfd_session;
static struct bfd_neighbor *this_bfd_neighbor;
+extern struct bfd_config *bfd_cf;
CF_DECLS
-CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, MULTIHOP, PASSIVE,
- NEIGHBOR, DEV)
+CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE,
+ INTERFACE, MULTIHOP, NEIGHBOR, DEV, LOCAL)
%type <iface> bfd_neigh_iface
%type <a> bfd_neigh_local
+%type <i> bfd_neigh_multihop
CF_GRAMMAR
@@ -34,12 +35,19 @@ 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->patt_list);
init_list(&BFD_CFG->neigh_list);
+
+ if (bfd_cf)
+ cf_error("Only one BFD instance allowed");
+ bfd_cf = BFD_CFG;
};
bfd_proto_item:
proto_item
- | bfd_neighbor
+ | INTERFACE bfd_iface
+ | MULTIHOP bfd_multihop
+ | NEIGHBOR bfd_neighbor
;
bfd_proto_opts:
@@ -51,38 +59,41 @@ bfd_proto:
bfd_proto_start proto_name '{' bfd_proto_opts '}';
-bfd_session_start:
+bfd_iface_start:
{
- this_bfd_session = cfg_allocz(sizeof(struct bfd_session_config));
+ this_ipatt = cfg_allocz(sizeof(struct bfd_iface_config));
+ init_list(&this_ipatt->ipn_list);
- 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_IFACE->min_rx_int = BFD_DEFAULT_MIN_RX_INT;
+ BFD_IFACE->min_tx_int = BFD_DEFAULT_MIN_TX_INT;
+ BFD_IFACE->idle_tx_int = BFD_DEFAULT_IDLE_TX_INT;
+ BFD_IFACE->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_iface_item:
+ INTERVAL expr_us { BFD_IFACE->min_rx_int = BFD_IFACE->min_tx_int = $2; }
+ | MIN RX INTERVAL expr_us { BFD_IFACE->min_rx_int = $4; }
+ | MIN TX INTERVAL expr_us { BFD_IFACE->min_tx_int = $4; }
+ | IDLE TX INTERVAL expr_us { BFD_IFACE->idle_tx_int = $4; }
+ | MULTIPLIER expr { BFD_IFACE->multiplier = $2; }
+ | PASSIVE bool { BFD_IFACE->passive = $2; }
;
-bfd_session_opts:
+bfd_iface_opts:
/* empty */
- | bfd_session_opts bfd_session_item ';'
+ | bfd_iface_opts bfd_iface_item ';'
;
-bfd_session_opt_list:
+bfd_iface_opt_list:
/* empty */
- | '{' bfd_session_opts '}'
+ | '{' bfd_iface_opts '}'
;
-bfd_session:
- bfd_session_start bfd_session_opt_list;
+bfd_iface: bfd_iface_start iface_patt_list bfd_iface_opt_list
+{ add_tail(&BFD_CFG->patt_list, NODE this_ipatt); };
+
+bfd_multihop: bfd_iface_start bfd_iface_opt_list
+{ BFD_CFG->multihop = BFD_IFACE; };
bfd_neigh_iface:
@@ -96,15 +107,26 @@ bfd_neigh_local:
| LOCAL ipa { $$ = $2; }
;
-bfd_neighbor: NEIGHBOR ipa bfd_neigh_iface bfd_neigh_local bfd_session
+bfd_neigh_multihop:
+ /* empty */ { $$ = 0; }
+ | MULTIHOP bool { $$ = $2; }
+ ;
+
+bfd_neighbor: ipa bfd_neigh_iface bfd_neigh_local bfd_neigh_multihop
{
this_bfd_neighbor = cfg_allocz(sizeof(struct bfd_neighbor));
add_tail(&BFD_CFG->neigh_list, NODE this_bfd_neighbor);
- BFD_NEIGHBOR->addr = $2;
- BFD_NEIGHBOR->local = $4;
- BFD_NEIGHBOR->iface = $3;
- BFD_NEIGHBOR->opts = BFD_SESSION;
+ BFD_NEIGHBOR->addr = $1;
+ BFD_NEIGHBOR->local = $3;
+ BFD_NEIGHBOR->iface = $2;
+ BFD_NEIGHBOR->multihop = $4;
+
+ if ($4 && $2)
+ cf_error("Neighbor cannot set both interface and multihop");
+
+ if ($4 && ipa_zero($3))
+ cf_error("Multihop neighbor requires specified local address");
};