00001 /* 00002 * $Id: dlist.h 5160 2008-11-03 17:51:22Z henningw $ 00003 * 00004 * Copyright (C) 2001-2003 FhG Fokus 00005 * 00006 * This file is part of Kamailio, a free SIP server. 00007 * 00008 * Kamailio is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * Kamailio is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 * History: 00023 * ======== 00024 * 2006-11-28 Added get_number_of_users() (Jeffrey Magder - SOMA Networks) 00025 * 2007-09-12 added partitioning support for fetching all ul contacts 00026 * (bogdan) 00027 */ 00028 00029 /*! \file 00030 * \brief USRLOC - List of registered domains 00031 * \ingroup usrloc 00032 */ 00033 00034 00035 #ifndef DLIST_H 00036 #define DLIST_H 00037 00038 #include <stdio.h> 00039 #include "udomain.h" 00040 #include "../../str.h" 00041 00042 00043 /*! 00044 * List of all domains registered with usrloc 00045 */ 00046 typedef struct dlist { 00047 str name; /*!< Name of the domain (null terminated) */ 00048 udomain_t* d; /*!< Payload */ 00049 struct dlist* next; /*!< Next element in the list */ 00050 } dlist_t; 00051 00052 /*! \brief Global list of all registered domains */ 00053 extern dlist_t* root; 00054 00055 00056 /*! 00057 * \brief Registers a new domain with usrloc 00058 * 00059 * Registers a new domain with usrloc. If the domain exists, 00060 * a pointer to existing structure will be returned, otherwise 00061 * a new domain will be created 00062 * \param _n domain name 00063 * \param _d new created domain 00064 * \return 0 on success, -1 on failure 00065 */ 00066 typedef int (*register_udomain_t)(const char* _n, udomain_t** _d); 00067 int register_udomain(const char* _n, udomain_t** _d); 00068 00069 00070 /*! 00071 * \brief Free all allocated memory for domains 00072 */ 00073 void free_all_udomains(void); 00074 00075 00076 /*! 00077 * \brief Print all domains, just for debugging 00078 * \param _f output file 00079 */ 00080 void print_all_udomains(FILE* _f); 00081 00082 00083 /*! 00084 * \brief Run timer handler of all domains 00085 * \return 0 if all timer return 0, != 0 otherwise 00086 */ 00087 int synchronize_all_udomains(void); 00088 00089 00090 /*! 00091 * \brief Get all contacts from the usrloc, in partitions if wanted 00092 * 00093 * Return list of all contacts for all currently registered 00094 * users in all domains. The caller must provide buffer of 00095 * sufficient length for fitting all those contacts. In the 00096 * case when buffer was exhausted, the function returns 00097 * estimated amount of additional space needed, in this 00098 * case the caller is expected to repeat the call using 00099 * this value as the hint. 00100 * 00101 * Information is packed into the buffer as follows: 00102 * 00103 * +------------+----------+-----+------+-----+ 00104 * |contact1.len|contact1.s|sock1|flags1|path1| 00105 * +------------+----------+-----+------+-----+ 00106 * |contact2.len|contact2.s|sock2|flags2|path1| 00107 * +------------+----------+-----+------+-----+ 00108 * |..........................................| 00109 * +------------+----------+-----+------+-----+ 00110 * |contactN.len|contactN.s|sockN|flagsN|pathN| 00111 * +------------+----------+-----+------+-----+ 00112 * |000000000000| 00113 * +------------+ 00114 * 00115 * \param buf target buffer 00116 * \param len length of buffer 00117 * \param flags contact flags 00118 * \param part_idx part index 00119 * \param part_max maximal part 00120 * \return 0 on success, positive if buffer size was not sufficient, negative on failure 00121 */ 00122 typedef int (*get_all_ucontacts_t) (void* buf, int len, unsigned int flags, 00123 unsigned int part_idx, unsigned int part_max); 00124 int get_all_ucontacts(void *, int, unsigned int, 00125 unsigned int part_idx, unsigned int part_max); 00126 00127 00128 /*! 00129 * \brief Loops through all domains summing up the number of users 00130 * \return the number of users, could be zero 00131 */ 00132 unsigned long get_number_of_users(void); 00133 00134 00135 /*! 00136 * \brief Find a particular domain, small wrapper around find_dlist 00137 * \param _d domain name 00138 * \param _p pointer to domain if found 00139 * \return 1 if domain was found, 0 otherwise 00140 */ 00141 int find_domain(str* _d, udomain_t** _p); 00142 00143 00144 #endif
1.5.6