The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
network.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: 7270ee76a4e1b064a7c2eb43018b719d28647efa $
20  * @file lib/bio/network.h
21  * @brief BIO patricia trie filtering handlers
22  *
23  * @copyright 2024 Network RADIUS SAS (legal@networkradius.com)
24  */
25 RCSIDH(lib_bio_network_h, "$Id: 7270ee76a4e1b064a7c2eb43018b719d28647efa $")
26 
27 #include <freeradius-devel/util/inet.h>
28 
29 fr_bio_t *fr_bio_network_alloc(TALLOC_CTX *ctx, fr_ipaddr_t const *allow, fr_ipaddr_t const *deny,
30  fr_bio_read_t discard, fr_bio_t *next) CC_HINT(nonnull(1,2,5));
31 
32 fr_trie_t *fr_bio_network_trie_alloc(TALLOC_CTX *ctx, int af, fr_ipaddr_t const *allow, fr_ipaddr_t const *deny);
33 
34 /*
35  * IP address lookups return one of these two magic pointers.
36  *
37  * NULL means "nothing matches", which should also be interpreted as "deny".
38  *
39  * The difference between "NULL" and "deny" is that NULL is an IP address which was never inserted into
40  * the trie. Whereas "deny" means that there is a parent "allow" range, and we are carving out a "deny"
41  * in the middle of that range.
42  */
43 #define FR_BIO_NETWORK_ALLOW ((void *) (-1))
44 #define FR_BIO_NETWORK_DENY ((void *) (-2))
ssize_t(* fr_bio_read_t)(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
Do a raw read from a socket, or other data source.
Definition: base.h:81
Definition: base.h:103
fr_trie_t * fr_bio_network_trie_alloc(TALLOC_CTX *ctx, int af, fr_ipaddr_t const *allow, fr_ipaddr_t const *deny)
Create a patricia trie for doing network filtering.
Definition: network.c:165
fr_bio_t * fr_bio_network_alloc(TALLOC_CTX *ctx, fr_ipaddr_t const *allow, fr_ipaddr_t const *deny, fr_bio_read_t discard, fr_bio_t *next))
Allocate a bio for filtering IP addresses.
Definition: network.c:92
#define RCSIDH(h, id)
Definition: build.h:445
IPv4/6 prefix.
Definition: merged_model.c:272
int nonnull(2, 5))