[PATCH] osmo-sip-connector[master]: dtmf: Start handling the DTMF MNCC messages and respond

Holger Freyther gerrit-no-reply at lists.osmocom.org
Wed Feb 22 13:13:43 UTC 2017


Review at  https://gerrit.osmocom.org/1873

dtmf: Start handling the DTMF MNCC messages and respond

Simply respond to the dtmf start/stop with a response
and move on.

Change-Id: Iffc92ea2112c9943ce89c244a9b323125c352ae5
---
M src/mncc.c
1 file changed, 57 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/73/1873/1

diff --git a/src/mncc.c b/src/mncc.c
index 7926f5e..ceb0fc1 100644
--- a/src/mncc.c
+++ b/src/mncc.c
@@ -102,23 +102,33 @@
 	return NULL;
 }
 
-static void mncc_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref)
+static void mncc_fill_header(struct gsm_mncc *mncc, uint32_t msg_type, uint32_t callref)
+{
+	mncc->msg_type = msg_type;
+	mncc->callref = callref;
+}
+
+static void mncc_write(struct mncc_connection *conn, struct gsm_mncc *mncc, uint32_t callref)
 {
 	int rc;
-	struct gsm_mncc mncc = { 0, };
-
-	mncc.msg_type = msg_type;
-	mncc.callref = callref;
 
 	/*
 	 * TODO: we need to put cause in here for release or such? shall we return a
 	 * static struct?
 	 */
-	rc = write(conn->fd.fd, &mncc, sizeof(mncc));
-	if (rc != sizeof(mncc)) {
+	rc = write(conn->fd.fd, mncc, sizeof(*mncc));
+	if (rc != sizeof(*mncc)) {
 		LOGP(DMNCC, LOGL_ERROR, "Failed to send message call(%u)\n", callref);
 		close_connection(conn);
 	}
+}
+
+static void mncc_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref)
+{
+	struct gsm_mncc mncc = { 0, };
+
+	mncc_fill_header(&mncc, msg_type, callref);
+	mncc_write(conn, &mncc, callref);
 }
 
 static void mncc_rtp_send(struct mncc_connection *conn, uint32_t msg_type, uint32_t callref)
@@ -617,6 +627,40 @@
 	other_leg->connect_call(other_leg);
 }
 
+static void check_dtmf_start(struct mncc_connection *conn, char *buf, int rc)
+{
+	struct gsm_mncc out_mncc = { 0, };
+	struct gsm_mncc *data;
+	struct mncc_call_leg *leg;
+
+	leg = find_leg(conn, buf, rc, &data);
+	if (!leg)
+		return;
+
+	LOGP(DMNCC, LOGL_DEBUG, "leg(%u) DTMF key=%c\n", leg->callref, data->keypad);
+
+	mncc_fill_header(&out_mncc, MNCC_START_DTMF_RSP, leg->callref);
+	out_mncc.keypad = data->keypad;
+	mncc_write(conn, &out_mncc, leg->callref);
+}
+
+static void check_dtmf_stop(struct mncc_connection *conn, char *buf, int rc)
+{
+	struct gsm_mncc out_mncc = { 0, };
+	struct gsm_mncc *data;
+	struct mncc_call_leg *leg;
+
+	leg = find_leg(conn, buf, rc, &data);
+	if (!leg)
+		return;
+
+	LOGP(DMNCC, LOGL_DEBUG, "leg(%u) DTMF key=%c\n", leg->callref, data->keypad);
+
+	mncc_fill_header(&out_mncc, MNCC_STOP_DTMF_RSP, leg->callref);
+	out_mncc.keypad = data->keypad;
+	mncc_write(conn, &out_mncc, leg->callref);
+}
+
 static void check_hello(struct mncc_connection *conn, char *buf, int rc)
 {
 	struct gsm_mncc_hello *hello;
@@ -778,6 +822,12 @@
 	case MNCC_HOLD_IND:
 		check_hold_ind(conn, buf, rc);
 		break;
+	case MNCC_START_DTMF_IND:
+		check_dtmf_start(conn, buf, rc);
+		break;
+	case MNCC_STOP_DTMF_IND:
+		check_dtmf_stop(conn, buf, rc);
+		break;
 	default:
 		LOGP(DMNCC, LOGL_ERROR, "Unhandled message type %d/0x%x\n",
 			msg_type, msg_type);

-- 
To view, visit https://gerrit.osmocom.org/1873
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iffc92ea2112c9943ce89c244a9b323125c352ae5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <holger at freyther.de>


More information about the gerrit-log mailing list