]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_fsm.h
[bgpd] Fix 0.99 shutdown regression, introduce Clearing and Deleted states
[mirror_frr.git] / bgpd / bgp_fsm.h
1 /* BGP-4 Finite State Machine
2 From RFC1771 [A Border Gateway Protocol 4 (BGP-4)]
3 Copyright (C) 1998 Kunihiro Ishiguro
4
5 This file is part of GNU Zebra.
6
7 GNU Zebra is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 GNU Zebra is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Zebra; see the file COPYING. If not, write to the Free
19 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22 #ifndef _QUAGGA_BGP_FSM_H
23 #define _QUAGGA_BGP_FSM_H
24
25 /* Macro for BGP read, write and timer thread. */
26 #define BGP_READ_ON(T,F,V) \
27 do { \
28 if (!T) \
29 { \
30 peer_lock (peer); \
31 THREAD_READ_ON(master,T,F,peer,V); \
32 } \
33 } while (0)
34
35 #define BGP_READ_OFF(T) \
36 do { \
37 if (T) \
38 { \
39 peer_unlock (peer); \
40 THREAD_READ_OFF(T); \
41 } \
42 } while (0)
43
44 #define BGP_WRITE_ON(T,F,V) \
45 do { \
46 if (!(T) && (peer->status != Deleted)) \
47 { \
48 peer_lock (peer); \
49 THREAD_WRITE_ON(master,(T),(F),peer,(V)); \
50 } \
51 } while (0)
52
53 #define BGP_WRITE_OFF(T) \
54 do { \
55 if (T) \
56 { \
57 peer_unlock (peer); \
58 THREAD_WRITE_OFF(T); \
59 } \
60 } while (0)
61
62 #define BGP_TIMER_ON(T,F,V) \
63 do { \
64 if (!(T) && (peer->status != Deleted)) \
65 { \
66 peer_lock (peer); \
67 THREAD_TIMER_ON(master,(T),(F),peer,(V)); \
68 } \
69 } while (0)
70
71 #define BGP_TIMER_OFF(T) \
72 do { \
73 if (T) \
74 { \
75 peer_unlock (peer); \
76 THREAD_TIMER_OFF(T); \
77 } \
78 } while (0)
79
80 #define BGP_EVENT_ADD(P,E) \
81 do { \
82 if ((P)->status != Deleted) \
83 { \
84 peer_lock (peer); /* bgp event reference */ \
85 thread_add_event (master, bgp_event, (P), (E)); \
86 } \
87 } while (0)
88
89 #define BGP_EVENT_DELETE(P) \
90 do { \
91 peer_unlock (peer); /* bgp event peer reference */ \
92 assert (peer); \
93 thread_cancel_event (master, (P)); \
94 } while (0)
95
96 #define BGP_EVENT_FLUSH_ADD(P,E) \
97 do { \
98 BGP_EVENT_DELETE(P); \
99 BGP_EVENT_ADD(P,E); \
100 } while (0)
101
102 /* Prototypes. */
103 extern int bgp_event (struct thread *);
104 extern int bgp_stop (struct peer *peer);
105 extern void bgp_timer_set (struct peer *);
106 extern void bgp_fsm_change_status (struct peer *peer, int status);
107 extern const char *peer_down_str[];
108
109 #endif /* _QUAGGA_BGP_FSM_H */