]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_io.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / bgpd / bgp_io.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP I/O.
3 * Implements packet I/O in a pthread.
4 * Copyright (C) 2017 Cumulus Networks
5 * Quentin Young
6 */
7
8 #ifndef _FRR_BGP_IO_H
9 #define _FRR_BGP_IO_H
10
11 #define BGP_WRITE_PACKET_MAX 64U
12 #define BGP_READ_PACKET_MAX 10U
13
14 #include "bgpd/bgpd.h"
15 #include "frr_pthread.h"
16
17 /**
18 * Start function for write thread.
19 *
20 * @param arg - unused
21 */
22 extern void *bgp_io_start(void *arg);
23
24 /**
25 * Start function for write thread.
26 *
27 * Uninitializes all resources and stops the thread.
28 *
29 * @param result - where to store data result, unused
30 */
31 extern int bgp_io_stop(void **result, struct frr_pthread *fpt);
32
33 /**
34 * Turns on packet writing for a peer.
35 *
36 * After this function is called, any packets placed on peer->obuf will be
37 * written to peer->fd until no more packets remain.
38 *
39 * Additionally, it becomes unsafe to perform socket actions on peer->fd.
40 *
41 * @param peer - peer to register
42 */
43 extern void bgp_writes_on(struct peer *peer);
44
45 /**
46 * Turns off packet writing for a peer.
47 *
48 * After this function returns, packets placed on peer->obuf will not be
49 * written to peer->fd by the I/O thread.
50 *
51 * After this function returns it becomes safe to perform socket actions on
52 * peer->fd.
53 *
54 * @param peer - peer to deregister
55 * @param flush - as described
56 */
57 extern void bgp_writes_off(struct peer *peer);
58
59 /**
60 * Turns on packet reading for a peer.
61 *
62 * After this function is called, any packets received on peer->fd will be read
63 * and copied into the FIFO queue peer->ibuf.
64 *
65 * Additionally, it becomes unsafe to perform socket actions on peer->fd.
66 *
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
69 *
70 * bgp_packet.c:bgp_process_packet()
71 *
72 * @param peer - peer to register
73 */
74 extern void bgp_reads_on(struct peer *peer);
75
76 /**
77 * Turns off packet reading for a peer.
78 *
79 * After this function is called, any packets received on peer->fd will not be
80 * read by the I/O thread.
81 *
82 * After this function returns it becomes safe to perform socket actions on
83 * peer->fd.
84 *
85 * @param peer - peer to deregister
86 */
87 extern void bgp_reads_off(struct peer *peer);
88
89 #endif /* _FRR_BGP_IO_H */