Qsmtp  0.30dev
Functions
match.c File Reference

IP and domain matching functions. More...

#include <match.h>
#include <netinet/in.h>
#include <string.h>
#include <strings.h>

Functions

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)
 

Detailed Description

IP and domain matching functions.

Function Documentation

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
ipthe IP address to check (network byte order)
netthe network to check (network byte order)
maskthe network mask, must be 0 <= netmask <= 32
Returns
if address is within net/mask
Return values
1on match
0no match
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
ipthe IP address to check (network byte order)
netthe network to check (network byte order)
maskthe network mask, must be 0 <= netmask <= 128
Returns
if address is within net/mask
Return values
1address is within the net/mask
0address 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
domainthe domain to check
dllength of domain
exprthe expression to match
Return values
1on match
0otherwise