]>
Commit | Line | Data |
---|---|---|
03014d48 | 1 | /* BGP Keepalives. |
5c0c651c | 2 | * Implements a producer thread to generate BGP keepalives for peers. |
03014d48 | 3 | * Copyright (C) 2017 Cumulus Networks, Inc. |
5c0c651c | 4 | * Quentin Young |
03014d48 | 5 | * |
5c0c651c | 6 | * This file is part of FRRouting. |
03014d48 | 7 | * |
5c0c651c QY |
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 | |
03014d48 QY |
11 | * version. |
12 | * | |
5c0c651c QY |
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. | |
03014d48 | 17 | * |
5c0c651c QY |
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 | |
03014d48 | 21 | */ |
5c0c651c | 22 | |
becedef6 QY |
23 | #ifndef _FRR_BGP_KEEPALIVES_H |
24 | #define _FRR_BGP_KEEPALIVES_H | |
03014d48 | 25 | |
424ab01d | 26 | #include "frr_pthread.h" |
03014d48 QY |
27 | #include "bgpd.h" |
28 | ||
becedef6 QY |
29 | /** |
30 | * Turns on keepalives for a peer. | |
03014d48 QY |
31 | * |
32 | * This function adds the peer to an internal list of peers to generate | |
33 | * keepalives for. | |
34 | * | |
35 | * At set intervals, a BGP KEEPALIVE packet is generated and placed on | |
36 | * peer->obuf. This operation is thread-safe with respect to peer->obuf. | |
37 | * | |
38 | * peer->v_keepalive determines the interval. Changing this value before | |
b72b6f4f | 39 | * unregistering this peer with bgp_keepalives_off() results in undefined |
03014d48 QY |
40 | * behavior. |
41 | * | |
42 | * If the peer is already registered for keepalives via this function, nothing | |
43 | * happens. | |
44 | */ | |
b72b6f4f | 45 | extern void bgp_keepalives_on(struct peer *); |
03014d48 | 46 | |
becedef6 QY |
47 | /** |
48 | * Turns off keepalives for a peer. | |
03014d48 QY |
49 | * |
50 | * Removes the peer from the internal list of peers to generate keepalives for. | |
51 | * | |
52 | * If the peer is already unregistered for keepalives, nothing happens. | |
53 | */ | |
b72b6f4f | 54 | extern void bgp_keepalives_off(struct peer *); |
03014d48 | 55 | |
becedef6 QY |
56 | /** |
57 | * Pre-run initialization function for keepalives pthread. | |
419dfe6a QY |
58 | * |
59 | * Initializes synchronization primitives. This should be called before | |
60 | * anything else to avoid race conditions. | |
61 | */ | |
b72b6f4f | 62 | extern void bgp_keepalives_init(void); |
419dfe6a | 63 | |
becedef6 QY |
64 | /** |
65 | * Entry function for keepalives pthread. | |
03014d48 QY |
66 | * |
67 | * This function loops over an internal list of peers, generating keepalives at | |
68 | * regular intervals as determined by each peer's keepalive timer. | |
69 | * | |
b72b6f4f | 70 | * See bgp_keepalives_on() for additional details. |
03014d48 QY |
71 | * |
72 | * @param arg pthread arg, not used | |
73 | */ | |
b72b6f4f | 74 | extern void *bgp_keepalives_start(void *arg); |
03014d48 | 75 | |
becedef6 QY |
76 | /** |
77 | * Poking function for keepalives pthread. | |
03014d48 QY |
78 | * |
79 | * Under normal circumstances the pthread will automatically wake itself | |
80 | * whenever it is necessary to do work. This function may be used to force the | |
81 | * thread to wake up and see if there is any work to do, or if it is time to | |
82 | * die. | |
83 | * | |
b72b6f4f | 84 | * It is not necessary to call this after bgp_keepalives_on(). |
03014d48 | 85 | */ |
b72b6f4f | 86 | extern void bgp_keepalives_wake(void); |
03014d48 | 87 | |
5c0c651c QY |
88 | /** |
89 | * Stops the thread and blocks until it terminates. | |
90 | */ | |
a715eab3 | 91 | int bgp_keepalives_stop(struct frr_pthread *fpt, void **result); |
0ca8b79f | 92 | |
becedef6 | 93 | #endif /* _FRR_BGP_KEEPALIVES_H */ |