tm_load.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-03-06  voicemail changes accepted
00031  * 2009-07-14  renamed which_cancel* to prepare_to_cancel* (andrei)
00032  *
00033  */
00034 
00035 
00036 #ifndef _TM_BIND_H
00037 #define _TM_BIND_H
00038 
00039 #include "defs.h"
00040 
00041 
00042 #include "../../sr_module.h"
00043 #include "t_hooks.h"
00044 #include "uac.h"
00045 #include "t_fwd.h"
00046 #include "t_lookup.h"
00047 #include "t_reply.h"
00048 #include "dlg.h"
00049 #include "callid.h"
00050 #include "t_cancel.h"
00051 #include "t_suspend.h"
00052 #include "t_stats.h"
00053 
00054 /* export not usable from scripts */
00055 #define NO_SCRIPT       -1
00056 
00057 struct tm_binds {
00058         register_tmcb_f  register_tmcb;
00059         cmd_function     t_relay_to_udp; /* WARNING: failure_route unsafe */
00060         cmd_function     t_relay_to_tcp; /* WARNING: failure_route unsafe */ 
00061         cmd_function     t_relay;        /* WARNING: failure_route unsafe */
00062         treplicate_uri_f t_replicate;    /* WARNING: failure_route unsafe */
00063         tnewtran_f       t_newtran;
00064         treply_f         t_reply;
00065         treply_wb_f      t_reply_with_body;
00066         tislocal_f       t_is_local;
00067         tget_ti_f        t_get_trans_ident;
00068         tlookup_ident_f  t_lookup_ident;
00069         taddblind_f      t_addblind;
00070         treply_f         t_reply_unsafe;
00071         treply_trans_f   t_reply_trans;
00072         tfwd_f           t_forward_nonack;
00073         reqwith_t        t_request_within;
00074         reqout_t         t_request_outside;
00075         req_t            t_request;
00076         new_dlg_uac_f      new_dlg_uac;
00077         dlg_response_uac_f dlg_response_uac;
00078         new_dlg_uas_f      new_dlg_uas;
00079         update_dlg_uas_f   update_dlg_uas;
00080         dlg_request_uas_f  dlg_request_uas;
00081         set_dlg_target_f   set_dlg_target;
00082         free_dlg_f         free_dlg;
00083         print_dlg_f        print_dlg;
00084         tgett_f            t_gett;
00085         calculate_hooks_f  calculate_hooks;
00086         t_uac_t            t_uac;
00087         t_uac_with_ids_t   t_uac_with_ids;
00088         trelease_f         t_release;
00089         tunref_f           t_unref;
00090         run_failure_handlers_f run_failure_handlers;
00091         cancel_uacs_f      cancel_uacs;
00092         cancel_all_uacs_f  cancel_all_uacs;
00093         prepare_request_within_f  prepare_request_within;
00094         send_prepared_request_f   send_prepared_request;
00095         enum route_mode*   route_mode;
00096 #ifdef DIALOG_CALLBACKS
00097         register_new_dlg_cb_f register_new_dlg_cb;
00098         register_dlg_tmcb_f   register_dlg_tmcb;
00099 #else
00100         void* reserved1; /* make sure the structure has the same size even
00101                             if no dlg callbacks are used/defined*/
00102         void* reserved2;
00103 #endif
00104 #ifdef WITH_AS_SUPPORT
00105         ack_local_uac_f           ack_local_uac;
00106         t_get_canceled_ident_f    t_get_canceled_ident;
00107 #else
00108         void* reserved3;
00109         void* reserved4;
00110 #endif
00111         t_suspend_f     t_suspend;
00112         t_continue_f    t_continue;
00113         t_cancel_suspend_f      t_cancel_suspend;
00114         tget_reply_totag_f t_get_reply_totag;
00115         tget_picked_f t_get_picked_branch;
00116         tlookup_callid_f t_lookup_callid;
00117         generate_callid_f generate_callid;
00118         generate_fromtag_f generate_fromtag;
00119         tlookup_request_f t_lookup_request;
00120         tlookup_original_f t_lookup_original;
00121         tcheck_f t_check;
00122         unref_cell_f unref_cell;
00123         prepare_to_cancel_f prepare_to_cancel;
00124         tm_get_stats_f get_stats;
00125         tm_get_table_f get_table;
00126         dlg_add_extra_f dlg_add_extra;
00127         tuaccancel_f    t_cancel_uac;
00128 #ifdef WITH_TM_CTX
00129         tm_ctx_get_f tm_ctx_get;
00130 #else
00131         void* reserved5;
00132 #endif
00133 };
00134 
00135 typedef struct tm_binds tm_api_t;
00136 
00137 extern int tm_init;
00138 
00139 typedef int(*load_tm_f)( struct tm_binds *tmb );
00140 int load_tm(struct tm_binds *tmb);
00141 
00142 
00143 static inline int load_tm_api(struct tm_binds* tmb)
00144 {
00145         load_tm_f load_tm;
00146 
00147         /* import the TM auto-loading function */
00148         load_tm = (load_tm_f)find_export("load_tm", NO_SCRIPT, 0);
00149         
00150         if (load_tm == NULL) {
00151                 LOG(L_WARN, "Cannot import load_tm function from tm module\n");
00152                 return -1;
00153         }
00154         
00155         /* let the auto-loading function load all TM stuff */
00156         if (load_tm(tmb) == -1) {
00157                 return -1;
00158         }
00159         return 0;
00160 }
00161 
00162 static inline int tm_load_api(tm_api_t *tmb)
00163 {
00164         return load_tm_api(tmb);
00165 }
00166 
00171 typedef void (*t_on_route_f)(unsigned int);
00172 typedef int (*t_no_param_f)(struct sip_msg *);
00173 
00174 int t_check_trans(struct sip_msg* msg);
00175 int t_is_canceled(struct sip_msg* msg);
00176 
00177 typedef struct tm_xbinds {
00178         t_on_route_f t_on_failure;
00179         t_on_route_f t_on_branch;
00180         t_on_route_f t_on_reply;
00181         t_no_param_f t_check_trans;
00182         t_no_param_f t_is_canceled;
00183 } tm_xapi_t;
00184 
00185 typedef int(*load_xtm_f)( tm_xapi_t *xtmb );
00186 int load_xtm(tm_xapi_t *xtmb);
00187 
00188 static inline int tm_load_xapi(tm_xapi_t *xtmb)
00189 {
00190         load_xtm_f load_xtm;
00191 
00192         /* import the TM auto-loading function */
00193         load_xtm = (load_xtm_f)find_export("load_xtm", NO_SCRIPT, 0);
00194 
00195         if (load_xtm == NULL) {
00196                 LOG(L_WARN, "Cannot import load_xtm function from tm module\n");
00197                 return -1;
00198         }
00199 
00200         /* let the auto-loading function load all extra TM stuff */
00201         if (load_xtm(xtmb) < 0) {
00202                 LOG(L_WARN, "Cannot bind xapi from tm module\n");
00203                 return -1;
00204         }
00205         return 0;
00206 }
00207 
00208 #endif