functions for matching IP and domains against patterns
More...
#include <netinet/in.h>
#include <sys/types.h>
Go to the source code of this file.
|
int | ip4_matchnet (const struct in6_addr *, const struct in_addr *, const unsigned char) |
|
int | ip6_matchnet (const struct in6_addr *, const struct in6_addr *, const unsigned char) |
|
int | matchdomain (const char *, const size_t, const char *) |
|
functions for matching IP and domains against patterns
int ip4_matchnet |
( |
const struct in6_addr * |
ip, |
|
|
const struct in_addr * |
net, |
|
|
const unsigned char |
mask |
|
) |
| |
check if an IPv4 address is in a given network
- Parameters
-
ip | the IP address to check (network byte order) |
net | the network to check (network byte order) |
mask | the network mask, must be 0 <= netmask <= 32 |
- Returns
- if address is within net/mask
- Return values
-
int ip6_matchnet |
( |
const struct in6_addr * |
ip, |
|
|
const struct in6_addr * |
net, |
|
|
const unsigned char |
mask |
|
) |
| |
check if an IPv6 address is in a given network
- Parameters
-
ip | the IP address to check (network byte order) |
net | the network to check (network byte order) |
mask | the network mask, must be 0 <= netmask <= 128 |
- Returns
- if address is within net/mask
- Return values
-
1 | address is within the net/mask |
0 | address is not within net/mask |
int matchdomain |
( |
const char * |
domain, |
|
|
const size_t |
dl, |
|
|
const char * |
expr |
|
) |
| |
check if a given expression matches a domain
- Parameters
-
domain | the domain to check |
dl | length of domain |
expr | the expression to match |
- Return values
-