IP and domain matching functions.
More...
#include <match.h>
#include <netinet/in.h>
#include <string.h>
#include <strings.h>
|
| int | ip4_matchnet (const struct in6_addr *ip, const struct in_addr *net, const unsigned char mask) |
| |
| int | ip6_matchnet (const struct in6_addr *ip, const struct in6_addr *net, const unsigned char mask) |
| |
| int | matchdomain (const char *domain, const size_t dl, const char *expr) |
| |
IP and domain matching functions.
| 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
-