Statistics
| Branch: | Revision:

iof-bird-daemon / proto / static / config.Y @ 4116db18

History | View | Annotate | Download (2.5 KB)

1
/*
2
 *	BIRD -- Static Protocol Configuration
3
 *
4
 *	(c) 1998--1999 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 "proto/static/static.h"
12

    
13
CF_DEFINES
14

    
15
#define STATIC_CFG ((struct static_config *) this_proto)
16
static struct static_route *this_srt, *this_srt_nh, *last_srt_nh;
17

    
18
CF_DECLS
19

    
20
CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK)
21
CF_KEYWORDS(MULTIPATH, WEIGHT, RECURSIVE, IGP, TABLE)
22

    
23

    
24
CF_GRAMMAR
25

    
26
CF_ADDTO(proto, static_proto '}')
27

    
28
static_proto_start: proto_start STATIC {
29
     this_proto = proto_config_new(&proto_static, sizeof(struct static_config));
30
     static_init_config((struct static_config *) this_proto);
31
  }
32
 ;
33

    
34
static_proto:
35
   static_proto_start proto_name '{'
36
 | static_proto proto_item ';'
37
 | static_proto CHECK LINK bool ';' { STATIC_CFG->check_link = $4; }
38
 | static_proto IGP TABLE rtable ';' { STATIC_CFG->igp_table = $4; }
39
 | static_proto stat_route ';'
40
 ;
41

    
42
stat_route0: ROUTE prefix {
43
     this_srt = cfg_allocz(sizeof(struct static_route));
44
     add_tail(&STATIC_CFG->other_routes, &this_srt->n);
45
     this_srt->net = $2.addr;
46
     this_srt->masklen = $2.len;
47
  }
48
 ;
49

    
50
stat_multipath1:
51
   VIA ipa {
52
     last_srt_nh = this_srt_nh;
53
     this_srt_nh = cfg_allocz(sizeof(struct static_route));
54
     this_srt_nh->dest = RTD_NONE;
55
     this_srt_nh->via = $2;
56
     this_srt_nh->if_name = (void *) this_srt; /* really */
57
   }
58
 | stat_multipath1 WEIGHT expr {
59
     this_srt_nh->masklen = $3 - 1; /* really */
60
     if (($3<1) || ($3>256)) cf_error("Weight must be in range 1-256"); 
61
   }
62
 ;
63

    
64
stat_multipath:
65
   stat_multipath1 { this_srt->mp_next = this_srt_nh; }
66
 | stat_multipath stat_multipath1 { last_srt_nh->mp_next = this_srt_nh; }
67
 ;
68

    
69
stat_route:
70
   stat_route0 VIA ipa {
71
      this_srt->dest = RTD_ROUTER;
72
      this_srt->via = $3;
73
   }
74
 | stat_route0 VIA TEXT {
75
      this_srt->dest = RTD_DEVICE;
76
      this_srt->if_name = $3;
77
      rem_node(&this_srt->n);
78
      add_tail(&STATIC_CFG->iface_routes, &this_srt->n);
79
   }
80
 | stat_route0 MULTIPATH stat_multipath {
81
      this_srt->dest = RTD_MULTIPATH;
82
   }
83
 | stat_route0 RECURSIVE ipa {
84
      this_srt->dest = RTDX_RECURSIVE;
85
      this_srt->via = $3;
86
   }
87
 | stat_route0 DROP { this_srt->dest = RTD_BLACKHOLE; }
88
 | stat_route0 REJECT { this_srt->dest = RTD_UNREACHABLE; }
89
 | stat_route0 PROHIBIT { this_srt->dest = RTD_PROHIBIT; }
90
 ;
91

    
92
CF_CLI(SHOW STATIC, optsym, [<name>], [[Show details of static protocol]])
93
{ static_show(proto_get_named($3, &proto_static)); } ;
94

    
95
CF_CODE
96

    
97
CF_END