aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-09-03 22:11:05 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-09-07 04:14:40 +0200
commit6531726a02c1da607789ab9327ab29dce3a0d2f5 (patch)
treea40899eebce59330054ef02d5b655121289e1fd8 /tests
parent31b4729f2731c747b8b33c4646dd5ade2ace29bc (diff)
mgcp_conn_get(): compare conn Id ('I:') case insensitively
The Connection Identifier is defined as a hex string, so clients may send the ID back in lower case. Convert to upper case before comparing. A specific SCCPlite MSC is observed to DLCX with Connection Identifier in lower case, which would mismatch pefore this patch. Add test_conn_id_matching() in mgcp_test.c to verify case insensitivity. Cosmetic: use strcmp(), not strncmp(). In the presence of a terminating nul as we can assume here, this makes no functional difference, but it clarifies the code. Related: OS#3508 Depends: Ib0ee1206b9f31d7ba25c31f8008119ac55440797 (libosmocore) Change-Id: I8e52278c3abe9e9c8c848c2b1538bce443f68a43
Diffstat (limited to 'tests')
-rw-r--r--tests/mgcp/mgcp_test.c35
-rw-r--r--tests/mgcp/mgcp_test.ok4
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index c40eabc1c..99ddd7186 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -1751,6 +1751,40 @@ static void test_mgcp_codec_pt_translate(void)
OSMO_ASSERT(pt_dst == -EINVAL);
}
+void test_conn_id_matching()
+{
+ struct mgcp_endpoint endp = {};
+ struct mgcp_conn *conn;
+ struct mgcp_conn *conn_match;
+ int i;
+ const char *conn_id_generated = "000023AB";
+ const char *conn_id_request[] = {
+ "000023AB",
+ "000023ab",
+ };
+
+ printf("\nTesting %s\n", __func__);
+
+ INIT_LLIST_HEAD(&endp.conns);
+
+ conn = talloc_zero(NULL, struct mgcp_conn);
+ OSMO_ASSERT(conn);
+ osmo_strlcpy(conn->id, conn_id_generated, sizeof(conn->id));
+ llist_add(&conn->entry, &endp.conns);
+
+ for (i = 0; i < ARRAY_SIZE(conn_id_request); i++) {
+ const char *needle = conn_id_request[i];
+ printf("needle='%s' ", needle);
+ conn_match = mgcp_conn_get(&endp, needle);
+ OSMO_ASSERT(conn_match);
+ printf("found '%s'\n", conn_match->id);
+ OSMO_ASSERT(conn_match == conn);
+ }
+
+ llist_del(&conn->entry);
+ talloc_free(conn);
+}
+
int main(int argc, char **argv)
{
void *ctx = talloc_named_const(NULL, 0, "mgcp_test");
@@ -1775,6 +1809,7 @@ int main(int argc, char **argv)
test_get_lco_identifier();
test_check_local_cx_options(ctx);
test_mgcp_codec_pt_translate();
+ test_conn_id_matching();
OSMO_ASSERT(talloc_total_size(msgb_ctx) == 0);
OSMO_ASSERT(talloc_total_blocks(msgb_ctx) == 1);
diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok
index ddda751b3..f50f487e8 100644
--- a/tests/mgcp/mgcp_test.ok
+++ b/tests/mgcp/mgcp_test.ok
@@ -1169,4 +1169,8 @@ p:10, a:PCMU -> p:10, a:PCMU
'' -> '(null)'
p10, aPCMU -> (null)
'10,a :PCMU' -> '(null)'
+
+Testing test_conn_id_matching
+needle='000023AB' found '000023AB'
+needle='000023ab' found '000023AB'
Done