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: 2b256fb65831b810cd4a3bd03d977c005a79f128 $
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: 2b256fb65831b810cd4a3bd03d977c005a79f128 $")
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 /** Common elements at the start of each private #fr_bio_t
37  *
38  */
39 #define FR_BIO_COMMON \
40  fr_bio_t bio; \
41  fr_bio_cb_funcs_t cb
42 
45 };
46 
47 ssize_t fr_bio_next_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size);
48 
49 ssize_t fr_bio_next_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size);
50 
51 ssize_t fr_bio_eof_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size);
52 
53 /** Chain one bio after another.
54  *
55  * @todo - this likely needs to be public
56  */
57 static inline void CC_HINT(nonnull) fr_bio_chain(fr_bio_t *first, fr_bio_t *second)
58 {
59  fr_assert(first->entry.prev == NULL);
60  fr_assert(first->entry.next == NULL);
61 
62  fr_assert(second->entry.prev == NULL);
63 
64  first->entry.next = &second->entry;
65  second->entry.prev = &first->entry;
66 }
67 
68 /** Remove a bio from a chain
69  *
70  * And reset prev/next ptrs to NULL.
71  *
72  * @todo - this likely needs to be public
73  */
74 static inline void CC_HINT(nonnull) fr_bio_unchain(fr_bio_t *bio)
75 {
76  fr_assert(fr_bio_prev(bio) != NULL);
77  fr_assert(fr_bio_next(bio) != NULL);
78 
80  bio->entry.prev = bio->entry.next = NULL;
81 }
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:109
static fr_bio_t * fr_bio_prev(fr_bio_t *bio)
Definition: base.h:112
static fr_bio_t * fr_bio_next(fr_bio_t *bio)
Definition: base.h:121
Definition: base.h:103
static void fr_bio_chain(fr_bio_t *first, fr_bio_t *second)
Chain one bio after another.
Definition: bio_priv.h:57
int(* fr_bio_shutdown_t)(fr_bio_t *bio)
Definition: bio_priv.h:32
ssize_t fr_bio_eof_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
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:59
static void fr_bio_unchain(fr_bio_t *bio)
Remove a bio from a chain.
Definition: bio_priv.h:74
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:82
#define RCSIDH(h, id)
Definition: build.h:445
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
static fr_bio_t * bio
Definition: radclient-ng.c:86
fr_assert(0)
int nonnull(2, 5))