2019-04-26 12:27:38 -07:00
|
|
|
/*
|
2020-03-13 04:12:52 -07:00
|
|
|
* Copyright 2013-2020 Software Radio Systems Limited
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* This file is part of srsLTE.
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2017-05-18 03:52:29 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2019-04-26 12:27:38 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2017-05-18 03:52:29 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-01-17 03:42:01 -08:00
|
|
|
#include "srslte/asn1/liblte_mme.h"
|
|
|
|
#include "srslte/asn1/rrc_asn1.h"
|
|
|
|
#include "srslte/common/log_filter.h"
|
2017-05-18 03:52:29 -07:00
|
|
|
#include <iostream>
|
|
|
|
#include <srslte/srslte.h>
|
2019-01-17 03:42:01 -08:00
|
|
|
|
|
|
|
#define TESTASSERT(cond) \
|
|
|
|
{ \
|
|
|
|
if (!(cond)) { \
|
|
|
|
std::cout << "[" << __FUNCTION__ << "][Line " << __LINE__ << "]: FAIL at " << (#cond) << std::endl; \
|
|
|
|
return -1; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace asn1;
|
|
|
|
using namespace asn1::rrc;
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2019-12-13 04:04:47 -08:00
|
|
|
int nas_test()
|
2019-12-16 07:04:22 -08:00
|
|
|
{
|
2017-06-23 07:29:46 -07:00
|
|
|
srslte::log_filter log1("NAS");
|
2017-05-18 03:52:29 -07:00
|
|
|
log1.set_level(srslte::LOG_LEVEL_DEBUG);
|
|
|
|
log1.set_hex_limit(-1);
|
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
uint8_t nas_message[128] = {0x27, 0x4f, 0xab, 0xef, 0x59, 0x01, 0x07, 0x42, 0x01, 0x49, 0x06, 0x40, 0x00, 0xf1, 0x10,
|
|
|
|
0x31, 0x32, 0x00, 0x22, 0x52, 0x01, 0xc1, 0x05, 0x07, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x0b,
|
|
|
|
0x76, 0x7a, 0x77, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x05, 0x01, 0x0e, 0x0e,
|
|
|
|
0x0e, 0x01, 0x5e, 0x04, 0xfe, 0xfe, 0x81, 0x4e, 0x50, 0x0b, 0xf6, 0x00, 0xf1, 0x10, 0x00,
|
|
|
|
0x02, 0x01, 0x01, 0x00, 0x00, 0x62, 0x17, 0x2c, 0x59, 0x49, 0x64, 0x01, 0x03};
|
2019-01-17 03:42:01 -08:00
|
|
|
uint32_t nas_message_len = sizeof(nas_message);
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
uint8 pd;
|
|
|
|
uint8 msg_type;
|
|
|
|
LIBLTE_BYTE_MSG_STRUCT buf;
|
|
|
|
LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept;
|
2018-05-03 08:36:39 -07:00
|
|
|
bzero(&attach_accept, sizeof(LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT));
|
2019-12-16 07:04:22 -08:00
|
|
|
LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req;
|
2018-05-03 08:36:39 -07:00
|
|
|
bzero(&act_def_eps_bearer_context_req, sizeof(LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT));
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2018-05-03 08:36:39 -07:00
|
|
|
bzero(&buf, sizeof(LIBLTE_BYTE_MSG_STRUCT));
|
2017-05-18 03:52:29 -07:00
|
|
|
memcpy(buf.msg, nas_message, nas_message_len);
|
|
|
|
buf.N_bytes = nas_message_len;
|
|
|
|
liblte_mme_parse_msg_header(&buf, &pd, &msg_type);
|
2019-12-16 07:04:22 -08:00
|
|
|
switch (msg_type) {
|
|
|
|
case LIBLTE_MME_MSG_TYPE_ATTACH_ACCEPT:
|
2017-05-18 03:52:29 -07:00
|
|
|
liblte_mme_unpack_attach_accept_msg(&buf, &attach_accept);
|
2019-12-16 07:04:22 -08:00
|
|
|
liblte_mme_unpack_activate_default_eps_bearer_context_request_msg(&attach_accept.esm_msg,
|
|
|
|
&act_def_eps_bearer_context_req);
|
2017-05-18 03:52:29 -07:00
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
case LIBLTE_MME_MSG_TYPE_ATTACH_REJECT:
|
2017-05-18 03:52:29 -07:00
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_REQUEST:
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
case LIBLTE_MME_MSG_TYPE_AUTHENTICATION_REJECT:
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
case LIBLTE_MME_MSG_TYPE_IDENTITY_REQUEST:
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
case LIBLTE_MME_MSG_TYPE_SECURITY_MODE_COMMAND:
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
case LIBLTE_MME_MSG_TYPE_SERVICE_REJECT:
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
case LIBLTE_MME_MSG_TYPE_ESM_INFORMATION_REQUEST:
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
case LIBLTE_MME_MSG_TYPE_EMM_INFORMATION:
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
break;
|
2019-12-16 07:04:22 -08:00
|
|
|
default:
|
2017-05-18 03:52:29 -07:00
|
|
|
break;
|
|
|
|
}
|
2019-12-13 04:04:47 -08:00
|
|
|
return 0;
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2019-12-13 04:04:47 -08:00
|
|
|
int meas_obj_test()
|
2019-01-17 03:42:01 -08:00
|
|
|
{
|
2017-06-23 07:29:46 -07:00
|
|
|
srslte::log_filter log1("RRC");
|
2017-05-18 03:52:29 -07:00
|
|
|
log1.set_level(srslte::LOG_LEVEL_DEBUG);
|
|
|
|
log1.set_hex_limit(-1);
|
|
|
|
|
2019-01-17 03:42:01 -08:00
|
|
|
asn1::rrc::dl_dcch_msg_s dl_dcch_msg;
|
|
|
|
|
|
|
|
uint8_t rrc_msg[256] = {
|
|
|
|
0x22, 0x16, 0x95, 0xa0, 0x18, 0x00, 0x05, 0xaa, 0x50, 0x36, 0x00, 0x61, 0x08, 0x9c, 0xe3, 0x40, 0xb0, 0x84, 0x4e,
|
|
|
|
0x71, 0xc0, 0x30, 0x84, 0x6e, 0x71, 0xe0, 0x70, 0x84, 0x6e, 0x70, 0x6c, 0x63, 0x1a, 0xc6, 0xb9, 0x8e, 0x7b, 0x1e,
|
|
|
|
0x84, 0xc0, 0x01, 0x24, 0x9d, 0x3e, 0xaf, 0xbd, 0x64, 0x04, 0x1d, 0x08, 0x05, 0x24, 0x19, 0x00, 0x03, 0xc4, 0x40,
|
|
|
|
0xc4, 0xc8, 0x00, 0x89, 0x48, 0x07, 0x04, 0x14, 0x1f, 0xff, 0xff, 0xff, 0xfc, 0x30, 0x2d, 0xd9, 0xe9, 0xdd, 0xa5,
|
|
|
|
0xb9, 0xd1, 0x95, 0xc9, 0xb9, 0x95, 0xd0, 0x14, 0x04, 0x38, 0x38, 0x38, 0x05, 0x78, 0x13, 0xfb, 0xfa, 0x05, 0x39,
|
|
|
|
0x40, 0x2f, 0xd8, 0x03, 0xc4, 0x40, 0x00, 0x08, 0x04, 0x04, 0x00, 0x01, 0x88, 0x5c, 0xb1, 0x65, 0x25, 0x90, 0x04,
|
|
|
|
0x0d, 0xa9, 0xc0, 0x2a, 0x9a, 0x01, 0x99, 0x3b, 0x01, 0xf5, 0x12, 0xf0, 0x85, 0x0d, 0x85, 0xef, 0xc0, 0x01, 0xf2,
|
|
|
|
0x20, 0x60, 0x18, 0x07, 0x97, 0x09, 0x1f, 0xc3, 0x06, 0x00, 0x81, 0x00, 0x00, 0x11};
|
|
|
|
uint32_t rrc_msg_len = sizeof(rrc_msg);
|
|
|
|
|
2020-01-23 03:11:14 -08:00
|
|
|
cbit_ref bref(&rrc_msg[0], sizeof(rrc_msg));
|
2019-01-17 03:42:01 -08:00
|
|
|
|
|
|
|
dl_dcch_msg.unpack(bref);
|
|
|
|
|
|
|
|
rrc_conn_recfg_r8_ies_s* reconf_r8 = &dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8();
|
|
|
|
TESTASSERT(reconf_r8->rr_cfg_ded_present);
|
|
|
|
TESTASSERT(reconf_r8->rr_cfg_ded.mac_main_cfg.type().value == rr_cfg_ded_s::mac_main_cfg_c_::types::explicit_value);
|
|
|
|
mac_main_cfg_s* mac_cfg = &reconf_r8->rr_cfg_ded.mac_main_cfg.explicit_value();
|
|
|
|
TESTASSERT(mac_cfg->ext);
|
|
|
|
TESTASSERT(mac_cfg->phr_cfg_present);
|
|
|
|
TESTASSERT(mac_cfg->phr_cfg.type() == setup_e::setup);
|
|
|
|
TESTASSERT(mac_cfg->sr_prohibit_timer_r9_present);
|
|
|
|
TESTASSERT(mac_cfg->sr_prohibit_timer_r9 == 0);
|
|
|
|
|
|
|
|
TESTASSERT(reconf_r8->rr_cfg_ded.phys_cfg_ded_present);
|
|
|
|
TESTASSERT(reconf_r8->rr_cfg_ded.phys_cfg_ded.pdsch_cfg_ded_present);
|
|
|
|
TESTASSERT(reconf_r8->rr_cfg_ded.phys_cfg_ded.pucch_cfg_ded_present);
|
|
|
|
TESTASSERT(reconf_r8->rr_cfg_ded.phys_cfg_ded.pusch_cfg_ded_present);
|
|
|
|
|
|
|
|
uint8_t rrc_msg2[rrc_msg_len];
|
2019-02-10 00:08:06 -08:00
|
|
|
bzero(rrc_msg2, sizeof(rrc_msg2));
|
2019-01-17 03:42:01 -08:00
|
|
|
bit_ref bref2(&rrc_msg2[0], rrc_msg_len);
|
|
|
|
dl_dcch_msg.pack(bref2);
|
|
|
|
|
|
|
|
//
|
2020-01-23 03:11:14 -08:00
|
|
|
bref = cbit_ref(&rrc_msg2[0], rrc_msg_len);
|
2019-01-17 03:42:01 -08:00
|
|
|
dl_dcch_msg.unpack(bref);
|
2020-01-23 03:11:14 -08:00
|
|
|
bit_ref bref_pack(&rrc_msg[0], rrc_msg_len);
|
|
|
|
dl_dcch_msg.pack(bref_pack);
|
|
|
|
uint32_t nof_bytes = (uint32_t)bref.distance_bytes();
|
2019-01-17 03:42:01 -08:00
|
|
|
|
2020-01-23 03:11:14 -08:00
|
|
|
TESTASSERT(bref_pack.distance() == bref2.distance());
|
2019-01-17 03:42:01 -08:00
|
|
|
TESTASSERT(memcmp(rrc_msg2, rrc_msg, nof_bytes) == 0);
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
printf("done\n");
|
2019-01-17 03:42:01 -08:00
|
|
|
return 0;
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2019-12-13 04:04:47 -08:00
|
|
|
TESTASSERT(meas_obj_test() == 0);
|
|
|
|
TESTASSERT(nas_test() == 0);
|
2017-05-18 03:52:29 -07:00
|
|
|
}
|