lynxis lazus has uploaded this change for review.

View Change

mgcp_client: add RQNT verb and telephone-event codec support

Add MGCP_VERB_RQNT to enum mgcp_verb for sending Request Notification
messages, and CODEC_TELEPHONE_EVT_8000 to enum mgcp_codecs for RFC 4733
telephone-event.

Add mgcp_client_tx_rqnt() as a public API for sending RQNT messages
with signal (S:) and connection ID (I:) parameters, used by osmo-msc
to request DTMF tone generation on the MGW.

Extend mgcp_msg_gen() to handle the RQNT verb and a new signal field
in struct mgcp_msg.

Change-Id: I784d105b03b0ff10fe42ceb8e3a19c74ce58cac8
---
M include/osmocom/mgcp_client/mgcp_client.h
M include/osmocom/mgcp_client/mgcp_client_internal.h
M src/libosmo-mgcp-client/mgcp_client.c
M src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c
4 files changed, 55 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/25/44025/1
diff --git a/include/osmocom/mgcp_client/mgcp_client.h b/include/osmocom/mgcp_client/mgcp_client.h
index 16b9c6f..6a077b1 100644
--- a/include/osmocom/mgcp_client/mgcp_client.h
+++ b/include/osmocom/mgcp_client/mgcp_client.h
@@ -59,6 +59,7 @@
CODEC_IUFP = 96,
CODEC_CLEARMODE = 120, /* 3GPP TS 48.103 table 5.4.2.2.1 */
CODEC_COMPR_CSD = 127, /* compressed CSD per TW-TS-007 */
+ CODEC_TELEPHONE_EVT_8000 = 101, /* RFC 4733 telephone-event */
};
/* Note: when new codec types are added, the corresponding value strings
* in mgcp_client.c (codec_table) must be updated as well. Enumerations
@@ -91,6 +92,7 @@
MGCP_VERB_DLCX,
MGCP_VERB_AUEP,
MGCP_VERB_RSIP,
+ MGCP_VERB_RQNT,
};

struct mgcp_client_conf *mgcp_client_conf_alloc(void *ctx);
@@ -130,3 +132,6 @@
unsigned int pt);

const char *mgcp_client_name(const struct mgcp_client *mgcp);
+
+int mgcp_client_tx_rqnt(struct mgcp_client *mgcp, const char *epname,
+ const char *conn_id, const char *signal);
diff --git a/include/osmocom/mgcp_client/mgcp_client_internal.h b/include/osmocom/mgcp_client/mgcp_client_internal.h
index 5251bd0..3ff96a7 100644
--- a/include/osmocom/mgcp_client/mgcp_client_internal.h
+++ b/include/osmocom/mgcp_client/mgcp_client_internal.h
@@ -73,6 +73,7 @@
#define MGCP_MSG_PRESENCE_X_SIDE 0x2000
#define MGCP_MSG_PRESENCE_X_OSMO_OSMUX_CID 0x4000
#define MGCP_MSG_PRESENCE_X_OSMO_IGN 0x8000
+#define MGCP_MSG_PRESENCE_SIGNAL 0x10000

struct mgcp_msg {
enum mgcp_verb verb;
@@ -93,6 +94,7 @@
char x_side[MGCP_SIDE_ID_MAXLEN];
bool param_present;
struct mgcp_codec_param param;
+ char signal[32];
};

int mgcp_response_parse_params(struct mgcp_response *r);
diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c
index 162bebd..4ae1c7b 100644
--- a/src/libosmo-mgcp-client/mgcp_client.c
+++ b/src/libosmo-mgcp-client/mgcp_client.c
@@ -62,6 +62,7 @@
{ CODEC_IUFP, "VND.3GPP.IUFP/16000" },
{ CODEC_CLEARMODE, "CLEARMODE/8000" },
{ CODEC_COMPR_CSD, "VND.THEMWI.CCSD/8000" },
+ { CODEC_TELEPHONE_EVT_8000, "telephone-event/8000" },
{ 0, NULL },
};

@@ -1288,6 +1289,7 @@
#define MGCP_DLCX_MANDATORY (MGCP_MSG_PRESENCE_ENDPOINT)
#define MGCP_AUEP_MANDATORY (MGCP_MSG_PRESENCE_ENDPOINT)
#define MGCP_RSIP_MANDATORY 0 /* none */
+#define MGCP_RQNT_MANDATORY (MGCP_MSG_PRESENCE_ENDPOINT)

