FreeCalypso > hg > themwi-system-sw
changeset 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 | 9aed16c30622 |
children | 738be11ac432 |
files | sip-in/mgw_ops.c sip-in/mncc_handle.c |
diffstat | 2 files changed, 56 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/sip-in/mgw_ops.c Sun Sep 25 20:05:02 2022 -0800 +++ b/sip-in/mgw_ops.c Sun Sep 25 20:28:54 2022 -0800 @@ -12,6 +12,7 @@ #include <string.h> #include <strings.h> #include <syslog.h> +#include "../include/gsm48_const.h" #include "../include/tmgw_ctrl.h" #include "../include/tmgw_const.h" #include "call.h" @@ -150,11 +151,64 @@ } static void +handle_mdcx_fail(call, msg) + struct call *call; + struct tmgw_ctrl_resp *msg; +{ + call->overall_state = OVERALL_STATE_TEARDOWN; + switch (msg->res) { + case TMGW_RESP_ERR_RSRC: + disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, + GSM48_CC_CAUSE_RESOURCE_UNAVAIL); + strcpy(call->invite_fail, + "503 Gateway resource allocation failure"); + break; + case TMGW_RESP_ERR_NOTSUP: + disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, + GSM48_CC_CAUSE_BEARER_CA_UNAVAIL); + strcpy(call->invite_fail, "502 Gateway internal error"); + break; + default: + disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, + GSM48_CC_CAUSE_PROTO_ERR); + strcpy(call->invite_fail, "502 Gateway internal error"); + } + signal_invite_error(call); +} + +static void mdcx_response(call, msg) struct call *call; struct tmgw_ctrl_resp *msg; { - /* will be handled later */ + if (msg->res == TMGW_RESP_OK) { + call->mgw_state = MGW_STATE_COMPLETE; + switch (call->overall_state) { + case OVERALL_STATE_ANSWERED: + signal_invite_200(call); + return; + case OVERALL_STATE_TEARDOWN: + tmgw_send_dlcx(call); + return; + default: + bad_state: + syslog(LOG_CRIT, + "FATAL: invalid overall state 0x%x on MDCX response", + call->overall_state); + exit(1); + } + } else { + tmgw_send_dlcx(call); + switch (call->overall_state) { + case OVERALL_STATE_ANSWERED: + handle_mdcx_fail(call, msg); + return; + case OVERALL_STATE_TEARDOWN: + return; + default: + goto bad_state; + } + } } static void