]> jfr.im git - solanum.git/blame - include/hostmask.h
m_starttls: advertise tls cap only if SSL is possible
[solanum.git] / include / hostmask.h
CommitLineData
212380e3 1/*
a6f63a82 2 * Solanum: a slightly advanced ircd
212380e3
AC
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
212380e3
AC
24 */
25
26#ifndef INCLUDE_hostmask_h
27#define INCLUDE_hostmask_h 1
28enum
29{
7d9e8e9d 30 HM_ERROR,
212380e3 31 HM_HOST,
de293496
SA
32 HM_IPV4,
33 HM_IPV6,
212380e3
AC
34};
35
625cbb19
EK
36enum aconf_category
37{
38 AC_CONFIG,
39 AC_BANDB,
40};
41
29c92cf9 42int parse_netmask(const char *, struct rb_sockaddr_storage *, int *);
7d9e8e9d 43int parse_netmask_strict(const char *, struct rb_sockaddr_storage *, int *);
212380e3
AC
44struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
45 const char *orighost, struct sockaddr *,
40c1fd47 46 int, int, const char *, const char *);
4e0f14a0
JT
47struct ConfItem *find_exact_conf_by_address(const char *address, int type,
48 const char *username);
3ff5a12e
EK
49struct ConfItem *find_exact_conf_by_address_filtered(const char *address, int type,
50 const char *username, bool (*filter)(struct ConfItem *));
40c1fd47 51void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
212380e3 52void delete_one_address_conf(const char *, struct ConfItem *);
625cbb19 53void clear_out_address_conf(enum aconf_category);
212380e3 54void init_host_hash(void);
55abcbb2 55struct ConfItem *find_address_conf(const char *host, const char *sockhost,
212380e3 56 const char *, const char *, struct sockaddr *,
40c1fd47 57 int, char *);
212380e3 58
54ac8b60
VY
59struct ConfItem *find_dline(struct sockaddr *, int);
60
67e05d5b
EK
61#define find_kline(x) ((IsConfDoSpoofIp((x)->localClient->att_conf) && IsConfKlineSpoof((x)->localClient->att_conf)) ? \
62 find_conf_by_address((x)->orighost, NULL, NULL, NULL, CONF_KILL, AF_INET, (x)->username, NULL) : \
63 find_conf_by_address((x)->host, (x)->sockhost, (x)->orighost, \
212380e3 64 (struct sockaddr *)&(x)->localClient->ip, CONF_KILL,\
4e376fff 65 GET_SS_FAMILY(&(x)->localClient->ip), (x)->username, NULL))
212380e3 66
212380e3 67void report_auth(struct Client *);
212380e3 68int match_ipv6(struct sockaddr *, struct sockaddr *, int);
212380e3
AC
69int match_ipv4(struct sockaddr *, struct sockaddr *, int);
70
71/* Hashtable stuff... */
72#define ATABLE_SIZE 0x1000 /* 2^12 */
73#define ATABLE_BITS (32-12)
74
75extern struct AddressRec *atable[ATABLE_SIZE];
76
77struct AddressRec
78{
79 /* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
80 int masktype;
81
82 union
83 {
84 struct
85 {
86 /* Pointer into ConfItem... -A1kmm */
e7046ee5 87 struct rb_sockaddr_storage addr;
212380e3
AC
88 int bits;
89 }
90 ipa;
91
92 /* Pointer into ConfItem... -A1kmm */
93 const char *hostname;
94 }
95 Mask;
96
97 /* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
98 int type;
99
100 /* Higher precedences overrule lower ones... */
101 unsigned long precedence;
102
103 /* Only checked if !(type & 1)... */
104 const char *username;
40c1fd47
VY
105 /* Only checked if type == CONF_CLIENT */
106 const char *auth_user;
212380e3
AC
107 struct ConfItem *aconf;
108
109 /* The next record in this hash bucket. */
110 struct AddressRec *next;
111};
112
113
114#endif /* INCLUDE_hostmask_h */