Statistics
| Branch: | Revision:

iof-bird-daemon / sysdep / unix / krt.Y @ f4a60a9b

History | View | Annotate | Download (2.4 KB)

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 "lib/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

    
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

    
28
CF_DECLS
29

    
30
CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS)
31

    
32
CF_GRAMMAR
33

    
34
/* Kernel syncer protocol */
35

    
36
CF_ADDTO(proto, kern_proto '}')
37

    
38
kern_proto_start: proto_start KERNEL {
39
     this_proto = krt_init_config($1);
40
}
41
 ;
42

    
43
CF_ADDTO(kern_proto, kern_proto_start proto_name '{')
44
CF_ADDTO(kern_proto, kern_proto kern_item ';')
45

    
46
kern_item:
47
   proto_item
48
 | proto_channel { this_proto->net_type = $1->net_type; }
49
 | PERSIST bool { THIS_KRT->persist = $2; }
50
 | SCAN TIME expr {
51
      /* Scan time of 0 means scan on startup only */
52
      THIS_KRT->scan_time = $3;
53
   }
54
 | LEARN bool {
55
      THIS_KRT->learn = $2;
56
#ifndef KRT_ALLOW_LEARN
57
      if ($2)
58
	cf_error("Learning of kernel routes not supported in this configuration");
59
#endif
60
   }
61
 | DEVICE ROUTES bool { THIS_KRT->devroutes = $3; }
62
 | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; }
63
 | MERGE PATHS bool { krt_set_merge_paths(this_channel, $3, KRT_DEFAULT_ECMP_LIMIT); }
64
 | MERGE PATHS bool LIMIT expr { krt_set_merge_paths(this_channel, $3, $5); }
65
 ;
66

    
67
/* Kernel interface protocol */
68

    
69
CF_ADDTO(proto, kif_proto '}')
70

    
71
kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); }
72
 ;
73

    
74
CF_ADDTO(kif_proto, kif_proto_start proto_name '{')
75
CF_ADDTO(kif_proto, kif_proto kif_item ';')
76

    
77
kif_item:
78
   proto_item
79
 | SCAN TIME expr {
80
      /* Scan time of 0 means scan on startup only */
81
      THIS_KIF->scan_time = $3;
82
   }
83
 | PRIMARY opttext net_or_ipa {
84
     struct kif_primary_item *kpi = cfg_alloc(sizeof (struct kif_primary_item));
85
     kpi->addr = $3;
86
     add_tail(&THIS_KIF->primary, &kpi->n);
87
   }
88
 ;
89

    
90
CF_ADDTO(dynamic_attr, KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_KRT_SOURCE); })
91
CF_ADDTO(dynamic_attr, KRT_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_KRT_METRIC); })
92

    
93
CF_CODE
94

    
95
CF_END