]>
Commit | Line | Data |
---|---|---|
bf139664 OZ |
1 | /* |
2 | * BIRD -- Router Advertisement Configuration | |
3 | * | |
4 | * | |
5 | * Can be freely distributed and used under the terms of the GNU GPL. | |
6 | */ | |
7 | ||
8 | CF_HDR | |
9 | ||
10 | #include "proto/bfd/bfd.h" | |
11 | ||
12 | CF_DEFINES | |
13 | ||
14 | #define BFD_CFG ((struct bfd_config *) this_proto) | |
15 | #define BFD_SESSION this_bfd_session | |
16 | #define BFD_NEIGHBOR this_bfd_neighbor | |
17 | ||
18 | static struct bfd_session_config *this_bfd_session; | |
19 | static struct bfd_neighbor *this_bfd_neighbor; | |
20 | ||
21 | ||
22 | CF_DECLS | |
23 | ||
24 | CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, MULTIHOP, PASSIVE, | |
6a8d3f1c | 25 | NEIGHBOR, DEV) |
bf139664 OZ |
26 | |
27 | %type <iface> bfd_neigh_iface | |
28 | %type <a> bfd_neigh_local | |
29 | ||
30 | CF_GRAMMAR | |
31 | ||
32 | CF_ADDTO(proto, bfd_proto) | |
33 | ||
34 | bfd_proto_start: proto_start BFD | |
35 | { | |
36 | this_proto = proto_config_new(&proto_bfd, sizeof(struct bfd_config), $1); | |
6a8d3f1c | 37 | init_list(&BFD_CFG->neigh_list); |
bf139664 OZ |
38 | }; |
39 | ||
40 | bfd_proto_item: | |
41 | proto_item | |
42 | | bfd_neighbor | |
43 | ; | |
44 | ||
45 | bfd_proto_opts: | |
46 | /* empty */ | |
47 | | bfd_proto_opts bfd_proto_item ';' | |
48 | ; | |
49 | ||
50 | bfd_proto: | |
51 | bfd_proto_start proto_name '{' bfd_proto_opts '}'; | |
52 | ||
53 | ||
54 | bfd_session_start: | |
55 | { | |
56 | this_bfd_session = cfg_allocz(sizeof(struct bfd_session_config)); | |
57 | ||
58 | BFD_SESSION->min_rx_int = BFD_DEFAULT_MIN_RX_INT; | |
59 | BFD_SESSION->min_tx_int = BFD_DEFAULT_MIN_TX_INT; | |
60 | BFD_SESSION->idle_tx_int = BFD_DEFAULT_IDLE_TX_INT; | |
61 | BFD_SESSION->multiplier = BFD_DEFAULT_MULTIPLIER; | |
62 | }; | |
63 | ||
64 | bfd_session_item: | |
65 | INTERVAL expr_us { BFD_SESSION->min_rx_int = BFD_SESSION->min_tx_int = $2; } | |
66 | | MIN RX INTERVAL expr_us { BFD_SESSION->min_rx_int = $4; } | |
67 | | MIN TX INTERVAL expr_us { BFD_SESSION->min_tx_int = $4; } | |
68 | | IDLE TX INTERVAL expr_us { BFD_SESSION->idle_tx_int = $4; } | |
69 | | MULTIPLIER expr { BFD_SESSION->multiplier = $2; } | |
70 | | MULTIHOP bool { BFD_SESSION->multihop = $2; } | |
71 | | PASSIVE bool { BFD_SESSION->passive = $2; } | |
72 | ; | |
73 | ||
74 | bfd_session_opts: | |
75 | /* empty */ | |
76 | | bfd_session_opts bfd_session_item ';' | |
77 | ; | |
78 | ||
79 | bfd_session_opt_list: | |
80 | /* empty */ | |
81 | | '{' bfd_session_opts '}' | |
82 | ; | |
83 | ||
84 | bfd_session: | |
85 | bfd_session_start bfd_session_opt_list; | |
86 | ||
87 | ||
88 | bfd_neigh_iface: | |
89 | /* empty */ { $$ = NULL; } | |
90 | | '%' SYM { $$ = if_get_by_name($2->name); } | |
91 | | DEV TEXT { $$ = if_get_by_name($2); } | |
92 | ; | |
93 | ||
94 | bfd_neigh_local: | |
95 | /* empty */ { $$ = IPA_NONE; } | |
96 | | LOCAL ipa { $$ = $2; } | |
97 | ; | |
98 | ||
99 | bfd_neighbor: NEIGHBOR ipa bfd_neigh_iface bfd_neigh_local bfd_session | |
100 | { | |
101 | this_bfd_neighbor = cfg_allocz(sizeof(struct bfd_neighbor)); | |
6a8d3f1c | 102 | add_tail(&BFD_CFG->neigh_list, NODE this_bfd_neighbor); |
bf139664 OZ |
103 | |
104 | BFD_NEIGHBOR->addr = $2; | |
105 | BFD_NEIGHBOR->local = $4; | |
106 | BFD_NEIGHBOR->iface = $3; | |
107 | BFD_NEIGHBOR->opts = BFD_SESSION; | |
108 | }; | |
109 | ||
110 | ||
6a8d3f1c OZ |
111 | CF_CLI(SHOW BFD SESSIONS, optsym, [<name>], [[Show information about BFD sessions]]) |
112 | { bfd_show_sessions(proto_get_named($4, &proto_bfd)); }; | |
113 | ||
bf139664 OZ |
114 | CF_CODE |
115 | ||
116 | CF_END |