]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_fsm.h
build: split off libfrrsnmp
[mirror_frr.git] / bgpd / bgp_fsm.h
CommitLineData
718e3744 1/* 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
00d252cb 22#ifndef _QUAGGA_BGP_FSM_H
23#define _QUAGGA_BGP_FSM_H
24
718e3744 25/* Macro for BGP read, write and timer thread. */
200df115 26#define BGP_READ_ON(T,F,V) \
27 do { \
9fde6624 28 if (!(T) && (peer->status != Deleted)) \
9229d914 29 THREAD_READ_ON(bm->master,T,F,peer,V); \
200df115 30 } while (0)
718e3744 31
200df115 32#define BGP_READ_OFF(T) \
33 do { \
34 if (T) \
9fde6624 35 THREAD_READ_OFF(T); \
200df115 36 } while (0)
718e3744 37
200df115 38#define BGP_WRITE_ON(T,F,V) \
39 do { \
ca058a30 40 if (!(T) && (peer->status != Deleted)) \
9229d914 41 THREAD_WRITE_ON(bm->master,(T),(F),peer,(V)); \
200df115 42 } while (0)
3f9c7369
DS
43
44#define BGP_PEER_WRITE_ON(T,F,V, peer) \
45 do { \
46 if (!(T) && ((peer)->status != Deleted)) \
9229d914 47 THREAD_WRITE_ON(bm->master,(T),(F),(peer),(V)); \
3f9c7369
DS
48 } while (0)
49
200df115 50#define BGP_WRITE_OFF(T) \
51 do { \
52 if (T) \
9fde6624 53 THREAD_WRITE_OFF(T); \
200df115 54 } while (0)
718e3744 55
200df115 56#define BGP_TIMER_ON(T,F,V) \
57 do { \
ca058a30 58 if (!(T) && (peer->status != Deleted)) \
9229d914 59 THREAD_TIMER_ON(bm->master,(T),(F),peer,(V)); \
200df115 60 } while (0)
718e3744 61
200df115 62#define BGP_TIMER_OFF(T) \
63 do { \
64 if (T) \
9fde6624 65 THREAD_TIMER_OFF(T); \
200df115 66 } while (0)
67
68#define BGP_EVENT_ADD(P,E) \
69 do { \
ca058a30 70 if ((P)->status != Deleted) \
9229d914 71 thread_add_event (bm->master, bgp_event, (P), (E)); \
200df115 72 } while (0)
73
9fde6624 74#define BGP_EVENT_FLUSH(P) \
200df115 75 do { \
200df115 76 assert (peer); \
9229d914 77 thread_cancel_event (bm->master, (P)); \
200df115 78 } while (0)
718e3744 79
cb1faec9
DS
80#define BGP_MSEC_JITTER 10
81
718e3744 82/* Prototypes. */
fc9a856f 83extern void bgp_fsm_nht_update(struct peer *, int valid);
00d252cb 84extern int bgp_event (struct thread *);
1ff9a340 85extern int bgp_event_update (struct peer *, int event);
00d252cb 86extern int bgp_stop (struct peer *peer);
87extern void bgp_timer_set (struct peer *);
3f9c7369 88extern int bgp_routeadv_timer (struct thread *);
00d252cb 89extern void bgp_fsm_change_status (struct peer *peer, int status);
fd79ac91 90extern const char *peer_down_str[];
f188f2c4 91extern void bgp_update_delay_end (struct bgp *);
abc920f8
DS
92extern void bgp_maxmed_update (struct bgp *);
93extern int bgp_maxmed_onstartup_configured (struct bgp *);
94extern int bgp_maxmed_onstartup_active (struct bgp *);
00d252cb 95
cb1faec9
DS
96/**
97 * Start the route advertisement timer (that honors MRAI) for all the
98 * peers. Typically called at the end of initial convergence, coming
99 * out of read-only mode.
100 */
101extern void bgp_start_routeadv (struct bgp *);
102
103/**
104 * See if the route advertisement timer needs to be adjusted for a
105 * peer. For example, if the last update was written to the peer a
106 * long while back, we don't need to wait for the periodic advertisement
107 * timer to expire to send the new set of prefixes. It should fire
108 * instantly and updates should go out sooner.
109 */
110extern void bgp_adjust_routeadv (struct peer *);
111
00d252cb 112#endif /* _QUAGGA_BGP_FSM_H */