]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_ism.h
Merge pull request #12908 from opensourcerouting/fix/memory_leak_path_attributes
[mirror_frr.git] / ospfd / ospf_ism.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * OSPF version 2 Interface State Machine.
4 * From RFC2328 [OSPF Version 2]
5 * Copyright (C) 1999 Toshiaki Takada
6 */
7
8 #ifndef _ZEBRA_OSPF_ISM_H
9 #define _ZEBRA_OSPF_ISM_H
10
11 #include "hook.h"
12
13 /* OSPF Interface State Machine Status. */
14 #define ISM_DependUpon 0
15 #define ISM_Down 1
16 #define ISM_Loopback 2
17 #define ISM_Waiting 3
18 #define ISM_PointToPoint 4
19 #define ISM_DROther 5
20 #define ISM_Backup 6
21 #define ISM_DR 7
22 #define OSPF_ISM_STATE_MAX 8
23
24 /* OSPF Interface State Machine Event. */
25 #define ISM_NoEvent 0
26 #define ISM_InterfaceUp 1
27 #define ISM_WaitTimer 2
28 #define ISM_BackupSeen 3
29 #define ISM_NeighborChange 4
30 #define ISM_LoopInd 5
31 #define ISM_UnloopInd 6
32 #define ISM_InterfaceDown 7
33 #define OSPF_ISM_EVENT_MAX 8
34
35 #define OSPF_ISM_WRITE_ON(O) \
36 do { \
37 if (oi->on_write_q == 0) { \
38 listnode_add((O)->oi_write_q, oi); \
39 oi->on_write_q = 1; \
40 } \
41 if (!list_isempty((O)->oi_write_q)) \
42 thread_add_write(master, ospf_write, (O), (O)->fd, \
43 &(O)->t_write); \
44 } while (0)
45
46 /* Macro for OSPF ISM timer turn on. */
47 #define OSPF_ISM_TIMER_ON(T, F, V) thread_add_timer(master, (F), oi, (V), &(T))
48
49 #define OSPF_ISM_TIMER_MSEC_ON(T, F, V) \
50 thread_add_timer_msec(master, (F), oi, (V), &(T))
51
52 /* convenience macro to set hello timer correctly, according to
53 * whether fast-hello is set or not
54 */
55 #define OSPF_HELLO_TIMER_ON(O) \
56 do { \
57 if (OSPF_IF_PARAM((O), fast_hello)) \
58 OSPF_ISM_TIMER_MSEC_ON( \
59 (O)->t_hello, ospf_hello_timer, \
60 1000 / OSPF_IF_PARAM((O), fast_hello)); \
61 else \
62 OSPF_ISM_TIMER_ON((O)->t_hello, ospf_hello_timer, \
63 OSPF_IF_PARAM((O), v_hello)); \
64 } while (0)
65
66 /* Macro for OSPF schedule event. */
67 #define OSPF_ISM_EVENT_SCHEDULE(I, E) \
68 thread_add_event(master, ospf_ism_event, (I), (E), NULL)
69
70 /* Macro for OSPF execute event. */
71 #define OSPF_ISM_EVENT_EXECUTE(I, E) \
72 thread_execute(master, ospf_ism_event, (I), (E))
73
74 /* Prototypes. */
75 extern void ospf_ism_event(struct thread *thread);
76 extern void ism_change_status(struct ospf_interface *, int);
77 extern void ospf_hello_timer(struct thread *thread);
78 extern int ospf_dr_election(struct ospf_interface *oi);
79
80 DECLARE_HOOK(ospf_ism_change,
81 (struct ospf_interface * oi, int state, int oldstate),
82 (oi, state, oldstate));
83
84 #endif /* _ZEBRA_OSPF_ISM_H */