The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
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: 75c82280e93b18ce3006aacc87e27fbc34d47f60 $
20 * @file lib/bio/network.h
21 * @brief BIO patricia trie filtering handlers
22 *
23 * @copyright 2024 Network RADIUS SAS (legal@networkradius.com)
24 */
25RCSIDH(lib_bio_network_h, "$Id: 75c82280e93b18ce3006aacc87e27fbc34d47f60 $")
26
27#include <freeradius-devel/util/inet.h>
28#include <freeradius-devel/util/trie.h>
29
30fr_trie_t *fr_bio_network_trie_alloc(TALLOC_CTX *ctx, int af, fr_ipaddr_t const *allow, fr_ipaddr_t const *deny);
31
32bool fr_bio_network_trie_allow(fr_trie_t const *trie, struct sockaddr const *sockaddr, socklen_t socklen) CC_HINT(nonnull);
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))
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:51
bool fr_bio_network_trie_allow(fr_trie_t const *trie, struct sockaddr const *sockaddr, socklen_t socklen)
Check if the source of a packet or connection is allowed by the network trie.
Definition network.c:39
#define RCSIDH(h, id)
Definition build.h:610
IPv4/6 prefix.
int nonnull(2, 5))