comparison sip-in/disconnect.c @ 83:3e3fbf44f9d7

sip-in: disconnect and call clearing implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 20 Sep 2022 22:06:37 -0800
parents 5beb51de1bae
children 0d6435808bcd
comparison
equal deleted inserted replaced
82:ff4b76a107a1 83:3e3fbf44f9d7
10 #include <stdlib.h> 10 #include <stdlib.h>
11 #include <string.h> 11 #include <string.h>
12 #include <strings.h> 12 #include <strings.h>
13 #include <syslog.h> 13 #include <syslog.h>
14 #include "../include/mncc.h" 14 #include "../include/mncc.h"
15 #include "../include/gsm48_const.h"
15 #include "call.h" 16 #include "call.h"
16 17
17 void 18 void
18 disconnect_mncc(call, cause_loc, cause_val) 19 disconnect_mncc(call, cause_loc, cause_val)
19 struct call *call; 20 struct call *call;
52 "FATAL: invalid MGW state 0x%x in disconnect_tmgw()", 53 "FATAL: invalid MGW state 0x%x in disconnect_tmgw()",
53 call->mgw_state); 54 call->mgw_state);
54 exit(1); 55 exit(1);
55 } 56 }
56 } 57 }
58
59 static char *
60 cause_to_invite_err(cause)
61 struct gsm_mncc_cause *cause;
62 {
63 switch (cause->value) {
64 case GSM48_CC_CAUSE_CALL_REJECTED:
65 return "403 Call rejected";
66 case GSM48_CC_CAUSE_UNASSIGNED_NR:
67 return "404 Unassigned number";
68 case GSM48_CC_CAUSE_USER_NOTRESPOND:
69 return "480 User not responding";
70 case GSM48_CC_CAUSE_RESOURCE_UNAVAIL:
71 return "503 GSM network resource unavailable";
72 case GSM48_CC_CAUSE_TEMP_FAILURE:
73 return "503 Temporary failure";
74 case GSM48_CC_CAUSE_SWITCH_CONG:
75 return "503 Switch congestion at MSC";
76 case GSM48_CC_CAUSE_USER_BUSY:
77 return "486 User busy";
78 case GSM48_CC_CAUSE_DEST_OOO:
79 return "502 Destination out of order";
80 case GSM48_CC_CAUSE_NETWORK_OOO:
81 return "503 Network out of order";
82 default:
83 return "480 Unavailable (unspecified)";
84 }
85 }
86
87 void
88 disconnect_sip(call, cause)
89 struct call *call;
90 struct gsm_mncc_cause *cause;
91 {
92 switch (call->sip_state) {
93 case SIP_STATE_INVITE_PROC:
94 case SIP_STATE_RINGING:
95 case SIP_STATE_RINGING_PRACK:
96 strcpy(call->invite_fail, cause_to_invite_err(cause));
97 signal_invite_error(call);
98 break;
99 case SIP_STATE_INVITE_200:
100 /* have to wait for SIP ACK, then send BYE */
101 break;
102 case SIP_STATE_CONNECTED:
103 initiate_bye(call);
104 break;
105 }
106 }