]>
Commit | Line | Data |
---|---|---|
980ffedb MM |
1 | /* |
2 | * BIRD -- UNIX Kernel Syncer Configuration | |
3 | * | |
d272fe22 | 4 | * (c) 1998--2000 Martin Mares <mj@ucw.cz> |
980ffedb MM |
5 | * |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | CF_HDR | |
10 | ||
7152e5ef | 11 | #include "sysdep/unix/krt.h" |
980ffedb | 12 | |
2edb31b0 MM |
13 | CF_DEFINES |
14 | ||
2d140452 | 15 | #define THIS_KRT ((struct krt_config *) this_proto) |
7e5f5ffd | 16 | #define THIS_KIF ((struct kif_config *) this_proto) |
153f02da | 17 | #define KIF_IFACE ((struct kif_iface_config *) this_ipatt) |
2d140452 | 18 | |
153f02da OZ |
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 | ||
980ffedb MM |
30 | CF_DECLS |
31 | ||
8d9eef17 | 32 | CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS) |
a63e78c3 | 33 | CF_KEYWORDS(INTERFACE, PREFERRED) |
980ffedb | 34 | |
f9f2e280 OZ |
35 | %type <i> kern_mp_limit |
36 | ||
980ffedb MM |
37 | CF_GRAMMAR |
38 | ||
7e5f5ffd | 39 | /* Kernel syncer protocol */ |
980ffedb | 40 | |
f851f0d7 | 41 | proto: kern_proto '}' ; |
980ffedb | 42 | |
f4a60a9b OZ |
43 | kern_proto_start: proto_start KERNEL { |
44 | this_proto = krt_init_config($1); | |
45 | } | |
980ffedb MM |
46 | ; |
47 | ||
f851f0d7 MM |
48 | kern_proto: kern_proto_start proto_name '{' ; |
49 | kern_proto: kern_proto kern_item ';' ; | |
2d140452 | 50 | |
f9f2e280 OZ |
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 | ||
2d140452 | 56 | kern_item: |
f4a60a9b OZ |
57 | proto_item |
58 | | proto_channel { this_proto->net_type = $1->net_type; } | |
59 | | PERSIST bool { THIS_KRT->persist = $2; } | |
2d140452 MM |
60 | | SCAN TIME expr { |
61 | /* Scan time of 0 means scan on startup only */ | |
21f4f0f4 | 62 | THIS_KRT->scan_time = $3 S_; |
2d140452 | 63 | } |
c10421d3 MM |
64 | | LEARN bool { |
65 | THIS_KRT->learn = $2; | |
66 | #ifndef KRT_ALLOW_LEARN | |
67 | if ($2) | |
f9f2e280 | 68 | cf_error("Learning of kernel routes not supported on this platform"); |
c10421d3 MM |
69 | #endif |
70 | } | |
0c791f87 | 71 | | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; } |
f9f2e280 | 72 | | MERGE PATHS bool kern_mp_limit { |
ace3072e | 73 | THIS_KRT->merge_paths = $3 ? $4 : 0; |
a1839f3c | 74 | #ifndef KRT_ALLOW_MERGE_PATHS |
f9f2e280 OZ |
75 | if ($3) |
76 | cf_error("Path merging not supported on this platform"); | |
77 | #endif | |
78 | } | |
2d140452 | 79 | ; |
980ffedb | 80 | |
7e5f5ffd MM |
81 | /* Kernel interface protocol */ |
82 | ||
f851f0d7 | 83 | proto: kif_proto '}' ; |
7e5f5ffd | 84 | |
396dfa90 | 85 | kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); } |
7e5f5ffd MM |
86 | ; |
87 | ||
f851f0d7 MM |
88 | kif_proto: kif_proto_start proto_name '{' ; |
89 | kif_proto: kif_proto kif_item ';' ; | |
7e5f5ffd MM |
90 | |
91 | kif_item: | |
f4a60a9b | 92 | proto_item |
153f02da | 93 | | INTERFACE kif_iface |
f4a60a9b | 94 | | SCAN TIME expr { |
7e5f5ffd | 95 | /* Scan time of 0 means scan on startup only */ |
21f4f0f4 | 96 | THIS_KIF->scan_time = $3 S_; |
7e5f5ffd MM |
97 | } |
98 | ; | |
99 | ||
153f02da OZ |
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 | ||
f851f0d7 MM |
125 | dynamic_attr: KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_SOURCE); } ; |
126 | dynamic_attr: KRT_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_METRIC); } ; | |
72aed1a0 | 127 | |
980ffedb MM |
128 | CF_CODE |
129 | ||
130 | CF_END |