]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * OSPF version 2 Interface State Machine. | |
3 | * From RFC2328 [OSPF Version 2] | |
4 | * Copyright (C) 1999 Toshiaki Takada | |
5 | * | |
6 | * This file is part of GNU Zebra. | |
7 | * | |
8 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * GNU Zebra is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
896014f4 DL |
18 | * You should have received a copy of the GNU General Public License along |
19 | * with this program; see the file COPYING; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 21 | */ |
22 | ||
23 | #ifndef _ZEBRA_OSPF_ISM_H | |
24 | #define _ZEBRA_OSPF_ISM_H | |
25 | ||
3012671f DL |
26 | #include "hook.h" |
27 | ||
718e3744 | 28 | /* OSPF Interface State Machine Status. */ |
29 | #define ISM_DependUpon 0 | |
30 | #define ISM_Down 1 | |
31 | #define ISM_Loopback 2 | |
32 | #define ISM_Waiting 3 | |
33 | #define ISM_PointToPoint 4 | |
34 | #define ISM_DROther 5 | |
35 | #define ISM_Backup 6 | |
36 | #define ISM_DR 7 | |
37 | #define OSPF_ISM_STATE_MAX 8 | |
38 | ||
39 | /* OSPF Interface State Machine Event. */ | |
40 | #define ISM_NoEvent 0 | |
41 | #define ISM_InterfaceUp 1 | |
42 | #define ISM_WaitTimer 2 | |
43 | #define ISM_BackupSeen 3 | |
44 | #define ISM_NeighborChange 4 | |
45 | #define ISM_LoopInd 5 | |
46 | #define ISM_UnloopInd 6 | |
47 | #define ISM_InterfaceDown 7 | |
48 | #define OSPF_ISM_EVENT_MAX 8 | |
49 | ||
d62a17ae | 50 | #define OSPF_ISM_WRITE_ON(O) \ |
51 | do { \ | |
52 | if (oi->on_write_q == 0) { \ | |
53 | listnode_add((O)->oi_write_q, oi); \ | |
54 | oi->on_write_q = 1; \ | |
55 | } \ | |
4173cc8e DS |
56 | if (!list_isempty((O)->oi_write_q)) \ |
57 | thread_add_write(master, ospf_write, (O), (O)->fd, \ | |
58 | &(O)->t_write); \ | |
d62a17ae | 59 | } while (0) |
60 | ||
718e3744 | 61 | /* Macro for OSPF ISM timer turn on. */ |
d62a17ae | 62 | #define OSPF_ISM_TIMER_ON(T, F, V) thread_add_timer(master, (F), oi, (V), &(T)) |
ffa2c898 | 63 | |
d62a17ae | 64 | #define OSPF_ISM_TIMER_MSEC_ON(T, F, V) \ |
65 | thread_add_timer_msec(master, (F), oi, (V), &(T)) | |
f9ad937f | 66 | |
67 | /* convenience macro to set hello timer correctly, according to | |
68 | * whether fast-hello is set or not | |
69 | */ | |
d62a17ae | 70 | #define OSPF_HELLO_TIMER_ON(O) \ |
71 | do { \ | |
72 | if (OSPF_IF_PARAM((O), fast_hello)) \ | |
73 | OSPF_ISM_TIMER_MSEC_ON( \ | |
74 | (O)->t_hello, ospf_hello_timer, \ | |
75 | 1000 / OSPF_IF_PARAM((O), fast_hello)); \ | |
76 | else \ | |
77 | OSPF_ISM_TIMER_ON((O)->t_hello, ospf_hello_timer, \ | |
78 | OSPF_IF_PARAM((O), v_hello)); \ | |
79 | } while (0) | |
718e3744 | 80 | |
81 | /* Macro for OSPF ISM timer turn off. */ | |
50478845 | 82 | #define OSPF_ISM_TIMER_OFF(X) thread_cancel(&(X)) |
718e3744 | 83 | |
84 | /* Macro for OSPF schedule event. */ | |
d62a17ae | 85 | #define OSPF_ISM_EVENT_SCHEDULE(I, E) \ |
86 | thread_add_event(master, ospf_ism_event, (I), (E), NULL) | |
718e3744 | 87 | |
88 | /* Macro for OSPF execute event. */ | |
d62a17ae | 89 | #define OSPF_ISM_EVENT_EXECUTE(I, E) \ |
90 | thread_execute(master, ospf_ism_event, (I), (E)) | |
718e3744 | 91 | |
92 | /* Prototypes. */ | |
d62a17ae | 93 | extern int ospf_ism_event(struct thread *); |
94 | extern void ism_change_status(struct ospf_interface *, int); | |
95 | extern int ospf_hello_timer(struct thread *thread); | |
df074ec3 | 96 | extern int ospf_dr_election(struct ospf_interface *oi); |
718e3744 | 97 | |
3012671f | 98 | DECLARE_HOOK(ospf_ism_change, |
d62a17ae | 99 | (struct ospf_interface * oi, int state, int oldstate), |
100 | (oi, state, oldstate)) | |
3012671f | 101 | |
718e3744 | 102 | #endif /* _ZEBRA_OSPF_ISM_H */ |