# HG changeset patch # User Mychaela Falconia # Date 1664166534 28800 # Node ID 423610bb2c9e3c3080d03e000429c3c3791719d6 # Parent 9aed16c30622edfec15e5089adbbe4bf203d3ddc sip-in: send MDCX to TMGW to connect the call through diff -r 9aed16c30622 -r 423610bb2c9e sip-in/mgw_ops.c --- 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 #include #include +#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 diff -r 9aed16c30622 -r 423610bb2c9e sip-in/mncc_handle.c --- a/sip-in/mncc_handle.c Sun Sep 25 20:05:02 2022 -0800 +++ b/sip-in/mncc_handle.c Sun Sep 25 20:28:54 2022 -0800 @@ -76,8 +76,7 @@ signal_invite_error(call); return; } - /* TODO: send MDCX to themwi-mgw */ - signal_invite_200(call); + tmgw_send_mdcx_connect(call); } static void