]>
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) |
2d140452 | 17 | |
f4a60a9b OZ |
18 | static void |
19 | krt_set_merge_paths(struct channel_config *cc, uint merge, uint limit) | |
20 | { | |
21 | if ((limit <= 0) || (limit > 255)) | |
22 | cf_error("Merge paths limit must be in range 1-255"); | |
23 | ||
24 | cc->ra_mode = merge ? RA_MERGED : RA_OPTIMAL; | |
25 | cc->merge_limit = limit; | |
26 | } | |
27 | ||
980ffedb MM |
28 | CF_DECLS |
29 | ||
8d9eef17 | 30 | CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS) |
980ffedb | 31 | |
f9f2e280 OZ |
32 | %type <i> kern_mp_limit |
33 | ||
980ffedb MM |
34 | CF_GRAMMAR |
35 | ||
7e5f5ffd | 36 | /* Kernel syncer protocol */ |
980ffedb MM |
37 | |
38 | CF_ADDTO(proto, kern_proto '}') | |
39 | ||
f4a60a9b OZ |
40 | kern_proto_start: proto_start KERNEL { |
41 | this_proto = krt_init_config($1); | |
42 | } | |
980ffedb MM |
43 | ; |
44 | ||
7e5f5ffd | 45 | CF_ADDTO(kern_proto, kern_proto_start proto_name '{') |
2d140452 MM |
46 | CF_ADDTO(kern_proto, kern_proto kern_item ';') |
47 | ||
f9f2e280 OZ |
48 | kern_mp_limit: |
49 | /* empty */ { $$ = KRT_DEFAULT_ECMP_LIMIT; } | |
50 | | LIMIT expr { $$ = $2; if (($2 <= 0) || ($2 > 255)) cf_error("Merge paths limit must be in range 1-255"); } | |
51 | ; | |
52 | ||
2d140452 | 53 | kern_item: |
f4a60a9b OZ |
54 | proto_item |
55 | | proto_channel { this_proto->net_type = $1->net_type; } | |
56 | | PERSIST bool { THIS_KRT->persist = $2; } | |
2d140452 MM |
57 | | SCAN TIME expr { |
58 | /* Scan time of 0 means scan on startup only */ | |
59 | THIS_KRT->scan_time = $3; | |
60 | } | |
c10421d3 MM |
61 | | LEARN bool { |
62 | THIS_KRT->learn = $2; | |
63 | #ifndef KRT_ALLOW_LEARN | |
64 | if ($2) | |
f9f2e280 | 65 | cf_error("Learning of kernel routes not supported on this platform"); |
c10421d3 MM |
66 | #endif |
67 | } | |
c429d4a4 | 68 | | DEVICE ROUTES bool { THIS_KRT->devroutes = $3; } |
0c791f87 | 69 | | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; } |
f9f2e280 | 70 | | MERGE PATHS bool kern_mp_limit { |
cc5b93f7 | 71 | krt_set_merge_paths(this_channel, $3, $4); |
a1839f3c | 72 | #ifndef KRT_ALLOW_MERGE_PATHS |
f9f2e280 OZ |
73 | if ($3) |
74 | cf_error("Path merging not supported on this platform"); | |
75 | #endif | |
76 | } | |
2d140452 | 77 | ; |
980ffedb | 78 | |
7e5f5ffd MM |
79 | /* Kernel interface protocol */ |
80 | ||
81 | CF_ADDTO(proto, kif_proto '}') | |
82 | ||
396dfa90 | 83 | kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); } |
7e5f5ffd MM |
84 | ; |
85 | ||
d272fe22 | 86 | CF_ADDTO(kif_proto, kif_proto_start proto_name '{') |
7e5f5ffd MM |
87 | CF_ADDTO(kif_proto, kif_proto kif_item ';') |
88 | ||
89 | kif_item: | |
f4a60a9b OZ |
90 | proto_item |
91 | | SCAN TIME expr { | |
7e5f5ffd MM |
92 | /* Scan time of 0 means scan on startup only */ |
93 | THIS_KIF->scan_time = $3; | |
94 | } | |
d44e686e | 95 | | PRIMARY opttext net_or_ipa { |
6f68f066 | 96 | struct kif_primary_item *kpi = cfg_alloc(sizeof (struct kif_primary_item)); |
95639d95 | 97 | kpi->pattern = $2; |
04632fd7 | 98 | kpi->addr = $3; |
6f68f066 OZ |
99 | add_tail(&THIS_KIF->primary, &kpi->n); |
100 | } | |
7e5f5ffd MM |
101 | ; |
102 | ||
9ba2798c OZ |
103 | CF_ADDTO(dynamic_attr, KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_KRT_SOURCE); }) |
104 | CF_ADDTO(dynamic_attr, KRT_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_KRT_METRIC); }) | |
72aed1a0 | 105 | |
980ffedb MM |
106 | CF_CODE |
107 | ||
108 | CF_END |