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