FreeCalypso > hg > themwi-system-sw
view sip-in/disconnect.c @ 224:62184b971c8e
smpp-send/input.c: copy-n-paste error
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 05 Aug 2023 12:27:36 -0800 |
parents | e499e8db8b82 |
children |
line wrap: on
line source
/* * In this module we implement call disconnection and clearing procedures. */ #include <sys/types.h> #include <sys/socket.h> #include <sys/time.h> #include <netinet/in.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <syslog.h> #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: case MGW_STATE_DTMF_OP: case MGW_STATE_HOLD_OP: case MGW_STATE_RETRIEVE_OP: return; case MGW_STATE_ALLOCATED: case MGW_STATE_COMPLETE: case MGW_STATE_HELD: tmgw_send_dlcx(call); return; default: syslog(LOG_CRIT, "FATAL: invalid MGW state 0x%x in disconnect_tmgw()", call->mgw_state); exit(1); } } static char * cause_to_invite_err(cause) struct gsm_mncc_cause *cause; { switch (cause->value) { case GSM48_CC_CAUSE_CALL_REJECTED: return "403 Call rejected"; case GSM48_CC_CAUSE_UNASSIGNED_NR: return "404 Unassigned number"; case GSM48_CC_CAUSE_USER_NOTRESPOND: return "480 User not responding"; case GSM48_CC_CAUSE_RESOURCE_UNAVAIL: return "503 GSM network resource unavailable"; case GSM48_CC_CAUSE_TEMP_FAILURE: return "503 Temporary failure"; case GSM48_CC_CAUSE_SWITCH_CONG: return "503 Switch congestion at MSC"; case GSM48_CC_CAUSE_USER_BUSY: return "486 User busy"; case GSM48_CC_CAUSE_DEST_OOO: return "502 Destination out of order"; case GSM48_CC_CAUSE_NETWORK_OOO: return "503 Network out of order"; default: return "480 Unavailable (unspecified)"; } } void disconnect_sip(call, cause) struct call *call; struct gsm_mncc_cause *cause; { switch (call->sip_state) { case SIP_STATE_INVITE_PROC: case SIP_STATE_RINGING: case SIP_STATE_RINGING_REL: strcpy(call->invite_fail, cause_to_invite_err(cause)); signal_invite_error(call); break; case SIP_STATE_INVITE_200: /* have to wait for SIP ACK, then send BYE */ break; case SIP_STATE_CONNECTED: initiate_bye(call); break; } }