2008-04-02 12:16:31 +02:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* hash.c: Maintains hashtables.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdinc.h"
|
|
|
|
#include "ircd_defs.h"
|
|
|
|
#include "s_conf.h"
|
|
|
|
#include "channel.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "hash.h"
|
2008-04-20 07:47:38 +02:00
|
|
|
#include "match.h"
|
2008-04-02 12:16:31 +02:00
|
|
|
#include "ircd.h"
|
|
|
|
#include "numeric.h"
|
|
|
|
#include "send.h"
|
|
|
|
#include "msg.h"
|
|
|
|
#include "cache.h"
|
|
|
|
#include "s_newconf.h"
|
2013-09-10 07:35:56 +02:00
|
|
|
#include "s_assert.h"
|
2016-03-06 21:17:19 +01:00
|
|
|
#include "rb_dictionary.h"
|
|
|
|
#include "rb_radixtree.h"
|
2008-04-06 16:52:42 +02:00
|
|
|
|
2016-03-23 14:09:58 +01:00
|
|
|
rb_dictionary *client_connid_tree = NULL;
|
|
|
|
rb_dictionary *client_zconnid_tree = NULL;
|
2016-03-06 21:17:19 +01:00
|
|
|
struct rb_radixtree *client_id_tree = NULL;
|
|
|
|
struct rb_radixtree *client_name_tree = NULL;
|
2016-01-09 11:25:41 +01:00
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
struct rb_radixtree *channel_tree = NULL;
|
|
|
|
struct rb_radixtree *resv_tree = NULL;
|
|
|
|
struct rb_radixtree *hostname_tree = NULL;
|
2016-01-09 11:59:02 +01:00
|
|
|
|
2008-04-02 12:16:31 +02:00
|
|
|
/*
|
|
|
|
* look in whowas.c for the missing ...[WW_MAX]; entry
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* init_hash()
|
|
|
|
*
|
|
|
|
* clears the various hashtables
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
init_hash(void)
|
|
|
|
{
|
2016-03-06 21:17:19 +01:00
|
|
|
client_connid_tree = rb_dictionary_create("client connid", rb_uint32cmp);
|
|
|
|
client_zconnid_tree = rb_dictionary_create("client zconnid", rb_uint32cmp);
|
|
|
|
client_id_tree = rb_radixtree_create("client id", NULL);
|
|
|
|
client_name_tree = rb_radixtree_create("client name", irccasecanon);
|
2016-01-09 11:59:02 +01:00
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
channel_tree = rb_radixtree_create("channel", irccasecanon);
|
|
|
|
resv_tree = rb_radixtree_create("resv", irccasecanon);
|
2016-01-23 17:40:17 +01:00
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
hostname_tree = rb_radixtree_create("hostname", irccasecanon);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u_int32_t
|
|
|
|
fnv_hash_upper(const unsigned char *s, int bits)
|
|
|
|
{
|
|
|
|
u_int32_t h = FNV1_32_INIT;
|
|
|
|
|
|
|
|
while (*s)
|
|
|
|
{
|
2016-03-08 02:04:24 +01:00
|
|
|
h ^= irctoupper(*s++);
|
2008-04-02 12:16:31 +02:00
|
|
|
h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
|
|
|
|
}
|
|
|
|
if (bits < 32)
|
|
|
|
h = ((h >> bits) ^ h) & ((1<<bits)-1);
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
u_int32_t
|
|
|
|
fnv_hash(const unsigned char *s, int bits)
|
|
|
|
{
|
|
|
|
u_int32_t h = FNV1_32_INIT;
|
|
|
|
|
|
|
|
while (*s)
|
|
|
|
{
|
|
|
|
h ^= *s++;
|
|
|
|
h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
|
|
|
|
}
|
|
|
|
if (bits < 32)
|
|
|
|
h = ((h >> bits) ^ h) & ((1<<bits)-1);
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
u_int32_t
|
|
|
|
fnv_hash_len(const unsigned char *s, int bits, int len)
|
|
|
|
{
|
|
|
|
u_int32_t h = FNV1_32_INIT;
|
|
|
|
const unsigned char *x = s + len;
|
|
|
|
while (*s && s < x)
|
|
|
|
{
|
|
|
|
h ^= *s++;
|
|
|
|
h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
|
|
|
|
}
|
|
|
|
if (bits < 32)
|
|
|
|
h = ((h >> bits) ^ h) & ((1<<bits)-1);
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
u_int32_t
|
|
|
|
fnv_hash_upper_len(const unsigned char *s, int bits, int len)
|
|
|
|
{
|
|
|
|
u_int32_t h = FNV1_32_INIT;
|
|
|
|
const unsigned char *x = s + len;
|
|
|
|
while (*s && s < x)
|
|
|
|
{
|
2016-03-08 02:04:24 +01:00
|
|
|
h ^= irctoupper(*s++);
|
2008-04-02 12:16:31 +02:00
|
|
|
h += (h<<1) + (h<<4) + (h<<7) + (h << 8) + (h << 24);
|
|
|
|
}
|
|
|
|
if (bits < 32)
|
|
|
|
h = ((h >> bits) ^ h) & ((1<<bits)-1);
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add_to_id_hash()
|
|
|
|
*
|
|
|
|
* adds an entry to the id hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
add_to_id_hash(const char *name, struct Client *client_p)
|
|
|
|
{
|
|
|
|
if(EmptyString(name) || (client_p == NULL))
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_add(client_id_tree, name, client_p);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add_to_client_hash()
|
|
|
|
*
|
|
|
|
* adds an entry (client/server) to the client hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
add_to_client_hash(const char *name, struct Client *client_p)
|
|
|
|
{
|
|
|
|
s_assert(name != NULL);
|
|
|
|
s_assert(client_p != NULL);
|
|
|
|
if(EmptyString(name) || (client_p == NULL))
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_add(client_name_tree, name, client_p);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add_to_hostname_hash()
|
|
|
|
*
|
|
|
|
* adds a client entry to the hostname hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
add_to_hostname_hash(const char *hostname, struct Client *client_p)
|
|
|
|
{
|
2016-01-23 17:40:17 +01:00
|
|
|
rb_dlink_list *list;
|
2008-04-02 12:16:31 +02:00
|
|
|
|
|
|
|
s_assert(hostname != NULL);
|
|
|
|
s_assert(client_p != NULL);
|
|
|
|
if(EmptyString(hostname) || (client_p == NULL))
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
list = rb_radixtree_retrieve(hostname_tree, hostname);
|
2016-01-23 17:40:17 +01:00
|
|
|
if (list != NULL)
|
|
|
|
{
|
|
|
|
rb_dlinkAddAlloc(client_p, list);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = rb_malloc(sizeof(*list));
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_add(hostname_tree, hostname, list);
|
2016-01-23 17:40:17 +01:00
|
|
|
rb_dlinkAddAlloc(client_p, list);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add_to_resv_hash()
|
|
|
|
*
|
|
|
|
* adds a resv channel entry to the resv hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
add_to_resv_hash(const char *name, struct ConfItem *aconf)
|
|
|
|
{
|
|
|
|
s_assert(!EmptyString(name));
|
|
|
|
s_assert(aconf != NULL);
|
|
|
|
if(EmptyString(name) || aconf == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_add(resv_tree, name, aconf);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* del_from_id_hash()
|
|
|
|
*
|
|
|
|
* removes an id from the id hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
del_from_id_hash(const char *id, struct Client *client_p)
|
|
|
|
{
|
|
|
|
s_assert(id != NULL);
|
|
|
|
s_assert(client_p != NULL);
|
|
|
|
if(EmptyString(id) || client_p == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_delete(client_id_tree, id);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* del_from_client_hash()
|
|
|
|
*
|
|
|
|
* removes a client/server from the client hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
del_from_client_hash(const char *name, struct Client *client_p)
|
|
|
|
{
|
|
|
|
/* no s_asserts, this can happen when removing a client that
|
|
|
|
* is unregistered.
|
|
|
|
*/
|
|
|
|
if(EmptyString(name) || client_p == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_delete(client_name_tree, name);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* del_from_channel_hash()
|
2014-03-03 05:25:47 +01:00
|
|
|
*
|
2008-04-02 12:16:31 +02:00
|
|
|
* removes a channel from the channel hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
del_from_channel_hash(const char *name, struct Channel *chptr)
|
|
|
|
{
|
|
|
|
s_assert(name != NULL);
|
|
|
|
s_assert(chptr != NULL);
|
|
|
|
|
|
|
|
if(EmptyString(name) || chptr == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_delete(channel_tree, name);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* del_from_hostname_hash()
|
|
|
|
*
|
|
|
|
* removes a client entry from the hostname hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
del_from_hostname_hash(const char *hostname, struct Client *client_p)
|
|
|
|
{
|
2016-01-23 17:40:17 +01:00
|
|
|
rb_dlink_list *list;
|
2008-04-02 12:16:31 +02:00
|
|
|
|
|
|
|
if(hostname == NULL || client_p == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
list = rb_radixtree_retrieve(hostname_tree, hostname);
|
2016-01-23 17:40:17 +01:00
|
|
|
if (list == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rb_dlinkFindDestroy(client_p, list);
|
2008-04-02 12:16:31 +02:00
|
|
|
|
2016-01-23 17:40:17 +01:00
|
|
|
if (rb_dlink_list_length(list) == 0)
|
|
|
|
{
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_delete(hostname_tree, hostname);
|
2016-01-23 17:40:17 +01:00
|
|
|
rb_free(list);
|
|
|
|
}
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* del_from_resv_hash()
|
|
|
|
*
|
|
|
|
* removes a resv entry from the resv hash table
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
del_from_resv_hash(const char *name, struct ConfItem *aconf)
|
|
|
|
{
|
|
|
|
s_assert(name != NULL);
|
|
|
|
s_assert(aconf != NULL);
|
|
|
|
if(EmptyString(name) || aconf == NULL)
|
|
|
|
return;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_delete(resv_tree, name);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* find_id()
|
|
|
|
*
|
|
|
|
* finds a client entry from the id hash table
|
|
|
|
*/
|
|
|
|
struct Client *
|
|
|
|
find_id(const char *name)
|
|
|
|
{
|
|
|
|
if(EmptyString(name))
|
|
|
|
return NULL;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
return rb_radixtree_retrieve(client_id_tree, name);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* find_client()
|
|
|
|
*
|
|
|
|
* finds a client/server entry from the client hash table
|
|
|
|
*/
|
|
|
|
struct Client *
|
|
|
|
find_client(const char *name)
|
|
|
|
{
|
|
|
|
s_assert(name != NULL);
|
|
|
|
if(EmptyString(name))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* hunting for an id, not a nick */
|
|
|
|
if(IsDigit(*name))
|
|
|
|
return (find_id(name));
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
return rb_radixtree_retrieve(client_name_tree, name);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* find_named_client()
|
|
|
|
*
|
|
|
|
* finds a client/server entry from the client hash table
|
|
|
|
*/
|
|
|
|
struct Client *
|
|
|
|
find_named_client(const char *name)
|
|
|
|
{
|
|
|
|
s_assert(name != NULL);
|
|
|
|
if(EmptyString(name))
|
|
|
|
return NULL;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
return rb_radixtree_retrieve(client_name_tree, name);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* find_server()
|
|
|
|
*
|
|
|
|
* finds a server from the client hash table
|
|
|
|
*/
|
|
|
|
struct Client *
|
|
|
|
find_server(struct Client *source_p, const char *name)
|
|
|
|
{
|
|
|
|
struct Client *target_p;
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2008-04-02 12:16:31 +02:00
|
|
|
if(EmptyString(name))
|
|
|
|
return NULL;
|
|
|
|
|
2014-03-03 05:25:47 +01:00
|
|
|
if((source_p == NULL || !MyClient(source_p)) &&
|
2008-04-02 12:16:31 +02:00
|
|
|
IsDigit(*name) && strlen(name) == 3)
|
|
|
|
{
|
|
|
|
target_p = find_id(name);
|
|
|
|
return(target_p);
|
|
|
|
}
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
target_p = rb_radixtree_retrieve(client_name_tree, name);
|
2016-01-09 12:30:13 +01:00
|
|
|
if (target_p != NULL)
|
2008-04-02 12:16:31 +02:00
|
|
|
{
|
2016-01-09 12:30:13 +01:00
|
|
|
if(IsServer(target_p) || IsMe(target_p))
|
|
|
|
return target_p;
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find_hostname()
|
|
|
|
*
|
|
|
|
* finds a hostname rb_dlink list from the hostname hash table.
|
|
|
|
* we return the full rb_dlink list, because you can have multiple
|
|
|
|
* entries with the same hostname
|
|
|
|
*/
|
|
|
|
rb_dlink_node *
|
|
|
|
find_hostname(const char *hostname)
|
|
|
|
{
|
2016-01-23 17:40:17 +01:00
|
|
|
rb_dlink_list *hlist;
|
2008-04-02 12:16:31 +02:00
|
|
|
|
|
|
|
if(EmptyString(hostname))
|
|
|
|
return NULL;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
hlist = rb_radixtree_retrieve(hostname_tree, hostname);
|
2016-01-23 17:40:17 +01:00
|
|
|
if (hlist == NULL)
|
|
|
|
return NULL;
|
2008-04-02 12:16:31 +02:00
|
|
|
|
2016-01-23 17:40:17 +01:00
|
|
|
return hlist->head;
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* find_channel()
|
|
|
|
*
|
|
|
|
* finds a channel from the channel hash table
|
|
|
|
*/
|
|
|
|
struct Channel *
|
|
|
|
find_channel(const char *name)
|
|
|
|
{
|
|
|
|
s_assert(name != NULL);
|
|
|
|
if(EmptyString(name))
|
|
|
|
return NULL;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
return rb_radixtree_retrieve(channel_tree, name);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get_or_create_channel
|
|
|
|
* inputs - client pointer
|
|
|
|
* - channel name
|
|
|
|
* - pointer to int flag whether channel was newly created or not
|
|
|
|
* output - returns channel block or NULL if illegal name
|
|
|
|
* - also modifies *isnew
|
|
|
|
*
|
|
|
|
* Get Channel block for chname (and allocate a new channel
|
|
|
|
* block, if it didn't exist before).
|
|
|
|
*/
|
|
|
|
struct Channel *
|
|
|
|
get_or_create_channel(struct Client *client_p, const char *chname, int *isnew)
|
|
|
|
{
|
|
|
|
struct Channel *chptr;
|
|
|
|
int len;
|
|
|
|
const char *s = chname;
|
|
|
|
|
|
|
|
if(EmptyString(s))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
len = strlen(s);
|
|
|
|
if(len > CHANNELLEN)
|
|
|
|
{
|
|
|
|
char *t;
|
|
|
|
if(IsServer(client_p))
|
|
|
|
{
|
|
|
|
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
|
|
|
"*** Long channel name from %s (%d > %d): %s",
|
|
|
|
client_p->name, len, CHANNELLEN, s);
|
|
|
|
}
|
|
|
|
len = CHANNELLEN;
|
|
|
|
t = LOCAL_COPY(s);
|
|
|
|
*(t + CHANNELLEN) = '\0';
|
|
|
|
s = t;
|
|
|
|
}
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
chptr = rb_radixtree_retrieve(channel_tree, s);
|
2016-01-10 06:47:50 +01:00
|
|
|
if (chptr != NULL)
|
2008-04-02 12:16:31 +02:00
|
|
|
{
|
2016-01-10 06:47:50 +01:00
|
|
|
if (isnew != NULL)
|
|
|
|
*isnew = 0;
|
|
|
|
return chptr;
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(isnew != NULL)
|
|
|
|
*isnew = 1;
|
|
|
|
|
|
|
|
chptr = allocate_channel(s);
|
|
|
|
chptr->channelts = rb_current_time(); /* doesn't hurt to set it here */
|
|
|
|
|
2016-01-10 06:47:50 +01:00
|
|
|
rb_dlinkAdd(chptr, &chptr->node, &global_channel_list);
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_add(channel_tree, chptr->chname, chptr);
|
2008-04-02 12:16:31 +02:00
|
|
|
|
|
|
|
return chptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* hash_find_resv()
|
|
|
|
*
|
|
|
|
* hunts for a resv entry in the resv hash table
|
|
|
|
*/
|
|
|
|
struct ConfItem *
|
|
|
|
hash_find_resv(const char *name)
|
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
|
|
|
|
s_assert(name != NULL);
|
|
|
|
if(EmptyString(name))
|
|
|
|
return NULL;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
aconf = rb_radixtree_retrieve(resv_tree, name);
|
2016-01-09 11:59:02 +01:00
|
|
|
if (aconf != NULL)
|
2008-04-02 12:16:31 +02:00
|
|
|
{
|
2016-01-09 11:59:02 +01:00
|
|
|
aconf->port++;
|
|
|
|
return aconf;
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
clear_resv_hash(void)
|
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
2016-03-06 21:17:19 +01:00
|
|
|
struct rb_radixtree_iteration_state iter;
|
2008-04-02 12:16:31 +02:00
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
RB_RADIXTREE_FOREACH(aconf, &iter, resv_tree)
|
2008-04-02 12:16:31 +02:00
|
|
|
{
|
|
|
|
/* skip temp resvs */
|
|
|
|
if(aconf->hold)
|
|
|
|
continue;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_radixtree_delete(resv_tree, aconf->host);
|
2016-01-09 11:59:02 +01:00
|
|
|
free_conf(aconf);
|
2008-04-02 12:16:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-13 17:54:23 +02:00
|
|
|
void
|
2015-12-12 12:20:51 +01:00
|
|
|
add_to_zconnid_hash(struct Client *client_p)
|
2008-04-13 17:54:23 +02:00
|
|
|
{
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_dictionary_add(client_zconnid_tree, RB_UINT_TO_POINTER(client_p->localClient->zconnid), client_p);
|
2008-04-13 17:54:23 +02:00
|
|
|
}
|
|
|
|
|
2015-12-12 12:20:51 +01:00
|
|
|
void
|
|
|
|
del_from_zconnid_hash(struct Client *client_p)
|
|
|
|
{
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_dictionary_delete(client_zconnid_tree, RB_UINT_TO_POINTER(client_p->localClient->zconnid));
|
2015-12-12 12:20:51 +01:00
|
|
|
}
|
2008-04-13 17:54:23 +02:00
|
|
|
|
|
|
|
void
|
2015-12-12 12:20:51 +01:00
|
|
|
add_to_cli_connid_hash(struct Client *client_p)
|
2008-04-13 17:54:23 +02:00
|
|
|
{
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_dictionary_add(client_connid_tree, RB_UINT_TO_POINTER(client_p->localClient->connid), client_p);
|
2015-12-12 12:20:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
del_from_cli_connid_hash(struct Client *client_p)
|
|
|
|
{
|
2016-03-06 21:17:19 +01:00
|
|
|
rb_dictionary_delete(client_connid_tree, RB_UINT_TO_POINTER(client_p->localClient->connid));
|
2008-04-13 17:54:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Client *
|
2016-01-09 11:25:41 +01:00
|
|
|
find_cli_connid_hash(uint32_t connid)
|
2008-04-13 17:54:23 +02:00
|
|
|
{
|
|
|
|
struct Client *target_p;
|
2015-12-12 12:20:51 +01:00
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
target_p = rb_dictionary_retrieve(client_connid_tree, RB_UINT_TO_POINTER(connid));
|
2016-01-09 11:25:41 +01:00
|
|
|
if (target_p != NULL)
|
|
|
|
return target_p;
|
|
|
|
|
2016-03-06 21:17:19 +01:00
|
|
|
target_p = rb_dictionary_retrieve(client_zconnid_tree, RB_UINT_TO_POINTER(connid));
|
2016-01-09 11:25:41 +01:00
|
|
|
if (target_p != NULL)
|
|
|
|
return target_p;
|
2015-12-12 12:20:51 +01:00
|
|
|
|
|
|
|
return NULL;
|
2008-04-06 16:52:42 +02:00
|
|
|
}
|