comparison mgw/mdcx.c @ 127:f062c32a5116

mgw: implement DTMF
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 01 Oct 2022 20:31:15 -0800
parents 3b3f07b112f3
children a6eb2de277f6
comparison
equal deleted inserted replaced
126:815e4c59162e 127:f062c32a5116
2 * In this module we implement our MDCX operation. 2 * In this module we implement our MDCX operation.
3 */ 3 */
4 4
5 #include <sys/types.h> 5 #include <sys/types.h>
6 #include <sys/socket.h> 6 #include <sys/socket.h>
7 #include <sys/time.h>
7 #include <netinet/in.h> 8 #include <netinet/in.h>
8 #include <stdio.h> 9 #include <stdio.h>
9 #include <stdint.h> 10 #include <stdint.h>
10 #include <stdlib.h> 11 #include <stdlib.h>
11 #include <string.h> 12 #include <string.h>
85 if (req->setup_mask & TMGW_CTRL_MASK_FWD_MODE) { 86 if (req->setup_mask & TMGW_CTRL_MASK_FWD_MODE) {
86 if (ep->ep_type != TMGW_EP_TYPE_GATEWAY || 87 if (ep->ep_type != TMGW_EP_TYPE_GATEWAY ||
87 ep->rtp_gsm.remote_addr.sin_family != AF_INET || 88 ep->rtp_gsm.remote_addr.sin_family != AF_INET ||
88 ep->rtp_pstn.remote_addr.sin_family != AF_INET) 89 ep->rtp_pstn.remote_addr.sin_family != AF_INET)
89 return TMGW_RESP_ERR_PROT; 90 return TMGW_RESP_ERR_PROT;
90 if ((req->fwd_mode & TMGW_FWD_ENABLE_GSM2PSTN) && 91 if (req->fwd_mode & TMGW_FWD_ENABLE_GSM2PSTN) {
91 !(ep->fwd_mode & TMGW_FWD_ENABLE_GSM2PSTN)) {
92 rc = gsm2pstn_init(ep); 92 rc = gsm2pstn_init(ep);
93 if (rc != TMGW_RESP_OK) 93 if (rc != TMGW_RESP_OK)
94 return rc; 94 return rc;
95 } 95 } else if (ep->dtmf_pp)
96 if ((req->fwd_mode & TMGW_FWD_ENABLE_PSTN2GSM) && 96 dtmf_stop_immediate(ep);
97 !(ep->fwd_mode & TMGW_FWD_ENABLE_PSTN2GSM)) { 97 if (req->fwd_mode & TMGW_FWD_ENABLE_PSTN2GSM) {
98 rc = pstn2gsm_init(ep); 98 rc = pstn2gsm_init(ep);
99 if (rc != TMGW_RESP_OK) 99 if (rc != TMGW_RESP_OK)
100 return rc; 100 return rc;
101 } 101 }
102 ep->fwd_mode = req->fwd_mode; 102 ep->fwd_mode = req->fwd_mode;
109 struct ctrl_conn *conn; 109 struct ctrl_conn *conn;
110 struct tmgw_ctrl_req *req; 110 struct tmgw_ctrl_req *req;
111 struct tmgw_ctrl_resp *resp; 111 struct tmgw_ctrl_resp *resp;
112 { 112 {
113 struct endpoint *ep; 113 struct endpoint *ep;
114 int rc;
115 114
116 ep = find_ep_by_id(conn, req->ep_id); 115 ep = find_ep_by_id(conn, req->ep_id);
117 if (!ep) { 116 if (!ep) {
118 resp->res = TMGW_RESP_ERR_PROT; 117 resp->res = TMGW_RESP_ERR_PROT;
119 return; 118 return;