2
0

dlg_profile.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2008 Voice System SRL
  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. * 2008-04-20 initial version (bogdan)
  25. *
  26. */
  27. #ifndef _DIALOG_DLG_PROFILE_H_
  28. #define _DIALOG_DLG_PROFILE_H_
  29. #include "../../parser/msg_parser.h"
  30. #include "../../locking.h"
  31. #include "../../str.h"
  32. #include "../../modules/tm/h_table.h"
  33. /*!
  34. * \file
  35. * \brief Profile related functions for the dialog module
  36. * \ingroup dialog
  37. * Module: \ref dialog
  38. */
  39. /*! dialog profile hash list */
  40. struct dlg_profile_hash {
  41. str value; /*!< hash value */
  42. struct dlg_cell *dlg; /*!< dialog cell */
  43. struct dlg_profile_hash *next;
  44. struct dlg_profile_hash *prev;
  45. unsigned int hash; /*!< position in the hash table */
  46. };
  47. /*! list with links to dialog profiles */
  48. struct dlg_profile_link {
  49. struct dlg_profile_hash hash_linker;
  50. struct dlg_profile_link *next;
  51. struct dlg_profile_table *profile;
  52. };
  53. /*! dialog profile entry */
  54. struct dlg_profile_entry {
  55. struct dlg_profile_hash *first;
  56. unsigned int content; /*!< content of the entry */
  57. };
  58. /*! dialog profile table */
  59. struct dlg_profile_table {
  60. str name; /*!< name of the dialog profile */
  61. unsigned int size; /*!< size of the dialog profile */
  62. unsigned int has_value; /*!< 0 for profiles without value, otherwise it has a value */
  63. gen_lock_t lock; /*! lock for concurrent access */
  64. struct dlg_profile_entry *entries;
  65. struct dlg_profile_table *next;
  66. };
  67. struct dlg_cell *get_current_dlg_pointer(void);
  68. void reset_current_dlg_pointer(void);
  69. struct dlg_cell* get_dialog_from_tm(struct cell *t);
  70. struct dlg_cell *get_current_dialog(struct sip_msg *msg);
  71. /*!
  72. * \brief Add profile definitions to the global list
  73. * \see new_dlg_profile
  74. * \param profiles profile name
  75. * \param has_value set to 0 for a profile without value, otherwise it has a value
  76. * \return 0 on success, -1 on failure
  77. */
  78. int add_profile_definitions( char* profiles, unsigned int has_value);
  79. /*!
  80. * \brief Destroy the global dialog profile list
  81. */
  82. void destroy_dlg_profiles(void);
  83. /*!
  84. * \brief Search a dialog profile in the global list
  85. * \note Linear search, this won't have the best performance for huge profile lists
  86. * \param name searched dialog profile
  87. * \return pointer to the profile on success, NULL otherwise
  88. */
  89. struct dlg_profile_table* search_dlg_profile(str *name);
  90. /*!
  91. * \brief Cleanup a profile
  92. * \param msg SIP message
  93. * \param flags unused
  94. * \param unused
  95. * \return 1
  96. */
  97. int profile_cleanup( struct sip_msg *msg, unsigned int flags, void *param );
  98. /*!
  99. * \brief Destroy dialog linkers
  100. * \param linker dialog linker
  101. */
  102. void destroy_linkers(struct dlg_profile_link *linker);
  103. /*!
  104. * \brief Set the global variables to the current dialog
  105. * \param msg SIP message
  106. * \param dlg dialog cell
  107. */
  108. void set_current_dialog(struct sip_msg *msg, struct dlg_cell *dlg);
  109. /*!
  110. * \brief Set the dialog profile
  111. * \param msg SIP message
  112. * \param value value
  113. * \param profile dialog profile table
  114. * \return 0 on success, -1 on failure
  115. */
  116. int set_dlg_profile(struct sip_msg *msg, str *value,
  117. struct dlg_profile_table *profile);
  118. /*!
  119. * \brief Unset a dialog profile
  120. * \param msg SIP message
  121. * \param value value
  122. * \param profile dialog profile table
  123. * \return 1 on success, -1 on failure
  124. */
  125. int unset_dlg_profile(struct sip_msg *msg, str *value,
  126. struct dlg_profile_table *profile);
  127. /*!
  128. * \brief Check if a dialog belongs to a profile
  129. * \param msg SIP message
  130. * \param profile dialog profile table
  131. * \param value value
  132. * \return 1 on success, -1 on failure
  133. */
  134. int is_dlg_in_profile(struct sip_msg *msg, struct dlg_profile_table *profile,
  135. str *value);
  136. /*!
  137. * \brief Get the size of a profile
  138. * \param profile evaluated profile
  139. * \param value value
  140. * \return the profile size
  141. */
  142. unsigned int get_profile_size(struct dlg_profile_table *profile, str *value);
  143. /*!
  144. * \brief Output a profile via MI interface
  145. * \param cmd_tree MI command tree
  146. * \param param MI parameter
  147. * \return MI root output on success, NULL on failure
  148. */
  149. struct mi_root * mi_get_profile(struct mi_root *cmd_tree, void *param );
  150. /*!
  151. * \brief List the profiles via MI interface
  152. * \param cmd_tree MI command tree
  153. * \param param unused
  154. * \return MI root output on success, NULL on failure
  155. */
  156. struct mi_root * mi_profile_list(struct mi_root *cmd_tree, void *param );
  157. /*!
  158. * \brief return true if the messages belongs to a tracked dialog
  159. */
  160. int is_known_dlg(struct sip_msg *msg);
  161. #endif