modules/tm/timer.h

Go to the documentation of this file.
00001 /*
00002  * $Id: timer.h 5003 2008-09-26 11:01:51Z henningw $
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
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  *  2003-09-12  timer_link.tg exists only if EXTRA_DEBUG (andrei)
00025  *  2004-02-13  timer_link.payload removed (bogdan)
00026  *  2007-02-02  retransmission timers have milliseconds resolution (bogdan)
00027  */
00028 
00029 /*! \file
00030  * \brief TM :: Timer handling
00031  *
00032  * \ingroup tm
00033  * - Module: \ref tm
00034  */
00035 
00036 
00037 
00038 #ifndef _TIMER_H
00039 #define _TIMER_H
00040 
00041 #include "../../timer.h"
00042 #include "lock.h"
00043 
00044 #define MIN_TIMER_VALUE  2
00045 
00046 /* identifiers of timer lists;*/
00047 /* fixed-timer retransmission lists (benefit: fixed timer$
00048    length allows for appending new items to the list as$
00049    opposed to inserting them which is costly */
00050 enum lists
00051 {
00052    FR_TIMER_LIST, FR_INV_TIMER_LIST,
00053    WT_TIMER_LIST,
00054    DELETE_LIST,
00055    RT_T1_TO_1, RT_T1_TO_2, RT_T1_TO_3,
00056    RT_T2,
00057    NR_OF_TIMER_LISTS
00058 };
00059 
00060 
00061 /* all you need to put a cell in a timer list
00062    links to neighbors and timer value */
00063 typedef struct timer_link
00064 {
00065    struct timer_link     *next_tl;
00066    struct timer_link     *prev_tl;
00067    struct timer_link     *ld_tl;
00068    volatile utime_t      time_out;
00069    struct timer          *timer_list;
00070    unsigned int          deleted;
00071 #ifdef EXTRA_DEBUG
00072    enum timer_groups  tg;
00073 #endif
00074 }timer_link_type ;
00075 
00076 
00077 /* timer list: includes head, tail and protection semaphore */
00078 typedef struct  timer
00079 {
00080    struct timer_link  first_tl;
00081    struct timer_link  last_tl;
00082    ser_lock_t*        mutex;
00083    enum lists         id;
00084 } timer_type;
00085 
00086 
00087 /* transaction table */
00088 struct timer_table
00089 {
00090    /* table of timer lists */
00091    struct timer   timers[ NR_OF_TIMER_LISTS ];
00092 };
00093 
00094 
00095 
00096 
00097 
00098 extern int timer_group[NR_OF_TIMER_LISTS];
00099 extern unsigned int timer_id2timeout[NR_OF_TIMER_LISTS];
00100 
00101 
00102 
00103 struct timer_table * tm_init_timers(void);
00104 void unlink_timer_lists(void);
00105 void free_timer_table(void);
00106 void init_timer_list( enum lists list_id);
00107 void reset_timer_list( enum lists list_id);
00108 
00109 void reset_timer( struct timer_link* tl );
00110 
00111 /* determine timer length and put on a correct timer list */
00112 void set_timer( struct timer_link *new_tl, enum lists list_id,
00113       utime_t* ext_timeout );
00114 
00115 /* similar to set_timer, except it allows only one-time
00116    timer setting and all later attempts are ignored */
00117 void set_1timer( struct timer_link *new_tl, enum lists list_id,
00118       utime_t* ext_timeout );
00119 
00120 void timer_routine( unsigned int, void*);
00121 
00122 void utimer_routine( utime_t, void*);
00123 
00124 struct timer_table *get_timertable(void);
00125 
00126 #endif

Generated on Wed May 23 20:00:32 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6