# HG changeset patch # User Mychaela Falconia # Date 1663543770 28800 # Node ID 1f863c63f96bd622e76ebbc3845f347211f2a730 # Parent e5aee661e3b2cd10919820e745b01a8e6877a235 sip-in: beginning of disconnect handling diff -r e5aee661e3b2 -r 1f863c63f96b sip-in/Makefile --- a/sip-in/Makefile Sun Sep 18 15:01:11 2022 -0800 +++ b/sip-in/Makefile Sun Sep 18 15:29:30 2022 -0800 @@ -1,8 +1,9 @@ CC= gcc CFLAGS= -O2 PROG= themwi-sip-in -OBJS= call_list.o call_setup.o invite.o main.o mgw_ops.o mgw_sock.o \ - mncc_handle.o mncc_sock.o readconf.o sip_log.o sip_uas.o sip_udp.o +OBJS= call_list.o call_setup.o disconnect.o invite.o main.o mgw_ops.o \ + mgw_sock.o mncc_handle.o mncc_sock.o readconf.o sip_log.o sip_uas.o \ + sip_udp.o LIBS= ../libnumdb/libnumdb.a ../libsip/libsip.a ../libutil/libutil.a INSTBIN=/usr/local/bin diff -r e5aee661e3b2 -r 1f863c63f96b sip-in/disconnect.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sip-in/disconnect.c Sun Sep 18 15:29:30 2022 -0800 @@ -0,0 +1,57 @@ +/* + * In this module we implement call disconnection and clearing procedures. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../include/mncc.h" +#include "../include/gsm48_const.h" +#include "call.h" + +void +disconnect_mncc(call, cause_loc, cause_val) + struct call *call; +{ + struct gsm_mncc msg; + + switch (call->mncc_state) { + case MNCC_STATE_NO_EXIST: + case MNCC_STATE_DISCONNECT: + case MNCC_STATE_RELEASE: + return; + } + bzero(&msg, sizeof(struct gsm_mncc)); + msg.msg_type = MNCC_DISC_REQ; + msg.callref = call->mncc_callref; + mncc_set_cause(&msg, cause_loc, cause_val); + send_mncc_to_gsm(&msg, sizeof(struct gsm_mncc)); + call->mncc_state = MNCC_STATE_DISCONNECT; +} + +void +disconnect_tmgw(call) + struct call *call; +{ + switch (call->mgw_state) { + case MGW_STATE_NO_EXIST: + case MGW_STATE_CONNECTING: + case MGW_STATE_DELETING: + return; + case MGW_STATE_ALLOCATED: + case MGW_STATE_COMPLETE: + tmgw_send_dlcx(call); + return; + default: + syslog(LOG_CRIT, + "FATAL: invalid MGW state 0x%x in disconnect_tmgw()", + call->mgw_state); + exit(1); + } +}