Statistics
| Branch: | Revision:

iof-bird-daemon / proto / bfd / config.Y @ d7c06285

History | View | Annotate | Download (3.08 KB)

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_IFACE ((struct bfd_iface_config *) this_ipatt)
16
#define BFD_NEIGHBOR this_bfd_neighbor
17

    
18
static struct bfd_neighbor *this_bfd_neighbor;
19

    
20
extern struct bfd_config *bfd_cf;
21

    
22
CF_DECLS
23

    
24
CF_KEYWORDS(BFD, MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE,
25
	INTERFACE, MULTIHOP, NEIGHBOR, DEV, LOCAL)
26

    
27
%type <iface> bfd_neigh_iface
28
%type <a> bfd_neigh_local
29
%type <i> bfd_neigh_multihop
30

    
31
CF_GRAMMAR
32

    
33
CF_ADDTO(proto, bfd_proto)
34

    
35
bfd_proto_start: proto_start BFD
36
{
37
  this_proto = proto_config_new(&proto_bfd, sizeof(struct bfd_config), $1);
38
  init_list(&BFD_CFG->patt_list);
39
  init_list(&BFD_CFG->neigh_list);
40

    
41
  if (bfd_cf)
42
    cf_error("Only one BFD instance allowed");
43
  bfd_cf = BFD_CFG;
44
};
45

    
46
bfd_proto_item:
47
   proto_item
48
 | INTERFACE bfd_iface
49
 | MULTIHOP bfd_multihop
50
 | NEIGHBOR bfd_neighbor
51
 ;
52

    
53
bfd_proto_opts:
54
   /* empty */
55
 | bfd_proto_opts bfd_proto_item ';'
56
 ;
57

    
58
bfd_proto:
59
   bfd_proto_start proto_name '{' bfd_proto_opts '}';
60

    
61

    
62
bfd_iface_start:
63
{
64
  this_ipatt = cfg_allocz(sizeof(struct bfd_iface_config));
65
  init_list(&this_ipatt->ipn_list);
66

    
67
  BFD_IFACE->min_rx_int = BFD_DEFAULT_MIN_RX_INT;
68
  BFD_IFACE->min_tx_int = BFD_DEFAULT_MIN_TX_INT;
69
  BFD_IFACE->idle_tx_int = BFD_DEFAULT_IDLE_TX_INT;
70
  BFD_IFACE->multiplier = BFD_DEFAULT_MULTIPLIER;
71
};
72

    
73
bfd_iface_item:
74
   INTERVAL expr_us { BFD_IFACE->min_rx_int = BFD_IFACE->min_tx_int = $2; }
75
 | MIN RX INTERVAL expr_us { BFD_IFACE->min_rx_int = $4; }
76
 | MIN TX INTERVAL expr_us { BFD_IFACE->min_tx_int = $4; }
77
 | IDLE TX INTERVAL expr_us { BFD_IFACE->idle_tx_int = $4; }
78
 | MULTIPLIER expr { BFD_IFACE->multiplier = $2; }
79
 | PASSIVE bool { BFD_IFACE->passive = $2; }
80
 ;
81

    
82
bfd_iface_opts:
83
   /* empty */
84
 | bfd_iface_opts bfd_iface_item ';'
85
 ;
86

    
87
bfd_iface_opt_list:
88
   /* empty */
89
 | '{' bfd_iface_opts '}'
90
 ;
91

    
92
bfd_iface: bfd_iface_start iface_patt_list_nopx bfd_iface_opt_list
93
{ add_tail(&BFD_CFG->patt_list, NODE this_ipatt); };
94

    
95
bfd_multihop: bfd_iface_start bfd_iface_opt_list
96
{ BFD_CFG->multihop = BFD_IFACE; };
97

    
98

    
99
bfd_neigh_iface:
100
   /* empty */ { $$ = NULL; }
101
 | '%' SYM { $$ = if_get_by_name($2->name); }
102
 | DEV TEXT { $$ = if_get_by_name($2); }
103
 ;
104

    
105
bfd_neigh_local:
106
   /* empty */ { $$ = IPA_NONE; }
107
 | LOCAL ipa { $$ = $2; }
108
 ;
109

    
110
bfd_neigh_multihop:
111
   /* empty */ { $$ = 0; }
112
 | MULTIHOP bool { $$ = $2; }
113
 ;
114

    
115
bfd_neighbor: ipa bfd_neigh_iface bfd_neigh_local bfd_neigh_multihop
116
{
117
  this_bfd_neighbor = cfg_allocz(sizeof(struct bfd_neighbor));
118
  add_tail(&BFD_CFG->neigh_list, NODE this_bfd_neighbor);
119

    
120
  BFD_NEIGHBOR->addr = $1;
121
  BFD_NEIGHBOR->local = $3;
122
  BFD_NEIGHBOR->iface = $2;
123
  BFD_NEIGHBOR->multihop = $4;
124

    
125
  if ($4 && $2)
126
    cf_error("Neighbor cannot set both interface and multihop");
127

    
128
  if ($4 && ipa_zero($3))
129
    cf_error("Multihop neighbor requires specified local address");
130
};
131

    
132

    
133
CF_CLI(SHOW BFD SESSIONS, optsym, [<name>], [[Show information about BFD sessions]])
134
{ bfd_show_sessions(proto_get_named($4, &proto_bfd)); };
135

    
136
CF_CODE
137

    
138
CF_END