]> jfr.im git - irc/rqf/shadowircd.git/blame - include/hostmask.h
Add mr_flea (and Taros) to the list of Charybdis contributors.
[irc/rqf/shadowircd.git] / include / hostmask.h
CommitLineData
212380e3 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 *
212380e3 25 */
26
27#ifndef INCLUDE_hostmask_h
28#define INCLUDE_hostmask_h 1
29enum
30{
31 HM_HOST,
32 HM_IPV4
2f5fa921 33#ifdef RB_IPV6
212380e3 34 , HM_IPV6
35#endif
36};
37
38int parse_netmask(const char *, struct sockaddr *, int *);
39struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
40 const char *orighost, struct sockaddr *,
969a1ae6 41 int, int, const char *, const char *);
4e0f14a0
JT
42struct ConfItem *find_exact_conf_by_address(const char *address, int type,
43 const char *username);
969a1ae6 44void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
212380e3 45void delete_one_address_conf(const char *, struct ConfItem *);
46void clear_out_address_conf(void);
47void clear_out_address_conf_bans(void);
48void init_host_hash(void);
49struct ConfItem *find_address_conf(const char *host, const char *sockhost,
50 const char *, const char *, struct sockaddr *,
969a1ae6 51 int, char *);
212380e3 52
21c9d815
VY
53struct ConfItem *find_dline(struct sockaddr *, int);
54
212380e3 55#define find_kline(x) (find_conf_by_address((x)->host, (x)->sockhost, \
56 (x)->orighost, \
57 (struct sockaddr *)&(x)->localClient->ip, CONF_KILL,\
969a1ae6 58 (x)->localClient->ip.ss_family, (x)->username, NULL))
212380e3 59
60void report_Klines(struct Client *);
61void report_auth(struct Client *);
2f5fa921 62#ifdef RB_IPV6
212380e3 63int match_ipv6(struct sockaddr *, struct sockaddr *, int);
64#endif
65int match_ipv4(struct sockaddr *, struct sockaddr *, int);
66
67/* Hashtable stuff... */
68#define ATABLE_SIZE 0x1000 /* 2^12 */
69#define ATABLE_BITS (32-12)
70
71extern struct AddressRec *atable[ATABLE_SIZE];
72
73struct AddressRec
74{
75 /* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
76 int masktype;
77
78 union
79 {
80 struct
81 {
82 /* Pointer into ConfItem... -A1kmm */
3ea5fee7 83 struct rb_sockaddr_storage addr;
212380e3 84 int bits;
85 }
86 ipa;
87
88 /* Pointer into ConfItem... -A1kmm */
89 const char *hostname;
90 }
91 Mask;
92
93 /* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
94 int type;
95
96 /* Higher precedences overrule lower ones... */
97 unsigned long precedence;
98
99 /* Only checked if !(type & 1)... */
100 const char *username;
969a1ae6
VY
101 /* Only checked if type == CONF_CLIENT */
102 const char *auth_user;
212380e3 103 struct ConfItem *aconf;
104
105 /* The next record in this hash bucket. */
106 struct AddressRec *next;
107};
108
109
110#endif /* INCLUDE_hostmask_h */