58fd440acbb6e907d0fa2a2d15ef7d3af2a0d2f7
[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,"
47                         " make sure that all modules that need"
48                     " tm module are loaded after tm in the configuration file\n");
49                 return -1;
50         }
51
52         memset(tmb, 0, sizeof(struct tm_binds));
53
54         /* exported to cfg */
55         if (!( tmb->t_newtran=(tnewtran_f)find_export("t_newtran", 0, 0)) ) {
56                 LOG(L_ERR, LOAD_ERROR "'t_newtran' not found\n");
57                 return -1;
58         }
59 #ifdef USE_TCP
60         if (!( tmb->t_relay_to_tcp=find_export("t_relay_to_tcp", 2, 0)) ) {
61                 LOG(L_ERR, LOAD_ERROR "'t_relay_to_tcp' not found\n");
62                 return -1;
63         }
64 #endif
65         if (!( tmb->t_relay_to_udp=find_export("t_relay_to_udp", 2, 0)) ) {
66                 LOG(L_ERR, LOAD_ERROR "'t_relay_to_udp' not found\n");
67                 return -1;
68         }
69         if (!( tmb->t_relay=find_export("t_relay", 0, 0)) ) {
70                 LOG(L_ERR, LOAD_ERROR "'t_relay' not found\n");
71                 return -1;
72         }
73         if (!(tmb->t_forward_nonack=(tfwd_f)find_export("t_forward_nonack",2,0))) {
74                 LOG( L_ERR, LOAD_ERROR "'t_forward_nonack' not found\n");
75                 return -1;
76         }
77         if (!(tmb->t_release=(trelease_f)find_export("t_release",0,0))) {
78                 LOG( L_ERR, LOAD_ERROR "'t_release' not found\n");
79                 return -1;
80         }
81 /*      if (!(tmb->t_reply=(treply_f)find_export(T_REPLY, 2, 0)) ) {
82                 LOG( L_ERR, LOAD_ERROR "'t_reply' not found\n");
83                 return -1;
84         }*/
85
86         /* non-cfg API */
87         tmb->register_tmcb =register_tmcb;
88         tmb->t_reply = w_t_reply_wrp;
89         tmb->t_reply_with_body = t_reply_with_body;
90         tmb->t_reply_trans = t_reply;
91         tmb->t_is_local = t_is_local;
92         tmb->t_get_trans_ident = t_get_trans_ident;
93         tmb->t_lookup_ident = t_lookup_ident;
94         tmb->t_addblind = add_blind_uac;
95         tmb->t_request_within = req_within;
96         tmb->t_request_outside = req_outside;
97         tmb->t_request = request;
98         tmb->new_dlg_uac = new_dlg_uac;
99         tmb->dlg_response_uac = dlg_response_uac;
100         tmb->new_dlg_uas = new_dlg_uas;
101         tmb->update_dlg_uas = update_dlg_uas;
102         tmb->dlg_request_uas = dlg_request_uas;
103         tmb->set_dlg_target = set_dlg_target;
104         tmb->free_dlg = free_dlg;
105         tmb->print_dlg = print_dlg;
106         tmb->t_gett = get_t;
107         tmb->calculate_hooks = w_calculate_hooks;
108         tmb->t_uac = t_uac;
109         tmb->t_uac_with_ids = t_uac_with_ids;
110         tmb->t_unref = t_unref;
111         tmb->run_failure_handlers = run_failure_handlers;
112         tmb->cancel_uacs = cancel_uacs;
113         tmb->cancel_all_uacs = cancel_all_uacs;
114         tmb->prepare_request_within = prepare_req_within;
115         tmb->send_prepared_request = send_prepared_request;
116         tmb->dlg_add_extra = dlg_add_extra;
117         tmb->t_cancel_uac = t_uac_cancel;
118
119 #ifdef DIALOG_CALLBACKS
120         tmb->register_new_dlg_cb=register_new_dlg_cb;
121         tmb->register_dlg_tmcb=register_dlg_tmcb;
122 #endif
123 #ifdef WITH_AS_SUPPORT
124         tmb->ack_local_uac = ack_local_uac;
125         tmb->t_get_canceled_ident = t_get_canceled_ident;
126 #endif
127         tmb->t_suspend = t_suspend;
128         tmb->t_continue = t_continue;
129         tmb->t_cancel_suspend = t_cancel_suspend;
130         tmb->t_get_reply_totag = t_get_reply_totag;
131         tmb->t_get_picked_branch = t_get_picked_branch;
132         tmb->t_lookup_callid = t_lookup_callid;
133         tmb->generate_callid = generate_callid;
134         tmb->generate_fromtag = generate_fromtag;
135         tmb->t_lookup_request = t_lookup_request;
136         tmb->t_lookup_original = t_lookupOriginalT;
137         tmb->t_check = t_check;
138         tmb->unref_cell = unref_cell;
139         tmb->prepare_to_cancel = prepare_to_cancel;
140         tmb->get_stats = tm_get_stats;
141         tmb->get_table = tm_get_table;
142
143 #ifdef WITH_TM_CTX
144         tmb->tm_ctx_get = tm_ctx_get;
145 #endif
146         return 1;
147 }