diff --git a/src/osmo-hnbgw/ranap_rab_ass.c b/src/osmo-hnbgw/ranap_rab_ass.c index cd8e625..e8addcd 100644 --- a/src/osmo-hnbgw/ranap_rab_ass.c +++ b/src/osmo-hnbgw/ranap_rab_ass.c @@ -176,7 +176,9 @@ static RANAP_IE_t *failed_list_item_from_rab_ass_resp(const RANAP_RAB_Assignment return ies->raB_FailedList.raB_FailedList_ies.list.array[index]; } -/* find the RAB specified by rab_id in ies and when found, decode the result into items_ies */ +/* Find the RAB specified by rab_id in ies, decode the result into items_ies and return a positive index. + * The caller is responsible for freeing the contents in items_ies. In case of failure, the return code + * will be negative. */ static int decode_rab_smditms_from_resp_ies(RANAP_RAB_SetupOrModifiedItemIEs_t *items_ies, RANAP_RAB_AssignmentResponseIEs_t *ies, uint8_t rab_id) { @@ -576,17 +578,16 @@ bool ranap_rab_ass_resp_ies_check_failure(RANAP_RAB_AssignmentResponseIEs_t *ies RANAP_RAB_FailedItemIEs_t _rab_failed_items_ies; RANAP_RAB_FailedItemIEs_t *rab_failed_items_ies = &_rab_failed_items_ies; int rc; - bool result = true; - /* If we can get a failed item for the specified RAB ID, then we know that the + /* If we can get a failed item (rc >= 0) for the specified RAB ID, then we know that the * HNB reported the RAB Assignment as failed */ rc = decode_rab_flitms_from_resp_ies(rab_failed_items_ies, ies, rab_id); if (rc < 0) - result = false; + return false; ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_RAB_FailedItem, rab_failed_items_ies); - return result; + return true; } /*! Check if a specific RAB is present in an RAB-ReleaseList inside RANAP_RAB_AssignmentRequestIEs. diff --git a/tests/ranap_rab_ass/ranap_rab_ass_test.c b/tests/ranap_rab_ass/ranap_rab_ass_test.c index fc2992d..fbdfa77 100644 --- a/tests/ranap_rab_ass/ranap_rab_ass_test.c +++ b/tests/ranap_rab_ass/ranap_rab_ass_test.c @@ -299,6 +299,31 @@ void test_ranap_rab_ass_resp_ies_check_failure(void) ranap_cn_rx_co_free(&message); } +/* Same as above but with a message that does not even contain a FailedItemsIEs list */ +void test_ranap_rab_ass_resp_ies_check_failure_no_faileditemies(void) +{ + int rc; + ranap_message message; + bool rab_failed_at_hnb; + uint8_t testvec[] = { + 0x60, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x01, 0x00, + 0x34, 0x40, 0x23, 0x00, 0x00, 0x01, 0x00, 0x33, + 0x40, 0x1c, 0x60, 0x3a, 0x7c, 0x35, 0x00, 0x01, + 0x0a, 0x09, 0x01, 0xa4, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x04, 0x0a, 0x00, 0x00 + }; + + rc = ranap_cn_rx_co_decode2(&message, testvec, sizeof(testvec)); + + OSMO_ASSERT(rc == 0); + rab_failed_at_hnb = + ranap_rab_ass_resp_ies_check_failure(&message.msg.raB_AssignmentResponseIEs, 23); + OSMO_ASSERT(rab_failed_at_hnb == 0) + + ranap_cn_rx_co_free(&message); +} + void test_ranap_rab_ass_req_ies_check_release(void) { int rc; @@ -413,6 +438,7 @@ int main(int argc, char **argv) test_ranap_rab_ass_req_ies_replace_inet_addr(); test_ranap_rab_ass_resp_ies_replace_inet_addr(); test_ranap_rab_ass_resp_ies_check_failure(); + test_ranap_rab_ass_resp_ies_check_failure_no_faileditemies(); test_ranap_rab_ass_req_ies_check_release(); test_ranap_rab_ass_req_ies_get_count();