blob: e90f3b433c97eba851cea200fe2602240cef635a [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP-4 Finite State Machine
2 From RFC1771 [A Border Gateway Protocol 4 (BGP-4)]
3 Copyright (C) 1998 Kunihiro Ishiguro
4
5This file is part of GNU Zebra.
6
7GNU Zebra is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by the
9Free Software Foundation; either version 2, or (at your option) any
10later version.
11
12GNU Zebra is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Zebra; see the file COPYING. If not, write to the Free
19Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA. */
21
paul00d252c2005-05-23 14:19:54 +000022#ifndef _QUAGGA_BGP_FSM_H
23#define _QUAGGA_BGP_FSM_H
24
paul718e3742002-12-13 20:15:29 +000025/* Macro for BGP read, write and timer thread. */
paul200df112005-06-01 11:17:05 +000026#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)
paul718e3742002-12-13 20:15:29 +000034
paul200df112005-06-01 11:17:05 +000035#define BGP_READ_OFF(T) \
36 do { \
37 if (T) \
38 { \
39 peer_unlock (peer); \
40 THREAD_READ_OFF(T); \
41 } \
42 } while (0)
paul718e3742002-12-13 20:15:29 +000043
paul200df112005-06-01 11:17:05 +000044#define BGP_WRITE_ON(T,F,V) \
45 do { \
46 if (!T) \
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)
paul718e3742002-12-13 20:15:29 +000061
paul200df112005-06-01 11:17:05 +000062#define BGP_TIMER_ON(T,F,V) \
63 do { \
64 if (!T) \
65 { \
66 peer_lock (peer); \
67 THREAD_TIMER_ON(master,(T),(F),peer,(V)); \
68 } \
69 } while (0)
paul718e3742002-12-13 20:15:29 +000070
paul200df112005-06-01 11:17:05 +000071#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 peer_lock (peer); /* bgp event reference */ \
83 thread_add_event (master, bgp_event, (P), (E)); \
84 } while (0)
85
86#define BGP_EVENT_DELETE(P) \
87 do { \
88 peer_unlock (peer); /* bgp event peer reference */ \
89 assert (peer); \
90 thread_cancel_event (master, (P)); \
91 } while (0)
paul718e3742002-12-13 20:15:29 +000092
93/* Prototypes. */
paul00d252c2005-05-23 14:19:54 +000094extern int bgp_event (struct thread *);
95extern int bgp_stop (struct peer *peer);
96extern void bgp_timer_set (struct peer *);
97extern void bgp_fsm_change_status (struct peer *peer, int status);
paulfd79ac92004-10-13 05:06:08 +000098extern const char *peer_down_str[];
paul00d252c2005-05-23 14:19:54 +000099
100#endif /* _QUAGGA_BGP_FSM_H */