Statistics
| Branch: | Revision:

iof-bird / bird-2.0.1 / sysdep / unix / krt.Y @ 6b3f1a54

History | View | Annotate | Download (3.21 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 "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
krt_set_merge_paths(struct channel_config *cc, uint merge, uint limit)
21
{
22
  if ((limit <= 0) || (limit > 255))
23
    cf_error("Merge paths limit must be in range 1-255");
24

    
25
  cc->ra_mode = merge ? RA_MERGED : RA_OPTIMAL;
26
  cc->merge_limit = limit;
27
}
28

    
29
static void
30
kif_set_preferred(ip_addr ip)
31
{
32
  if (ipa_is_ip4(ip))
33
    KIF_IFACE->pref_v4 = ip;
34
  else if (!ipa_is_link_local(ip))
35
    KIF_IFACE->pref_v6 = ip;
36
  else
37
    KIF_IFACE->pref_ll = ip;
38
}
39

    
40
CF_DECLS
41

    
42
CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS)
43
CF_KEYWORDS(INTERFACE, PREFERRED)
44

    
45
%type <i> kern_mp_limit
46

    
47
CF_GRAMMAR
48

    
49
/* Kernel syncer protocol */
50

    
51
CF_ADDTO(proto, kern_proto '}')
52

    
53
kern_proto_start: proto_start KERNEL {
54
     this_proto = krt_init_config($1);
55
}
56
 ;
57

    
58
CF_ADDTO(kern_proto, kern_proto_start proto_name '{')
59
CF_ADDTO(kern_proto, kern_proto kern_item ';')
60

    
61
kern_mp_limit:
62
   /* empty */ { $$ = KRT_DEFAULT_ECMP_LIMIT; }
63
 | LIMIT expr  { $$ = $2; if (($2 <= 0) || ($2 > 255)) cf_error("Merge paths limit must be in range 1-255"); }
64
 ;
65

    
66
kern_item:
67
   proto_item
68
 | proto_channel { this_proto->net_type = $1->net_type; }
69
 | PERSIST bool { THIS_KRT->persist = $2; }
70
 | SCAN TIME expr {
71
      /* Scan time of 0 means scan on startup only */
72
      THIS_KRT->scan_time = $3 S_;
73
   }
74
 | LEARN bool {
75
      THIS_KRT->learn = $2;
76
#ifndef KRT_ALLOW_LEARN
77
      if ($2)
78
	cf_error("Learning of kernel routes not supported on this platform");
79
#endif
80
   }
81
 | DEVICE ROUTES bool { THIS_KRT->devroutes = $3; }
82
 | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; }
83
 | MERGE PATHS bool kern_mp_limit {
84
      krt_set_merge_paths(this_channel, $3, $4);
85
#ifndef KRT_ALLOW_MERGE_PATHS
86
      if ($3)
87
	cf_error("Path merging not supported on this platform");
88
#endif
89
   }
90
 ;
91

    
92
/* Kernel interface protocol */
93

    
94
CF_ADDTO(proto, kif_proto '}')
95

    
96
kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); }
97
 ;
98

    
99
CF_ADDTO(kif_proto, kif_proto_start proto_name '{')
100
CF_ADDTO(kif_proto, kif_proto kif_item ';')
101

    
102
kif_item:
103
   proto_item
104
 | INTERFACE kif_iface
105
 | SCAN TIME expr {
106
      /* Scan time of 0 means scan on startup only */
107
      THIS_KIF->scan_time = $3 S_;
108
   }
109
 ;
110

    
111
kif_iface_start:
112
{
113
  this_ipatt = cfg_allocz(sizeof(struct kif_iface_config));
114
  add_tail(&THIS_KIF->iface_list, NODE this_ipatt);
115
  init_list(&this_ipatt->ipn_list);
116
}
117

    
118
kif_iface_item:
119
   PREFERRED ipa { kif_set_preferred($2); }
120
 ;
121

    
122
kif_iface_opts:
123
   /* empty */
124
 | kif_iface_opts kif_iface_item ';'
125
 ;
126

    
127
kif_iface_opt_list:
128
   /* empty */
129
 | '{' kif_iface_opts '}'
130
 ;
131

    
132
kif_iface:
133
  kif_iface_start iface_patt_list_nopx kif_iface_opt_list;
134

    
135

    
136
CF_ADDTO(dynamic_attr, KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_KRT_SOURCE); })
137
CF_ADDTO(dynamic_attr, KRT_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_KRT_METRIC); })
138

    
139
CF_CODE
140

    
141
CF_END