sbcap: Fix encoding of Warning-Type

Change-Id: I9f6a0779c20ba86962aaaebc9b40ad162d2f2f3e
This commit is contained in:
Pau Espin 2022-07-22 19:26:41 +02:00
parent 028b48b967
commit 3468e90ab3
3 changed files with 8 additions and 13 deletions

View File

@ -84,7 +84,6 @@ SBcAP_SBC_AP_PDU_t *cbcmsg_to_sbcap(void *ctx, const struct cbc_message *cbcmsg)
const struct smscb_message *smscb = &cbcmsg->msg;
SBcAP_SBC_AP_PDU_t *pdu;
SBcAP_Write_Replace_Warning_Request_IEs_t *ie;
uint16_t ie_warning_type;
unsigned int i;
uint8_t *ptr;
#if 0
@ -150,17 +149,15 @@ SBcAP_SBC_AP_PDU_t *cbcmsg_to_sbcap(void *ctx, const struct cbc_message *cbcmsg)
if (smscb->is_etws) {
/* Warning Type, 3GPP TS 36.413 sec 9.2.1.50: */
ie_warning_type = smscb->etws.warning_type;
if (smscb->etws.user_alert)
ie_warning_type |= 0x0100;
if (smscb->etws.popup_on_display)
ie_warning_type |= 0x0080;
/* static const long asn_VAL_8_SBcAP_id_Warning_Type = 18; */
ie = sbcap_alloc_Write_Replace_Warning_Request_IE(18, SBcAP_Criticality_ignore,
SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Warning_Type);
ie->value.choice.Warning_Type.buf = MALLOC(sizeof(ie_warning_type));
ie->value.choice.Warning_Type.size = sizeof(ie_warning_type);
memcpy(ie->value.choice.Warning_Type.buf, &ie_warning_type, sizeof(ie_warning_type));
ie->value.choice.Warning_Type.buf = MALLOC(2);
ie->value.choice.Warning_Type.size = 2;
ie->value.choice.Warning_Type.buf[0] = ((smscb->etws.warning_type & 0x7f) << 1);
if (smscb->etws.user_alert)
ie->value.choice.Warning_Type.buf[0] |= 0x01;
ie->value.choice.Warning_Type.buf[1] = (smscb->etws.popup_on_display) ? 0x80 : 0x0;
ASN_SEQUENCE_ADD(as_pdu, ie);
/* Warning Security Information, 3GPP TS 36.413 sec 9.2.1.51: */

View File

@ -14,7 +14,7 @@ void test_asn1c_enc(void)
struct msgb *msg;
SBcAP_SBC_AP_PDU_t *pdu;
SBcAP_Write_Replace_Warning_Request_IEs_t *ie;
uint16_t ie_warning_type = 0x01;
uint8_t ie_warning_type[2] = {(0x01 << 1) | 0x01, 0x80};
uint8_t ie_dcs = 2;
uint8_t ie_warning_sec_info[50] = {0x30, 0x40, 0x12, 0x23, 0x45};
uint8_t ie_warning_msg_content[SBCAP_WARN_MSG_CONTENTS_IE_MAX_LEN] = {0x30, 0x40, 0x12, 0x23, 0x45};
@ -68,8 +68,6 @@ void test_asn1c_enc(void)
SBcAP_Write_Replace_Warning_Request_IEs__value_PR_Warning_Type);
ie->value.choice.Warning_Type.buf = MALLOC(sizeof(ie_warning_type));
ie->value.choice.Warning_Type.size = sizeof(ie_warning_type);
ie_warning_type |= 0x0100;
ie_warning_type |= 0x0080;
memcpy(ie->value.choice.Warning_Type.buf, &ie_warning_type, sizeof(ie_warning_type));
ASN_SEQUENCE_ADD(as_pdu, ie);

View File

@ -1,5 +1,5 @@
==== test_asn1c_enc ====
Encoded message: 00 00 00 76 00 00 08 00 05 00 02 ab 01 00 0b 00 02 ab cd 00 0a 00 02 00 1e 00 07 00 02 00 59 00 12 40 02 81 01 00 11 40 32 30 40 12 23 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 40 01 02 00 10 40 16 00 13 30 40 12 23 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Encoded message: 00 00 00 76 00 00 08 00 05 00 02 ab 01 00 0b 00 02 ab cd 00 0a 00 02 00 1e 00 07 00 02 00 59 00 12 40 02 03 80 00 11 40 32 30 40 12 23 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 40 01 02 00 10 40 16 00 13 30 40 12 23 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==== test_asn1c_dec ====
Decoding message: 20 00 00 14 00 00 03 00 05 00 02 00 2b 00 0b 00 02 41 70 00 01 00 01 00
Decoded message successfully