Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00037 #include "dlist.h"
00038 #include <stdlib.h>
00039 #include <string.h>
00040 #include <stdio.h>
00041 #include "../../ut.h"
00042 #include "../../lib/srdb1/db.h"
00043 #include "../../mem/shm_mem.h"
00044 #include "../../dprint.h"
00045 #include "../../ip_addr.h"
00046 #include "../../socket_info.h"
00047 #include "udomain.h"
00048 #include "utime.h"
00049 #include "p_usrloc_mod.h"
00050
00051 #include "ul_db_layer.h"
00052
00053 static struct domain_list_item *domain_list;
00054
00055
00056
00057 static inline struct domain_list_item * find_dlist (str *name) {
00058 struct domain_list_item *item;
00059
00060 for (item = domain_list; item != NULL; item = item->next) {
00061 if (item->name.len == name->len
00062 && memcmp (item->name.s, name->s, name->len) == 0) {
00063 return item;
00064 }
00065 }
00066 return NULL;
00067 }
00068
00069
00070
00071
00072 static inline struct domain_list_item * add_to_dlist (str *name, int type) {
00073 struct domain_list_item *item;
00074 int i;
00075 item = (struct domain_list_item *)
00076 pkg_malloc (sizeof (struct domain_list_item));
00077 if (item == NULL) {
00078 LM_ERR("Out of shared memory.\n");
00079 return NULL;
00080 }
00081 item->name.s = (char *) pkg_malloc (name->len + 1);
00082 if (item->name.s == NULL) {
00083 LM_ERR("Out of shared memory.\n");
00084 return NULL;
00085 }
00086 memcpy (item->name.s, name->s, name->len);
00087 item->name.s[name->len] = '\0';
00088 item->name.len = name->len;
00089
00090 memset (&item->domain, 0, sizeof (struct udomain));
00091 item->domain.name = &item->name;
00092 item->domain.dbt = type;
00093
00094 item->domain.table = (hslot_t*)pkg_malloc(sizeof(hslot_t) * ul_hash_size);
00095 if (!item->domain.table) {
00096 LM_ERR("no memory left 2\n");
00097 return NULL;
00098 }
00099
00100 for(i = 0; i < ul_hash_size; i++) {
00101 init_slot(&item->domain, &(item->domain.table[i]), i);
00102 }
00103
00104 item->domain.size = ul_hash_size;
00105
00106
00107 item->next = domain_list;
00108 domain_list = item;
00109
00110 return item;
00111 }
00112
00113
00124 int register_udomain(const char *name, udomain_t **domain) {
00125 struct domain_list_item *item;
00126 str name_str;
00127 ul_domain_db_t * d;
00128
00129 name_str.s = (char *) name;
00130 name_str.len = strlen (name);
00131 item = find_dlist (&name_str);
00132 if (item == NULL) {
00133 if((d = ul_find_domain(name)) == NULL){
00134 LM_ERR("domain %s not found.\n", name);
00135 return -1;
00136 }
00137 item = add_to_dlist (&name_str, d->dbt);
00138 }
00139 if (item == NULL) {
00140 return -1;
00141 }
00142 *domain = &item->domain;
00143 LM_DBG("found domain %.*s, type: %s\n", (*domain)->name->len, (*domain)->name->s, (((*domain)->dbt) == DB_TYPE_CLUSTER ? "cluster" : "single"));
00144 return 0;
00145 }
00146
00147
00148
00149
00154 unsigned long get_number_of_users(void)
00155 {
00156 int numberOfUsers = 0;
00157 LM_INFO("not available with partitioned interface");
00158 return numberOfUsers;
00159 }
00160
00161
00162 int get_all_ucontacts(void *buf, int len, unsigned int flags,
00163 unsigned int part_idx, unsigned int part_max)
00164 {
00165 LM_INFO("not available with partitioned interface");
00166 return -1;
00167 }
00172 int synchronize_all_udomains(void)
00173 {
00174 int res = 0;
00175 LM_INFO("not available with partitioned interface");
00176 return res;
00177 }
00178
00179