Statistics
| Branch: | Revision:

iof-bird-daemon / sysdep / unix / krt.Y @ 153f02da

History | View | Annotate | Download (3.17 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

    
44
%type <i> kern_mp_limit
45

    
46
CF_GRAMMAR
47

    
48
/* Kernel syncer protocol */
49

    
50
CF_ADDTO(proto, kern_proto '}')
51

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

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

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

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

    
91
/* Kernel interface protocol */
92

    
93
CF_ADDTO(proto, kif_proto '}')
94

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

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

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

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

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

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

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

    
131
kif_iface:
132
  kif_iface_start iface_patt_list_nopx kif_iface_opt_list;
133

    
134

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

    
138
CF_CODE
139

    
140
CF_END