]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_io.h
2 * Implements packet I/O in a pthread.
3 * Copyright (C) 2017 Cumulus Networks
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
25 #define BGP_WRITE_PACKET_MAX 10U
26 #define BGP_READ_PACKET_MAX 10U
28 #include "bgpd/bgpd.h"
29 #include "frr_pthread.h"
32 * Initializes data structures and flags for the write thread.
34 * This function should be called from the main thread before
35 * bgp_writes_start() is invoked.
37 extern void bgp_io_init(void);
40 * Ensure that the BGP IO thread is actually up and running
42 * This function must be called immediately after the thread
43 * has been created for running. This is because we want
44 * to make sure that the io thread is ready before other
45 * threads start attempting to use it.
47 extern void bgp_io_running(void);
50 * Start function for write thread.
54 extern void *bgp_io_start(void *arg
);
57 * Start function for write thread.
59 * Uninitializes all resources and stops the thread.
61 * @param result - where to store data result, unused
63 extern int bgp_io_stop(void **result
, struct frr_pthread
*fpt
);
66 * Turns on packet writing for a peer.
68 * After this function is called, any packets placed on peer->obuf will be
69 * written to peer->fd until no more packets remain.
71 * Additionally, it becomes unsafe to perform socket actions on peer->fd.
73 * @param peer - peer to register
75 extern void bgp_writes_on(struct peer
*peer
);
78 * Turns off packet writing for a peer.
80 * After this function returns, packets placed on peer->obuf will not be
81 * written to peer->fd by the I/O thread.
83 * After this function returns it becomes safe to perform socket actions on
86 * @param peer - peer to deregister
87 * @param flush - as described
89 extern void bgp_writes_off(struct peer
*peer
);
92 * Turns on packet reading for a peer.
94 * After this function is called, any packets received on peer->fd will be read
95 * and copied into the FIFO queue peer->ibuf.
97 * Additionally, it becomes unsafe to perform socket actions on peer->fd.
99 * Whenever one or more packets are placed onto peer->ibuf, a task of type
100 * THREAD_EVENT will be placed on the main thread whose handler is
102 * bgp_packet.c:bgp_process_packet()
104 * @param peer - peer to register
106 extern void bgp_reads_on(struct peer
*peer
);
109 * Turns off packet reading for a peer.
111 * After this function is called, any packets received on peer->fd will not be
112 * read by the I/O thread.
114 * After this function returns it becomes safe to perform socket actions on
117 * @param peer - peer to deregister
119 extern void bgp_reads_off(struct peer
*peer
);
121 #endif /* _FRR_BGP_IO_H */