]>
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 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
20 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
21 | * 02111-1307, USA. | |
22 | */ | |
23 | ||
24 | #ifndef _ZEBRA_OSPF_ISM_H | |
25 | #define _ZEBRA_OSPF_ISM_H | |
26 | ||
3012671f DL |
27 | #include "hook.h" |
28 | ||
718e3744 | 29 | /* OSPF Interface State Machine Status. */ |
30 | #define ISM_DependUpon 0 | |
31 | #define ISM_Down 1 | |
32 | #define ISM_Loopback 2 | |
33 | #define ISM_Waiting 3 | |
34 | #define ISM_PointToPoint 4 | |
35 | #define ISM_DROther 5 | |
36 | #define ISM_Backup 6 | |
37 | #define ISM_DR 7 | |
38 | #define OSPF_ISM_STATE_MAX 8 | |
39 | ||
40 | /* OSPF Interface State Machine Event. */ | |
41 | #define ISM_NoEvent 0 | |
42 | #define ISM_InterfaceUp 1 | |
43 | #define ISM_WaitTimer 2 | |
44 | #define ISM_BackupSeen 3 | |
45 | #define ISM_NeighborChange 4 | |
46 | #define ISM_LoopInd 5 | |
47 | #define ISM_UnloopInd 6 | |
48 | #define ISM_InterfaceDown 7 | |
49 | #define OSPF_ISM_EVENT_MAX 8 | |
50 | ||
ffa2c898 QY |
51 | #define OSPF_ISM_WRITE_ON(O) \ |
52 | do \ | |
53 | { \ | |
54 | if (oi->on_write_q == 0) \ | |
55 | { \ | |
56 | listnode_add ((O)->oi_write_q, oi); \ | |
57 | oi->on_write_q = 1; \ | |
58 | } \ | |
59 | thread_add_write (master, ospf_write, (O), (O)->fd, &(O)->t_write); \ | |
60 | } while (0) | |
718e3744 | 61 | |
62 | /* Macro for OSPF ISM timer turn on. */ | |
63 | #define OSPF_ISM_TIMER_ON(T,F,V) \ | |
ffa2c898 QY |
64 | thread_add_timer (master, (F), oi, (V), &(T)) |
65 | ||
f9ad937f | 66 | #define OSPF_ISM_TIMER_MSEC_ON(T,F,V) \ |
ffa2c898 | 67 | thread_add_timer_msec (master, (F), oi, (V), &(T)) |
f9ad937f | 68 | |
69 | /* convenience macro to set hello timer correctly, according to | |
70 | * whether fast-hello is set or not | |
71 | */ | |
72 | #define OSPF_HELLO_TIMER_ON(O) \ | |
73 | do { \ | |
74 | if (OSPF_IF_PARAM ((O), fast_hello)) \ | |
75 | OSPF_ISM_TIMER_MSEC_ON ((O)->t_hello, ospf_hello_timer, \ | |
76 | 1000 / OSPF_IF_PARAM ((O), fast_hello)); \ | |
77 | else \ | |
78 | OSPF_ISM_TIMER_ON ((O)->t_hello, ospf_hello_timer, \ | |
79 | OSPF_IF_PARAM ((O), v_hello)); \ | |
80 | } while (0) | |
718e3744 | 81 | |
82 | /* Macro for OSPF ISM timer turn off. */ | |
83 | #define OSPF_ISM_TIMER_OFF(X) \ | |
70cd3474 | 84 | do { \ |
85 | if (X) \ | |
86 | { \ | |
87 | thread_cancel (X); \ | |
88 | (X) = NULL; \ | |
89 | } \ | |
90 | } while (0) | |
718e3744 | 91 | |
92 | /* Macro for OSPF schedule event. */ | |
93 | #define OSPF_ISM_EVENT_SCHEDULE(I,E) \ | |
ffa2c898 | 94 | thread_add_event (master, ospf_ism_event, (I), (E), NULL) |
718e3744 | 95 | |
96 | /* Macro for OSPF execute event. */ | |
97 | #define OSPF_ISM_EVENT_EXECUTE(I,E) \ | |
98 | thread_execute (master, ospf_ism_event, (I), (E)) | |
99 | ||
100 | /* Prototypes. */ | |
4dadc291 | 101 | extern int ospf_ism_event (struct thread *); |
102 | extern void ism_change_status (struct ospf_interface *, int); | |
103 | extern int ospf_hello_timer (struct thread *thread); | |
718e3744 | 104 | |
3012671f DL |
105 | DECLARE_HOOK(ospf_ism_change, |
106 | (struct ospf_interface *oi, int state, int oldstate), | |
107 | (oi, state, oldstate)) | |
108 | ||
718e3744 | 109 | #endif /* _ZEBRA_OSPF_ISM_H */ |