]> jfr.im git - solanum.git/blob - include/hostmask.h
Merge pull request #296 from edk0/modreload
[solanum.git] / include / hostmask.h
1 /*
2 * charybdis: an advanced Internet Relay Chat Daemon(ircd).
3 * hostmask.h: A header for the hostmask code.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2004 ircd-ratbox development team
8 * Copyright (C) 2005-2006 charybdis development team
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 */
25
26 #ifndef INCLUDE_hostmask_h
27 #define INCLUDE_hostmask_h 1
28 enum
29 {
30 HM_HOST,
31 HM_IPV4,
32 HM_IPV6,
33 };
34
35 int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
36 struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
37 const char *orighost, struct sockaddr *,
38 int, int, const char *, const char *);
39 struct ConfItem *find_exact_conf_by_address(const char *address, int type,
40 const char *username);
41 void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
42 void delete_one_address_conf(const char *, struct ConfItem *);
43 void clear_out_address_conf(void);
44 void clear_out_address_conf_bans(void);
45 void init_host_hash(void);
46 struct ConfItem *find_address_conf(const char *host, const char *sockhost,
47 const char *, const char *, struct sockaddr *,
48 int, char *);
49
50 struct ConfItem *find_dline(struct sockaddr *, int);
51
52 #define find_kline(x) (find_conf_by_address((x)->host, (x)->sockhost, \
53 (x)->orighost, \
54 (struct sockaddr *)&(x)->localClient->ip, CONF_KILL,\
55 GET_SS_FAMILY(&(x)->localClient->ip), (x)->username, NULL))
56
57 void report_auth(struct Client *);
58 int match_ipv6(struct sockaddr *, struct sockaddr *, int);
59 int match_ipv4(struct sockaddr *, struct sockaddr *, int);
60
61 /* Hashtable stuff... */
62 #define ATABLE_SIZE 0x1000 /* 2^12 */
63 #define ATABLE_BITS (32-12)
64
65 extern struct AddressRec *atable[ATABLE_SIZE];
66
67 struct AddressRec
68 {
69 /* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
70 int masktype;
71
72 union
73 {
74 struct
75 {
76 /* Pointer into ConfItem... -A1kmm */
77 struct rb_sockaddr_storage addr;
78 int bits;
79 }
80 ipa;
81
82 /* Pointer into ConfItem... -A1kmm */
83 const char *hostname;
84 }
85 Mask;
86
87 /* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
88 int type;
89
90 /* Higher precedences overrule lower ones... */
91 unsigned long precedence;
92
93 /* Only checked if !(type & 1)... */
94 const char *username;
95 /* Only checked if type == CONF_CLIENT */
96 const char *auth_user;
97 struct ConfItem *aconf;
98
99 /* The next record in this hash bucket. */
100 struct AddressRec *next;
101 };
102
103
104 #endif /* INCLUDE_hostmask_h */