FreeCalypso > hg > themwi-system-sw
annotate sip-in/disconnect.c @ 69:8cf85edca543
sip-in: implement SIP ACK handling
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 19 Sep 2022 14:55:57 -0800 |
parents | 5beb51de1bae |
children | 3e3fbf44f9d7 |
rev | line source |
---|---|
64
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement call disconnection and clearing procedures. |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/socket.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <netinet/in.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdint.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <string.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <strings.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <syslog.h> |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "../include/mncc.h" |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "call.h" |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 void |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 disconnect_mncc(call, cause_loc, cause_val) |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 struct call *call; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 { |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 struct gsm_mncc msg; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 switch (call->mncc_state) { |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 case MNCC_STATE_NO_EXIST: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 case MNCC_STATE_DISCONNECT: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 case MNCC_STATE_RELEASE: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 return; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 bzero(&msg, sizeof(struct gsm_mncc)); |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 msg.msg_type = MNCC_DISC_REQ; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 msg.callref = call->mncc_callref; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 mncc_set_cause(&msg, cause_loc, cause_val); |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 send_mncc_to_gsm(&msg, sizeof(struct gsm_mncc)); |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 call->mncc_state = MNCC_STATE_DISCONNECT; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 void |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 disconnect_tmgw(call) |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 struct call *call; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 { |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 switch (call->mgw_state) { |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 case MGW_STATE_NO_EXIST: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 case MGW_STATE_CONNECTING: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 case MGW_STATE_DELETING: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 return; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 case MGW_STATE_ALLOCATED: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 case MGW_STATE_COMPLETE: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 tmgw_send_dlcx(call); |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 return; |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 default: |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 syslog(LOG_CRIT, |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 "FATAL: invalid MGW state 0x%x in disconnect_tmgw()", |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 call->mgw_state); |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 exit(1); |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
1f863c63f96b
sip-in: beginning of disconnect handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 } |