paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 22 | #ifndef _QUAGGA_BGP_FSM_H |
| 23 | #define _QUAGGA_BGP_FSM_H |
| 24 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 25 | /* Macro for BGP read, write and timer thread. */ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 26 | #define BGP_READ_ON(T,F,V) \ |
| 27 | do { \ |
Paul Jakma | 9fde662 | 2006-09-14 03:02:02 +0000 | [diff] [blame] | 28 | if (!(T) && (peer->status != Deleted)) \ |
Donald Sharp | 774914f | 2015-10-14 08:50:39 -0400 | [diff] [blame] | 29 | THREAD_READ_ON(bm->master,T,F,peer,V); \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 30 | } while (0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 31 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 32 | #define BGP_READ_OFF(T) \ |
| 33 | do { \ |
| 34 | if (T) \ |
Paul Jakma | 9fde662 | 2006-09-14 03:02:02 +0000 | [diff] [blame] | 35 | THREAD_READ_OFF(T); \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 36 | } while (0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 38 | #define BGP_WRITE_ON(T,F,V) \ |
| 39 | do { \ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 40 | if (!(T) && (peer->status != Deleted)) \ |
Donald Sharp | 774914f | 2015-10-14 08:50:39 -0400 | [diff] [blame] | 41 | THREAD_WRITE_ON(bm->master,(T),(F),peer,(V)); \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 42 | } while (0) |
| 43 | |
| 44 | #define BGP_WRITE_OFF(T) \ |
| 45 | do { \ |
| 46 | if (T) \ |
Paul Jakma | 9fde662 | 2006-09-14 03:02:02 +0000 | [diff] [blame] | 47 | THREAD_WRITE_OFF(T); \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 48 | } while (0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 49 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 50 | #define BGP_TIMER_ON(T,F,V) \ |
| 51 | do { \ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 52 | if (!(T) && (peer->status != Deleted)) \ |
Donald Sharp | 774914f | 2015-10-14 08:50:39 -0400 | [diff] [blame] | 53 | THREAD_TIMER_ON(bm->master,(T),(F),peer,(V)); \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 54 | } while (0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 55 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 56 | #define BGP_TIMER_OFF(T) \ |
| 57 | do { \ |
| 58 | if (T) \ |
Paul Jakma | 9fde662 | 2006-09-14 03:02:02 +0000 | [diff] [blame] | 59 | THREAD_TIMER_OFF(T); \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 60 | } while (0) |
| 61 | |
| 62 | #define BGP_EVENT_ADD(P,E) \ |
| 63 | do { \ |
Paul Jakma | ca058a3 | 2006-09-14 02:58:49 +0000 | [diff] [blame] | 64 | if ((P)->status != Deleted) \ |
Donald Sharp | 774914f | 2015-10-14 08:50:39 -0400 | [diff] [blame] | 65 | thread_add_event (bm->master, bgp_event, (P), (E)); \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 66 | } while (0) |
| 67 | |
Paul Jakma | 9fde662 | 2006-09-14 03:02:02 +0000 | [diff] [blame] | 68 | #define BGP_EVENT_FLUSH(P) \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 69 | do { \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 70 | assert (peer); \ |
Donald Sharp | 774914f | 2015-10-14 08:50:39 -0400 | [diff] [blame] | 71 | thread_cancel_event (bm->master, (P)); \ |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 72 | } while (0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 73 | |
| 74 | /* Prototypes. */ |
Dinesh Dutt | d9ab53a | 2015-05-19 17:47:21 -0700 | [diff] [blame^] | 75 | extern void bgp_fsm_nht_update(struct peer *, int valid); |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 76 | extern int bgp_event (struct thread *); |
| 77 | extern int bgp_stop (struct peer *peer); |
| 78 | extern void bgp_timer_set (struct peer *); |
| 79 | extern void bgp_fsm_change_status (struct peer *peer, int status); |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 80 | extern const char *peer_down_str[]; |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 81 | |
| 82 | #endif /* _QUAGGA_BGP_FSM_H */ |