Statistics
| Branch: | Revision:

iof-bird-daemon / proto / rip / config.Y @ d7c06285

History | View | Annotate | Download (3.03 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
CF_DEFINES
21

    
22
#define RIP_CFG ((struct rip_proto_config *) this_proto)
23
#define RIP_IPATT ((struct rip_patt *) this_ipatt)
24

    
25
#ifdef IPV6
26
#define RIP_DEFAULT_TTL_SECURITY 2
27
#else
28
#define RIP_DEFAULT_TTL_SECURITY 0
29
#endif
30

    
31
CF_DECLS
32

    
33
CF_KEYWORDS(RIP, INFINITY, METRIC, PORT, PERIOD, GARBAGE, TIMEOUT,
34
	    MODE, BROADCAST, MULTICAST, QUIET, NOLISTEN, VERSION1, 
35
	    AUTHENTICATION, NONE, PLAINTEXT, MD5, TTL, SECURITY,
36
	    HONOR, NEVER, NEIGHBOR, ALWAYS, TX, PRIORITY, ONLY,
37
	    RIP_METRIC, RIP_TAG)
38

    
39
%type <i> rip_mode rip_auth
40

    
41
CF_GRAMMAR
42

    
43
CF_ADDTO(proto, rip_cfg '}' { RIP_CFG->passwords = get_passwords(); } )
44

    
45
rip_cfg_start: proto_start RIP {
46
     this_proto = proto_config_new(&proto_rip, sizeof(struct rip_proto_config), $1);
47
     rip_init_config(RIP_CFG);
48
   }
49
 ;
50

    
51
rip_cfg:
52
   rip_cfg_start proto_name '{'
53
 | rip_cfg proto_item ';'
54
 | rip_cfg INFINITY expr ';'	{ RIP_CFG->infinity = $3; }
55
 | rip_cfg PORT expr ';'	{ RIP_CFG->port = $3; }
56
 | rip_cfg PERIOD expr ';'	{ RIP_CFG->period = $3; }
57
 | rip_cfg GARBAGE TIME expr ';' { RIP_CFG->garbage_time = $4; }
58
 | rip_cfg TIMEOUT TIME expr ';' { RIP_CFG->timeout_time = $4; }
59
 | rip_cfg AUTHENTICATION rip_auth ';' {RIP_CFG->authtype = $3; }
60
 | rip_cfg password_list ';'
61
 | rip_cfg HONOR ALWAYS ';'    { RIP_CFG->honor = HO_ALWAYS; }
62
 | rip_cfg HONOR NEIGHBOR ';'    { RIP_CFG->honor = HO_NEIGHBOR; }
63
 | rip_cfg HONOR NEVER ';'    { RIP_CFG->honor = HO_NEVER; }
64
 | rip_cfg INTERFACE rip_iface ';'
65
 ;
66

    
67
rip_auth:
68
   PLAINTEXT { $$=AT_PLAINTEXT; }
69
 | MD5 { $$=AT_MD5; }
70
 | NONE { $$=AT_NONE; }
71
 ;
72

    
73

    
74
rip_mode: 
75
    BROADCAST { $$=IM_BROADCAST; }
76
  | MULTICAST { $$=0; }
77
  | QUIET     { $$=IM_QUIET; }
78
  | NOLISTEN  { $$=IM_NOLISTEN; }
79
  | VERSION1  { $$=IM_VERSION1 | IM_BROADCAST; }
80
 ;
81

    
82
rip_iface_item:
83
 | METRIC expr { RIP_IPATT->metric = $2; }
84
 | MODE rip_mode { RIP_IPATT->mode |= $2; }
85
 | TX tos { RIP_IPATT->tx_tos = $2; }
86
 | TX PRIORITY expr { RIP_IPATT->tx_priority = $3; }
87
 | TTL SECURITY bool { RIP_IPATT->ttl_security = $3; }
88
 | TTL SECURITY TX ONLY { RIP_IPATT->ttl_security = 2; }
89
 ;
90

    
91
rip_iface_opts: 
92
   /* empty */
93
 | rip_iface_opts rip_iface_item ';'
94
 ;
95

    
96
rip_iface_opt_list:
97
   /* empty */
98
 | '{' rip_iface_opts '}'
99
 ;
100

    
101
rip_iface_init:
102
   /* EMPTY */ {
103
     this_ipatt = cfg_allocz(sizeof(struct rip_patt));
104
     add_tail(&RIP_CFG->iface_list, NODE this_ipatt);
105
     init_list(&this_ipatt->ipn_list);
106
     RIP_IPATT->metric = 1;
107
     RIP_IPATT->tx_tos = IP_PREC_INTERNET_CONTROL;
108
     RIP_IPATT->tx_priority = sk_priority_control;
109
     RIP_IPATT->ttl_security = RIP_DEFAULT_TTL_SECURITY;
110
   }
111
 ;
112

    
113
rip_iface:	/* TODO: switch to iface_patt_list_nopx */
114
   rip_iface_init iface_patt_list rip_iface_opt_list
115
 ;
116

    
117
CF_ADDTO(dynamic_attr, RIP_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_RIP_METRIC); })
118
CF_ADDTO(dynamic_attr, RIP_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_RIP_TAG); })
119

    
120
CF_CODE
121

    
122
CF_END