pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28740 )
Change subject: sbcap: Fix encoding of Warning-Type
......................................................................
sbcap: Fix encoding of Warning-Type
Change-Id: I9f6a0779c20ba86962aaaebc9b40ad162d2f2f3e
---
M src/sbcap_msg.c
M tests/sbcap/sbcap_test.c
M tests/sbcap/sbcap_test.ok
3 files changed, 8 insertions(+), 13 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/src/sbcap_msg.c b/src/sbcap_msg.c
index d38f861..7dc3410 100644
--- a/src/sbcap_msg.c
+++ b/src/sbcap_msg.c
@@ -84,7 +84,6 @@
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 @@
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: */
diff --git a/tests/sbcap/sbcap_test.c b/tests/sbcap/sbcap_test.c
index 747d0b2..9c8a60f 100644
--- a/tests/sbcap/sbcap_test.c
+++ b/tests/sbcap/sbcap_test.c
@@ -14,7 +14,7 @@
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 @@
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);
diff --git a/tests/sbcap/sbcap_test.ok b/tests/sbcap/sbcap_test.ok
index b67583a..e679721 100644
--- a/tests/sbcap/sbcap_test.ok
+++ b/tests/sbcap/sbcap_test.ok
@@ -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
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28740
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc
Gerrit-Branch: master
Gerrit-Change-Id: I9f6a0779c20ba86962aaaebc9b40ad162d2f2f3e
Gerrit-Change-Number: 28740
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged