The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
bio_priv.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /**
19  * $Id: 55195b4b9de3fa5aebb18f7b86820b4b2f29fdb1 $
20  * @file lib/bio/bio_priv.h
21  * @brief Binary IO private functions
22  *
23  * Create abstract binary input / output buffers.
24  *
25  * @copyright 2024 Network RADIUS SAS (legal@networkradius.com)
26  */
27 RCSIDH(lib_bio_bio_priv_h, "$Id: 55195b4b9de3fa5aebb18f7b86820b4b2f29fdb1 $")
28 
29 #define _BIO_PRIVATE 1
30 #include <freeradius-devel/bio/base.h>
31 
32 typedef int (*fr_bio_shutdown_t)(fr_bio_t *bio);
33 
34 typedef struct fr_bio_common_s fr_bio_common_t;
35 
36 typedef struct {
41 
44 
45  fr_bio_io_t read_resume; //!< "unblocked" is too similar to "blocked"
48 
49 /** Common elements at the start of each private #fr_bio_t
50  *
51  */
52 #define FR_BIO_COMMON \
53  fr_bio_t bio; \
54  fr_bio_cb_funcs_t cb; \
55  fr_bio_priv_callback_t priv_cb
56 
59 };
60 
61 ssize_t fr_bio_next_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size);
62 
63 ssize_t fr_bio_next_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size);
64 
65 /** Chain one bio after another.
66  *
67  * @todo - this likely needs to be public
68  */
69 static inline void CC_HINT(nonnull) fr_bio_chain(fr_bio_t *first, fr_bio_t *second)
70 {
71  fr_assert(first->entry.prev == NULL);
72  fr_assert(first->entry.next == NULL);
73 
74  fr_assert(second->entry.prev == NULL);
75 
76  first->entry.next = &second->entry;
77  second->entry.prev = &first->entry;
78 }
79 
80 /** Remove a bio from a chain
81  *
82  * And reset prev/next ptrs to NULL.
83  *
84  * @todo - this likely needs to be public
85  */
86 static inline void CC_HINT(nonnull) fr_bio_unchain(fr_bio_t *bio)
87 {
88  fr_assert(fr_bio_prev(bio) != NULL);
89  fr_assert(fr_bio_next(bio) != NULL);
90 
92  bio->entry.prev = bio->entry.next = NULL;
93 }
94 
95 void fr_bio_eof(fr_bio_t *bio) CC_HINT(nonnull);
96 
97 int fr_bio_write_blocked(fr_bio_t *bio) CC_HINT(nonnull);
static int const char char buffer[256]
Definition: acutest.h:574
fr_dlist_t _CONST entry
in the linked list of multiple bios
Definition: base.h:118
int(* fr_bio_io_t)(fr_bio_t *bio)
Definition: base.h:83
static fr_bio_t * fr_bio_prev(fr_bio_t *bio)
Definition: base.h:121
static fr_bio_t * fr_bio_next(fr_bio_t *bio)
Definition: base.h:130
void(* fr_bio_callback_t)(fr_bio_t *bio)
Definition: base.h:85
Definition: base.h:112
fr_bio_io_t read_resume
"unblocked" is too similar to "blocked"
Definition: bio_priv.h:45
fr_bio_io_t write_blocked
Definition: bio_priv.h:43
fr_bio_io_t connected
Definition: bio_priv.h:37
fr_bio_callback_t failed
Definition: bio_priv.h:40
static void fr_bio_chain(fr_bio_t *first, fr_bio_t *second)
Chain one bio after another.
Definition: bio_priv.h:69
int fr_bio_write_blocked(fr_bio_t *bio)
Internal BIO function to tell all BIOs that it's blocked.
Definition: base.c:293
int(* fr_bio_shutdown_t)(fr_bio_t *bio)
Definition: bio_priv.h:32
fr_bio_io_t eof
Definition: bio_priv.h:39
fr_bio_io_t write_resume
Definition: bio_priv.h:46
fr_bio_callback_t shutdown
Definition: bio_priv.h:38
fr_bio_io_t read_blocked
Definition: bio_priv.h:42
void fr_bio_eof(fr_bio_t *bio)
Internal BIO function to run EOF callbacks.
Definition: base.c:244
ssize_t fr_bio_next_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
Internal bio function which just reads from the "next" bio.
Definition: base.c:51
static void fr_bio_unchain(fr_bio_t *bio)
Remove a bio from a chain.
Definition: bio_priv.h:86
ssize_t fr_bio_next_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
Internal bio function which just writes to the "next" bio.
Definition: base.c:74
#define RCSIDH(h, id)
Definition: build.h:482
fr_dlist_t * next
Definition: dlist.h:43
static void fr_dlist_entry_unlink(fr_dlist_t *entry)
Remove an item from the dlist when we don't have access to the head.
Definition: dlist.h:146
fr_dlist_t * prev
Definition: dlist.h:42
long int ssize_t
Definition: merged_model.c:24
fr_assert(0)
int nonnull(2, 5))