]> git.ipfire.org Git - thirdparty/bird.git/blob - sysdep/unix/krt.Y
e3f6271c4da552ae4fad4671262f3cdf44ab04ab
[thirdparty/bird.git] / sysdep / unix / krt.Y
1 /*
2 * BIRD -- UNIX Kernel Syncer Configuration
3 *
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 CF_HDR
10
11 #include "sysdep/unix/krt.h"
12
13 CF_DEFINES
14
15 #define THIS_KRT ((struct krt_config *) this_proto)
16 #define THIS_KIF ((struct kif_config *) this_proto)
17 #define KIF_IFACE ((struct kif_iface_config *) this_ipatt)
18
19 static void
20 kif_set_preferred(ip_addr ip)
21 {
22 if (ipa_is_ip4(ip))
23 KIF_IFACE->pref_v4 = ip;
24 else if (!ipa_is_link_local(ip))
25 KIF_IFACE->pref_v6 = ip;
26 else
27 KIF_IFACE->pref_ll = ip;
28 }
29
30 CF_DECLS
31
32 CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS)
33 CF_KEYWORDS(INTERFACE, PREFERRED)
34
35 %type <i> kern_mp_limit
36
37 CF_GRAMMAR
38
39 /* Kernel syncer protocol */
40
41 proto: kern_proto '}' ;
42
43 kern_proto_start: proto_start KERNEL {
44 this_proto = krt_init_config($1);
45 }
46 ;
47
48 kern_proto: kern_proto_start proto_name '{' ;
49 kern_proto: kern_proto kern_item ';' ;
50
51 kern_mp_limit:
52 /* empty */ { $$ = KRT_DEFAULT_ECMP_LIMIT; }
53 | LIMIT expr { $$ = $2; if (($2 <= 0) || ($2 > 255)) cf_error("Merge paths limit must be in range 1-255"); }
54 ;
55
56 kern_item:
57 proto_item
58 | proto_channel { this_proto->net_type = $1->net_type; }
59 | PERSIST bool { THIS_KRT->persist = $2; }
60 | SCAN TIME expr {
61 /* Scan time of 0 means scan on startup only */
62 THIS_KRT->scan_time = $3 S_;
63 }
64 | LEARN bool {
65 THIS_KRT->learn = $2;
66 #ifndef KRT_ALLOW_LEARN
67 if ($2)
68 cf_error("Learning of kernel routes not supported on this platform");
69 #endif
70 }
71 | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; }
72 | MERGE PATHS bool kern_mp_limit {
73 THIS_KRT->merge_paths = $3 ? $4 : 0;
74 #ifndef KRT_ALLOW_MERGE_PATHS
75 if ($3)
76 cf_error("Path merging not supported on this platform");
77 #endif
78 }
79 ;
80
81 /* Kernel interface protocol */
82
83 proto: kif_proto '}' ;
84
85 kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); }
86 ;
87
88 kif_proto: kif_proto_start proto_name '{' ;
89 kif_proto: kif_proto kif_item ';' ;
90
91 kif_item:
92 proto_item
93 | INTERFACE kif_iface
94 | SCAN TIME expr {
95 /* Scan time of 0 means scan on startup only */
96 THIS_KIF->scan_time = $3 S_;
97 }
98 ;
99
100 kif_iface_start:
101 {
102 this_ipatt = cfg_allocz(sizeof(struct kif_iface_config));
103 add_tail(&THIS_KIF->iface_list, NODE this_ipatt);
104 init_list(&this_ipatt->ipn_list);
105 }
106
107 kif_iface_item:
108 PREFERRED ipa { kif_set_preferred($2); }
109 ;
110
111 kif_iface_opts:
112 /* empty */
113 | kif_iface_opts kif_iface_item ';'
114 ;
115
116 kif_iface_opt_list:
117 /* empty */
118 | '{' kif_iface_opts '}'
119 ;
120
121 kif_iface:
122 kif_iface_start iface_patt_list_nopx kif_iface_opt_list;
123
124
125 dynamic_attr: KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, 0, T_INT, EA_KRT_SOURCE); } ;
126 dynamic_attr: KRT_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, 0, T_INT, EA_KRT_METRIC); } ;
127
128 CF_CODE
129
130 CF_END