t_lookup.h

00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of ser, a free SIP server.
00007  *
00008  * ser 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  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * ser is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00027 /*
00028  * History:
00029  * --------
00030  *  2003-02-24  s/T_NULL/T_NULL_CELL/ to avoid redefinition conflict w/
00031  *               nameser_compat.h (andrei)
00032  *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
00033  *  2005-12-09  added t_set_fr()  (andrei)
00034  * 2009-06-24  changed set_t() to take also a branch parameter (andrei)
00035  */
00036 
00037 
00038 
00039 #ifndef _T_LOOKUP_H
00040 #define _T_LOOKUP_H
00041 
00042 #include "defs.h"
00043 
00044 
00045 #include "config.h"
00046 #include "t_funcs.h"
00047 
00048 #define T_UNDEFINED  ( (struct cell*) -1 )
00049 #define T_NULL_CELL       ( (struct cell*) 0 )
00050 
00051 #define T_BR_UNDEFINED (-1)
00052 
00053 extern unsigned int     global_msg_id;
00054 
00055 
00056 
00057 void init_t(void);
00058 int init_rb( struct retr_buf *rb, struct sip_msg *msg );
00059 
00060 typedef struct cell* (*tlookup_original_f)( struct sip_msg* p_msg );
00061 struct cell* t_lookupOriginalT( struct sip_msg* p_msg );
00062 
00063 int t_reply_matching( struct sip_msg* , int* );
00064 
00065 typedef int (*tlookup_request_f)(struct sip_msg*, int, int*);
00066 
00067 int t_lookup_request( struct sip_msg* p_msg, int leave_new_locked,
00068                                                 int* canceled);
00069 int t_newtran( struct sip_msg* p_msg );
00070 
00071 int _add_branch_label( struct cell *trans,
00072     char *str, int *len, int branch );
00073 int add_branch_label( struct cell *trans, 
00074         struct sip_msg *p_msg, int branch );
00075 
00076 /* releases T-context */
00077 int t_unref( struct sip_msg *p_msg);
00078 typedef int (*tunref_f)( struct sip_msg *p_msg);
00079 
00080 typedef int (*tcheck_f)(struct sip_msg*, int*);
00081 
00082 /* old t_check version (no e2eack support) */
00083 int t_check(struct sip_msg* , int *branch );
00084 /* new version, e2eack and different return convention */
00085 int t_check_msg(struct sip_msg* , int *branch );
00086 
00087 typedef struct cell * (*tgett_f)(void);
00088 struct cell *get_t(void);
00089 int get_t_branch(void);
00090 
00091 /* use carefully or better not at all -- current transaction is 
00092  * primarily set by lookup functions */
00093 void set_t(struct cell *t, int branch);
00094 
00095 
00096 #define T_GET_TI       "t_get_trans_ident"
00097 #define T_LOOKUP_IDENT "t_lookup_ident"
00098 #define T_IS_LOCAL     "t_is_local"
00099 
00100 typedef int (*tislocal_f)(struct sip_msg*);
00101 typedef int (*tnewtran_f)(struct sip_msg*);
00102 typedef int (*tget_ti_f)(struct sip_msg*, unsigned int*, unsigned int*);
00103 typedef int (*tlookup_ident_f)(struct cell**, unsigned int, unsigned int);
00104 typedef int (*trelease_f)(struct sip_msg*);
00105 typedef int (*tlookup_callid_f)(struct cell **, str, str);
00106 
00107 int t_is_local(struct sip_msg*);
00108 int t_get_trans_ident(struct sip_msg* p_msg, unsigned int* hash_index, unsigned int* label);
00109 int t_lookup_ident(struct cell** trans, unsigned int hash_index, unsigned int label);
00110 /* lookup a transaction by callid and cseq */
00111 int t_lookup_callid(struct cell** trans, str callid, str cseq);
00112 
00113 int t_set_fr(struct sip_msg* msg, unsigned int fr_inv_to, unsigned int fr_to );
00114 int t_reset_fr(void);
00115 #ifdef TM_DIFF_RT_TIMEOUT
00116 int t_set_retr(struct sip_msg* msg, unsigned int t1_to, unsigned int t2_to);
00117 int t_reset_retr(void);
00118 #endif
00119 int t_set_max_lifetime(struct sip_msg* msg, unsigned int eol_inv,
00120                                                                                         unsigned int eol_noninv);
00121 int t_reset_max_lifetime(void);
00122 
00123 #ifdef WITH_AS_SUPPORT
00124 
00127 int t_get_canceled_ident(struct sip_msg *msg, unsigned int *hash_index, 
00128                 unsigned int *label);
00129 typedef int (*t_get_canceled_ident_f)(struct sip_msg *msg, 
00130                 unsigned int *hash_index, unsigned int *label);
00131 #endif /* WITH_AS_SUPPORT */
00132 
00136 #define WITH_TM_CTX
00137 #ifdef WITH_TM_CTX
00138 
00139 typedef struct _tm_ctx {
00140         int branch_index;
00141 } tm_ctx_t;
00142 
00143 typedef tm_ctx_t* (*tm_ctx_get_f)(void);
00144 
00145 tm_ctx_t* tm_ctx_get(void);
00146 void tm_ctx_init(void);
00147 void tm_ctx_set_branch_index(int v);
00148 
00149 #else
00150 
00151 #define tm_ctx_get() NULL
00152 #define tm_ctx_init()
00153 #define tm_ctx_set_branch_index(v)
00154 
00155 #endif /* WITH_TM_CTX */
00156 
00157 #endif