2
0

dlist.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * $Id: dlist.h 5160 2008-11-03 17:51:22Z henningw $
  3. *
  4. * Copyright (C) 2001-2003 FhG Fokus
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * History:
  23. * ========
  24. * 2006-11-28 Added get_number_of_users() (Jeffrey Magder - SOMA Networks)
  25. * 2007-09-12 added partitioning support for fetching all ul contacts
  26. * (bogdan)
  27. */
  28. /*! \file
  29. * \brief USRLOC - List of registered domains
  30. * \ingroup usrloc
  31. */
  32. #ifndef DLIST_H
  33. #define DLIST_H
  34. #include <stdio.h>
  35. #include "../../str.h"
  36. #include "../usrloc/usrloc.h"
  37. #include "udomain.h"
  38. /*!
  39. * List of all domains registered with usrloc
  40. */
  41. struct domain_list_item {
  42. str name;
  43. udomain_t domain;
  44. struct domain_list_item*next;
  45. };
  46. /*!
  47. * \brief Free all allocated memory for domains
  48. */
  49. void free_all_udomains(void);
  50. /*!
  51. * \brief Run timer handler of all domains
  52. * \return 0 if all timer return 0, != 0 otherwise
  53. */
  54. int synchronize_all_udomains(void);
  55. /*!
  56. * \brief Loops through all domains summing up the number of users
  57. * \return the number of users, could be zero
  58. */
  59. unsigned long get_number_of_users(void);
  60. /*!
  61. * \brief Registers a new domain with usrloc
  62. *
  63. * Registers a new domain with usrloc. If the domain exists,
  64. * a pointer to existing structure will be returned, otherwise
  65. * a new domain will be created
  66. * \param _n domain name
  67. * \param _d new created domain
  68. * \return 0 on success, -1 on failure
  69. */
  70. int register_udomain(const char* _n, udomain_t** _d);
  71. /*!
  72. * \brief Get all contacts from the usrloc, in partitions if wanted
  73. *
  74. * Return list of all contacts for all currently registered
  75. * users in all domains. The caller must provide buffer of
  76. * sufficient length for fitting all those contacts. In the
  77. * case when buffer was exhausted, the function returns
  78. * estimated amount of additional space needed, in this
  79. * case the caller is expected to repeat the call using
  80. * this value as the hint.
  81. *
  82. * Information is packed into the buffer as follows:
  83. *
  84. * +------------+----------+-----+------+-----+
  85. * |contact1.len|contact1.s|sock1|flags1|path1|
  86. * +------------+----------+-----+------+-----+
  87. * |contact2.len|contact2.s|sock2|flags2|path1|
  88. * +------------+----------+-----+------+-----+
  89. * |..........................................|
  90. * +------------+----------+-----+------+-----+
  91. * |contactN.len|contactN.s|sockN|flagsN|pathN|
  92. * +------------+----------+-----+------+-----+
  93. * |000000000000|
  94. * +------------+
  95. *
  96. * \param buf target buffer
  97. * \param len length of buffer
  98. * \param flags contact flags
  99. * \param part_idx part index
  100. * \param part_max maximal part
  101. * \return 0 on success, positive if buffer size was not sufficient, negative on failure
  102. */
  103. int get_all_ucontacts(void *, int, unsigned int,
  104. unsigned int part_idx, unsigned int part_max);
  105. /*!
  106. * \brief Find a particular domain, small wrapper around find_dlist
  107. * \param _d domain name
  108. * \param _p pointer to domain if found
  109. * \return 1 if domain was found, 0 otherwise
  110. */
  111. int find_domain(str* _d, udomain_t** _p);
  112. #endif