]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_io.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Implements packet I/O in a pthread.
4 * Copyright (C) 2017 Cumulus Networks
11 #define BGP_WRITE_PACKET_MAX 64U
12 #define BGP_READ_PACKET_MAX 10U
14 #include "bgpd/bgpd.h"
15 #include "frr_pthread.h"
18 * Start function for write thread.
22 extern void *bgp_io_start(void *arg
);
25 * Start function for write thread.
27 * Uninitializes all resources and stops the thread.
29 * @param result - where to store data result, unused
31 extern int bgp_io_stop(void **result
, struct frr_pthread
*fpt
);
34 * Turns on packet writing for a peer.
36 * After this function is called, any packets placed on peer->obuf will be
37 * written to peer->fd until no more packets remain.
39 * Additionally, it becomes unsafe to perform socket actions on peer->fd.
41 * @param peer - peer to register
43 extern void bgp_writes_on(struct peer
*peer
);
46 * Turns off packet writing for a peer.
48 * After this function returns, packets placed on peer->obuf will not be
49 * written to peer->fd by the I/O thread.
51 * After this function returns it becomes safe to perform socket actions on
54 * @param peer - peer to deregister
55 * @param flush - as described
57 extern void bgp_writes_off(struct peer
*peer
);
60 * Turns on packet reading for a peer.
62 * After this function is called, any packets received on peer->fd will be read
63 * and copied into the FIFO queue peer->ibuf.
65 * Additionally, it becomes unsafe to perform socket actions on peer->fd.
67 * Whenever one or more packets are placed onto peer->ibuf, a task of type
68 * THREAD_EVENT will be placed on the main thread whose handler is
70 * bgp_packet.c:bgp_process_packet()
72 * @param peer - peer to register
74 extern void bgp_reads_on(struct peer
*peer
);
77 * Turns off packet reading for a peer.
79 * After this function is called, any packets received on peer->fd will not be
80 * read by the I/O thread.
82 * After this function returns it becomes safe to perform socket actions on
85 * @param peer - peer to deregister
87 extern void bgp_reads_off(struct peer
*peer
);
89 #endif /* _FRR_BGP_IO_H */