27304870fa64d8782a91fe6db235f3d434a65071
[sip-router] / modules / tm / tm_load.c
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  * History:
28  * --------
29  * 2003-03-06  voicemail changes accepted (jiri)
30  * 2003-04-14  t_relay_to split in udp and tcp (jiri)
31  */
32
33 #include "defs.h"
34
35
36 #include "tm_load.h"
37 #include "uac.h"
38
39 #define LOAD_ERROR "ERROR: tm_bind: TM module function "
40
41 int tm_init = 0;
42
43 int load_tm( struct tm_binds *tmb)
44 {
45         if (!tm_init) {
46                 LOG(L_ERR, "tm:load_tm: Module not initialized yet, make sure that all modules that need"
47                     " tm module are loaded after tm in the configuration file\n");
48                 return -1;
49         }
50
51         if (!( tmb->register_tmcb=(register_tmcb_f) 
52                 find_export("register_tmcb", NO_SCRIPT, 0)) ) {
53                 LOG(L_ERR, LOAD_ERROR "'register_tmcb' not found\n");
54                 return -1;
55         }
56         if (!( tmb->t_newtran=(tnewtran_f)find_export("t_newtran", 0, 0)) ) {
57                 LOG(L_ERR, LOAD_ERROR "'t_newtran' not found\n");
58                 return -1;
59         }
60 #ifdef USE_TCP
61         if (!( tmb->t_relay_to_tcp=find_export(T_RELAY_TO_TCP, 2, 0)) ) {
62                 LOG(L_ERR, LOAD_ERROR "'t_relay_to_tcp' not found\n");
63                 return -1;
64         }
65 #endif
66         if (!( tmb->t_relay_to_udp=find_export(T_RELAY_TO_UDP, 2, 0)) ) {
67                 LOG(L_ERR, LOAD_ERROR "'t_relay_to_udp' not found\n");
68                 return -1;
69         }
70         if (!( tmb->t_relay=find_export(T_RELAY, 0, 0)) ) {
71                 LOG(L_ERR, LOAD_ERROR "'t_relay' not found\n");
72                 return -1;
73         }
74 /*      if (!(tmb->t_reply=(treply_f)find_export(T_REPLY, 2, 0)) ) {
75                 LOG( L_ERR, LOAD_ERROR "'t_reply' not found\n");
76                 return -1;
77         }*/
78         tmb->t_reply = w_t_reply_wrp;
79         
80         if (!(tmb->t_reply_with_body=(treply_wb_f)find_export
81         (T_REPLY_WB, NO_SCRIPT, 0)) ) {
82                 LOG( L_ERR, LOAD_ERROR "'t_reply_with_body' not found\n");
83                 return -1;
84         }
85         if (!(tmb->t_is_local=(tislocal_f)find_export(T_IS_LOCAL,NO_SCRIPT,0)) ) {
86                 LOG( L_ERR, LOAD_ERROR "'t_get_trans_ident' not found\n");
87                 return -1;
88         }
89         if (!(tmb->t_get_trans_ident=(tget_ti_f)find_export
90         (T_GET_TI, NO_SCRIPT, 0)) ) {
91                 LOG( L_ERR, LOAD_ERROR "'t_get_trans_ident' not found\n");
92                 return -1;
93         }
94         if (!(tmb->t_lookup_ident=(tlookup_ident_f)find_export
95         (T_LOOKUP_IDENT, NO_SCRIPT, 0)) ) {
96                 LOG( L_ERR, LOAD_ERROR "'t_lookup_ident' not found\n");
97                 return -1;
98         }
99         if (!(tmb->t_addblind=(taddblind_f)find_export(T_ADDBLIND,NO_SCRIPT,0))) {
100                 LOG( L_ERR, LOAD_ERROR "'addblind' not found\n");
101                 return -1;
102         }
103         if (!(tmb->t_forward_nonack=(tfwd_f)find_export(T_FORWARD_NONACK,2,0))) {
104                 LOG( L_ERR, LOAD_ERROR "'t_forward_nonack' not found\n");
105                 return -1;
106         }
107         if (!(tmb->t_request_within=(reqwith_t)find_export
108         ("t_request_within", NO_SCRIPT, 0)) ) {
109                 LOG( L_ERR, LOAD_ERROR "'t_request_within' not found\n");
110                 return -1;
111         }
112         if (!(tmb->t_request_outside=(reqout_t)find_export
113         ("t_request_outside", NO_SCRIPT, 0)) ) {
114                 LOG( L_ERR, LOAD_ERROR "'t_request_outside' not found\n");
115                 return -1;
116         }
117         if (!(tmb->t_request=(req_t)find_export("t_request", NO_SCRIPT, 0)) ) {
118                 LOG( L_ERR, LOAD_ERROR "'t_request' not found\n");
119                 return -1;
120         }
121         if (!(tmb->new_dlg_uac=(new_dlg_uac_f)find_export
122         ("new_dlg_uac", NO_SCRIPT, 0)) ) {
123                 LOG( L_ERR, LOAD_ERROR "'new_dlg_uac' not found\n");
124                 return -1;
125         }
126         if (!(tmb->dlg_response_uac=(dlg_response_uac_f)find_export
127         ("dlg_response_uac", NO_SCRIPT, 0)) ) {
128                 LOG( L_ERR, LOAD_ERROR "'dlg_response_uac' not found\n");
129                 return -1;
130         }
131         if (!(tmb->new_dlg_uas=(new_dlg_uas_f)find_export
132         ("new_dlg_uas", NO_SCRIPT, 0)) ) {
133                 LOG( L_ERR, LOAD_ERROR "'new_dlg_uas' not found\n");
134                 return -1;
135         }
136         if (!(tmb->dlg_request_uas=(dlg_request_uas_f)find_export
137         ("dlg_request_uas", NO_SCRIPT, 0)) ) {
138                 LOG( L_ERR, LOAD_ERROR "'dlg_request_uas' not found\n");
139                 return -1;
140         }
141         if (!(tmb->free_dlg=(free_dlg_f)find_export("free_dlg", NO_SCRIPT, 0)) ) {
142                 LOG( L_ERR, LOAD_ERROR "'free_dlg' not found\n");
143                 return -1;
144         }
145         if (!(tmb->print_dlg=(print_dlg_f)find_export("print_dlg",NO_SCRIPT,0))) {
146                 LOG( L_ERR, LOAD_ERROR "'print_dlg' not found\n");
147                 return -1;
148         }
149         if (!(tmb->t_gett=(tgett_f)find_export(T_GETT,NO_SCRIPT,0))) {
150                 LOG( L_ERR, LOAD_ERROR "'" T_GETT "' not found\n");
151                 return -1;
152         }
153         if (!(tmb->calculate_hooks=(calculate_hooks_f)find_export("calculate_hooks",NO_SCRIPT,0))) {
154                 LOG( L_ERR, LOAD_ERROR "' calculate_hooks ' not found\n");
155                 return -1;
156         }
157         if (!(tmb->t_uac=(t_uac_t)find_export("t_uac", NO_SCRIPT, 0)) ) {
158                 LOG( L_ERR, LOAD_ERROR "'t_uac' not found\n");
159                 return -1;
160         }
161
162         tmb->route_mode = &rmode;
163         return 1;
164 }