test-hnbap: Test decoding of the hnbap registration request

The 16-bit values are not decoded correctly
This commit is contained in:
Daniel Willmann 2015-11-27 16:14:09 +01:00
parent 1a86955288
commit ea4c088e78
1 changed files with 50 additions and 0 deletions

View File

@ -20,6 +20,7 @@
*/
#include "iu_helpers.h"
#include "asn1helpers.h"
#include "hnbap_common.h"
#include "hnbap_ies_defs.h"
@ -32,6 +33,28 @@
void *talloc_asn1_ctx;
static const unsigned char hnbap_reg_req[] = {
0x00, 0x01,
0x00, 0x57, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00,
0x15, 0x04, 0x80, 0x31, 0x30, 0x30, 0x30, 0x35,
0x42, 0x39, 0x2d, 0x30, 0x30, 0x31, 0x30, 0x39,
0x34, 0x32, 0x30, 0x35, 0x30, 0x40, 0x00, 0x08,
0x00, 0x17, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x11, 0x00, 0x05, 0x00, 0xc0, 0xa8, 0x00,
0x32, 0x00, 0x09, 0x00, 0x03, 0x09, 0xf1, 0x99,
0x00, 0x0b, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x06, 0x00, 0x02, 0x40, 0x20, 0x00, 0x07,
0x00, 0x01, 0x64, 0x00, 0x0a, 0x00, 0x02, 0x00,
0x01
};
static const unsigned char hnbap_reg_acc[] = {
0x20, 0x01,
0x00, 0x09, 0x00, 0x00, 0x01, 0x00, 0x0e, 0x00,
0x02, 0x00, 0x00
};
static const unsigned char hnbap_ue_reg_req[] = {
0x00, 0x03,
0x00, 0x1a, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00,
@ -56,6 +79,7 @@ void test_asn1_decoding(void)
InitiatingMessage_t *im;
SuccessfulOutcome_t *so;
UERegisterRequestIEs_t ies;
HNBRegisterRequestIEs_t hnb_ies;
char imsi[16];
@ -64,6 +88,32 @@ void test_asn1_decoding(void)
memset(pdu, 0, sizeof(*pdu));
printf("Testing asn.1 HNBAP decoding\n");
dec_ret = aper_decode(NULL, &asn_DEF_HNBAP_PDU, (void **) &pdu,
hnbap_reg_req, sizeof(hnbap_reg_req), 0, 0);
ASSERT(dec_ret.code == RC_OK);
ASSERT(pdu->present == HNBAP_PDU_PR_initiatingMessage);
im = &pdu->choice.initiatingMessage;
ASSERT(im->procedureCode == ProcedureCode_id_HNBRegister);
rc = hnbap_decode_hnbregisterrequesties(&hnb_ies, &im->value);
ASSERT(rc >= 0);
uint16_t lac, sac;
uint8_t rac;
uint32_t cid;
lac = asn1str_to_u16(&hnb_ies.lac);
sac = asn1str_to_u16(&hnb_ies.sac);
rac = asn1str_to_u8(&hnb_ies.rac);
ASSERT(lac == 0x4020);
ASSERT(sac == 0x0001);
ASSERT(rac == 0x64);
dec_ret = aper_decode(NULL, &asn_DEF_HNBAP_PDU, (void **) &pdu,
hnbap_ue_reg_req, sizeof(hnbap_ue_reg_req), 0, 0);