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