comparison sip-in/mgw_ops.c @ 98:423610bb2c9e

sip-in: send MDCX to TMGW to connect the call through
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2022 20:28:54 -0800
parents f332ccc240f1
children 9b87894704eb
comparison
equal deleted inserted replaced
97:9aed16c30622 98:423610bb2c9e
10 #include <stdint.h> 10 #include <stdint.h>
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <string.h> 12 #include <string.h>
13 #include <strings.h> 13 #include <strings.h>
14 #include <syslog.h> 14 #include <syslog.h>
15 #include "../include/gsm48_const.h"
15 #include "../include/tmgw_ctrl.h" 16 #include "../include/tmgw_ctrl.h"
16 #include "../include/tmgw_const.h" 17 #include "../include/tmgw_const.h"
17 #include "call.h" 18 #include "call.h"
18 19
19 extern struct call *call_list; 20 extern struct call *call_list;
148 } 149 }
149 } 150 }
150 } 151 }
151 152
152 static void 153 static void
154 handle_mdcx_fail(call, msg)
155 struct call *call;
156 struct tmgw_ctrl_resp *msg;
157 {
158 call->overall_state = OVERALL_STATE_TEARDOWN;
159 switch (msg->res) {
160 case TMGW_RESP_ERR_RSRC:
161 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
162 GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
163 strcpy(call->invite_fail,
164 "503 Gateway resource allocation failure");
165 break;
166 case TMGW_RESP_ERR_NOTSUP:
167 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
168 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL);
169 strcpy(call->invite_fail, "502 Gateway internal error");
170 break;
171 default:
172 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
173 GSM48_CC_CAUSE_PROTO_ERR);
174 strcpy(call->invite_fail, "502 Gateway internal error");
175 }
176 signal_invite_error(call);
177 }
178
179 static void
153 mdcx_response(call, msg) 180 mdcx_response(call, msg)
154 struct call *call; 181 struct call *call;
155 struct tmgw_ctrl_resp *msg; 182 struct tmgw_ctrl_resp *msg;
156 { 183 {
157 /* will be handled later */ 184 if (msg->res == TMGW_RESP_OK) {
185 call->mgw_state = MGW_STATE_COMPLETE;
186 switch (call->overall_state) {
187 case OVERALL_STATE_ANSWERED:
188 signal_invite_200(call);
189 return;
190 case OVERALL_STATE_TEARDOWN:
191 tmgw_send_dlcx(call);
192 return;
193 default:
194 bad_state:
195 syslog(LOG_CRIT,
196 "FATAL: invalid overall state 0x%x on MDCX response",
197 call->overall_state);
198 exit(1);
199 }
200 } else {
201 tmgw_send_dlcx(call);
202 switch (call->overall_state) {
203 case OVERALL_STATE_ANSWERED:
204 handle_mdcx_fail(call, msg);
205 return;
206 case OVERALL_STATE_TEARDOWN:
207 return;
208 default:
209 goto bad_state;
210 }
211 }
158 } 212 }
159 213
160 static void 214 static void
161 dlcx_response(call, msg) 215 dlcx_response(call, msg)
162 struct call *call; 216 struct call *call;