/* Helper function for mgcp_msg_gen(): Add LCO information to MGCP message */
static int add_lco(struct msgb *msg, struct mgcp_msg *mgcp_msg)
@@ -1545,6 +1547,10 @@
mandatory_mask = MGCP_RSIP_MANDATORY;
MSGB_PRINTF_OR_RET("RSIP %u", trans_id);
break;
+ case MGCP_VERB_RQNT:
+ mandatory_mask = MGCP_RQNT_MANDATORY;
+ MSGB_PRINTF_OR_RET("RQNT %u", trans_id);
+ break;
default:
LOGPMGW(mgcp, LOGL_ERROR, "Invalid command verb, can not generate MGCP message\n");
goto exit_error;
@@ -1638,6 +1644,10 @@
}


+ /* Add signal line for RQNT */
+ if (mgcp_msg->presence & MGCP_MSG_PRESENCE_SIGNAL)
+ MSGB_PRINTF_OR_RET("S: %s\r\n", mgcp_msg->signal);
+
/* Add session description protocol (SDP) */
if (use_sdp
&& (mgcp_msg->verb == MGCP_VERB_CRCX
@@ -1720,3 +1730,40 @@
return rc;
return strcmp(a->fmtp, b->fmtp);
}
+
+/*! Send an MGCP RQNT (Request Notification) message to the MGW.
+ * Used to request DTMF tone generation via RFC 4733 telephone-event.
+ * \param[in] mgcp MGCP client instance.
+ * \param[in] epname endpoint name (e.g. "rtpbridge/1@mgw").
+ * \param[in] conn_id connection ID on which to inject the signal, or NULL.
+ * \param[in] signal signal line content (e.g. "D/5" for DTMF 5), or NULL to stop.
+ * \returns 0 on success, negative on error. */
+int mgcp_client_tx_rqnt(struct mgcp_client *mgcp, const char *epname,
+ const char *conn_id, const char *signal)
+{
+ struct mgcp_msg mgcp_msg;
+ struct msgb *msg;
+
+ memset(&mgcp_msg, 0, sizeof(mgcp_msg));
+ mgcp_msg.verb = MGCP_VERB_RQNT;
+ mgcp_msg.presence = MGCP_MSG_PRESENCE_ENDPOINT | MGCP_MSG_PRESENCE_SIGNAL;
+ OSMO_STRLCPY_ARRAY(mgcp_msg.endpoint, epname);
+
+ if (conn_id) {
+ mgcp_msg.presence |= MGCP_MSG_PRESENCE_CONN_ID;
+ mgcp_msg.conn_id = (char *)conn_id;
+ }
+
+ if (signal)
+ OSMO_STRLCPY_ARRAY(mgcp_msg.signal, signal);
+ /* else: empty signal string stops active tone */
+
+ msg = mgcp_msg_gen(mgcp, &mgcp_msg);
+ if (!msg) {
+ LOGPMGW(mgcp, LOGL_ERROR,
+ "Failed to generate MGCP RQNT for %s\n", epname);
+ return -EINVAL;
+ }
+
+ return mgcp_client_tx(mgcp, msg, NULL, NULL);
+}
diff --git a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c
index f2ec7fd..0e30a00 100644
--- a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c
+++ b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c
@@ -136,6 +136,7 @@
{ MGCP_VERB_DLCX, "DLCX" },
{ MGCP_VERB_AUEP, "AUEP" },
{ MGCP_VERB_RSIP, "RSIP" },
+ { MGCP_VERB_RQNT, "RQNT" },
{}
};


To view, visit change 44025. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I784d105b03b0ff10fe42ceb8e3a19c74ce58cac8
Gerrit-Change-Number: 44025
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis@fe80.eu>