Return to config.Y CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / bird2 / proto / babel |
1.1 ! misho 1: /* ! 2: * BIRD -- Babel Configuration ! 3: * ! 4: * Copyright (c) 2015-2016 Toke Hoiland-Jorgensen ! 5: * (c) 2016--2017 Ondrej Zajicek <santiago@crfreenet.org> ! 6: * (c) 2016--2017 CZ.NIC z.s.p.o. ! 7: * ! 8: * Can be freely distributed and used under the terms of the GNU GPL. ! 9: */ ! 10: ! 11: ! 12: ! 13: CF_HDR ! 14: ! 15: #include "proto/babel/babel.h" ! 16: #include "nest/iface.h" ! 17: ! 18: CF_DEFINES ! 19: ! 20: #define BABEL_CFG ((struct babel_config *) this_proto) ! 21: #define BABEL_IFACE ((struct babel_iface_config *) this_ipatt) ! 22: ! 23: CF_DECLS ! 24: ! 25: CF_KEYWORDS(BABEL, INTERFACE, METRIC, RXCOST, HELLO, UPDATE, INTERVAL, PORT, ! 26: TYPE, WIRED, WIRELESS, RX, TX, BUFFER, PRIORITY, LENGTH, CHECK, LINK, ! 27: NEXT, HOP, IPV4, IPV6, BABEL_METRIC, SHOW, INTERFACES, NEIGHBORS, ! 28: ENTRIES, RANDOMIZE, ROUTER, ID) ! 29: ! 30: CF_GRAMMAR ! 31: ! 32: proto: babel_proto ; ! 33: ! 34: babel_proto_start: proto_start BABEL ! 35: { ! 36: this_proto = proto_config_new(&proto_babel, $1); ! 37: init_list(&BABEL_CFG->iface_list); ! 38: BABEL_CFG->hold_time = 1 S_; ! 39: }; ! 40: ! 41: babel_proto_item: ! 42: proto_item ! 43: | proto_channel ! 44: | INTERFACE babel_iface ! 45: | RANDOMIZE ROUTER ID bool { BABEL_CFG->randomize_router_id = $4; } ! 46: ; ! 47: ! 48: babel_proto_opts: ! 49: /* empty */ ! 50: | babel_proto_opts babel_proto_item ';' ! 51: ; ! 52: ! 53: babel_proto: ! 54: babel_proto_start proto_name '{' babel_proto_opts '}'; ! 55: ! 56: ! 57: babel_iface_start: ! 58: { ! 59: this_ipatt = cfg_allocz(sizeof(struct babel_iface_config)); ! 60: add_tail(&BABEL_CFG->iface_list, NODE this_ipatt); ! 61: init_list(&this_ipatt->ipn_list); ! 62: BABEL_IFACE->port = BABEL_PORT; ! 63: BABEL_IFACE->type = BABEL_IFACE_TYPE_WIRED; ! 64: BABEL_IFACE->limit = BABEL_HELLO_LIMIT; ! 65: BABEL_IFACE->tx_tos = IP_PREC_INTERNET_CONTROL; ! 66: BABEL_IFACE->tx_priority = sk_priority_control; ! 67: BABEL_IFACE->check_link = 1; ! 68: }; ! 69: ! 70: ! 71: babel_iface_finish: ! 72: { ! 73: if (BABEL_IFACE->type == BABEL_IFACE_TYPE_WIRELESS) ! 74: { ! 75: if (!BABEL_IFACE->hello_interval) ! 76: BABEL_IFACE->hello_interval = BABEL_HELLO_INTERVAL_WIRELESS; ! 77: if (!BABEL_IFACE->rxcost) ! 78: BABEL_IFACE->rxcost = BABEL_RXCOST_WIRELESS; ! 79: } ! 80: else ! 81: { ! 82: if (!BABEL_IFACE->hello_interval) ! 83: BABEL_IFACE->hello_interval = BABEL_HELLO_INTERVAL_WIRED; ! 84: if (!BABEL_IFACE->rxcost) ! 85: BABEL_IFACE->rxcost = BABEL_RXCOST_WIRED; ! 86: } ! 87: ! 88: /* Make sure we do not overflow the 16-bit centisec fields */ ! 89: if (!BABEL_IFACE->update_interval) ! 90: BABEL_IFACE->update_interval = MIN_(BABEL_IFACE->hello_interval*BABEL_UPDATE_INTERVAL_FACTOR, BABEL_MAX_INTERVAL); ! 91: BABEL_IFACE->ihu_interval = MIN_(BABEL_IFACE->hello_interval*BABEL_IHU_INTERVAL_FACTOR, BABEL_MAX_INTERVAL); ! 92: ! 93: BABEL_CFG->hold_time = MAX_(BABEL_CFG->hold_time, BABEL_IFACE->update_interval*BABEL_HOLD_TIME_FACTOR); ! 94: }; ! 95: ! 96: ! 97: babel_iface_item: ! 98: | PORT expr { BABEL_IFACE->port = $2; if (($2<1) || ($2>65535)) cf_error("Invalid port number"); } ! 99: | RXCOST expr { BABEL_IFACE->rxcost = $2; if (($2<1) || ($2>65535)) cf_error("Invalid rxcost"); } ! 100: | LIMIT expr { BABEL_IFACE->limit = $2; if (($2<1) || ($2>16)) cf_error("Limit must be in range 1-16"); } ! 101: | TYPE WIRED { BABEL_IFACE->type = BABEL_IFACE_TYPE_WIRED; } ! 102: | TYPE WIRELESS { BABEL_IFACE->type = BABEL_IFACE_TYPE_WIRELESS; } ! 103: | HELLO INTERVAL expr_us { BABEL_IFACE->hello_interval = $3; if (($3<BABEL_MIN_INTERVAL) || ($3>BABEL_MAX_INTERVAL)) cf_error("Hello interval must be in range 10 ms - 655 s"); } ! 104: | UPDATE INTERVAL expr_us { BABEL_IFACE->update_interval = $3; if (($3<BABEL_MIN_INTERVAL) || ($3>BABEL_MAX_INTERVAL)) cf_error("Update interval must be in range 10 ms - 655 s"); } ! 105: | RX BUFFER expr { BABEL_IFACE->rx_buffer = $3; if (($3<256) || ($3>65535)) cf_error("RX buffer must be in range 256-65535"); } ! 106: | TX LENGTH expr { BABEL_IFACE->tx_length = $3; if (($3<256) || ($3>65535)) cf_error("TX length must be in range 256-65535"); } ! 107: | TX tos { BABEL_IFACE->tx_tos = $2; } ! 108: | TX PRIORITY expr { BABEL_IFACE->tx_priority = $3; } ! 109: | CHECK LINK bool { BABEL_IFACE->check_link = $3; } ! 110: | NEXT HOP IPV4 ipa { BABEL_IFACE->next_hop_ip4 = $4; if (!ipa_is_ip4($4)) cf_error("Must be an IPv4 address"); } ! 111: | NEXT HOP IPV6 ipa { BABEL_IFACE->next_hop_ip6 = $4; if (!ipa_is_ip6($4)) cf_error("Must be an IPv6 address"); } ! 112: ; ! 113: ! 114: babel_iface_opts: ! 115: /* empty */ ! 116: | babel_iface_opts babel_iface_item ';' ! 117: ; ! 118: ! 119: babel_iface_opt_list: ! 120: /* empty */ ! 121: | '{' babel_iface_opts '}' ! 122: ; ! 123: ! 124: ! 125: babel_iface: ! 126: babel_iface_start iface_patt_list_nopx babel_iface_opt_list babel_iface_finish; ! 127: ! 128: dynamic_attr: BABEL_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_BABEL_METRIC); } ; ! 129: ! 130: CF_CLI_HELP(SHOW BABEL, ..., [[Show information about Babel protocol]]); ! 131: ! 132: CF_CLI(SHOW BABEL INTERFACES, optproto opttext, [<name>] [\"<interface>\"], [[Show information about Babel interfaces]]) ! 133: { babel_show_interfaces(proto_get_named($4, &proto_babel), $5); }; ! 134: ! 135: CF_CLI(SHOW BABEL NEIGHBORS, optproto opttext, [<name>] [\"<interface>\"], [[Show information about Babel neighbors]]) ! 136: { babel_show_neighbors(proto_get_named($4, &proto_babel), $5); }; ! 137: ! 138: CF_CLI(SHOW BABEL ENTRIES, optproto opttext, [<name>], [[Show information about Babel prefix entries]]) ! 139: { babel_show_entries(proto_get_named($4, &proto_babel)); }; ! 140: ! 141: CF_CLI(SHOW BABEL ROUTES, optproto opttext, [<name>], [[Show information about Babel route entries]]) ! 142: { babel_show_routes(proto_get_named($4, &proto_babel)); }; ! 143: ! 144: CF_CODE ! 145: ! 146: CF_END