Annotation of embedaddon/bird/proto/babel/config.Y, revision 1.1.1.2
1.1 misho 1: /*
2: * BIRD -- Babel Configuration
3: *
4: * Copyright (c) 2015-2016 Toke Hoiland-Jorgensen
5: *
6: * Can be freely distributed and used under the terms of the GNU GPL.
7: */
8:
9:
10:
11: CF_HDR
12:
13: #include "proto/babel/babel.h"
14: #include "nest/iface.h"
15:
16: CF_DEFINES
17:
18: #define BABEL_CFG ((struct babel_config *) this_proto)
19: #define BABEL_IFACE ((struct babel_iface_config *) this_ipatt)
20:
21: CF_DECLS
22:
1.1.1.2 ! misho 23: CF_KEYWORDS(BABEL, INTERFACE, METRIC, RXCOST, HELLO, UPDATE, INTERVAL, PORT,
! 24: TYPE, WIRED, WIRELESS, RX, TX, BUFFER, PRIORITY, LENGTH, CHECK, LINK,
! 25: BABEL_METRIC, SHOW, INTERFACES, NEIGHBORS, ENTRIES)
1.1 misho 26:
27: CF_GRAMMAR
28:
29: CF_ADDTO(proto, babel_proto)
30:
31: babel_proto_start: proto_start BABEL
32: {
33: this_proto = proto_config_new(&proto_babel, $1);
34: init_list(&BABEL_CFG->iface_list);
35: };
36:
37: babel_proto_item:
38: proto_item
39: | INTERFACE babel_iface
40: ;
41:
42: babel_proto_opts:
43: /* empty */
44: | babel_proto_opts babel_proto_item ';'
45: ;
46:
47: babel_proto:
48: babel_proto_start proto_name '{' babel_proto_opts '}';
49:
50:
51: babel_iface_start:
52: {
53: this_ipatt = cfg_allocz(sizeof(struct babel_iface_config));
54: add_tail(&BABEL_CFG->iface_list, NODE this_ipatt);
55: init_list(&this_ipatt->ipn_list);
56: BABEL_IFACE->port = BABEL_PORT;
57: BABEL_IFACE->type = BABEL_IFACE_TYPE_WIRED;
58: BABEL_IFACE->tx_tos = IP_PREC_INTERNET_CONTROL;
59: BABEL_IFACE->tx_priority = sk_priority_control;
60: BABEL_IFACE->check_link = 1;
61: };
62:
63:
64: babel_iface_finish:
65: {
66: if (BABEL_IFACE->type == BABEL_IFACE_TYPE_WIRELESS)
67: {
68: if (!BABEL_IFACE->hello_interval)
69: BABEL_IFACE->hello_interval = BABEL_HELLO_INTERVAL_WIRELESS;
70: if (!BABEL_IFACE->rxcost)
71: BABEL_IFACE->rxcost = BABEL_RXCOST_WIRELESS;
72: }
73: else
74: {
75: if (!BABEL_IFACE->hello_interval)
76: BABEL_IFACE->hello_interval = BABEL_HELLO_INTERVAL_WIRED;
77: if (!BABEL_IFACE->rxcost)
78: BABEL_IFACE->rxcost = BABEL_RXCOST_WIRED;
79: }
80:
81: /* Make sure we do not overflow the 16-bit centisec fields */
82: if (!BABEL_IFACE->update_interval)
83: BABEL_IFACE->update_interval = MIN_(BABEL_IFACE->hello_interval*BABEL_UPDATE_INTERVAL_FACTOR, BABEL_MAX_INTERVAL);
84: BABEL_IFACE->ihu_interval = MIN_(BABEL_IFACE->hello_interval*BABEL_IHU_INTERVAL_FACTOR, BABEL_MAX_INTERVAL);
85: };
86:
87:
88: babel_iface_item:
89: | PORT expr { BABEL_IFACE->port = $2; if (($2<1) || ($2>65535)) cf_error("Invalid port number"); }
90: | RXCOST expr { BABEL_IFACE->rxcost = $2; if (($2<1) || ($2>65535)) cf_error("Invalid rxcost"); }
91: | HELLO INTERVAL expr { BABEL_IFACE->hello_interval = $3; if (($3<1) || ($3>BABEL_MAX_INTERVAL)) cf_error("Invalid hello interval"); }
92: | UPDATE INTERVAL expr { BABEL_IFACE->update_interval = $3; if (($3<1) || ($3>BABEL_MAX_INTERVAL)) cf_error("Invalid update interval"); }
93: | TYPE WIRED { BABEL_IFACE->type = BABEL_IFACE_TYPE_WIRED; }
94: | TYPE WIRELESS { BABEL_IFACE->type = BABEL_IFACE_TYPE_WIRELESS; }
95: | RX BUFFER expr { BABEL_IFACE->rx_buffer = $3; if (($3<256) || ($3>65535)) cf_error("RX buffer must be in range 256-65535"); }
96: | TX LENGTH expr { BABEL_IFACE->tx_length = $3; if (($3<256) || ($3>65535)) cf_error("TX length must be in range 256-65535"); }
97: | TX tos { BABEL_IFACE->tx_tos = $2; }
98: | TX PRIORITY expr { BABEL_IFACE->tx_priority = $3; }
99: | CHECK LINK bool { BABEL_IFACE->check_link = $3; }
100: ;
101:
102: babel_iface_opts:
103: /* empty */
104: | babel_iface_opts babel_iface_item ';'
105: ;
106:
107: babel_iface_opt_list:
108: /* empty */
109: | '{' babel_iface_opts '}'
110: ;
111:
112:
113: babel_iface:
114: babel_iface_start iface_patt_list_nopx babel_iface_opt_list babel_iface_finish;
115:
116: CF_ADDTO(dynamic_attr, BABEL_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_BABEL_METRIC); })
117:
118: CF_CLI_HELP(SHOW BABEL, ..., [[Show information about Babel protocol]]);
119:
120: CF_CLI(SHOW BABEL INTERFACES, optsym opttext, [<name>] [\"<interface>\"], [[Show information about Babel interfaces]])
121: { babel_show_interfaces(proto_get_named($4, &proto_babel), $5); };
122:
123: CF_CLI(SHOW BABEL NEIGHBORS, optsym opttext, [<name>] [\"<interface>\"], [[Show information about Babel neighbors]])
124: { babel_show_neighbors(proto_get_named($4, &proto_babel), $5); };
125:
126: CF_CLI(SHOW BABEL ENTRIES, optsym opttext, [<name>], [[Show information about Babel prefix entries]])
127: { babel_show_entries(proto_get_named($4, &proto_babel)); };
128:
129: CF_CODE
130:
131: CF_END
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>