vty_out(vty, " route %s\n", yang_dnode_get_string(dnode, NULL));
}
+/*
+ * XPath: /frr-ripd:ripd/instance/timers
+ */
+DEFPY (rip_timers,
+ rip_timers_cmd,
+ "timers basic (5-2147483647)$update (5-2147483647)$timeout (5-2147483647)$garbage",
+ "Adjust routing timers\n"
+ "Basic routing protocol update timers\n"
+ "Routing table update timer value in second. Default is 30.\n"
+ "Routing information timeout timer. Default is 180.\n"
+ "Garbage collection timer. Default is 120.\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./timers/update-interval",
+ .operation = NB_OP_MODIFY,
+ .value = update_str,
+ },
+ {
+ .xpath = "./timers/holddown-interval",
+ .operation = NB_OP_MODIFY,
+ .value = timeout_str,
+ },
+ {
+ .xpath = "./timers/flush-interval",
+ .operation = NB_OP_MODIFY,
+ .value = garbage_str,
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+DEFPY (no_rip_timers,
+ no_rip_timers_cmd,
+ "no timers basic [(5-2147483647) (5-2147483647) (5-2147483647)]",
+ NO_STR
+ "Adjust routing timers\n"
+ "Basic routing protocol update timers\n"
+ "Routing table update timer value in second. Default is 30.\n"
+ "Routing information timeout timer. Default is 180.\n"
+ "Garbage collection timer. Default is 120.\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./timers/update-interval",
+ .operation = NB_OP_MODIFY,
+ .value = NULL,
+ },
+ {
+ .xpath = "./timers/holddown-interval",
+ .operation = NB_OP_MODIFY,
+ .value = NULL,
+ },
+ {
+ .xpath = "./timers/flush-interval",
+ .operation = NB_OP_MODIFY,
+ .value = NULL,
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+void cli_show_rip_timers(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " timers basic %s %s %s\n",
+ yang_dnode_get_string(dnode, "./update-interval"),
+ yang_dnode_get_string(dnode, "./holddown-interval"),
+ yang_dnode_get_string(dnode, "./flush-interval"));
+}
+
void rip_cli_init(void)
{
install_element(CONFIG_NODE, &router_rip_cmd);
install_element(RIP_NODE, &rip_redistribute_cmd);
install_element(RIP_NODE, &no_rip_redistribute_cmd);
install_element(RIP_NODE, &rip_route_cmd);
+ install_element(RIP_NODE, &rip_timers_cmd);
+ install_element(RIP_NODE, &no_rip_timers_cmd);
}
bool show_defaults);
extern void cli_show_rip_route(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+extern void cli_show_rip_timers(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
#endif /* _FRR_RIP_CLI_H_ */
return NB_OK;
}
+/*
+ * XPath: /frr-ripd:ripd/instance/timers/
+ */
+static void ripd_instance_timers_apply_finish(const struct lyd_node *dnode)
+{
+ /* Reset update timer thread. */
+ rip_event(RIP_UPDATE_EVENT, 0);
+}
+
/*
* XPath: /frr-ripd:ripd/instance/timers/flush-interval
*/
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ rip->garbage_time = yang_dnode_get_uint32(dnode, NULL);
+
return NB_OK;
}
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ rip->timeout_time = yang_dnode_get_uint32(dnode, NULL);
+
return NB_OK;
}
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ rip->update_time = yang_dnode_get_uint32(dnode, NULL);
+
return NB_OK;
}
.cbs.delete = ripd_instance_static_route_delete,
.cbs.cli_show = cli_show_rip_route,
},
+ {
+ .xpath = "/frr-ripd:ripd/instance/timers",
+ .cbs.apply_finish = ripd_instance_timers_apply_finish,
+ .cbs.cli_show = cli_show_rip_timers,
+ },
{
.xpath = "/frr-ripd:ripd/instance/timers/flush-interval",
.cbs.modify = ripd_instance_timers_flush_interval_modify,
long rip_global_queries = 0;
/* Prototypes. */
-static void rip_event(enum rip_event, int);
static void rip_output_process(struct connected *, struct sockaddr_in *, int,
uint8_t);
static int rip_triggered_update(struct thread *);
}
#endif
-DEFUN (rip_timers,
- rip_timers_cmd,
- "timers basic (5-2147483647) (5-2147483647) (5-2147483647)",
- "Adjust routing timers\n"
- "Basic routing protocol update timers\n"
- "Routing table update timer value in second. Default is 30.\n"
- "Routing information timeout timer. Default is 180.\n"
- "Garbage collection timer. Default is 120.\n")
-{
- int idx_number = 2;
- int idx_number_2 = 3;
- int idx_number_3 = 4;
- unsigned long update;
- unsigned long timeout;
- unsigned long garbage;
- char *endptr = NULL;
- unsigned long RIP_TIMER_MAX = 2147483647;
- unsigned long RIP_TIMER_MIN = 5;
-
- update = strtoul(argv[idx_number]->arg, &endptr, 10);
- if (update > RIP_TIMER_MAX || update < RIP_TIMER_MIN
- || *endptr != '\0') {
- vty_out(vty, "update timer value error\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- timeout = strtoul(argv[idx_number_2]->arg, &endptr, 10);
- if (timeout > RIP_TIMER_MAX || timeout < RIP_TIMER_MIN
- || *endptr != '\0') {
- vty_out(vty, "timeout timer value error\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- garbage = strtoul(argv[idx_number_3]->arg, &endptr, 10);
- if (garbage > RIP_TIMER_MAX || garbage < RIP_TIMER_MIN
- || *endptr != '\0') {
- vty_out(vty, "garbage timer value error\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- /* Set each timer value. */
- rip->update_time = update;
- rip->timeout_time = timeout;
- rip->garbage_time = garbage;
-
- /* Reset update timer thread. */
- rip_event(RIP_UPDATE_EVENT, 0);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_rip_timers,
- no_rip_timers_cmd,
- "no timers basic [(0-65535) (0-65535) (0-65535)]",
- NO_STR
- "Adjust routing timers\n"
- "Basic routing protocol update timers\n"
- "Routing table update timer value in second. Default is 30.\n"
- "Routing information timeout timer. Default is 180.\n"
- "Garbage collection timer. Default is 120.\n")
-{
- /* Set each timer value to the default. */
- rip->update_time = RIP_UPDATE_TIMER_DEFAULT;
- rip->timeout_time = RIP_TIMEOUT_TIMER_DEFAULT;
- rip->garbage_time = RIP_GARBAGE_TIMER_DEFAULT;
-
- /* Reset update timer thread. */
- rip_event(RIP_UPDATE_EVENT, 0);
-
- return CMD_SUCCESS;
-}
-
struct route_table *rip_distance_table;
return CMD_SUCCESS;
vty_out(vty, "Routing Protocol is \"rip\"\n");
- vty_out(vty, " Sending updates every %ld seconds with +/-50%%,",
+ vty_out(vty, " Sending updates every %u seconds with +/-50%%,",
rip->update_time);
vty_out(vty, " next due in %lu seconds\n",
thread_timer_remain_second(rip->t_update));
- vty_out(vty, " Timeout after %ld seconds,", rip->timeout_time);
- vty_out(vty, " garbage collect after %ld seconds\n", rip->garbage_time);
+ vty_out(vty, " Timeout after %u seconds,", rip->timeout_time);
+ vty_out(vty, " garbage collect after %u seconds\n", rip->garbage_time);
/* Filtering status show. */
config_show_distribute(vty);
|| rip->version_recv != RI_RIP_VERSION_1_AND_2)
vty_out(vty, " version %d\n", rip->version_send);
- /* RIP timer configuration. */
- if (rip->update_time != RIP_UPDATE_TIMER_DEFAULT
- || rip->timeout_time != RIP_TIMEOUT_TIMER_DEFAULT
- || rip->garbage_time != RIP_GARBAGE_TIMER_DEFAULT)
- vty_out(vty, " timers basic %lu %lu %lu\n",
- rip->update_time, rip->timeout_time,
- rip->garbage_time);
-
/* Distribute configuration. */
write += config_write_distribute(vty);
install_default(RIP_NODE);
install_element(RIP_NODE, &rip_version_cmd);
install_element(RIP_NODE, &no_rip_version_cmd);
- install_element(RIP_NODE, &rip_timers_cmd);
- install_element(RIP_NODE, &no_rip_timers_cmd);
/* Debug related init. */
rip_debug_init();
#define INADDR_RIP_GROUP 0xe0000009 /* 224.0.0.9 */
#endif
-/* RIP timers */
-#define RIP_UPDATE_TIMER_DEFAULT 30
-#define RIP_TIMEOUT_TIMER_DEFAULT 180
-#define RIP_GARBAGE_TIMER_DEFAULT 120
-
/* RIP peer timeout value. */
#define RIP_PEER_TIMER_DEFAULT 180
struct thread *t_triggered_interval;
/* RIP timer values. */
- unsigned long update_time;
- unsigned long timeout_time;
- unsigned long garbage_time;
+ uint32_t update_time;
+ uint32_t timeout_time;
+ uint32_t garbage_time;
/* RIP default metric. */
uint8_t default_metric;
extern int rip_enable_if_add(const char *ifname);
extern int rip_enable_if_delete(const char *ifname);
+extern void rip_event(enum rip_event, int);
extern void rip_ecmp_disable(void);
extern int rip_create_socket(void);