3 Implements a consumer thread to flush packets destined for remote peers.
5 Copyright (C) 2017 Cumulus Networks
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING; if not, write to the
19 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
26 #include "bgpd/bgpd.h"
29 * Control variable for write thread.
31 * Setting this variable to false and calling peer_writes_wake() will
32 * eventually result in thread termination.
34 extern bool bgp_packet_writes_thread_run
;
37 * Initializes data structures and flags for the write thread.
39 * This function should be called from the main thread before
40 * peer_writes_start() is invoked.
42 extern void peer_writes_init(void);
45 * Start function for write thread.
47 * This function should be passed to pthread_create() during BGP startup.
49 extern void *peer_writes_start(void *arg
);
52 * Start function for write thread.
54 * Uninitializes all resources and stops the thread.
56 * @param result -- where to store data result, unused
58 extern int peer_writes_stop(void **result
);
61 * Registers a peer with the write thread.
63 * This function adds the peer to an internal data structure, which must be
64 * locked for write access. This call will block until the structure can be
67 * After this function is called, any packets placed on peer->obuf will be
68 * written to peer->fd at regular intervals.
70 * This function increments the peer reference counter with peer_lock().
72 * If the peer is already registered, nothing happens.
74 * @param peer - peer to register
76 extern void peer_writes_on(struct peer
*peer
);
79 * Deregisters a peer with the write thread.
81 * This function removes the peer from an internal data structure, which must
82 * be locked for write access. This call will block until the structure can be
85 * After this function is called, any packets placed on peer->obuf will not be
86 * written to peer->fd.
88 * This function decrements the peer reference counter with peer_unlock().
90 * If the peer is not registered, nothing happens.
92 * @param peer - peer to deregister
94 extern void peer_writes_off(struct peer
*peer
);
97 * Notifies the write thread that there is work to be done.
99 * This function has the effect of waking the write thread if it is sleeping.
100 * If the thread is not sleeping, this signal will be ignored.
102 extern void peer_writes_wake(void);
104 #endif /* _FRR_BGP_IO_H */