blob: a749f8ea31d35419868d05cf57b0f778721f7d39 [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 { \
Paul Jakma9fde6622006-09-14 03:02:02 +000028 if (!(T) && (peer->status != Deleted)) \
29 THREAD_READ_ON(master,T,F,peer,V); \
paul200df112005-06-01 11:17:05 +000030 } while (0)
paul718e3742002-12-13 20:15:29 +000031
paul200df112005-06-01 11:17:05 +000032#define BGP_READ_OFF(T) \
33 do { \
34 if (T) \
Paul Jakma9fde6622006-09-14 03:02:02 +000035 THREAD_READ_OFF(T); \
paul200df112005-06-01 11:17:05 +000036 } while (0)
paul718e3742002-12-13 20:15:29 +000037
paul200df112005-06-01 11:17:05 +000038#define BGP_WRITE_ON(T,F,V) \
39 do { \
Paul Jakmaca058a32006-09-14 02:58:49 +000040 if (!(T) && (peer->status != Deleted)) \
Paul Jakma9fde6622006-09-14 03:02:02 +000041 THREAD_WRITE_ON(master,(T),(F),peer,(V)); \
paul200df112005-06-01 11:17:05 +000042 } while (0)
43
44#define BGP_WRITE_OFF(T) \
45 do { \
46 if (T) \
Paul Jakma9fde6622006-09-14 03:02:02 +000047 THREAD_WRITE_OFF(T); \
paul200df112005-06-01 11:17:05 +000048 } while (0)
paul718e3742002-12-13 20:15:29 +000049
paul200df112005-06-01 11:17:05 +000050#define BGP_TIMER_ON(T,F,V) \
51 do { \
Paul Jakmaca058a32006-09-14 02:58:49 +000052 if (!(T) && (peer->status != Deleted)) \
Paul Jakma9fde6622006-09-14 03:02:02 +000053 THREAD_TIMER_ON(master,(T),(F),peer,(V)); \
paul200df112005-06-01 11:17:05 +000054 } while (0)
paul718e3742002-12-13 20:15:29 +000055
paul200df112005-06-01 11:17:05 +000056#define BGP_TIMER_OFF(T) \
57 do { \
58 if (T) \
Paul Jakma9fde6622006-09-14 03:02:02 +000059 THREAD_TIMER_OFF(T); \
paul200df112005-06-01 11:17:05 +000060 } while (0)
61
62#define BGP_EVENT_ADD(P,E) \
63 do { \
Paul Jakmaca058a32006-09-14 02:58:49 +000064 if ((P)->status != Deleted) \
Paul Jakma9fde6622006-09-14 03:02:02 +000065 thread_add_event (master, bgp_event, (P), (E)); \
paul200df112005-06-01 11:17:05 +000066 } while (0)
67
Paul Jakma9fde6622006-09-14 03:02:02 +000068#define BGP_EVENT_FLUSH(P) \
paul200df112005-06-01 11:17:05 +000069 do { \
paul200df112005-06-01 11:17:05 +000070 assert (peer); \
71 thread_cancel_event (master, (P)); \
72 } while (0)
paul718e3742002-12-13 20:15:29 +000073
74/* Prototypes. */
paul00d252c2005-05-23 14:19:54 +000075extern int bgp_event (struct thread *);
76extern int bgp_stop (struct peer *peer);
77extern void bgp_timer_set (struct peer *);
78extern void bgp_fsm_change_status (struct peer *peer, int status);
paulfd79ac92004-10-13 05:06:08 +000079extern const char *peer_down_str[];
paul00d252c2005-05-23 14:19:54 +000080
81#endif /* _QUAGGA_BGP_FSM_H */