1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
/*
* $Id$
*
* Copyright (C) 2012 Smile Communications, jason.penton@smilecoms.com
* Copyright (C) 2012 Smile Communications, richard.good@smilecoms.com
*
* The initial version of this code was written by Dragos Vingarzan
* (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
* Fruanhofer Institute. It was and still is maintained in a separate
* branch of the original SER. We are therefore migrating it to
* Kamailio/SR and look forward to maintaining it from here on out.
* 2011/2012 Smile Communications, Pty. Ltd.
* ported/maintained/improved by
* Jason Penton (jason(dot)penton(at)smilecoms.com and
* Richard Good (richard(dot)good(at)smilecoms.com) as part of an
* effort to add full IMS support to Kamailio/SR using a new and
* improved architecture
*
* NB: Alot of this code was originally part of OpenIMSCore,
* FhG Fokus.
* Copyright (C) 2004-2006 FhG Fokus
* Thanks for great work! This is an effort to
* break apart the various CSCF functions into logically separate
* components. We hope this will drive wider use. We also feel
* that in this way the architecture is more complete and thereby easier
* to manage in the Kamailio/SR environment
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio 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
*
* Kamailio 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef DLIST_H
#define DLIST_H
#include <stdio.h>
#include "../../str.h"
#include "usrloc.h"
#include "udomain.h"
/*!
* List of all domains registered with usrloc
*/
typedef struct dlist {
str name; /*!< Name of the domain (null terminated) */
udomain_t* d; /*!< Payload */
struct dlist* next; /*!< Next element in the list */
} dlist_t;
/*! \brief Global list of all registered domains */
extern dlist_t* root;
/*!
* \brief 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
* \param _n domain name
* \param _d new created domain
* \return 0 on success, -1 on failure
*/
int register_udomain(const char* _n, udomain_t** _d);
/*!
* \brief Free all allocated memory for domains
*/
void free_all_udomains(void);
/*!
* \brief Print all domains, just for debugging
* \param _f output file
*/
void print_all_udomains(FILE* _f);
/*!
* \brief Run timer handler of all domains
* \return 0 if all timer return 0, != 0 otherwise
*/
int synchronize_all_udomains(void);
/*!
* \brief 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|
* +------------+
*
* \param buf target buffer
* \param len length of buffer
* \param flags contact flags
* \param part_idx part index
* \param part_max maximal part
* \return 0 on success, positive if buffer size was not sufficient, negative on failure
*/
int get_all_ucontacts(void *buf, int len, unsigned int flags,
unsigned int part_idx, unsigned int part_max);
/*!
* \brief Find and return usrloc domain
*
* \param _n domain name
* \param _d usrloc domain (location table)
* \return 0 on success, -1 on failure
*/
int get_udomain(const char* _n, udomain_t** _d);
/*!
* \brief Loops through all domains summing up the number of users
* \return the number of users, could be zero
*/
unsigned long get_number_of_users(void);
/*!
* \brief Find a particular domain, small wrapper around find_dlist
* \param _d domain name
* \param _p pointer to domain if found
* \return 1 if domain was found, 0 otherwise
*/
int find_domain(str* _d, udomain_t** _p);
#endif
|