#include "dlist.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "../../ut.h"
#include "../../db/db_ut.h"
#include "../../mem/shm_mem.h"
#include "../../dprint.h"
#include "../../ip_addr.h"
#include "../../socket_info.h"
#include "udomain.h"
#include "utime.h"
#include "ul_mod.h"

Go to the source code of this file.
Functions | |
| static int | find_dlist (str *_n, dlist_t **_d) |
| Find domain with the given name. | |
| int | find_domain (str *_d, udomain_t **_p) |
| Find a particular domain, small wrapper around find_dlist. | |
| void | free_all_udomains (void) |
| Free all allocated memory for domains. | |
| static int | get_all_db_ucontacts (void *buf, int len, unsigned int flags, unsigned int part_idx, unsigned int part_max) |
| Get all contacts from the database, in partitions if wanted. | |
| static int | get_all_mem_ucontacts (void *buf, int len, unsigned int flags, unsigned int part_idx, unsigned int part_max) |
| Get all contacts from the memory, in partitions if wanted. | |
| int | get_all_ucontacts (void *buf, int len, unsigned int flags, unsigned int part_idx, unsigned int part_max) |
| Get all contacts from the usrloc, in partitions if wanted. | |
| unsigned long | get_number_of_users (void) |
| Loops through all domains summing up the number of users. | |
| static int | new_dlist (str *_n, dlist_t **_d) |
| Create a new domain structure. | |
| void | print_all_udomains (FILE *_f) |
| Print all domains, just for debugging. | |
| int | register_udomain (const char *_n, udomain_t **_d) |
| Registers a new domain with usrloc. | |
| int | synchronize_all_udomains (void) |
| Run timer handler of all domains. | |
Variables | |
| dlist_t * | root = 0 |
| Global list of all registered domains. | |
Definition in file dlist.c.
Find domain with the given name.
| _n | domain name | |
| _d | pointer to domain |
Definition at line 63 of file dlist.c.
References _str::len, dlist::name, dlist::next, and _str::s.
Referenced by find_domain(), and register_udomain().
Find a particular domain, small wrapper around find_dlist.
| _d | domain name | |
| _p | pointer to domain if found |
Definition at line 606 of file dlist.c.
References dlist::d, and find_dlist().
| void free_all_udomains | ( | void | ) |
Free all allocated memory for domains.
Definition at line 521 of file dlist.c.
References dlist::d, free_udomain(), dlist::name, dlist::next, _str::s, and shm_free.
| static int get_all_db_ucontacts | ( | void * | buf, | |
| int | len, | |||
| unsigned int | flags, | |||
| unsigned int | part_idx, | |||
| unsigned int | part_max | |||
| ) | [inline, static] |
Get all contacts from the database, in partitions if wanted.
| buf | target buffer | |
| len | length of buffer | |
| flags | contact flags | |
| part_idx | part index | |
| part_max | maximal part |
Definition at line 92 of file dlist.c.
References cflags_col, contact_col, dlist::d, db_time2str(), expires_col, db_func::free_result, grep_sock_info(), _str::len, LM_ERR, LM_WARN, udomain::name, dlist::next, NULL, parse_phostport(), path_col, port, socket_info::proto, db_func::raw_query, received_col, RES_ROW_N, RES_ROWS, ROW_VALUES, _str::s, snprintf, sock, sock_col, ul_dbf, ul_dbh, VAL_BITMAP, VAL_NULL, and VAL_STRING.
Referenced by get_all_ucontacts().
| static int get_all_mem_ucontacts | ( | void * | buf, | |
| int | len, | |||
| unsigned int | flags, | |||
| unsigned int | part_idx, | |||
| unsigned int | part_max | |||
| ) | [inline, static] |
Get all contacts from the memory, in partitions if wanted.
| buf | target buffer | |
| len | length of buffer | |
| flags | contact flags | |
| part_idx | part index | |
| part_max | maximal part |
Definition at line 259 of file dlist.c.
References ucontact::c, ucontact::cflags, urecord::contacts, dlist::d, hslot::first, _str::len, lock_ulslot(), hslot::n, ucontact::next, urecord::next, dlist::next, NULL, ucontact::path, ucontact::received, _str::s, udomain::size, ucontact::sock, udomain::table, and unlock_ulslot().
Referenced by get_all_ucontacts().
| int get_all_ucontacts | ( | void * | buf, | |
| int | len, | |||
| unsigned int | flags, | |||
| unsigned int | part_idx, | |||
| unsigned int | part_max | |||
| ) |
Get all contacts from the usrloc, in partitions if wanted.
Return list of all contacts for all currently registered users in all domains. The caller must provide buffer of sufficient length for fitting all those contacts. In the case when buffer was exhausted, the function returns estimated amount of additional space needed, in this case the caller is expected to repeat the call using this value as the hint.
Information is packed into the buffer as follows:
+------------+----------+-----+------+-----+ |contact1.len|contact1.s|sock1|flags1|path1| +------------+----------+-----+------+-----+ |contact2.len|contact2.s|sock2|flags2|path1| +------------+----------+-----+------+-----+ |..........................................| +------------+----------+-----+------+-----+ |contactN.len|contactN.s|sockN|flagsN|pathN| +------------+----------+-----+------+-----+ |000000000000| +------------+
| buf | target buffer | |
| len | length of buffer | |
| flags | contact flags | |
| part_idx | part index | |
| part_max | maximal part |
Definition at line 394 of file dlist.c.
References db_mode, DB_ONLY, get_all_db_ucontacts(), and get_all_mem_ucontacts().
Referenced by bind_usrloc().
| unsigned long get_number_of_users | ( | void | ) |
Loops through all domains summing up the number of users.
Definition at line 559 of file dlist.c.
References dlist::d, get_stat_val, dlist::next, and udomain::users.
Create a new domain structure.
Definition at line 413 of file dlist.c.
References dlist::d, _str::len, LM_ERR, dlist::name, new_udomain(), _str::s, shm_free, shm_malloc(), and ul_hash_size.
Referenced by register_udomain().
| void print_all_udomains | ( | FILE * | _f | ) |
Print all domains, just for debugging.
| _f | output file |
Definition at line 540 of file dlist.c.
References dlist::d, dlist::next, and print_udomain().
| int register_udomain | ( | const char * | _n, | |
| udomain_t ** | _d | |||
| ) |
Registers a new domain with usrloc.
Registers a new domain with usrloc. If the domain exists, a pointer to existing structure will be returned, otherwise a new domain will be created
| _n | domain name | |
| _d | new created domain |
Definition at line 461 of file dlist.c.
References db_func::close, dlist::d, db_check_table_version(), db_mode, db_url, find_dlist(), free_udomain(), db_func::init, _str::len, LM_ERR, dlist::name, new_dlist(), dlist::next, NO_DB, _str::s, s, shm_free, testdb_udomain(), ul_dbf, UL_TABLE_VERSION, and ZSW.
Referenced by bind_usrloc().
| int synchronize_all_udomains | ( | void | ) |
Run timer handler of all domains.
Definition at line 581 of file dlist.c.
References dlist::d, db_mode, DB_ONLY, db_timer_udomain(), get_act_time(), mem_timer_udomain(), and dlist::next.
Referenced by mi_usrloc_flush().
1.5.6