aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-04-04 10:30:33 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-04-08 10:04:42 +0000
commit83a00a9457cec94febbef5afbf04777ccab9d902 (patch)
treea76ea3c4c958bc5d2992374d1f722aed23677bd8
parent7e0404c6c2928347f4f69906db7055444285c80e (diff)
modem-helpers: new helper to lookup range from CGDCONT=? response
-rw-r--r--src/mm-modem-helpers.c23
-rw-r--r--src/mm-modem-helpers.h5
2 files changed, 20 insertions, 8 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 5ff2498c..41573ede 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -1477,20 +1477,27 @@ mm_3gpp_cmp_apn_name (const gchar *requested,
/*************************************************************************/
-static guint
-find_max_allowed_cid (GList *context_format_list,
- MMBearerIpFamily ip_family)
+gboolean
+mm_3gpp_pdp_context_format_list_find_range (GList *pdp_format_list,
+ MMBearerIpFamily ip_family,
+ guint *out_min_cid,
+ guint *out_max_cid)
{
GList *l;
- for (l = context_format_list; l; l = g_list_next (l)) {
+ for (l = pdp_format_list; l; l = g_list_next (l)) {
MM3gppPdpContextFormat *format = l->data;
/* Found exact PDP type? */
- if (format->pdp_type == ip_family)
- return format->max_cid;
+ if (format->pdp_type == ip_family) {
+ if (out_min_cid)
+ *out_min_cid = format->min_cid;
+ if (out_max_cid)
+ *out_max_cid = format->max_cid;
+ return TRUE;
+ }
}
- return 0;
+ return FALSE;
}
guint
@@ -1573,7 +1580,7 @@ mm_3gpp_select_best_cid (const gchar *apn,
/* If the max existing CID found during CGDCONT? is below the max allowed
* CID, then we can use the next available CID because it's an unused one. */
- max_allowed_cid = find_max_allowed_cid (context_format_list, ip_family);
+ mm_3gpp_pdp_context_format_list_find_range (context_format_list, ip_family, NULL, &max_allowed_cid);
if (max_cid && (max_cid < max_allowed_cid)) {
mm_obj_dbg (log_object, "found unused context at CID %u (<%u)", max_cid + 1, max_allowed_cid);
*out_cid_reused = FALSE;
diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h
index 06eb9444..dfa71884 100644
--- a/src/mm-modem-helpers.h
+++ b/src/mm-modem-helpers.h
@@ -185,6 +185,11 @@ GList *mm_3gpp_parse_cgdcont_test_response (const gchar *reply,
gpointer log_object,
GError **error);
+gboolean mm_3gpp_pdp_context_format_list_find_range (GList *pdp_format_list,
+ MMBearerIpFamily ip_family,
+ guint *out_min_cid,
+ guint *out_max_cid);
+
/* AT+CGDCONT? (PDP context query) response parser */
typedef struct {
guint cid;