Statistics
| Branch: | Revision:

iof-bird-daemon / proto / bgp / config.Y @ 56a2bed4

History | View | Annotate | Download (2.92 KB)

1
/*
2
 *	BIRD -- Border Gateway Protocol Configuration
3
 *
4
 *	(c) 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 "proto/bgp/bgp.h"
12

    
13
#define BGP_CFG ((struct bgp_config *) this_proto)
14

    
15
CF_DECLS
16

    
17
CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, HOLD, TIME, CONNECT, RETRY, KEEPALIVE,
18
	MULTIHOP, STARTUP, VIA, NEXT, HOP, SELF, DEFAULT, PATH, METRIC,
19
	BGP_PATH, BGP_LOCAL_PREF, BGP_MED, BGP_ORIGIN, BGP_NEXT_HOP,
20
	BGP_ATOMIC_AGGR, BGP_AGGREGATOR, BGP_COMMUNITY)
21

    
22
CF_GRAMMAR
23

    
24
CF_ADDTO(proto, bgp_proto '}' { bgp_check(BGP_CFG); } )
25

    
26
bgp_proto_start: proto_start BGP {
27
     this_proto = proto_config_new(&proto_bgp, sizeof(struct bgp_config));
28
     this_proto->preference = DEF_PREF_BGP;
29
     BGP_CFG->hold_time = 240;
30
     BGP_CFG->connect_retry_time = 120;
31
     BGP_CFG->initial_hold_time = 240;
32
     BGP_CFG->default_med = ~0;
33
     BGP_CFG->compare_path_lengths = 1;
34
  }
35
 ;
36

    
37
bgp_proto:
38
   bgp_proto_start proto_name '{'
39
 | bgp_proto proto_item ';'
40
 | bgp_proto LOCAL AS NUM ';' {
41
     if ($4 < 0 || $4 > 65535) cf_error("AS number out of range");
42
     BGP_CFG->local_as = $4;
43
   }
44
 | bgp_proto NEIGHBOR IPA AS NUM ';' {
45
     if ($5 < 0 || $5 > 65535) cf_error("AS number out of range");
46
     BGP_CFG->remote_ip = $3;
47
     BGP_CFG->remote_as = $5;
48
   }
49
 | bgp_proto HOLD TIME NUM ';' { BGP_CFG->hold_time = $4; }
50
 | bgp_proto STARTUP HOLD TIME NUM ';' { BGP_CFG->initial_hold_time = $5; }
51
 | bgp_proto CONNECT RETRY TIME NUM ';' { BGP_CFG->connect_retry_time = $5; }
52
 | bgp_proto KEEPALIVE TIME NUM ';' { BGP_CFG->connect_retry_time = $4; }
53
 | bgp_proto MULTIHOP NUM VIA IPA ';' { BGP_CFG->multihop = $3; BGP_CFG->multihop_via = $5; }
54
 | bgp_proto NEXT HOP SELF ';' { BGP_CFG->next_hop_self = 1; }
55
 | bgp_proto PATH METRIC NUM ';' { BGP_CFG->compare_path_lengths = $4; }
56
 | bgp_proto DEFAULT BGP_MED NUM ';' { BGP_CFG->default_med = $4; }
57
 | bgp_proto DEFAULT BGP_LOCAL_PREF NUM ';' { BGP_CFG->default_local_pref = $4; }
58
 ;
59

    
60
CF_ADDTO(dynamic_attr, BGP_PATH
61
	{ $$ = f_new_dynamic_attr(EAF_TYPE_AS_PATH, T_PATH, EA_CODE(EAP_BGP, BA_AS_PATH)); })
62
CF_ADDTO(dynamic_attr, BGP_LOCAL_PREF
63
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(EAP_BGP, BA_LOCAL_PREF)); })
64
CF_ADDTO(dynamic_attr, BGP_MED
65
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(EAP_BGP, BA_MULTI_EXIT_DISC)); })
66
CF_ADDTO(dynamic_attr, BGP_ORIGIN
67
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(EAP_BGP, BA_ORIGIN)); })
68
CF_ADDTO(dynamic_attr, BGP_NEXT_HOP
69
	{ $$ = f_new_dynamic_attr(EAF_TYPE_IP_ADDRESS, T_IP, EA_CODE(EAP_BGP, BA_NEXT_HOP)); })
70
CF_ADDTO(dynamic_attr, BGP_ATOMIC_AGGR
71
	{ $$ = f_new_dynamic_attr(EAF_TYPE_OPAQUE, T_ENUM_EMPTY, EA_CODE(EAP_BGP, BA_ATOMIC_AGGR)); })
72
CF_ADDTO(dynamic_attr, BGP_AGGREGATOR
73
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(EAP_BGP, BA_AGGREGATOR)); })
74
CF_ADDTO(dynamic_attr, BGP_COMMUNITY
75
	{ $$ = f_new_dynamic_attr(EAF_TYPE_INT_SET, T_CLIST, EA_CODE(EAP_BGP, BA_COMMUNITY)); })
76

    
77
CF_CODE
78

    
79
CF_END