src/modules/dispatcher/ds_ht.h
59c31fe7
 /**
  *
  * Copyright (C) 2010 Daniel-Constantin Mierla (asipto.com)
  *
fb6f8e11
  * This file is part of Kamailio, a free SIP server.
59c31fe7
  *
6c780225
  * Kamailio is free software; you can redistribute it and/or modify
59c31fe7
  * 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
  *
6c780225
  * Kamailio is distributed in the hope that it will be useful,
59c31fe7
  * 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
9e1ff448
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
59c31fe7
  */
d081ee4e
 
59c31fe7
 #ifndef _DS_HT_H_
 #define _DS_HT_H_
 
 #include <time.h>
 
cf83221d
 #include "../../core/str.h"
 #include "../../core/locking.h"
59c31fe7
 
d081ee4e
 /* clang-format off */
9cdc3e70
 #define DS_LOAD_INIT		0
 #define DS_LOAD_CONFIRMED	1
59c31fe7
 
d081ee4e
 typedef struct _ds_cell {
fb6f8e11
     unsigned int cellid;   /* item hash id */
 	str callid;            /* sip call-id */
 	str duid;              /* destination unique id (duid attribute) */
 	int dset;              /* destination set */
 	int state;             /* state */
 	time_t  expire;        /* expiration of the item */
 	time_t  initexpire;    /* expiration in initial state of the item */
59c31fe7
     struct _ds_cell *prev;
     struct _ds_cell *next;
 } ds_cell_t;
 
d081ee4e
 typedef struct _ds_entry {
59c31fe7
 	unsigned int esize;
 	ds_cell_t *first;
 	gen_lock_t lock;	
 } ds_entry_t;
 
d081ee4e
 typedef struct _ds_ht {
59c31fe7
 	unsigned int htexpire;
9cdc3e70
 	unsigned int htinitexpire;
59c31fe7
 	unsigned int htsize;
 	ds_entry_t *entries;
 	struct _ds_ht *next;
 } ds_ht_t;
d081ee4e
 /* clang-format on */
59c31fe7
 
9cdc3e70
 ds_ht_t *ds_ht_init(unsigned int htsize, int expire, int initexpire);
59c31fe7
 int ds_ht_destroy(ds_ht_t *dsht);
9cdc3e70
 int ds_add_cell(ds_ht_t *dsht, str *cid, str *did, int dset);
59c31fe7
 int ds_del_cell(ds_ht_t *dsht, str *cid);
d081ee4e
 ds_cell_t *ds_get_cell(ds_ht_t *dsht, str *cid);
9cdc3e70
 int ds_unlock_cell(ds_ht_t *dsht, str *cid);
59c31fe7
 
 int ds_ht_dbg(ds_ht_t *dsht);
 int ds_cell_free(ds_cell_t *cell);
86646d0d
 int ds_ht_clear_slots(ds_ht_t *dsht);
59c31fe7
 
 #endif