aboutsummaryrefslogtreecommitdiffstats
path: root/src/mgcp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-11-29 20:19:32 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-12-16 11:33:27 +0100
commit9b2474490a738665247ea3a04648f96411a78d6d (patch)
tree7520d11b2a24075f2686f0f5c069a826bbedd82c /src/mgcp
parent611d238a681ebbe48839a725648ac185305733a3 (diff)
mgcp: Begin handling of the RQNT message as needed for DTMF
Introduce a callback for the request and forward the signalrequest to the callback. This is not a full implementation of MGCP RQNT. Manual merge and backport from OpenBSC.
Diffstat (limited to 'src/mgcp')
-rw-r--r--src/mgcp/mgcp_protocol.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/mgcp/mgcp_protocol.c b/src/mgcp/mgcp_protocol.c
index f76342c..92559a3 100644
--- a/src/mgcp/mgcp_protocol.c
+++ b/src/mgcp/mgcp_protocol.c
@@ -2,8 +2,8 @@
/* The protocol implementation */
/*
- * (C) 2009-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2009-2011 by On-Waves
+ * (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2009-2012 by On-Waves
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -879,6 +879,15 @@ static struct msgb *handle_rsip(struct mgcp_config *cfg, struct msgb *msg)
return NULL;
}
+static char extract_tone(const char *line)
+{
+ const char *str = strstr(line, "D/");
+ if (!str)
+ return CHAR_MAX;
+
+ return str[2];
+}
+
/*
* This can request like DTMF detection and forward, fax detection... it
* can also request when the notification should be send and such. We don't
@@ -889,7 +898,8 @@ static struct msgb *handle_noti_req(struct mgcp_config *cfg, struct msgb *msg)
struct mgcp_msg_ptr data_ptrs[6];
const char *trans_id;
struct mgcp_endpoint *endp;
- int found;
+ int found, res = 0, i, line_start;
+ char tone = 0;
found = mgcp_analyze_header(cfg, msg, data_ptrs, ARRAY_SIZE(data_ptrs), &trans_id, &endp);
if (found != 0)
@@ -899,7 +909,31 @@ static struct msgb *handle_noti_req(struct mgcp_config *cfg, struct msgb *msg)
LOGP(DMGCP, LOGL_ERROR, "Endpoint is not used. 0x%x\n", ENDPOINT_NUMBER(endp));
return create_err_response(400, "RQNT", trans_id);
}
- return create_ok_response(200, "RQNT", trans_id);
+
+ MSG_TOKENIZE_START
+ switch (msg->l3h[line_start]) {
+ case 'S':
+ tone = extract_tone((const char *)&msg->l3h[line_start]);
+ break;
+ }
+ MSG_TOKENIZE_END
+
+ /* we didn't see a signal request with a tone */
+ if (tone == CHAR_MAX)
+ return create_ok_response(200, "RQNT", trans_id);
+
+ if (cfg->rqnt_cb)
+ res = cfg->rqnt_cb(endp, tone, (const char *) msg->l3h);
+
+ return res == 0 ?
+ create_ok_response(200, "RQNT", trans_id) :
+ create_err_response(res, "RQNT", trans_id);
+
+error:
+ LOGP(DMGCP, LOGL_ERROR, "Malformed line: %s on 0x%x with: line_start: %d %d\n",
+ osmo_hexdump(msg->l3h, msgb_l3len(msg)),
+ ENDPOINT_NUMBER(endp), line_start, i);
+ return create_err_response(400, "RQNT", trans_id);
}
static void trunk_init(struct mgcp_trunk_config *trunk)