diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-11-29 12:54:22 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-11-29 19:56:22 +0100 |
commit | 8d0be259cb0ed8c33a373bbdfe88aafe4cfc27c0 (patch) | |
tree | 5dd1fd93a27ee7cfafb5ae5d47ac1950cd556935 /openbsc/tests | |
parent | 0d0c9ec5c54d8b66ec54c498c3dfcf0ba04372ca (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.
Diffstat (limited to 'openbsc/tests')
-rw-r--r-- | openbsc/tests/mgcp/mgcp_test.c | 58 | ||||
-rw-r--r-- | openbsc/tests/mgcp/mgcp_test.ok | 2 |
2 files changed, 60 insertions, 0 deletions
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c index 9b65666f4..74f5efee1 100644 --- a/openbsc/tests/mgcp/mgcp_test.c +++ b/openbsc/tests/mgcp/mgcp_test.c @@ -74,6 +74,15 @@ #define DLCX_RET "250 7 OK\r\n" \ "P: PS=0, OS=0, PR=0, OR=0, PL=0, JI=0\r\n" +#define RQNT "RQNT 186908780 1@mgw MGCP 1.0\r\n" \ + "X: B244F267488\r\n" \ + "S: D/9\r\n" + +#define RQNT2 "RQNT 186908780 1@mgw MGCP 1.0\r\n" \ + "X: ADD4F26746F\r\n" \ + "R: D/[0-9#*](N), G/ft, fxr/t38\r\n" + +#define RQNT_RET "200 186908780 OK\r\n" struct mgcp_test { const char *name; @@ -91,6 +100,8 @@ const struct mgcp_test tests[] = { { "SHORT2", SHORT2, SHORT2_RET }, { "SHORT3", SHORT3, SHORT2_RET }, { "SHORT4", SHORT4, SHORT2_RET }, + { "RQNT1", RQNT, RQNT_RET }, + { "RQNT2", RQNT2, RQNT_RET }, { "DLCX", DLCX, DLCX_RET }, }; @@ -137,6 +148,52 @@ static void test_messages(void) talloc_free(cfg); } +static int rqnt_cb(struct mgcp_endpoint *endp, char _tone, const char *data) +{ + ptrdiff_t tone = _tone; + endp->cfg->data = (void *) tone; + return 0; +} + +static void test_rqnt_cb(void) +{ + struct mgcp_config *cfg; + struct msgb *inp, *msg; + + cfg = mgcp_config_alloc(); + cfg->rqnt_cb = rqnt_cb; + + cfg->trunk.number_endpoints = 64; + mgcp_endpoints_allocate(&cfg->trunk); + + mgcp_endpoints_allocate(mgcp_trunk_alloc(cfg, 1)); + + inp = create_msg(CRCX); + msgb_free(mgcp_handle_message(cfg, inp)); + msgb_free(inp); + + /* send the RQNT and check for the CB */ + inp = create_msg(RQNT); + msg = mgcp_handle_message(cfg, inp); + if (strncmp((const char *) msg->l2h, "200", 3) != 0) { + printf("FAILED: message is not 200. '%s'\n", msg->l2h); + abort(); + } + + if (cfg->data != (void *) '9') { + printf("FAILED: callback not called: %p\n", cfg->data); + abort(); + } + + msgb_free(msg); + msgb_free(inp); + + inp = create_msg(DLCX); + msgb_free(mgcp_handle_message(cfg, inp)); + msgb_free(inp); + talloc_free(cfg); +} + struct pl_test { int cycles; uint16_t base_seq; @@ -195,6 +252,7 @@ int main(int argc, char **argv) test_messages(); test_packet_loss_calc(); + test_rqnt_cb(); printf("Done\n"); return EXIT_SUCCESS; diff --git a/openbsc/tests/mgcp/mgcp_test.ok b/openbsc/tests/mgcp/mgcp_test.ok index e61c0bc15..1143a0441 100644 --- a/openbsc/tests/mgcp/mgcp_test.ok +++ b/openbsc/tests/mgcp/mgcp_test.ok @@ -7,6 +7,8 @@ Testing SHORT1 Testing SHORT2 Testing SHORT3 Testing SHORT4 +Testing RQNT1 +Testing RQNT2 Testing DLCX Testing packet loss calculation. Done |