Move sbcap_as_find_ie() to libsbcap

This function is generic and can be (will be) used in more places.

Change-Id: Ib0c7fa12a8f6faa4271e4132ca5a5c656e717400
This commit is contained in:
Pau Espin 2022-07-26 15:33:29 +02:00
parent 745a2d6600
commit e67faef4ec
3 changed files with 16 additions and 14 deletions

View File

@ -144,6 +144,8 @@ void sbcap_set_log_area(int log_area);
SBcAP_ProcedureCode_t sbcap_pdu_get_procedure_code(const SBcAP_SBC_AP_PDU_t *pdu);
SBcAP_Criticality_t sbcap_pdu_get_criticality(const SBcAP_SBC_AP_PDU_t *pdu);
void *sbcap_as_find_ie(void *void_list, SBcAP_ProtocolIE_ID_t ie_id);
SBcAP_Write_Replace_Warning_Request_IEs_t *sbcap_alloc_Write_Replace_Warning_Request_IE(
long id, SBcAP_Criticality_t criticality, SBcAP_Write_Replace_Warning_Request_IEs__value_PR present);

View File

@ -141,6 +141,20 @@ SBcAP_Criticality_t sbcap_pdu_get_criticality(const SBcAP_SBC_AP_PDU_t *pdu)
}
}
void *sbcap_as_find_ie(void *void_list, SBcAP_ProtocolIE_ID_t ie_id)
{
A_SEQUENCE_OF(SBcAP_ProtocolIE_ID_t) *li = (void *)void_list;
int i;
for (i = 0; i < li->count; i++) {
/* "SBcAP_ProtocolIE_ID_t id" is first element in all *_IEs struct */
SBcAP_ProtocolIE_ID_t *cur_ie_id = li->array[i];
if (*cur_ie_id == ie_id) {
return cur_ie_id;
}
}
return NULL;
}
void sbcap_set_log_area(int log_area)
{
_sbcap_DSBCAP = log_area;

View File

@ -129,20 +129,6 @@ struct osmo_fsm sbcap_link_fsm = {
.cleanup = sbcap_link_fsm_cleanup,
};
static void *sbcap_as_find_ie(void *void_list, SBcAP_ProtocolIE_ID_t ie_id)
{
A_SEQUENCE_OF(SBcAP_ProtocolIE_ID_t) *li = (void *)void_list;
int i;
for (i = 0; i < li->count; i++) {
/* "SBcAP_ProtocolIE_ID_t id" is first element in all *_IEs struct */
SBcAP_ProtocolIE_ID_t *cur_ie_id = li->array[i];
if (*cur_ie_id == ie_id) {
return cur_ie_id;
}
}
return NULL;
}
static SBcAP_Message_Identifier_t *get_msg_id_ie(struct cbc_sbcap_link *link,
const SBcAP_SBC_AP_PDU_t *pdu)
{