dlg_timer.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2006 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. * 2006-04-14 initial version (bogdan)
  25. */
  26. /*!
  27. * \file
  28. * \brief Timer related functions for the dialog module
  29. * \ingroup dialog
  30. * Module: \ref dialog
  31. */
  32. #ifndef _DIALOG_DLG_TIMER_H_
  33. #define _DIALOG_DLG_TIMER_H_
  34. #include "../../locking.h"
  35. /*! dialog timeout list */
  36. struct dlg_tl
  37. {
  38. struct dlg_tl *next;
  39. struct dlg_tl *prev;
  40. volatile unsigned int timeout; /*!< timeout in seconds */
  41. };
  42. /*! dialog timer */
  43. struct dlg_timer
  44. {
  45. struct dlg_tl first; /*!< dialog timeout list */
  46. gen_lock_t *lock; /*!< lock for the list */
  47. };
  48. /*! dialog timer handler */
  49. typedef void (*dlg_timer_handler)(struct dlg_tl *);
  50. /*!
  51. * \brief Initialize the dialog timer handler
  52. * Initialize the dialog timer handler, allocate the lock and a global
  53. * timer in shared memory. The global timer handler will be set on success.
  54. * \param hdl dialog timer handler
  55. * \return 0 on success, -1 on failure
  56. */
  57. int init_dlg_timer(dlg_timer_handler);
  58. /*!
  59. * \brief Destroy global dialog timer
  60. */
  61. void destroy_dlg_timer(void);
  62. /*!
  63. * \brief Insert a dialog timer to the list
  64. * \param tl dialog timer list
  65. * \param interval timeout value in seconds
  66. * \return 0 on success, -1 when the input timer list is invalid
  67. */
  68. int insert_dlg_timer(struct dlg_tl *tl, int interval);
  69. /*!
  70. * \brief Remove a dialog timer from the list
  71. * \param tl dialog timer that should be removed
  72. * \return 1 when the input timer is empty, 0 when the timer was removed,
  73. * -1 when the input timer list is invalid
  74. */
  75. int remove_dialog_timer(struct dlg_tl *tl);
  76. /*!
  77. * \brief Update a dialog timer on the list
  78. * \param tl dialog timer
  79. * \param timeout new timeout value in seconds
  80. * \return 0 on success, -1 when the input list is invalid
  81. * \note the update is implemented as a remove, insert
  82. */
  83. int update_dlg_timer(struct dlg_tl *tl, int timeout);
  84. /*!
  85. * \brief Timer routine for expiration of dialogs
  86. * Timer handler for expiration of dialogs, runs the global timer handler on them.
  87. * \param time for expiration checks
  88. * \param attr unused
  89. */
  90. void dlg_timer_routine(unsigned int ticks , void * attr);
  91. #endif