| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
* |
| 4 |
* Copyright (c) 2001-2020 ircd-hybrid development team |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
* USA |
| 20 |
*/ |
| 21 |
|
| 22 |
/*! \file hostmask.h |
| 23 |
* \brief A header for the hostmask code. |
| 24 |
* \version $Id$ |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef INCLUDED_hostmask_h |
| 28 |
#define INCLUDED_hostmask_h |
| 29 |
|
| 30 |
enum { ATABLE_SIZE = 0x1000 }; |
| 31 |
|
| 32 |
enum hostmask_type |
| 33 |
{ |
| 34 |
HM_HOST, |
| 35 |
HM_IPV4, |
| 36 |
HM_IPV6 |
| 37 |
}; |
| 38 |
|
| 39 |
struct AddressRec |
| 40 |
{ |
| 41 |
/* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */ |
| 42 |
enum hostmask_type masktype; |
| 43 |
/* type: CONF_CLIENT, CONF_DLINE, CONF_KLINE etc... -A1kmm */ |
| 44 |
enum maskitem_type type; |
| 45 |
|
| 46 |
union |
| 47 |
{ |
| 48 |
struct |
| 49 |
{ |
| 50 |
/* Pointer into MaskItem... -A1kmm */ |
| 51 |
struct irc_ssaddr addr; |
| 52 |
int bits; |
| 53 |
} ipa; |
| 54 |
|
| 55 |
/* Pointer into MaskItem... -A1kmm */ |
| 56 |
const char *hostname; |
| 57 |
} Mask; |
| 58 |
|
| 59 |
/* Higher precedences overrule lower ones... */ |
| 60 |
unsigned int precedence; |
| 61 |
|
| 62 |
/* Only checked if !(type & 1)... */ |
| 63 |
const char *username; |
| 64 |
struct MaskItem *conf; |
| 65 |
|
| 66 |
dlink_node node; |
| 67 |
}; |
| 68 |
|
| 69 |
extern dlink_list atable[ATABLE_SIZE]; |
| 70 |
extern int parse_netmask(const char *, struct irc_ssaddr *, int *); |
| 71 |
extern bool match_ipv6(const struct irc_ssaddr *, const struct irc_ssaddr *, int); |
| 72 |
extern bool match_ipv4(const struct irc_ssaddr *, const struct irc_ssaddr *, int); |
| 73 |
|
| 74 |
extern struct AddressRec *add_conf_by_address(const unsigned int, struct MaskItem *); |
| 75 |
extern void delete_one_address_conf(const char *, struct MaskItem *); |
| 76 |
extern void clear_out_address_conf(void); |
| 77 |
extern void hostmask_expire_temporary(void); |
| 78 |
|
| 79 |
extern struct MaskItem *find_address_conf(const char *, const char *, const struct irc_ssaddr *, const char *); |
| 80 |
extern struct MaskItem *find_dline_conf(const struct irc_ssaddr *); |
| 81 |
extern struct MaskItem *find_conf_by_address(const char *, const struct irc_ssaddr *, |
| 82 |
unsigned int, const char *, const char *, int); |
| 83 |
#endif /* INCLUDED_hostmask_h */ |