dlg_handlers.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (C) 2006 Voice System SRL
  3. *
  4. * This file is part of Kamailio, a free SIP server.
  5. *
  6. * Kamailio is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. * Kamailio is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. * History:
  21. * --------
  22. * 2006-04-14 initial version (bogdan)
  23. * 2007-03-06 syncronized state machine added for dialog state. New tranzition
  24. * design based on events; removed num_1xx and num_2xx (bogdan)
  25. * 2011-10 added support for forked calls (richard and jason)
  26. */
  27. /*!
  28. * \file
  29. * \brief Functions related to dialog handling
  30. * \ingroup dialog
  31. * Module: \ref dialog
  32. */
  33. #ifndef _DIALOG_DLG_HANDLERS_H_
  34. #define _DIALOG_DLG_HANDLERS_H_
  35. #include "../../parser/msg_parser.h"
  36. #include "../../str.h"
  37. #include "../../pvar.h"
  38. #include "../../modules/tm/t_hooks.h"
  39. #include "dlg_timer.h"
  40. #define MI_DIALOG_NOT_FOUND "Requested Dialog not found"
  41. #define MI_DIALOG_NOT_FOUND_LEN (sizeof(MI_DIALOG_NOT_FOUND)-1)
  42. #define MI_DLG_OPERATION_ERR "Operation failed"
  43. #define MI_DLG_OPERATION_ERR_LEN (sizeof(MI_DLG_OPERATION_ERR)-1)
  44. #define MAX_DLG_RR_PARAM_NAME 32
  45. /* values for the sequential match mode */
  46. #define SEQ_MATCH_STRICT_ID 0
  47. #define SEQ_MATCH_FALLBACK 1
  48. #define SEQ_MATCH_NO_ID 2
  49. /*!
  50. * \brief Initialize the dialog handlers
  51. * \param rr_param_p added record-route parameter
  52. * \param dlg_flag_p dialog flag
  53. * \param timeout_avp_p AVP for timeout setting
  54. * \param default_timeout_p default timeout
  55. * \param seq_match_mode_p matching mode
  56. */
  57. void init_dlg_handlers(char *rr_param, int dlg_flag,
  58. pv_spec_t *timeout_avp, int default_timeout,
  59. int seq_match_mode);
  60. /*!
  61. * \brief Shutdown operation of the module
  62. */
  63. void destroy_dlg_handlers(void);
  64. /*!
  65. * \brief Parse SIP message and populate leg informations
  66. *
  67. * Parse SIP message and populate leg informations.
  68. * \param dlg the dialog to add cseq, contact & record_route
  69. * \param msg sip message
  70. * \param t transaction
  71. * \param leg type of the call leg
  72. * \param tag SIP To tag
  73. * \return 0 on success, -1 on failure
  74. * \note for a request: get record route in normal order, for a reply get
  75. * in reverse order, skipping the ones from the request and the proxies' own
  76. */
  77. int populate_leg_info( struct dlg_cell *dlg, struct sip_msg *msg,
  78. struct cell* t, unsigned int leg, str *tag);
  79. /*!
  80. * \brief Function that is registered as TM callback and called on requests
  81. * \param t transaction, used to created the dialog
  82. * \param type type of the entered callback
  83. * \param param saved dialog structure in the callback
  84. */
  85. void dlg_onreq(struct cell* t, int type, struct tmcb_params *param);
  86. /*!
  87. * \brief Function that is registered as RR callback for dialog tracking
  88. *
  89. * Function that is registered as RR callback for dialog tracking. It
  90. * sets the appropriate events after the SIP method and run the state
  91. * machine to update the dialog state. It updates then the saved
  92. * dialogs and also the statistics.
  93. * \param req SIP request
  94. * \param route_params record-route parameter
  95. * \param param unused
  96. */
  97. void dlg_onroute(struct sip_msg* req, str *rr_param, void *param);
  98. /*!
  99. * \brief Timer function that removes expired dialogs, run timeout route
  100. * \param tl dialog timer list
  101. */
  102. void dlg_ontimeout( struct dlg_tl *tl);
  103. /*!
  104. * \brief Create a new dialog from a sip message
  105. *
  106. * Create a new dialog from a SIP message, register a callback
  107. * to keep track of the dialog with help of the tm module.
  108. * This function is either called from the request callback, or
  109. * from the dlg_manage function in the configuration script.
  110. * \see dlg_onreq
  111. * \see w_dlg_manage
  112. * \param msg SIP message
  113. * \param t transaction
  114. * \return 0 on success, -1 on failure
  115. */
  116. int dlg_new_dialog(struct sip_msg *msg, struct cell *t, const int run_initial_cbs);
  117. /*!
  118. * \brief Function that returns the dialog lifetime as pseudo-variable
  119. * \param msg SIP message
  120. * \param param pseudo-variable parameter
  121. * \param res pseudo-variable result
  122. * \return 0 on success, -1 on failure
  123. */
  124. int pv_get_dlg_lifetime(struct sip_msg *msg, pv_param_t *param,
  125. pv_value_t *res);
  126. /*!
  127. * \brief Function that returns the dialog state as pseudo-variable
  128. * \param msg SIP message
  129. * \param param pseudo-variable parameter
  130. * \param res pseudo-variable result
  131. * \return 0 on success, -1 on failure
  132. */
  133. int pv_get_dlg_status(struct sip_msg *msg, pv_param_t *param,
  134. pv_value_t *res);
  135. /*!
  136. * \brief Dummy callback just to keep the compiler happy
  137. * \param t unused
  138. * \param type unused
  139. * \param param unused
  140. */
  141. void dlg_tmcb_dummy(struct cell* t, int type, struct tmcb_params *param);
  142. /*!
  143. * \brief Helper function that prints information for all dialogs
  144. * \return void
  145. */
  146. void print_all_dlgs();
  147. /*!
  148. * \brief Helper function that prints all the properties of a dialog including all the dlg_out's
  149. * \param dlg dialog cell
  150. * \return void
  151. */
  152. void internal_print_all_dlg(struct dlg_cell *dlg);
  153. /*!
  154. * \get the current dialog based on the current SIP message
  155. * \param msg SIP message
  156. * \return current dialog, null if none.
  157. */
  158. struct dlg_cell *dlg_get_msg_dialog(sip_msg_t *msg);
  159. #endif