]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_keepalives.h
bgpd: restyle bgp_keepalives.[ch]
[mirror_frr.git] / bgpd / bgp_keepalives.h
1 /* BGP Keepalives.
2 * Implements a producer thread to generate BGP keepalives for peers.
3 * Copyright (C) 2017 Cumulus Networks, Inc.
4 * Quentin Young
5 *
6 * This file is part of FRRouting.
7 *
8 * FRRouting is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any later
11 * version.
12 *
13 * FRRouting is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #ifndef _BGP_KEEPALIVES_H_
24 #define _BGP_KEEPALIVES_H_
25
26 #include "frr_pthread.h"
27 #include "bgpd.h"
28
29 /* Turns on keepalives for a peer.
30 *
31 * This function adds the peer to an internal list of peers to generate
32 * keepalives for.
33 *
34 * At set intervals, a BGP KEEPALIVE packet is generated and placed on
35 * peer->obuf. This operation is thread-safe with respect to peer->obuf.
36 *
37 * peer->v_keepalive determines the interval. Changing this value before
38 * unregistering this peer with bgp_keepalives_off() results in undefined
39 * behavior.
40 *
41 * If the peer is already registered for keepalives via this function, nothing
42 * happens.
43 */
44 extern void bgp_keepalives_on(struct peer *);
45
46 /* Turns off keepalives for a peer.
47 *
48 * Removes the peer from the internal list of peers to generate keepalives for.
49 *
50 * If the peer is already unregistered for keepalives, nothing happens.
51 */
52 extern void bgp_keepalives_off(struct peer *);
53
54 /* Pre-run initialization function for keepalives pthread.
55 *
56 * Initializes synchronization primitives. This should be called before
57 * anything else to avoid race conditions.
58 */
59 extern void bgp_keepalives_init(void);
60
61 /* Entry function for keepalives pthread.
62 *
63 * This function loops over an internal list of peers, generating keepalives at
64 * regular intervals as determined by each peer's keepalive timer.
65 *
66 * See bgp_keepalives_on() for additional details.
67 *
68 * @param arg pthread arg, not used
69 */
70 extern void *bgp_keepalives_start(void *arg);
71
72 /* Poking function for keepalives pthread.
73 *
74 * Under normal circumstances the pthread will automatically wake itself
75 * whenever it is necessary to do work. This function may be used to force the
76 * thread to wake up and see if there is any work to do, or if it is time to
77 * die.
78 *
79 * It is not necessary to call this after bgp_keepalives_on().
80 */
81 extern void bgp_keepalives_wake(void);
82
83 /**
84 * Stops the thread and blocks until it terminates.
85 */
86 int bgp_keepalives_stop(void **result, struct frr_pthread *fpt);
87
88 #endif /* _BGP_KEEPALIVES_H */