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