]>
Commit | Line | Data |
---|---|---|
51abb4b4 QY |
1 | /* BGP I/O. |
2 | * Implements packet I/O in a pthread. | |
3 | * Copyright (C) 2017 Cumulus Networks | |
4 | * Quentin Young | |
5 | * | |
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. | |
10 | * | |
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. | |
15 | * | |
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, | |
19 | * MA 02110-1301 USA | |
56257a44 QY |
20 | */ |
21 | ||
22 | #ifndef _FRR_BGP_IO_H | |
23 | #define _FRR_BGP_IO_H | |
24 | ||
8fa7732f | 25 | #define BGP_WRITE_PACKET_MAX 64U |
555e09d4 QY |
26 | #define BGP_READ_PACKET_MAX 10U |
27 | ||
56257a44 | 28 | #include "bgpd/bgpd.h" |
42cf651e | 29 | #include "frr_pthread.h" |
56257a44 | 30 | |
88b24dee | 31 | /** |
f09a656d | 32 | * Start function for write thread. |
88b24dee | 33 | * |
f09a656d | 34 | * @param arg - unused |
88b24dee | 35 | */ |
f09a656d | 36 | extern void *bgp_io_start(void *arg); |
88b24dee | 37 | |
56257a44 QY |
38 | /** |
39 | * Start function for write thread. | |
40 | * | |
41 | * Uninitializes all resources and stops the thread. | |
42 | * | |
424ab01d | 43 | * @param result - where to store data result, unused |
56257a44 | 44 | */ |
424ab01d | 45 | extern int bgp_io_stop(void **result, struct frr_pthread *fpt); |
56257a44 QY |
46 | |
47 | /** | |
424ab01d | 48 | * Turns on packet writing for a peer. |
56257a44 QY |
49 | * |
50 | * After this function is called, any packets placed on peer->obuf will be | |
51abb4b4 | 51 | * written to peer->fd until no more packets remain. |
56257a44 | 52 | * |
51abb4b4 | 53 | * Additionally, it becomes unsafe to perform socket actions on peer->fd. |
56257a44 QY |
54 | * |
55 | * @param peer - peer to register | |
56 | */ | |
424ab01d | 57 | extern void bgp_writes_on(struct peer *peer); |
56257a44 QY |
58 | |
59 | /** | |
424ab01d | 60 | * Turns off packet writing for a peer. |
56257a44 | 61 | * |
51abb4b4 QY |
62 | * After this function returns, packets placed on peer->obuf will not be |
63 | * written to peer->fd by the I/O thread. | |
56257a44 | 64 | * |
51abb4b4 QY |
65 | * After this function returns it becomes safe to perform socket actions on |
66 | * peer->fd. | |
56257a44 QY |
67 | * |
68 | * @param peer - peer to deregister | |
424ab01d QY |
69 | * @param flush - as described |
70 | */ | |
71 | extern void bgp_writes_off(struct peer *peer); | |
72 | ||
73 | /** | |
74 | * Turns on packet reading for a peer. | |
75 | * | |
76 | * After this function is called, any packets received on peer->fd will be read | |
51abb4b4 | 77 | * and copied into the FIFO queue peer->ibuf. |
424ab01d | 78 | * |
51abb4b4 | 79 | * Additionally, it becomes unsafe to perform socket actions on peer->fd. |
424ab01d | 80 | * |
51abb4b4 QY |
81 | * Whenever one or more packets are placed onto peer->ibuf, a task of type |
82 | * THREAD_EVENT will be placed on the main thread whose handler is | |
424ab01d | 83 | * |
51abb4b4 | 84 | * bgp_packet.c:bgp_process_packet() |
424ab01d QY |
85 | * |
86 | * @param peer - peer to register | |
56257a44 | 87 | */ |
424ab01d | 88 | extern void bgp_reads_on(struct peer *peer); |
56257a44 QY |
89 | |
90 | /** | |
424ab01d QY |
91 | * Turns off packet reading for a peer. |
92 | * | |
93 | * After this function is called, any packets received on peer->fd will not be | |
51abb4b4 | 94 | * read by the I/O thread. |
424ab01d | 95 | * |
51abb4b4 QY |
96 | * After this function returns it becomes safe to perform socket actions on |
97 | * peer->fd. | |
424ab01d QY |
98 | * |
99 | * @param peer - peer to deregister | |
56257a44 | 100 | */ |
424ab01d | 101 | extern void bgp_reads_off(struct peer *peer); |
56257a44 QY |
102 | |
103 | #endif /* _FRR_BGP_IO_H */ |