3 * Implemented server-style in a pthread.
4 * --------------------------------------
5 * Copyright (C) 2017 Cumulus Networks, Inc.
7 * This file is part of Free Range Routing.
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
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
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
24 #ifndef _BGP_KEEPALIVES_H_
25 #define _BGP_KEEPALIVES_H_
27 #include "frr_pthread.h"
30 /* Thread control flag.
32 * Setting this flag to 'false' while the thread is running will result in
35 extern bool bgp_keepalives_thread_run
;
37 /* Turns on keepalives for a peer.
39 * This function adds the peer to an internal list of peers to generate
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.
45 * peer->v_keepalive determines the interval. Changing this value before
46 * unregistering this peer with peer_keepalives_off() results in undefined
49 * If the peer is already registered for keepalives via this function, nothing
52 extern void peer_keepalives_on(struct peer
*);
54 /* Turns off keepalives for a peer.
56 * Removes the peer from the internal list of peers to generate keepalives for.
58 * If the peer is already unregistered for keepalives, nothing happens.
60 extern void peer_keepalives_off(struct peer
*);
62 /* Pre-run initialization function for keepalives pthread.
64 * Initializes synchronization primitives. This should be called before
65 * anything else to avoid race conditions.
67 extern void peer_keepalives_init(void);
69 /* Entry function for keepalives pthread.
71 * This function loops over an internal list of peers, generating keepalives at
72 * regular intervals as determined by each peer's keepalive timer.
74 * See peer_keepalives_on() for additional details.
76 * @param arg pthread arg, not used
78 extern void *peer_keepalives_start(void *arg
);
80 /* Poking function for keepalives pthread.
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
87 * It is not necessary to call this after peer_keepalives_on().
89 extern void peer_keepalives_wake(void);
92 int peer_keepalives_stop(void **result
, struct frr_pthread
*fpt
);
94 #endif /* _BGP_KEEPALIVES_H */