00001 /* 00002 * $Id: dlg_timer.h 5785 2009-04-02 18:24:17Z henningw $ 00003 * 00004 * Copyright (C) 2006 Voice System SRL 00005 * 00006 * This file is part of Kamailio, a free SIP server. 00007 * 00008 * Kamailio is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * Kamailio is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 * History: 00023 * -------- 00024 * 2006-04-14 initial version (bogdan) 00025 */ 00026 00027 /*! 00028 * \file 00029 * \brief Timer related functions for the dialog module 00030 * \ingroup dialog 00031 * Module: \ref dialog 00032 */ 00033 00034 #ifndef _DIALOG_DLG_TIMER_H_ 00035 #define _DIALOG_DLG_TIMER_H_ 00036 00037 00038 #include "../../locking.h" 00039 00040 00041 /*! dialog timeout list */ 00042 struct dlg_tl 00043 { 00044 struct dlg_tl *next; 00045 struct dlg_tl *prev; 00046 volatile unsigned int timeout; /*!< timeout in seconds */ 00047 }; 00048 00049 00050 /*! dialog timer */ 00051 struct dlg_timer 00052 { 00053 struct dlg_tl first; /*!< dialog timeout list */ 00054 gen_lock_t *lock; /*!< lock for the list */ 00055 }; 00056 00057 00058 /*! dialog timer handler */ 00059 typedef void (*dlg_timer_handler)(struct dlg_tl *); 00060 00061 00062 /*! 00063 * \brief Initialize the dialog timer handler 00064 * Initialize the dialog timer handler, allocate the lock and a global 00065 * timer in shared memory. The global timer handler will be set on success. 00066 * \param hdl dialog timer handler 00067 * \return 0 on success, -1 on failure 00068 */ 00069 int init_dlg_timer(dlg_timer_handler); 00070 00071 00072 /*! 00073 * \brief Destroy global dialog timer 00074 */ 00075 void destroy_dlg_timer(void); 00076 00077 00078 /*! 00079 * \brief Insert a dialog timer to the list 00080 * \param tl dialog timer list 00081 * \param interval timeout value in seconds 00082 * \return 0 on success, -1 when the input timer list is invalid 00083 */ 00084 int insert_dlg_timer(struct dlg_tl *tl, int interval); 00085 00086 00087 /*! 00088 * \brief Remove a dialog timer from the list 00089 * \param tl dialog timer that should be removed 00090 * \return 1 when the input timer is empty, 0 when the timer was removed, 00091 * -1 when the input timer list is invalid 00092 */ 00093 int remove_dialog_timer(struct dlg_tl *tl); 00094 00095 00096 /*! 00097 * \brief Update a dialog timer on the list 00098 * \param tl dialog timer 00099 * \param timeout new timeout value in seconds 00100 * \return 0 on success, -1 when the input list is invalid 00101 * \note the update is implemented as a remove, insert 00102 */ 00103 int update_dlg_timer(struct dlg_tl *tl, int timeout); 00104 00105 00106 /*! 00107 * \brief Timer routine for expiration of dialogs 00108 * Timer handler for expiration of dialogs, runs the global timer handler on them. 00109 * \param time for expiration checks 00110 * \param attr unused 00111 */ 00112 void dlg_timer_routine(unsigned int ticks , void * attr); 00113 00114 #endif
1.5.6