1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* hostmask.h: A header for the hostmask code. |
4 |
* |
5 |
* Copyright (C) 2005 by the past and present ircd coders, and others. |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
* USA |
21 |
* |
22 |
* $Id$ |
23 |
*/ |
24 |
|
25 |
#ifndef INCLUDE_hostmask_h |
26 |
#define INCLUDE_hostmask_h 1 |
27 |
|
28 |
#define ATABLE_SIZE 0x1000 |
29 |
|
30 |
|
31 |
enum hostmask_type |
32 |
{ |
33 |
HM_HOST, |
34 |
HM_IPV4, |
35 |
HM_IPV6 |
36 |
}; |
37 |
|
38 |
struct AddressRec |
39 |
{ |
40 |
/* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */ |
41 |
enum hostmask_type masktype; |
42 |
|
43 |
union |
44 |
{ |
45 |
struct |
46 |
{ |
47 |
/* Pointer into AccessItem... -A1kmm */ |
48 |
struct irc_ssaddr addr; |
49 |
int bits; |
50 |
} ipa; |
51 |
|
52 |
/* Pointer into AccessItem... -A1kmm */ |
53 |
const char *hostname; |
54 |
} Mask; |
55 |
|
56 |
/* type: CONF_CLIENT, CONF_DLINE, CONF_KLINE etc... -A1kmm */ |
57 |
unsigned int type; |
58 |
|
59 |
/* Higher precedences overrule lower ones... */ |
60 |
unsigned int precedence; |
61 |
|
62 |
/* Only checked if !(type & 1)... */ |
63 |
const char *username; |
64 |
struct AccessItem *aconf; |
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 int match_ipv6(const struct irc_ssaddr *, const struct irc_ssaddr *, int); |
72 |
extern int match_ipv4(const struct irc_ssaddr *, const struct irc_ssaddr *, int); |
73 |
|
74 |
extern void mask_addr(struct irc_ssaddr *, int); |
75 |
extern void init_host_hash(void); |
76 |
extern void add_conf_by_address(const unsigned int, struct AccessItem *); |
77 |
extern void delete_one_address_conf(const char *, struct AccessItem *); |
78 |
extern void clear_out_address_conf(void); |
79 |
extern void hostmask_expire_temporary(void); |
80 |
|
81 |
extern struct AccessItem *find_address_conf(const char *, const char *, |
82 |
struct irc_ssaddr *, int, char *); |
83 |
extern struct AccessItem *find_dline_conf(struct irc_ssaddr *, int); |
84 |
extern struct AccessItem *find_conf_by_address(const char *, struct irc_ssaddr *, |
85 |
unsigned int, int, const char *, const char *, int); |
86 |
#endif /* INCLUDE_hostmask_h */ |