e4829acfa3e731a64fd3f8978167fb6fed1322c9
[sip-router] / modules / tm / tm_load.h
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2001-2003 FhG Fokus
5  *
6  * This file is part of ser, a free SIP server.
7  *
8  * ser 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  * For a license to use the ser software under conditions
14  * other than those described here, or to purchase support for this
15  * software, please contact iptel.org by e-mail at the following addresses:
16  *    info@iptel.org
17  *
18  * ser is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License 
24  * along with this program; if not, write to the Free Software 
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26  *
27  *
28  * History:
29  * --------
30  * 2003-03-06  voicemail changes accepted
31  * 2009-07-14  renamed which_cancel* to prepare_to_cancel* (andrei)
32  *
33  */
34
35
36 #ifndef _TM_BIND_H
37 #define _TM_BIND_H
38
39 #include "defs.h"
40
41
42 #include "../../sr_module.h"
43 #include "t_hooks.h"
44 #include "uac.h"
45 #include "t_fwd.h"
46 #include "t_lookup.h"
47 #include "t_reply.h"
48 #include "dlg.h"
49 #include "callid.h"
50 #include "t_cancel.h"
51 #include "t_suspend.h"
52 #include "t_stats.h"
53
54 /* export not usable from scripts */
55 #define NO_SCRIPT       -1
56
57 struct tm_binds {
58         register_tmcb_f  register_tmcb;
59         cmd_function     t_relay_to_udp; /* WARNING: failure_route unsafe */
60         cmd_function     t_relay_to_tcp; /* WARNING: failure_route unsafe */ 
61         cmd_function     t_relay;        /* WARNING: failure_route unsafe */
62         tnewtran_f       t_newtran;
63         treply_f         t_reply;
64         treply_wb_f      t_reply_with_body;
65         tislocal_f       t_is_local;
66         tget_ti_f        t_get_trans_ident;
67         tlookup_ident_f  t_lookup_ident;
68         taddblind_f      t_addblind;
69         treply_f         t_reply_unsafe;
70         treply_trans_f   t_reply_trans;
71         tfwd_f           t_forward_nonack;
72         reqwith_t        t_request_within;
73         reqout_t         t_request_outside;
74         req_t            t_request;
75         new_dlg_uac_f      new_dlg_uac;
76         dlg_response_uac_f dlg_response_uac;
77         new_dlg_uas_f      new_dlg_uas;
78         update_dlg_uas_f   update_dlg_uas;
79         dlg_request_uas_f  dlg_request_uas;
80         set_dlg_target_f   set_dlg_target;
81         free_dlg_f         free_dlg;
82         print_dlg_f        print_dlg;
83         tgett_f            t_gett;
84         calculate_hooks_f  calculate_hooks;
85         t_uac_t            t_uac;
86         t_uac_with_ids_t   t_uac_with_ids;
87         trelease_f         t_release;
88         tunref_f           t_unref;
89         run_failure_handlers_f run_failure_handlers;
90         cancel_uacs_f      cancel_uacs;
91         cancel_all_uacs_f  cancel_all_uacs;
92         prepare_request_within_f  prepare_request_within;
93         send_prepared_request_f   send_prepared_request;
94         enum route_mode*   route_mode;
95 #ifdef DIALOG_CALLBACKS
96         register_new_dlg_cb_f register_new_dlg_cb;
97         register_dlg_tmcb_f   register_dlg_tmcb;
98 #else
99         void* reserved1; /* make sure the structure has the same size even
100                             if no dlg callbacks are used/defined*/
101         void* reserved2;
102 #endif
103 #ifdef WITH_AS_SUPPORT
104         ack_local_uac_f           ack_local_uac;
105         t_get_canceled_ident_f    t_get_canceled_ident;
106 #else
107         void* reserved3;
108         void* reserved4;
109 #endif
110         t_suspend_f     t_suspend;
111         t_continue_f    t_continue;
112         t_cancel_suspend_f      t_cancel_suspend;
113         tget_reply_totag_f t_get_reply_totag;
114         tget_picked_f t_get_picked_branch;
115         tlookup_callid_f t_lookup_callid;
116         generate_callid_f generate_callid;
117         generate_fromtag_f generate_fromtag;
118         tlookup_request_f t_lookup_request;
119         tlookup_original_f t_lookup_original;
120         tcheck_f t_check;
121         unref_cell_f unref_cell;
122         prepare_to_cancel_f prepare_to_cancel;
123         tm_get_stats_f get_stats;
124         tm_get_table_f get_table;
125         dlg_add_extra_f dlg_add_extra;
126         tuaccancel_f    t_cancel_uac;
127 #ifdef WITH_TM_CTX
128         tm_ctx_get_f tm_ctx_get;
129 #else
130         void* reserved5;
131 #endif
132 };
133
134 typedef struct tm_binds tm_api_t;
135
136 extern int tm_init;
137
138 typedef int(*load_tm_f)( struct tm_binds *tmb );
139 int load_tm(struct tm_binds *tmb);
140
141
142 static inline int load_tm_api(struct tm_binds* tmb)
143 {
144         load_tm_f load_tm;
145
146         /* import the TM auto-loading function */
147         load_tm = (load_tm_f)find_export("load_tm", NO_SCRIPT, 0);
148         
149         if (load_tm == NULL) {
150                 LOG(L_WARN, "Cannot import load_tm function from tm module\n");
151                 return -1;
152         }
153         
154         /* let the auto-loading function load all TM stuff */
155         if (load_tm(tmb) == -1) {
156                 return -1;
157         }
158         return 0;
159 }
160
161 static inline int tm_load_api(tm_api_t *tmb)
162 {
163         return load_tm_api(tmb);
164 }
165
166 #endif