modem-helpers: handle +CGDCONT=? replies with single context
https://bugzilla.gnome.org/show_bug.cgi?id=708983
This commit is contained in:
@@ -764,7 +764,7 @@ mm_3gpp_parse_cgdcont_test_response (const gchar *response,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = g_regex_new ("\\+CGDCONT:\\s*\\((\\d+)-(\\d+)\\),\\(?\"(\\S+)\"",
|
r = g_regex_new ("\\+CGDCONT:\\s*\\((\\d+)-?(\\d+)?\\),\\(?\"(\\S+)\"",
|
||||||
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
|
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
|
||||||
0, &inner_error);
|
0, &inner_error);
|
||||||
g_assert (r != NULL);
|
g_assert (r != NULL);
|
||||||
@@ -786,19 +786,18 @@ mm_3gpp_parse_cgdcont_test_response (const gchar *response,
|
|||||||
if (!mm_get_uint_from_match_info (match_info, 1, &min_cid))
|
if (!mm_get_uint_from_match_info (match_info, 1, &min_cid))
|
||||||
mm_warn ("Invalid min CID in CGDCONT=? reply for PDP type '%s'", pdp_type_str);
|
mm_warn ("Invalid min CID in CGDCONT=? reply for PDP type '%s'", pdp_type_str);
|
||||||
else {
|
else {
|
||||||
/* Read max CID */
|
MM3gppPdpContextFormat *format;
|
||||||
|
|
||||||
|
/* Read max CID: Optional! If no value given, we default to min CID */
|
||||||
if (!mm_get_uint_from_match_info (match_info, 2, &max_cid))
|
if (!mm_get_uint_from_match_info (match_info, 2, &max_cid))
|
||||||
mm_warn ("Invalid max CID in CGDCONT=? reply for PDP type '%s'", pdp_type_str);
|
max_cid = min_cid;
|
||||||
else {
|
|
||||||
MM3gppPdpContextFormat *format;
|
|
||||||
|
|
||||||
format = g_slice_new (MM3gppPdpContextFormat);
|
format = g_slice_new (MM3gppPdpContextFormat);
|
||||||
format->pdp_type = pdp_type;
|
format->pdp_type = pdp_type;
|
||||||
format->min_cid = min_cid;
|
format->min_cid = min_cid;
|
||||||
format->max_cid = max_cid;
|
format->max_cid = max_cid;
|
||||||
|
|
||||||
list = g_list_prepend (list, format);
|
list = g_list_prepend (list, format);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1707,6 +1707,20 @@ test_cgdcont_test_response_multiple_and_ignore (void *f, gpointer d)
|
|||||||
test_cgdcont_test_results ("Multiple and Ignore", reply, &expected[0], G_N_ELEMENTS (expected));
|
test_cgdcont_test_results ("Multiple and Ignore", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_cgdcont_test_response_single_context (void *f, gpointer d)
|
||||||
|
{
|
||||||
|
const gchar *reply =
|
||||||
|
"+CGDCONT: (1),\"IP\",,,(0),(0)\r\n"
|
||||||
|
"+CGDCONT: (1),\"IPV6\",,,(0),(0)\r\n";
|
||||||
|
static MM3gppPdpContextFormat expected[] = {
|
||||||
|
{ 1, 1, MM_BEARER_IP_FAMILY_IPV4 },
|
||||||
|
{ 1, 1, MM_BEARER_IP_FAMILY_IPV6 }
|
||||||
|
};
|
||||||
|
|
||||||
|
test_cgdcont_test_results ("Single Context", reply, &expected[0], G_N_ELEMENTS (expected));
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Test CGDCONT read responses */
|
/* Test CGDCONT read responses */
|
||||||
|
|
||||||
@@ -2443,6 +2457,7 @@ int main (int argc, char **argv)
|
|||||||
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_single, NULL));
|
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_single, NULL));
|
||||||
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_multiple, NULL));
|
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_multiple, NULL));
|
||||||
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_multiple_and_ignore, NULL));
|
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_multiple_and_ignore, NULL));
|
||||||
|
g_test_suite_add (suite, TESTCASE (test_cgdcont_test_response_single_context, NULL));
|
||||||
|
|
||||||
g_test_suite_add (suite, TESTCASE (test_cgdcont_read_response_nokia, NULL));
|
g_test_suite_add (suite, TESTCASE (test_cgdcont_read_response_nokia, NULL));
|
||||||
g_test_suite_add (suite, TESTCASE (test_cgdcont_read_response_samsung, NULL));
|
g_test_suite_add (suite, TESTCASE (test_cgdcont_read_response_samsung, NULL));
|
||||||
|
Reference in New Issue
Block a user