Statistics
| Branch: | Revision:

iof-bird-daemon / proto / rip / config.Y @ 9607536d

History | View | Annotate | Download (2.21 KB)

1
/*
2
 *	BIRD -- RIP Configuration
3
 *
4
 *	Can be freely distributed and used under the terms of the GNU GPL.
5
 */
6

    
7
/*
8
To add:
9

    
10
version1 switch
11

    
12
*/
13

    
14

    
15
CF_HDR
16

    
17
#include "proto/rip/rip.h"
18
#include "nest/iface.h"
19

    
20
void rip_dev_add_iface(char *);
21
struct rip_patt *rip_get_iface(void);
22

    
23
#define RIP_CFG ((struct rip_proto_config *) this_proto)
24

    
25
CF_DECLS
26

    
27
CF_KEYWORDS(RIP, INFINITY, METRIC, PORT, PERIOD, GARBAGETIME, PASSWORDS,
28
	    MODE, BROADCAST, QUIET, NOLISTEN, VERSION1, 
29
	    AUTHENTICATION, NONE, PLAINTEXT, MD5)
30

    
31
%type <i> rip_mode rip_auth
32

    
33
CF_GRAMMAR
34

    
35
CF_ADDTO(proto, RIP_CFG '}')
36

    
37
RIP_CFG_start: proto_start RIP {
38
     RIP_CFG = proto_config_new(&proto_rip, sizeof(struct rip_proto_config));
39
     rip_init_config(RIP_CFG);
40
   }
41
 ;
42

    
43
RIP_CFG:
44
   RIP_CFG_start proto_name '{'
45
 | RIP_CFG proto_item ';'
46
 | RIP_CFG INFINITY expr ';'	{ RIP_CFG->infinity = $3; }
47
 | RIP_CFG PORT expr ';'	{ RIP_CFG->port = $3; }
48
 | RIP_CFG PERIOD expr ';'	{ RIP_CFG->period = $3; }
49
 | RIP_CFG GARBAGETIME expr ';' { RIP_CFG->garbage_time = $3; }
50
 | RIP_CFG AUTHENTICATION rip_auth ';' {RIP_CFG->authtype = $3; }
51
 | RIP_CFG PASSWORDS '{' password_list '}' {RIP_CFG->passwords = $4; }
52
 | RIP_CFG rip_iface_list ';'
53
 ;
54

    
55
rip_auth:
56
   PLAINTEXT { $$=AT_PLAINTEXT; }
57
 | MD5 { $$=AT_MD5; }
58
 | NONE { $$=AT_NONE; }
59
 ;
60

    
61
rip_mode: 
62
    BROADCAST { $$|=IM_BROADCAST; }
63
  | QUIET     { $$|=IM_QUIET; }
64
  | NOLISTEN  { $$|=IM_NOLISTEN; }
65
  | VERSION1  { $$|=IM_VERSION1 | IM_BROADCAST; }
66
 ;
67

    
68
rip_iface_item:
69
 | METRIC expr { 
70
   struct rip_patt *k = rip_get_iface();
71
   k->metric = $2;
72
 }
73
 | MODE rip_mode {
74
   struct rip_patt *k = rip_get_iface();
75
   k->mode = $2;
76
 }
77
 ;
78

    
79
rip_iface_opts: 
80
   '{'
81
 | rip_iface_opts rip_iface_item ';'
82
 ;
83

    
84
rip_iface_empty: /* EMPTY */ | rip_iface_opts '}' ;
85

    
86
rip_iface_list:
87
   INTERFACE TEXT rip_iface_empty { rip_dev_add_iface($2); }
88
 | dev_iface_list ',' TEXT rip_iface_empty { rip_dev_add_iface($3); }
89
 ;
90

    
91
CF_CODE
92

    
93
void
94
rip_dev_add_iface(char *n)
95
{
96
  struct rip_patt *k = cfg_allocz(sizeof(struct rip_patt));
97
  k->metric = 1;
98
  k->i.pattern = cfg_strdup(n);
99
  add_tail(&RIP_CFG->iface_list, &k->i.n);
100
}
101

    
102
struct rip_patt *
103
rip_get_iface(void)
104
{
105
  struct rip_patt *k = TAIL(RIP_CFG->iface_list);
106
  if (!k)
107
    cf_error( "This cannot happen" );
108
  return k;
109
}
110

    
111

    
112
CF_END