1998-11-27 21:09:57 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- RIP Configuration
|
|
|
|
*
|
2015-10-05 10:14:50 +00:00
|
|
|
* (c) 1998--1999 Pavel Machek <pavel@ucw.cz>
|
|
|
|
* (c) 2004--2013 Ondrej Filip <feela@network.cz>
|
|
|
|
* (c) 2009--2015 Ondrej Zajicek <santiago@crfreenet.org>
|
|
|
|
* (c) 2009--2015 CZ.NIC z.s.p.o.
|
|
|
|
*
|
1998-11-27 21:09:57 +00:00
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CF_HDR
|
|
|
|
|
|
|
|
#include "proto/rip/rip.h"
|
1998-12-04 11:45:51 +00:00
|
|
|
#include "nest/iface.h"
|
|
|
|
|
2000-04-28 15:11:10 +00:00
|
|
|
CF_DEFINES
|
|
|
|
|
2015-10-05 10:14:50 +00:00
|
|
|
#define RIP_CFG ((struct rip_config *) this_proto)
|
|
|
|
#define RIP_IFACE ((struct rip_iface_config *) this_ipatt)
|
|
|
|
|
|
|
|
static inline int rip_cfg_is_v2(void) { return RIP_CFG->rip2; }
|
|
|
|
static inline int rip_cfg_is_ng(void) { return ! RIP_CFG->rip2; }
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
rip_check_auth(void)
|
|
|
|
{
|
|
|
|
if (rip_cfg_is_ng())
|
|
|
|
cf_error("Authentication not supported in RIPng");
|
|
|
|
}
|
1998-11-27 21:09:57 +00:00
|
|
|
|
2013-06-25 13:33:00 +00:00
|
|
|
|
1998-11-27 21:09:57 +00:00
|
|
|
CF_DECLS
|
|
|
|
|
2017-03-08 16:37:11 +00:00
|
|
|
CF_KEYWORDS(RIP, NG, ECMP, LIMIT, WEIGHT, INFINITY, METRIC, UPDATE, TIMEOUT,
|
2021-03-17 14:56:12 +00:00
|
|
|
GARBAGE, RETRANSMIT, PORT, ADDRESS, MODE, BROADCAST, MULTICAST,
|
|
|
|
PASSIVE, VERSION, SPLIT, HORIZON, POISON, REVERSE, CHECK, ZERO,
|
|
|
|
TIME, BFD, AUTHENTICATION, NONE, PLAINTEXT, CRYPTOGRAPHIC, MD5,
|
|
|
|
TTL, SECURITY, RX, TX, BUFFER, LENGTH, PRIORITY, ONLY, LINK,
|
2022-05-04 10:24:30 +00:00
|
|
|
DEMAND, CIRCUIT)
|
1999-01-12 16:40:55 +00:00
|
|
|
|
2015-12-21 02:27:41 +00:00
|
|
|
%type <i> rip_variant rip_auth
|
1998-11-27 21:09:57 +00:00
|
|
|
|
|
|
|
CF_GRAMMAR
|
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
proto: rip_proto ;
|
1998-11-27 21:09:57 +00:00
|
|
|
|
2015-12-21 02:27:41 +00:00
|
|
|
rip_variant:
|
2017-03-08 16:37:11 +00:00
|
|
|
RIP { $$ = 1; }
|
|
|
|
| RIP NG { $$ = 0; }
|
2015-12-21 02:27:41 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
rip_proto_start: proto_start rip_variant
|
2015-10-05 10:14:50 +00:00
|
|
|
{
|
|
|
|
this_proto = proto_config_new(&proto_rip, $1);
|
2016-01-26 10:48:58 +00:00
|
|
|
this_proto->net_type = $2 ? NET_IP4 : NET_IP6;
|
1998-11-27 21:09:57 +00:00
|
|
|
|
2016-01-26 10:48:58 +00:00
|
|
|
init_list(&RIP_CFG->patt_list);
|
2015-12-21 02:27:41 +00:00
|
|
|
RIP_CFG->rip2 = $2;
|
2017-12-08 14:59:44 +00:00
|
|
|
RIP_CFG->ecmp = rt_default_ecmp;
|
2015-10-05 10:14:50 +00:00
|
|
|
RIP_CFG->infinity = RIP_DEFAULT_INFINITY;
|
2017-06-20 12:30:44 +00:00
|
|
|
RIP_CFG->min_timeout_time = 60 S_;
|
|
|
|
RIP_CFG->max_garbage_time = 60 S_;
|
2015-10-05 10:14:50 +00:00
|
|
|
};
|
1999-01-12 16:40:55 +00:00
|
|
|
|
2015-10-05 10:14:50 +00:00
|
|
|
rip_proto_item:
|
|
|
|
proto_item
|
2016-01-26 10:48:58 +00:00
|
|
|
| proto_channel
|
2015-10-05 10:14:50 +00:00
|
|
|
| ECMP bool { RIP_CFG->ecmp = $2 ? RIP_DEFAULT_ECMP_LIMIT : 0; }
|
2017-05-23 15:22:53 +00:00
|
|
|
| ECMP bool LIMIT expr { RIP_CFG->ecmp = $2 ? $4 : 0; }
|
2015-10-05 10:14:50 +00:00
|
|
|
| INFINITY expr { RIP_CFG->infinity = $2; }
|
|
|
|
| INTERFACE rip_iface
|
|
|
|
;
|
2009-05-06 20:02:45 +00:00
|
|
|
|
2015-10-05 10:14:50 +00:00
|
|
|
rip_proto_opts:
|
|
|
|
/* empty */
|
|
|
|
| rip_proto_opts rip_proto_item ';'
|
1999-01-12 16:40:55 +00:00
|
|
|
;
|
|
|
|
|
2015-10-05 10:14:50 +00:00
|
|
|
rip_proto:
|
|
|
|
rip_proto_start proto_name '{' rip_proto_opts '}';
|
|
|
|
|
|
|
|
|
|
|
|
rip_iface_start:
|
|
|
|
{
|
|
|
|
this_ipatt = cfg_allocz(sizeof(struct rip_iface_config));
|
|
|
|
add_tail(&RIP_CFG->patt_list, NODE this_ipatt);
|
|
|
|
init_list(&this_ipatt->ipn_list);
|
|
|
|
reset_passwords();
|
|
|
|
|
|
|
|
RIP_IFACE->metric = 1;
|
|
|
|
RIP_IFACE->port = rip_cfg_is_v2() ? RIP_PORT : RIP_NG_PORT;
|
|
|
|
RIP_IFACE->version = rip_cfg_is_v2() ? RIP_V2 : RIP_V1;
|
|
|
|
RIP_IFACE->split_horizon = 1;
|
|
|
|
RIP_IFACE->poison_reverse = 1;
|
|
|
|
RIP_IFACE->check_zero = 1;
|
2017-12-08 14:59:44 +00:00
|
|
|
RIP_IFACE->check_link = 1;
|
2015-10-05 10:14:50 +00:00
|
|
|
RIP_IFACE->ttl_security = rip_cfg_is_v2() ? 0 : 1;
|
|
|
|
RIP_IFACE->rx_buffer = rip_cfg_is_v2() ? RIP_MAX_PKT_LENGTH : 0;
|
|
|
|
RIP_IFACE->tx_length = rip_cfg_is_v2() ? RIP_MAX_PKT_LENGTH : 0;
|
|
|
|
RIP_IFACE->tx_tos = IP_PREC_INTERNET_CONTROL;
|
|
|
|
RIP_IFACE->tx_priority = sk_priority_control;
|
|
|
|
RIP_IFACE->update_time = RIP_DEFAULT_UPDATE_TIME;
|
|
|
|
RIP_IFACE->timeout_time = RIP_DEFAULT_TIMEOUT_TIME;
|
|
|
|
RIP_IFACE->garbage_time = RIP_DEFAULT_GARBAGE_TIME;
|
2020-02-21 01:35:50 +00:00
|
|
|
RIP_IFACE->rxmt_time = RIP_DEFAULT_RXMT_TIME;
|
2015-10-05 10:14:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
rip_iface_finish:
|
|
|
|
{
|
2016-10-26 14:07:45 +00:00
|
|
|
/* Default mode is broadcast for RIPv1, multicast for RIPv2 and RIPng */
|
|
|
|
if (!RIP_IFACE->mode)
|
|
|
|
RIP_IFACE->mode = (rip_cfg_is_v2() && (RIP_IFACE->version == RIP_V1)) ?
|
|
|
|
RIP_IM_BROADCAST : RIP_IM_MULTICAST;
|
|
|
|
|
2015-10-05 10:14:50 +00:00
|
|
|
RIP_IFACE->passwords = get_passwords();
|
|
|
|
|
|
|
|
if (!RIP_IFACE->auth_type != !RIP_IFACE->passwords)
|
2023-06-16 20:11:03 +00:00
|
|
|
cf_warn("Authentication and password options should be used together");
|
2015-10-05 10:14:50 +00:00
|
|
|
|
2016-10-26 14:07:45 +00:00
|
|
|
if (RIP_IFACE->passwords)
|
|
|
|
{
|
|
|
|
struct password_item *pass;
|
|
|
|
WALK_LIST(pass, *RIP_IFACE->passwords)
|
|
|
|
{
|
|
|
|
if (pass->alg && (RIP_IFACE->auth_type != RIP_AUTH_CRYPTO))
|
|
|
|
cf_error("Password algorithm option requires cryptographic authentication");
|
|
|
|
|
|
|
|
/* Set default crypto algorithm (MD5) */
|
|
|
|
if (!pass->alg && (RIP_IFACE->auth_type == RIP_AUTH_CRYPTO))
|
|
|
|
pass->alg = ALG_MD5;
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 10:14:50 +00:00
|
|
|
|
|
|
|
RIP_CFG->min_timeout_time = MIN_(RIP_CFG->min_timeout_time, RIP_IFACE->timeout_time);
|
|
|
|
RIP_CFG->max_garbage_time = MAX_(RIP_CFG->max_garbage_time, RIP_IFACE->garbage_time);
|
|
|
|
};
|
|
|
|
|
1998-12-04 11:45:51 +00:00
|
|
|
rip_iface_item:
|
2015-10-05 10:14:50 +00:00
|
|
|
METRIC expr { RIP_IFACE->metric = $2; if (($2<1) || ($2>255)) cf_error("Metric must be in range 1-255"); }
|
|
|
|
| MODE MULTICAST { RIP_IFACE->mode = RIP_IM_MULTICAST; }
|
|
|
|
| MODE BROADCAST { RIP_IFACE->mode = RIP_IM_BROADCAST; if (rip_cfg_is_ng()) cf_error("Broadcast not supported in RIPng"); }
|
|
|
|
| PASSIVE bool { RIP_IFACE->passive = $2; }
|
2016-05-17 13:21:49 +00:00
|
|
|
| ADDRESS ipa { RIP_IFACE->address = $2; if (ipa_is_ip4($2) != rip_cfg_is_v2()) cf_error("IP address version mismatch"); }
|
2015-10-05 10:14:50 +00:00
|
|
|
| PORT expr { RIP_IFACE->port = $2; if (($2<1) || ($2>65535)) cf_error("Invalid port number"); }
|
|
|
|
| VERSION expr { RIP_IFACE->version = $2;
|
|
|
|
if (rip_cfg_is_ng()) cf_error("Version not supported in RIPng");
|
|
|
|
if (($2 != RIP_V1) && ($2 != RIP_V2)) cf_error("Unsupported version");
|
|
|
|
}
|
|
|
|
| VERSION ONLY bool { RIP_IFACE->version_only = $3; }
|
|
|
|
| SPLIT HORIZON bool { RIP_IFACE->split_horizon = $3; }
|
|
|
|
| POISON REVERSE bool { RIP_IFACE->poison_reverse = $3; }
|
|
|
|
| CHECK ZERO bool { RIP_IFACE->check_zero = $3; }
|
2020-02-21 01:35:50 +00:00
|
|
|
| DEMAND CIRCUIT bool { RIP_IFACE->demand_circuit = $3; }
|
2017-06-20 13:55:39 +00:00
|
|
|
| UPDATE TIME expr { RIP_IFACE->update_time = $3 S_; if ($3<=0) cf_error("Update time must be positive"); }
|
|
|
|
| TIMEOUT TIME expr { RIP_IFACE->timeout_time = $3 S_; if ($3<=0) cf_error("Timeout time must be positive"); }
|
|
|
|
| GARBAGE TIME expr { RIP_IFACE->garbage_time = $3 S_; if ($3<=0) cf_error("Garbage time must be positive"); }
|
2020-02-21 01:35:50 +00:00
|
|
|
| RETRANSMIT TIME expr_us { RIP_IFACE->rxmt_time = $3; if ($3<=0) cf_error("Retransmit time must be positive"); }
|
2015-10-05 10:14:50 +00:00
|
|
|
| ECMP WEIGHT expr { RIP_IFACE->ecmp_weight = $3 - 1; if (($3<1) || ($3>256)) cf_error("ECMP weight must be in range 1-256"); }
|
2016-03-15 13:55:40 +00:00
|
|
|
| RX BUFFER expr { RIP_IFACE->rx_buffer = $3; if (($3<256) || ($3>65535)) cf_error("RX length must be in range 256-65535"); }
|
2015-10-05 10:14:50 +00:00
|
|
|
| TX LENGTH expr { RIP_IFACE->tx_length = $3; if (($3<256) || ($3>65535)) cf_error("TX length must be in range 256-65535"); }
|
|
|
|
| TX tos { RIP_IFACE->tx_tos = $2; }
|
|
|
|
| TX PRIORITY expr { RIP_IFACE->tx_priority = $3; }
|
|
|
|
| TTL SECURITY bool { RIP_IFACE->ttl_security = $3; }
|
|
|
|
| TTL SECURITY TX ONLY { RIP_IFACE->ttl_security = 2; }
|
|
|
|
| CHECK LINK bool { RIP_IFACE->check_link = $3; }
|
|
|
|
| BFD bool { RIP_IFACE->bfd = $2; cf_check_bfd($2); }
|
|
|
|
| AUTHENTICATION rip_auth { RIP_IFACE->auth_type = $2; if ($2) rip_check_auth(); }
|
|
|
|
| password_list { rip_check_auth(); }
|
|
|
|
;
|
|
|
|
|
|
|
|
rip_auth:
|
|
|
|
NONE { $$ = RIP_AUTH_NONE; }
|
|
|
|
| PLAINTEXT { $$ = RIP_AUTH_PLAIN; }
|
|
|
|
| CRYPTOGRAPHIC { $$ = RIP_AUTH_CRYPTO; }
|
2016-01-26 15:45:13 +00:00
|
|
|
| MD5 { $$ = RIP_AUTH_CRYPTO; } /* For backward compatibility */
|
1998-12-04 11:45:51 +00:00
|
|
|
;
|
|
|
|
|
2015-10-05 10:14:50 +00:00
|
|
|
rip_iface_opts:
|
2009-05-06 20:02:45 +00:00
|
|
|
/* empty */
|
1998-12-04 11:45:51 +00:00
|
|
|
| rip_iface_opts rip_iface_item ';'
|
|
|
|
;
|
|
|
|
|
2009-05-06 20:02:45 +00:00
|
|
|
rip_iface_opt_list:
|
|
|
|
/* empty */
|
|
|
|
| '{' rip_iface_opts '}'
|
|
|
|
;
|
1998-12-04 11:45:51 +00:00
|
|
|
|
2015-10-05 10:14:50 +00:00
|
|
|
rip_iface:
|
|
|
|
rip_iface_start iface_patt_list_nopx rip_iface_opt_list rip_iface_finish;
|
1998-11-27 21:09:57 +00:00
|
|
|
|
1998-12-04 11:45:51 +00:00
|
|
|
|
2015-10-05 10:14:50 +00:00
|
|
|
CF_CLI_HELP(SHOW RIP, ..., [[Show information about RIP protocol]]);
|
|
|
|
|
2019-01-30 13:03:47 +00:00
|
|
|
CF_CLI(SHOW RIP INTERFACES, optproto opttext, [<name>] [\"<interface>\"], [[Show information about RIP interfaces]])
|
2020-05-14 01:48:17 +00:00
|
|
|
{ PROTO_WALK_CMD($4, &proto_rip, p) rip_show_interfaces(p, $5); };
|
2015-10-05 10:14:50 +00:00
|
|
|
|
2019-01-30 13:03:47 +00:00
|
|
|
CF_CLI(SHOW RIP NEIGHBORS, optproto opttext, [<name>] [\"<interface>\"], [[Show information about RIP neighbors]])
|
2020-05-14 01:48:17 +00:00
|
|
|
{ PROTO_WALK_CMD($4, &proto_rip, p) rip_show_neighbors(p, $5); };
|
2015-10-05 10:14:50 +00:00
|
|
|
|
|
|
|
|
1999-08-03 19:30:49 +00:00
|
|
|
CF_CODE
|
1998-12-04 11:45:51 +00:00
|
|
|
|
1998-11-27 21:09:57 +00:00
|
|
|
CF_END
|