Skip to content

Commit 64ea52b

Browse files
tokangasnordicjm
authored andcommitted
lib: pdn: Fix handling of APN rate control and malformed +CGEV
+CGEV: APNRATECTRL STAT can also have status 2, which means that no APN rate control is configured for the CID. Fixed the implementation to map this to PDN_EVENT_APN_RATE_CONTROL_OFF event instead of PDN_EVENT_APN_RATE_CONTROL_ON. Fixed handling of malformed +CGEV notifications where the CID can not be parsed. Earlier these caused the malformed event to be sent for all PDNs. Only PDN_EVENT_NETWORK_DETACH is intended to be sent for all PDNs, because the AT notification does not contain a CID and it affects all PDNs. Signed-off-by: Tommi Kangas <[email protected]>
1 parent 5ced5d9 commit 64ea52b

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,13 @@ Modem libraries
688688
* Added the :c:func:`nrf_modem_lib_trace_peek_at` function to the :c:struct:`nrf_modem_lib_trace_backend` interface to peek trace data at a byte offset without consuming it.
689689
Support for this API has been added to the flash trace backend.
690690

691+
* :ref:`pdn_readme` library:
692+
693+
* Fixed:
694+
695+
* An issue where wrong APN rate control event was sent.
696+
* An issue where a malformed +CGEV notification was not handled correctly.
697+
691698
Multiprotocol Service Layer libraries
692699
-------------------------------------
693700

lib/pdn/pdn.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ static void parse_cgev(const char *notif)
206206
}
207207

208208
SYS_SLIST_FOR_EACH_CONTAINER(&pdn_contexts, pdn, node) {
209-
if (pdn->callback && (pdn->context_id == cid || cid == CID_UNASSIGNED)) {
209+
if (pdn->callback &&
210+
(pdn->context_id == cid || map[i].event == PDN_EVENT_NETWORK_DETACH)) {
210211
pdn->callback(pdn->context_id, map[i].event, 0);
211212
}
212213
}
@@ -240,8 +241,8 @@ static void parse_cgev_apn_rate_ctrl(const char *notif)
240241
SYS_SLIST_FOR_EACH_CONTAINER(&pdn_contexts, pdn, node) {
241242
if (pdn->callback && pdn->context_id == cid) {
242243
pdn->callback(pdn->context_id,
243-
apn_rate_ctrl_status ? PDN_EVENT_APN_RATE_CONTROL_ON
244-
: PDN_EVENT_APN_RATE_CONTROL_OFF,
244+
apn_rate_ctrl_status == 1 ? PDN_EVENT_APN_RATE_CONTROL_ON
245+
: PDN_EVENT_APN_RATE_CONTROL_OFF,
245246
0);
246247
}
247248
}

tests/lib/pdn/src/main.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,13 @@ void test_pdn_deactivate(void)
12351235
TEST_ASSERT_EQUAL(PDN_EVENT_DEACTIVATED, pdn_evt_event);
12361236
}
12371237

1238+
void test_detach(void)
1239+
{
1240+
on_cgev("+CGEV: NW DETACH\r\n");
1241+
1242+
TEST_ASSERT_EQUAL(CID_1, pdn_evt_cid);
1243+
TEST_ASSERT_EQUAL(PDN_EVENT_NETWORK_DETACH, pdn_evt_event);
1244+
}
12381245

12391246
void test_pdn_id_get_eshutdown(void)
12401247
{
@@ -1346,6 +1353,19 @@ void test_pdn_apn_rate_control_deactivate(void)
13461353
TEST_ASSERT_EQUAL(PDN_EVENT_APN_RATE_CONTROL_OFF, pdn_evt_event);
13471354
}
13481355

1356+
void test_pdn_apn_rate_control_not_configured(void)
1357+
{
1358+
on_cgev("+CGEV: APNRATECTRL STAT 2,2");
1359+
/* no callback */
1360+
TEST_ASSERT_EQUAL(0, pdn_evt_cid);
1361+
TEST_ASSERT_EQUAL(0, pdn_evt_event);
1362+
1363+
on_cgev("+CGEV: APNRATECTRL STAT 1,2");
1364+
1365+
TEST_ASSERT_EQUAL(CID_1, pdn_evt_cid);
1366+
TEST_ASSERT_EQUAL(PDN_EVENT_APN_RATE_CONTROL_OFF, pdn_evt_event);
1367+
}
1368+
13491369
void test_pdn_ctx_destroy_einval(void)
13501370
{
13511371
int ret;

0 commit comments

Comments
 (0)