Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (3.17 KB)

1 980ffedb Martin Mares
/*
2
 *	BIRD -- UNIX Kernel Syncer Configuration
3
 *
4 d272fe22 Martin Mares
 *	(c) 1998--2000 Martin Mares <mj@ucw.cz>
5 980ffedb Martin Mares
 *
6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8
9
CF_HDR
10
11 7152e5ef Jan Moskyto Matejka
#include "sysdep/unix/krt.h"
12 980ffedb Martin Mares
13 2edb31b0 Martin Mares
CF_DEFINES
14
15 2d140452 Martin Mares
#define THIS_KRT ((struct krt_config *) this_proto)
16 7e5f5ffd Martin Mares
#define THIS_KIF ((struct kif_config *) this_proto)
17 153f02da Ondrej Zajicek (work)
#define KIF_IFACE ((struct kif_iface_config *) this_ipatt)
18 2d140452 Martin Mares
19 f4a60a9b Ondrej Zajicek (work)
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 153f02da Ondrej Zajicek (work)
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 980ffedb Martin Mares
CF_DECLS
41
42 8d9eef17 Ondrej Zajicek
CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS)
43 980ffedb Martin Mares
44 f9f2e280 Ondrej Zajicek (work)
%type <i> kern_mp_limit
45
46 980ffedb Martin Mares
CF_GRAMMAR
47
48 7e5f5ffd Martin Mares
/* Kernel syncer protocol */
49 980ffedb Martin Mares
50
CF_ADDTO(proto, kern_proto '}')
51
52 f4a60a9b Ondrej Zajicek (work)
kern_proto_start: proto_start KERNEL {
53
     this_proto = krt_init_config($1);
54
}
55 980ffedb Martin Mares
 ;
56
57 7e5f5ffd Martin Mares
CF_ADDTO(kern_proto, kern_proto_start proto_name '{')
58 2d140452 Martin Mares
CF_ADDTO(kern_proto, kern_proto kern_item ';')
59
60 f9f2e280 Ondrej Zajicek (work)
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 2d140452 Martin Mares
kern_item:
66 f4a60a9b Ondrej Zajicek (work)
   proto_item
67
 | proto_channel { this_proto->net_type = $1->net_type; }
68
 | PERSIST bool { THIS_KRT->persist = $2; }
69 2d140452 Martin Mares
 | SCAN TIME expr {
70
      /* Scan time of 0 means scan on startup only */
71
      THIS_KRT->scan_time = $3;
72
   }
73 c10421d3 Martin Mares
 | LEARN bool {
74
      THIS_KRT->learn = $2;
75
#ifndef KRT_ALLOW_LEARN
76
      if ($2)
77 f9f2e280 Ondrej Zajicek (work)
	cf_error("Learning of kernel routes not supported on this platform");
78 c10421d3 Martin Mares
#endif
79
   }
80 c429d4a4 Ondrej Zajicek
 | DEVICE ROUTES bool { THIS_KRT->devroutes = $3; }
81 0c791f87 Ondrej Zajicek
 | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; }
82 f9f2e280 Ondrej Zajicek (work)
 | MERGE PATHS bool kern_mp_limit {
83 cc5b93f7 Ondrej Zajicek (work)
      krt_set_merge_paths(this_channel, $3, $4);
84 a1839f3c Ondrej Zajicek (work)
#ifndef KRT_ALLOW_MERGE_PATHS
85 f9f2e280 Ondrej Zajicek (work)
      if ($3)
86
	cf_error("Path merging not supported on this platform");
87
#endif
88
   }
89 2d140452 Martin Mares
 ;
90 980ffedb Martin Mares
91 7e5f5ffd Martin Mares
/* Kernel interface protocol */
92
93
CF_ADDTO(proto, kif_proto '}')
94
95 396dfa90 Ondrej Zajicek
kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); }
96 7e5f5ffd Martin Mares
 ;
97
98 d272fe22 Martin Mares
CF_ADDTO(kif_proto, kif_proto_start proto_name '{')
99 7e5f5ffd Martin Mares
CF_ADDTO(kif_proto, kif_proto kif_item ';')
100
101
kif_item:
102 f4a60a9b Ondrej Zajicek (work)
   proto_item
103 153f02da Ondrej Zajicek (work)
 | INTERFACE kif_iface
104 f4a60a9b Ondrej Zajicek (work)
 | SCAN TIME expr {
105 7e5f5ffd Martin Mares
      /* Scan time of 0 means scan on startup only */
106
      THIS_KIF->scan_time = $3;
107
   }
108
 ;
109
110 153f02da Ondrej Zajicek (work)
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 9ba2798c Ondrej Zajicek
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 72aed1a0 Ondrej Zajicek
138 980ffedb Martin Mares
CF_CODE
139
140
CF_END