2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2002-12-13 21:15:29 +01:00
|
|
|
/*
|
|
|
|
* OSPF version 2 Interface State Machine.
|
|
|
|
* From RFC2328 [OSPF Version 2]
|
|
|
|
* Copyright (C) 1999 Toshiaki Takada
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ZEBRA_OSPF_ISM_H
|
|
|
|
#define _ZEBRA_OSPF_ISM_H
|
|
|
|
|
2016-06-12 17:32:23 +02:00
|
|
|
#include "hook.h"
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* OSPF Interface State Machine Status. */
|
|
|
|
#define ISM_DependUpon 0
|
|
|
|
#define ISM_Down 1
|
|
|
|
#define ISM_Loopback 2
|
|
|
|
#define ISM_Waiting 3
|
|
|
|
#define ISM_PointToPoint 4
|
|
|
|
#define ISM_DROther 5
|
|
|
|
#define ISM_Backup 6
|
|
|
|
#define ISM_DR 7
|
|
|
|
#define OSPF_ISM_STATE_MAX 8
|
|
|
|
|
|
|
|
/* OSPF Interface State Machine Event. */
|
|
|
|
#define ISM_NoEvent 0
|
|
|
|
#define ISM_InterfaceUp 1
|
|
|
|
#define ISM_WaitTimer 2
|
|
|
|
#define ISM_BackupSeen 3
|
|
|
|
#define ISM_NeighborChange 4
|
|
|
|
#define ISM_LoopInd 5
|
|
|
|
#define ISM_UnloopInd 6
|
|
|
|
#define ISM_InterfaceDown 7
|
|
|
|
#define OSPF_ISM_EVENT_MAX 8
|
|
|
|
|
2017-04-25 00:33:25 +02:00
|
|
|
#define OSPF_ISM_WRITE_ON(O) \
|
|
|
|
do { \
|
|
|
|
if (oi->on_write_q == 0) { \
|
|
|
|
listnode_add((O)->oi_write_q, oi); \
|
|
|
|
oi->on_write_q = 1; \
|
|
|
|
} \
|
2019-08-30 12:03:09 +02:00
|
|
|
if (!list_isempty((O)->oi_write_q)) \
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_write(master, ospf_write, (O), (O)->fd, \
|
|
|
|
&(O)->t_write); \
|
2017-04-25 00:33:25 +02:00
|
|
|
} while (0)
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* Macro for OSPF ISM timer turn on. */
|
2022-05-20 20:19:08 +02:00
|
|
|
#define OSPF_ISM_TIMER_ON(T, F, V) event_add_timer(master, (F), oi, (V), &(T))
|
2017-04-25 00:33:25 +02:00
|
|
|
|
2005-10-21 Paul Jakma <paul.jakma@sun.com>
* (general) OSPF fast, sub-second hello and 1s dead-interval
support. A warning fix. Millisec support for ospf_timer_dump.
Change auto-cost ref-bandwidth to add a comment to write out
of config, rather than printing annoying messages to vty on
startup.
* ospf_dump.c: (ospf_timer_dump) Print out milliseconds too.
Callers typically specify a length of 9, so most see
millisecs unless they specify the additional length.
* ospf_interface.h: (struct ospf_interface) new interface param,
fast_hello.
* ospf_interface.c: (ospf_if_table_lookup) add brackets,
gcc warning fix.
(ospf_new_if_params) Initialise fast_hello param.
(ospf_free_if_params) Check whether fast_hello is configured.
(ospf_if_new_hook) set fast_hello to default.
* ospf_ism.h: Wrap OSPF_ISM_TIMER_ON inside do {} while (0) to
prevent funny side-effects from its if statement when this
macro is used conditionally by other macros.
(OSPF_ISM_TIMER_MSEC_ON) new macro, set in milliseconds.
(OSPF_HELLO_TIMER_ON) new macro to set hello timer according
to whether fast_hello is set.
* ospf_ism.c: Update all setting of the hello timer to use
either OSPF_ISM_TIMER_MSEC_ON or OSPF_HELLO_TIMER_ON. The
former is used when hello is to be sent immediately.
* ospf_nsm.c: ditto
* ospf_packet.c: (ospf_hello) hello-interval is not checked
for mismatch if fast_hello is set.
(ospf_read) Annoying nit, fix "no ospf_interface" to be debug
rather than a warning, as it can be perfectly normal to
receive packets when logical subnets are used.
(ospf_make_hello) Set hello-interval to 0 if fast-hellos are
configured.
* ospf_vty.c: (ospf_auto_cost_reference_bandwidth) annoying
nit, don't vty_out if this command is given, it gets tired
quick.
(show_ip_ospf_interface_sub) Print the hello-interval
according to whether fast-hello is set or not.
Print the extra 5 millisec characters from (ospf_timer_dump)
if fast-hello is configured.
(ospf_vty_dead_interval_set) new function, common to all
forms of dead-interval command, to set dead-interval and
fast-hello correctly. If a dead-interval is given, unset
fast-hello, else if a hello-multiplier is set, set
dead-interval to 1 and fast-hello to given multiplier.
(ip_ospf_dead_interval_addr_cmd) use
ospf_vty_dead_interval_set().
(ip_ospf_dead_interval_minimal_addr_cmd) ditto.
(no_ip_ospf_dead_interval) Unset fast-hello.
(no_ip_ospf_hello_interval) Bug-fix, unset of hello-interval
should set it to OSPF_HELLO_INTERVAL_DEFAULT, not
OSPF_ROUTER_DEAD_INTERVAL_DEFAULT.
(config_write_interface) Write out fast-hello.
(ospf_config_write) Write a comment about
"auto-cost reference-bandwidth" having to be equal on all
routers. Hopefully just as noticeable as old practice of
writing to vty, but less annoying.
(ospf_vty_if_init) install the two new dead-interval
commands.
* ospfd.h: Add defines for OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
and OSPF_FAST_HELLO_DEFAULT.
2005-10-21 02:45:17 +02:00
|
|
|
#define OSPF_ISM_TIMER_MSEC_ON(T, F, V) \
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_timer_msec(master, (F), oi, (V), &(T))
|
2005-10-21 Paul Jakma <paul.jakma@sun.com>
* (general) OSPF fast, sub-second hello and 1s dead-interval
support. A warning fix. Millisec support for ospf_timer_dump.
Change auto-cost ref-bandwidth to add a comment to write out
of config, rather than printing annoying messages to vty on
startup.
* ospf_dump.c: (ospf_timer_dump) Print out milliseconds too.
Callers typically specify a length of 9, so most see
millisecs unless they specify the additional length.
* ospf_interface.h: (struct ospf_interface) new interface param,
fast_hello.
* ospf_interface.c: (ospf_if_table_lookup) add brackets,
gcc warning fix.
(ospf_new_if_params) Initialise fast_hello param.
(ospf_free_if_params) Check whether fast_hello is configured.
(ospf_if_new_hook) set fast_hello to default.
* ospf_ism.h: Wrap OSPF_ISM_TIMER_ON inside do {} while (0) to
prevent funny side-effects from its if statement when this
macro is used conditionally by other macros.
(OSPF_ISM_TIMER_MSEC_ON) new macro, set in milliseconds.
(OSPF_HELLO_TIMER_ON) new macro to set hello timer according
to whether fast_hello is set.
* ospf_ism.c: Update all setting of the hello timer to use
either OSPF_ISM_TIMER_MSEC_ON or OSPF_HELLO_TIMER_ON. The
former is used when hello is to be sent immediately.
* ospf_nsm.c: ditto
* ospf_packet.c: (ospf_hello) hello-interval is not checked
for mismatch if fast_hello is set.
(ospf_read) Annoying nit, fix "no ospf_interface" to be debug
rather than a warning, as it can be perfectly normal to
receive packets when logical subnets are used.
(ospf_make_hello) Set hello-interval to 0 if fast-hellos are
configured.
* ospf_vty.c: (ospf_auto_cost_reference_bandwidth) annoying
nit, don't vty_out if this command is given, it gets tired
quick.
(show_ip_ospf_interface_sub) Print the hello-interval
according to whether fast-hello is set or not.
Print the extra 5 millisec characters from (ospf_timer_dump)
if fast-hello is configured.
(ospf_vty_dead_interval_set) new function, common to all
forms of dead-interval command, to set dead-interval and
fast-hello correctly. If a dead-interval is given, unset
fast-hello, else if a hello-multiplier is set, set
dead-interval to 1 and fast-hello to given multiplier.
(ip_ospf_dead_interval_addr_cmd) use
ospf_vty_dead_interval_set().
(ip_ospf_dead_interval_minimal_addr_cmd) ditto.
(no_ip_ospf_dead_interval) Unset fast-hello.
(no_ip_ospf_hello_interval) Bug-fix, unset of hello-interval
should set it to OSPF_HELLO_INTERVAL_DEFAULT, not
OSPF_ROUTER_DEAD_INTERVAL_DEFAULT.
(config_write_interface) Write out fast-hello.
(ospf_config_write) Write a comment about
"auto-cost reference-bandwidth" having to be equal on all
routers. Hopefully just as noticeable as old practice of
writing to vty, but less annoying.
(ospf_vty_if_init) install the two new dead-interval
commands.
* ospfd.h: Add defines for OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
and OSPF_FAST_HELLO_DEFAULT.
2005-10-21 02:45:17 +02:00
|
|
|
|
|
|
|
/* convenience macro to set hello timer correctly, according to
|
|
|
|
* whether fast-hello is set or not
|
|
|
|
*/
|
|
|
|
#define OSPF_HELLO_TIMER_ON(O) \
|
|
|
|
do { \
|
|
|
|
if (OSPF_IF_PARAM((O), fast_hello)) \
|
|
|
|
OSPF_ISM_TIMER_MSEC_ON( \
|
|
|
|
(O)->t_hello, ospf_hello_timer, \
|
|
|
|
1000 / OSPF_IF_PARAM((O), fast_hello)); \
|
|
|
|
else \
|
|
|
|
OSPF_ISM_TIMER_ON((O)->t_hello, ospf_hello_timer, \
|
|
|
|
OSPF_IF_PARAM((O), v_hello)); \
|
|
|
|
} while (0)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Macro for OSPF schedule event. */
|
|
|
|
#define OSPF_ISM_EVENT_SCHEDULE(I, E) \
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_event(master, ospf_ism_event, (I), (E), NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Macro for OSPF execute event. */
|
|
|
|
#define OSPF_ISM_EVENT_EXECUTE(I, E) \
|
2023-07-11 22:03:38 +02:00
|
|
|
event_execute(master, ospf_ism_event, (I), (E), NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
/* Prototypes. */
|
2022-03-01 22:18:12 +01:00
|
|
|
extern void ospf_ism_event(struct event *thread);
|
2005-05-06 23:37:42 +02:00
|
|
|
extern void ism_change_status(struct ospf_interface *, int);
|
2022-03-01 22:18:12 +01:00
|
|
|
extern void ospf_hello_timer(struct event *thread);
|
2020-08-22 19:49:30 +02:00
|
|
|
extern int ospf_dr_election(struct ospf_interface *oi);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2016-06-12 17:32:23 +02:00
|
|
|
DECLARE_HOOK(ospf_ism_change,
|
|
|
|
(struct ospf_interface * oi, int state, int oldstate),
|
|
|
|
(oi, state, oldstate));
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#endif /* _ZEBRA_OSPF_ISM_H */
|