From f7154126596155abb83d66bccad612fb99c12d4d Mon Sep 17 00:00:00 2001 From: Dottore Spina Date: Mon, 8 Jul 2019 18:12:00 +0200 Subject: [PATCH 01/25] Fix call to CHECK_LIBRARY_EXISTS in FindbladeRF An invalid call to the CMake macro CHECK_LIBRARY_EXISTS() in cmake/modules/FindbladeRF.cmake prevents srsLTE to enable support for the bladeRF driver when: * libbladeRF is installed to the same custom prefix we use to build srsLTE, as with cmake -DCMAKE_INSTALL_PREFIX=/path/to/custom/prefix * libbladeRF is installed to /usr/local/lib BUT the linker does not search this path by default This trivial patch makes FindbladeRF.cmake provide the linker with the path libbladeRF is actually installed to. --- cmake/modules/FindbladeRF.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindbladeRF.cmake b/cmake/modules/FindbladeRF.cmake index 565603000..b971c3b84 100644 --- a/cmake/modules/FindbladeRF.cmake +++ b/cmake/modules/FindbladeRF.cmake @@ -15,7 +15,8 @@ if(NOT BLADERF_FOUND) ) if(BLADERF_INCLUDE_DIRS AND BLADERF_LIBRARIES) - CHECK_LIBRARY_EXISTS(bladeRF bladerf_get_board_name BLADERF_LIBRARIES BLADERF_VERSION_OK) + get_filename_component(bladerf_lib_dir ${BLADERF_LIBRARIES} DIRECTORY) + CHECK_LIBRARY_EXISTS(bladeRF bladerf_get_board_name ${bladerf_lib_dir} BLADERF_VERSION_OK) if (BLADERF_VERSION_OK) set(BLADERF_FOUND TRUE CACHE INTERNAL "libbladeRF found") message(STATUS "Found libbladeRF: ${BLADERF_INCLUDE_DIRS}, ${BLADERF_LIBRARIES}") From 743f1e2e8c2baafbc68a1598502e012a08a64cf0 Mon Sep 17 00:00:00 2001 From: Digicrat Date: Fri, 26 Jul 2019 16:15:16 -0400 Subject: [PATCH 02/25] Fix bug wherein blank lines or trailing newlines causes parsing of user_db.csv to fail. --- srsepc/src/hss/hss.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index fb7d79fd2..1df484802 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -110,7 +110,7 @@ bool hss::read_db_file(std::string db_filename) std::string line; while (std::getline(m_db_file, line)) { - if (line[0] != '#') { + if (line[0] != '#' && line.length() > 0) { uint column_size = 10; std::vector split = split_string(line, ','); if (split.size() != column_size) { From 10720aeacead696dc8c1fe32d32aed633d202a18 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 4 Aug 2019 12:49:28 +0200 Subject: [PATCH 03/25] [ENB] Fix enabling of MAC pcap file when using [pcap] enable = true filename = /tmp/enb.pcap in enb.conf, there is no pcap file created. The problem is somewhere in the way how arguments are handled. pcap.enable is properly parsed into args.pcap. However, later on, lte_stack->init(args.stack, rrc_cfg, lte_phy.get()) only passes args.stack down the road, not args.pcap. enb_stack_lte::init() then basically uses args.stack.pcap and not args.pcap, and the latter appears always false. Let's remove pcap_args_t from all_args and only use the instance in stack_args_t. Closes: #359 --- srsenb/hdr/enb.h | 1 - srsenb/src/main.cc | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index 45592e401..7ef46f1a1 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -101,7 +101,6 @@ struct all_args_t { enb_args_t enb; enb_files_t enb_files; srslte::rf_args_t rf; - pcap_args_t pcap; log_args_t log; gui_args_t gui; general_args_t general; diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index fbf0e1077..e4b9b40e8 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -97,8 +97,8 @@ void parse_args(all_args_t *args, int argc, char* argv[]) { ("rf.time_adv_nsamples", bpo::value(&args->rf.time_adv_nsamples)->default_value("auto"), "Transmission time advance") ("rf.burst_preamble_us", bpo::value(&args->rf.burst_preamble)->default_value("auto"), "Transmission time advance") - ("pcap.enable", bpo::value(&args->pcap.enable)->default_value(false), "Enable MAC packet captures for wireshark") - ("pcap.filename", bpo::value(&args->pcap.filename)->default_value("ue.pcap"), "MAC layer capture filename") + ("pcap.enable", bpo::value(&args->stack.pcap.enable)->default_value(false), "Enable MAC packet captures for wireshark") + ("pcap.filename", bpo::value(&args->stack.pcap.filename)->default_value("ue.pcap"), "MAC layer capture filename") ("gui.enable", bpo::value(&args->gui.enable)->default_value(false), "Enable GUI plots") From 6a4dcc8c0c240dad5fd6597a6c63c21688bfa0c1 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 4 Aug 2019 12:17:53 +0200 Subject: [PATCH 04/25] [ENB] Fix builds with #define WRITE_SIB_PCAP Building with WRITE_SIB_PCAP was broken in April 2019 in commit 7780b1aba592789523f90ac66840dd07f36f93ee. Let's make it work again. --- srsenb/src/stack/mac/mac.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index a49c19836..c1ec75529 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -630,7 +630,7 @@ int mac::get_dl_sched(uint32_t tti, dl_sched_t *dl_sched_res) dl_sched_res->pdsch[n].data[0] = assemble_si(sched_result.bc[i].index); #ifdef WRITE_SIB_PCAP if (pcap) { - pcap->write_dl_sirnti(dl_sched_res->sched_grants[n].data[0], sched_result.bc[i].tbs, true, tti); + pcap->write_dl_sirnti(dl_sched_res->pdsch[n].data[0], sched_result.bc[i].tbs, true, tti); } #endif } else { From 6773826b26d8791d9635f5f9469b6cd76c916357 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 4 Aug 2019 12:14:13 +0200 Subject: [PATCH 05/25] [ENB] enb.conf.example: Mention WRITE_SIB_PCAP The documentation talks about a MAC protocol trace, but in fact it is only a protocol trace of dedicated channels. There's a related define in the source code, but that's not documented. Let's at least make the user aware that the MAC pcap trace is for dedicated channels only, unless he uses that #define. --- srsenb/enb.conf.example | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/srsenb/enb.conf.example b/srsenb/enb.conf.example index bb6002661..262833977 100644 --- a/srsenb/enb.conf.example +++ b/srsenb/enb.conf.example @@ -89,6 +89,11 @@ rx_gain = 40 # add an entry with DLT=147, Payload Protocol=mac-lte-framed. # For more information see: https://wiki.wireshark.org/MAC-LTE # +# Please note that this setting will by default only capture MAC +# frames on dedicated channels, and not SIB. You have to build with +# WRITE_SIB_PCAP enabled in srsenb/src/stack/mac/mac.cc if you want +# SIB to be part of the MAC pcap file. +# # enable: Enable MAC layer packet captures (true/false) # filename: File path to use for packet captures ##################################################################### From 8c16bcaf30827dc2865f1ffe36fdaa165f92cf95 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Thu, 8 Aug 2019 13:27:21 +0100 Subject: [PATCH 06/25] Fix for [gw] parameter names --- srsue/ue.conf.example | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 0dc68b19c..acb9345c2 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -164,12 +164,12 @@ imei = 353490069873319 ##################################################################### # GW configuration # -# tun_dev_name: Name of the tun_srsue device. Default: tun_srsue -# tun_dev_netmask: Netmask of the tun_srsue device. Default: 255.255.255.0 +# ip_devname: Name of the tun_srsue device. Default: tun_srsue +# ip_netmask: Netmask of the tun_srsue device. Default: 255.255.255.0 ##################################################################### [gw] -#tun_dev_name = tun_srsue -#tun_dev_netmask = 255.255.255.0 +#ip_devname = tun_srsue +#ip_netmask = 255.255.255.0 ##################################################################### # GUI configuration From dc73f546b65551c6064deafdbaa38352d3c2d958 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 3 Aug 2019 22:05:38 +0200 Subject: [PATCH 07/25] SRSENB: Add SIB7 (GERAN neighbor) support This adds the required missing bits to the eNB config file parser to enable minimalistic support of parsing SIB7 configuration. SIB7 contains GERAN (GSM) neighbor cell information, which is important if you are operating a combined 2G+4G netowrk and want to assist the UEs to reselect GSM cells once they move out of LTE coverage. An example SIB7 section looks as follows: sib7 = { t_resel_geran = 1; carrier_freqs_info_list = ( { cell_resel_prio = 0; ncc_permitted = 255; q_rx_lev_min = 0; thresh_x_high = 7; thresh_x_low = 7; start_arfcn = 871; band_ind = "dcs1800"; explicit_list_of_arfcns = ( 873, 875, 877 ); } ); }; Closes: #357 --- srsenb/hdr/enb.h | 1 + srsenb/src/enb_cfg_parser.cc | 117 +++++++++++++++++++++++++++++++++++ srsenb/src/enb_cfg_parser.h | 14 +++++ 3 files changed, 132 insertions(+) diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index 7ef46f1a1..f58007747 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -173,6 +173,7 @@ private: int parse_sib2(std::string filename, asn1::rrc::sib_type2_s* data); int parse_sib3(std::string filename, asn1::rrc::sib_type3_s* data); int parse_sib4(std::string filename, asn1::rrc::sib_type4_s* data); + int parse_sib7(std::string filename, asn1::rrc::sib_type7_s* data); int parse_sib9(std::string filename, asn1::rrc::sib_type9_s* data); int parse_sib13(std::string filename, asn1::rrc::sib_type13_r9_s* data); int parse_sibs(all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_config_common); diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 80d5a8ad8..5a61dd670 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -129,6 +129,97 @@ int field_intra_black_cell_list::parse(libconfig::Setting& root) return 0; } +int field_carrier_freqs_info_list::parse(libconfig::Setting& root) +{ + data->carrier_freqs_info_list.resize((uint32_t)root.getLength()); + data->carrier_freqs_info_list_present = data->carrier_freqs_info_list.size() > 0; + if (data->carrier_freqs_info_list.size() > ASN1_RRC_MAX_GNFG) { + ERROR("CarrierFreqsInfoGERAN cannot have more than %d entries\n", ASN1_RRC_MAX_GNFG); + return -1; + } + for (uint32_t i = 0; i < data->carrier_freqs_info_list.size(); i++) { + + int cell_resel_prio; + if (root[i].lookupValue("cell_resel_prio", cell_resel_prio)) { + data->carrier_freqs_info_list[i].common_info.cell_resel_prio_present = true; + data->carrier_freqs_info_list[i].common_info.cell_resel_prio = cell_resel_prio; + } + + int p_max_geran; + if (root[i].lookupValue("p_max_geran", p_max_geran)) { + data->carrier_freqs_info_list[i].common_info.p_max_geran_present = true; + data->carrier_freqs_info_list[i].common_info.p_max_geran = p_max_geran; + } + + field_asn1_bitstring_number, uint8_t> ncc_permitted("ncc_permitted", + &data->carrier_freqs_info_list[i].common_info.ncc_permitted); + if (ncc_permitted.parse(root[i])) { + ERROR("Error parsing `ncc_permitted` in carrier_freqs_info_lsit=%d\n", i); + return -1; + } + + int q_rx_lev_min = 0; + if (!root[i].lookupValue("q_rx_lev_min", q_rx_lev_min)) { + ERROR("Missing field `q_rx_lev_min` in carrier_freqs_info_list=%d\n", i); + return -1; + } + data->carrier_freqs_info_list[i].common_info.q_rx_lev_min = q_rx_lev_min; + + int thresh_x_high = 0; + if (!root[i].lookupValue("thresh_x_high", thresh_x_high)) { + ERROR("Missing field `thresh_x_high` in carrier_freqs_info_list=%d\n", i); + return -1; + } + data->carrier_freqs_info_list[i].common_info.thresh_x_high = thresh_x_high; + + int thresh_x_low = 0; + if (!root[i].lookupValue("thresh_x_low", thresh_x_low)) { + ERROR("Missing field `thresh_x_low` in carrier_freqs_info_list=%d\n", i); + return -1; + } + data->carrier_freqs_info_list[i].common_info.thresh_x_low = thresh_x_low; + + int start_arfcn = 0; + if (root[i].lookupValue("start_arfcn", start_arfcn)) { + data->carrier_freqs_info_list[i].carrier_freqs.start_arfcn = start_arfcn; + } + + field_asn1_enum_str band_ind("band_ind", + &data->carrier_freqs_info_list[i].carrier_freqs.band_ind); + if (band_ind.parse(root[i])) { + ERROR("Error parsing `band_ind` in carrier_freqs_info_list=%d\n", i); + return -1; + } + + data->carrier_freqs_info_list[i].carrier_freqs.following_arfcns.set_explicit_list_of_arfcns(); + + explicit_list_of_arfcns_l &exp_l = + data->carrier_freqs_info_list[i].carrier_freqs.following_arfcns.explicit_list_of_arfcns(); + if (root[i].exists("explicit_list_of_arfcns")) { + exp_l.resize((uint32_t)root[i]["explicit_list_of_arfcns"].getLength()); + if (exp_l.size() < 31) { /* SEQUENCE (SIZE (0..31)) OF ARFCN-ValueGERAN */ + for (uint32_t j = 0; j < exp_l.size(); j++) { + int arfcn = root[i]["explicit_list_of_arfcns"][j]; + if (arfcn >= 0 && arfcn <= 1024) { + exp_l[j] = (short unsigned int)arfcn; + } else { + fprintf(stderr, "Invalid ARFCN %d in for carrier_freqs_info_list=%d explicit_list_of_arfcns\n", i, j); + return -1; + } + } + } else { + fprintf(stderr, "Number of ARFCN in explicit_list_of_arfcns exceeds maximum (%d)\n", 31); + return -1; + } + } else { + exp_l.resize(0); + } + + } + return 0; +} + + int enb::parse_sib1(std::string filename, sib_type1_s* data) { parser::section sib1("sib1"); @@ -483,6 +574,24 @@ int enb::parse_sib4(std::string filename, sib_type4_s* data) return parser::parse_section(filename, &sib4); } +int enb::parse_sib7(std::string filename, sib_type7_s* data) +{ + parser::section sib7("sib7"); + + sib7.add_field(new parser::field("t_resel_geran", &data->t_resel_geran)); + // TODO: t_resel_geran_sf + + data->carrier_freqs_info_list_present = true; + parser::section geran_neigh("carrier_freqs_info_list"); + sib7.add_subsection(&geran_neigh); + + bool dummy_bool = false; + geran_neigh.set_optional(&dummy_bool); + geran_neigh.add_field(new field_carrier_freqs_info_list(data)); + + return parser::parse_section(filename, &sib7); +} + int enb::parse_sib9(std::string filename, sib_type9_s* data) { parser::section sib9("sib9"); @@ -613,6 +722,7 @@ int enb::parse_sibs(all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_config_ sib_type2_s* sib2 = &rrc_cfg->sibs[1].set_sib2(); sib_type3_s* sib3 = &rrc_cfg->sibs[2].set_sib3(); sib_type4_s* sib4 = &rrc_cfg->sibs[3].set_sib4(); + sib_type7_s* sib7 = &rrc_cfg->sibs[6].set_sib7(); sib_type9_s* sib9 = &rrc_cfg->sibs[8].set_sib9(); sib_type13_r9_s* sib13 = &rrc_cfg->sibs[12].set_sib13_v920(); @@ -686,6 +796,13 @@ int enb::parse_sibs(all_args_t* args, rrc_cfg_t* rrc_cfg, phy_cfg_t* phy_config_ } } + // Generate SIB7 if defined in mapping info + if (sib_is_present(sib1->sched_info_list, sib_type_e::sib_type7)) { + if (parse_sib7(args->enb_files.sib_config, sib7)) { + return -1; + } + } + // Generate SIB9 if defined in mapping info if (sib_is_present(sib1->sched_info_list, sib_type_e::sib_type9)) { if (parse_sib9(args->enb_files.sib_config, sib9)) { diff --git a/srsenb/src/enb_cfg_parser.h b/srsenb/src/enb_cfg_parser.h index 72b7ea5af..464e73311 100644 --- a/srsenb/src/enb_cfg_parser.h +++ b/srsenb/src/enb_cfg_parser.h @@ -79,6 +79,20 @@ private: asn1::rrc::sib_type4_s* data; }; +class field_carrier_freqs_info_list : public parser::field_itf +{ +public: + field_carrier_freqs_info_list(asn1::rrc::sib_type7_s* data_) { data = data_; } + ~field_carrier_freqs_info_list(){} + int parse(Setting &root); + const char* get_name() { + return "carrier_freqs_info_list"; + } + +private: + asn1::rrc::sib_type7_s* data; +}; + class field_sf_mapping : public parser::field_itf { public: From 92ed3f2705749e879901c6c3d4a5878bacf47ce9 Mon Sep 17 00:00:00 2001 From: Igor Kim Date: Fri, 9 Aug 2019 20:38:43 +0200 Subject: [PATCH 08/25] Fix TBS table with auto-generated one (#368) --- lib/src/phy/phch/tbs_tables.h | 66 ++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/lib/src/phy/phch/tbs_tables.h b/lib/src/phy/phch/tbs_tables.h index a0743195f..31d675fb4 100644 --- a/lib/src/phy/phch/tbs_tables.h +++ b/lib/src/phy/phch/tbs_tables.h @@ -33,6 +33,7 @@ static const int ul_mcs_tbs_idx_table[29] = {0, 1, 2, 3, 4, 5, 6, 7, 8, /* Transport Block Size from 3GPP TS 36.213 v12.13.0 table 7.1.7.2.1-1 */ static const int tbs_table[34][110] = { + /* The matrix below is automatically generated from ETSI TS 136 213 V12.13.0 (2019-03) */ {16, 32, 56, 88, 120, 152, 176, 208, 224, 256, 288, 328, 344, 376, 392, 424, 456, 488, 504, 536, 568, 600, 616, 648, 680, 712, 744, 776, 776, 808, 840, 872, 904, 936, 968, 1000, 1032, 1032, 1064, 1096, 1128, 1160, 1192, 1224, 1256, 1256, 1288, 1320, 1352, 1384, 1416, 1416, 1480, 1480, 1544, 1544, 1608, @@ -216,52 +217,53 @@ static const int tbs_table[34][110] = { 48936, 48936, 48936, 51024, 51024, 52752, 52752, 52752, 55056, 55056, 55056, 55056, 57336, 57336, 57336, 59256, 59256, 59256, 61664, 61664, 61664, 63776, 63776, 63776, 66592, 66592, 66592, 68808, 68808, 68808, 71112, 71112, 71112, 73712, 73712, 75376, 75376, 75376, 75376, 75376, 75376, 75376, 75376, 75376, 75376, 75376}, - {648, 1320, 1992, 2664, 3368, 4008, 4584, 5352, 5992, 6712, 7224, 7992, 8504, 9144, 9912, - 10680, 11448, 11832, 12576, 12960, 14112, 14688, 15264, 15840, 16416, 16992, 17568, 18336, 19080, 19848, - 20616, 21384, 22152, 22920, 22920, 23688, 24496, 25456, 25456, 26416, 27376, 27376, 28336, 29296, 29296, - 30576, 31704, 31704, 32856, 32856, 34008, 34008, 35160, 36696, 37888, 39232, 39232, 40576, 40576, 42368, - 42368, 43816, 43816, 43816, 45352, 46888, 46888, 46888, 48936, 48936, 48936, 51024, 51024, 51024, 52752, - 52752, 52752, 55056, 55056, 55056, 57336, 57336, 57336, 59256, 59256, 59256, 59256, 61664, 61664, 61664, - 63776, 63776, 63776, 63776, 66592, 66592, 66592, 66592, 68808, 68808, 71112, 71112, 71112, 71112, 73712}, + {648, 1320, 1992, 2664, 3368, 4008, 4584, 5352, 5992, 6712, 7224, 7992, 8504, 9144, 9912, + 10680, 11448, 11832, 12576, 12960, 14112, 14688, 15264, 15840, 16416, 16992, 17568, 18336, 19080, 19848, + 20616, 21384, 22152, 22920, 22920, 23688, 24496, 25456, 25456, 26416, 27376, 27376, 28336, 29296, 29296, + 30576, 31704, 31704, 32856, 32856, 34008, 34008, 35160, 35160, 36696, 36696, 37888, 37888, 39232, 39232, + 40576, 40576, 42368, 42368, 43816, 43816, 43816, 45352, 45352, 46888, 46888, 46888, 48936, 48936, 48936, + 51024, 51024, 51024, 52752, 52752, 52752, 55056, 55056, 55056, 57336, 57336, 57336, 59256, 59256, 59256, + 59256, 61664, 61664, 61664, 63776, 63776, 63776, 63776, 66592, 66592, 66592, 66592, 68808, 68808, 68808, + 71112, 71112, 71112, 71112, 73712}, {680, 1384, 2088, 2792, 3496, 4264, 4968, 5544, 6200, 6968, 7736, 8504, 9144, 9912, 10680, 11064, 11832, 12576, 13536, 14112, 14688, 15264, 16416, 16992, 17568, 18336, 19080, 19848, 20616, 21384, 22152, 22152, - 22920, 23668, 24496, 25456, 26416, 26416, 27376, 28336, 29296, 29296, 30576, 31704, 32856, 34008, 34008, 35160, - 35160, 36696, 36696, 37888, 39232, 29232, 40576, 40576, 42368, 42368, 42368, 43816, 43816, 45352, 45352, 46888, - 46888, 46888, 48936, 48936, 48936, 51024, 51024, 52752, 52752, 52752, 55056, 55056, 55056, 57336, 57336, 57336, - 59256, 59256, 59256, 61664, 61664, 61664, 61664, 63776, 63776, 63776, 66592, 66592, 66592, 66592, 68808, 68808, - 68808, 71112, 71112, 71112, 73712, 73712, 75376, 75376, 76208, 76208}, - {712, 1480, 2216, 2984, 3752, 4392, 5160, 5992, 6712, 7480, 8248, 4760, 9528, 10296, 11064, 11832, - 12576, 13536, 14112, 14668, 15840, 16416, 16992, 17568, 18336, 19080, 19848, 20616, 61384, 22152, 22920, 23688, + 22920, 23688, 24496, 25456, 26416, 26416, 27376, 28336, 29296, 29296, 30576, 30576, 31704, 32856, 32856, 34008, + 34008, 35160, 35160, 36696, 36696, 37888, 39232, 39232, 40576, 40576, 42368, 42368, 42368, 43816, 43816, 45352, + 45352, 46888, 46888, 46888, 48936, 48936, 48936, 51024, 51024, 52752, 52752, 52752, 55056, 55056, 55056, 57336, + 57336, 57336, 59256, 59256, 59256, 61664, 61664, 61664, 61664, 63776, 63776, 63776, 66592, 66592, 66592, 66592, + 68808, 68808, 68808, 71112, 71112, 71112, 73712, 73712, 73712, 75376, 75376, 76208, 76208, 76208}, + {712, 1480, 2216, 2984, 3752, 4392, 5160, 5992, 6712, 7480, 8248, 8760, 9528, 10296, 11064, 11832, + 12576, 13536, 14112, 14688, 15840, 16416, 16992, 17568, 18336, 19080, 19848, 20616, 21384, 22152, 22920, 23688, 24496, 25456, 26416, 26416, 27376, 28336, 29296, 29296, 30576, 31704, 31704, 32856, 34008, 34008, 35160, 35160, 36696, 36696, 37888, 39232, 39232, 40576, 40576, 42368, 42368, 43816, 43816, 45352, 45352, 45352, 46888, 46888, - 48936, 48936, 48936, 51024, 51024, 52752, 52752, 55056, 55056, 55056, 57336, 57336, 57336, 59256, 59256, 59256, - 61664, 61664, 61664, 63776, 63776, 63776, 63776, 66592, 66592, 66592, 66592, 68808, 68808, 68808, 71112, 71112, + 48936, 48936, 48936, 51024, 51024, 52752, 52752, 52752, 55056, 55056, 55056, 57336, 57336, 57336, 59256, 59256, + 59256, 61664, 61664, 61664, 63776, 63776, 63776, 66592, 66592, 66592, 66592, 68808, 68808, 68808, 71112, 71112, 71112, 73712, 73712, 73712, 75376, 76208, 76208, 76208, 78704, 78704, 78704, 81176, 81176, 81176}, - {776, 1544, 2344, 3112, 3880, 4776, 5544, 3200, 3938, 7736, 8504, 9528, 10296, 11064, 11832, 12576, + {776, 1544, 2344, 3112, 3880, 4776, 5544, 6200, 6968, 7736, 8504, 9528, 10296, 11064, 11832, 12576, 13536, 14112, 14688, 15840, 16416, 16992, 18336, 19080, 19848, 20616, 21384, 22152, 22920, 23688, 24496, 25456, - 25456, 26416, 27276, 28336, 29296, 29296, 30576, 31704, 31704, 32856, 34008, 34008, 35160, 36696, 36696, 37888, + 25456, 26416, 27376, 28336, 29296, 29296, 30576, 31704, 31704, 32856, 34008, 34008, 35160, 36696, 36696, 37888, 37888, 39232, 40576, 40576, 42368, 42368, 43816, 43816, 45352, 45352, 46888, 46888, 46888, 48936, 48936, 51024, - 51024, 52752, 52752, 55056, 55056, 55056, 57336, 57336, 57336, 59256, 59256, 59256, 61664, 61664, 63776, 63776, - 63776, 63776, 66592, 66592, 66592, 68808, 68808, 68808, 71112, 71112, 71112, 73712, 73712, 75376, 75376, 76208, - 76208, 78704, 78704, 78704, 81176, 81176, 81176, 81176, 84760, 84760, 84760, 84760, 87936}, - {808, 1608, 2472, 3240, 4136, 4968, 5736, 6456, 7480, 8248, 9144, 9912, 10680, 11148, 12216, 12960, + 51024, 51024, 52752, 52752, 55056, 55056, 55056, 57336, 57336, 57336, 59256, 59256, 59256, 61664, 61664, 63776, + 63776, 63776, 63776, 66592, 66592, 66592, 68808, 68808, 68808, 71112, 71112, 71112, 73712, 73712, 75376, 75376, + 76208, 76208, 78704, 78704, 78704, 81176, 81176, 81176, 81176, 84760, 84760, 84760, 84760, 87936}, + {808, 1608, 2472, 3240, 4136, 4968, 5736, 6456, 7480, 8248, 9144, 9912, 10680, 11448, 12216, 12960, 14112, 14688, 15840, 16416, 17568, 18336, 19080, 19848, 20616, 21384, 22152, 22920, 23688, 24496, 25456, 26416, 27376, 28336, 29296, 29296, 30576, 31704, 31704, 32856, 34008, 35160, 35160, 36696, 36696, 37888, 39232, 39232, - 40576, 40576, 42368, 42368, 43816, 45352, 45352, 46888, 46888, 46888, 48396, 48396, 51024, 51024, 52752, 52752, + 40576, 40576, 42368, 42368, 43816, 45352, 45352, 46888, 46888, 46888, 48936, 48936, 51024, 51024, 52752, 52752, 52752, 55056, 55056, 55056, 57336, 57336, 59256, 59256, 59256, 61664, 61664, 63776, 63776, 63776, 66592, 66592, - 66592, 68808, 68808, 68808, 71112, 71112, 71112, 73712, 73715, 73712, 75376, 76208, 76208, 78704, 78704, 78704, + 66592, 68808, 68808, 68808, 71112, 71112, 71112, 73712, 73712, 73712, 75376, 76208, 76208, 78704, 78704, 78704, 81176, 81176, 81176, 81176, 84760, 84760, 84760, 84760, 87936, 87936, 87936, 87936, 90816, 90816}, {840, 1672, 2536, 3368, 4264, 5160, 5992, 6712, 7736, 8504, 9528, 10296, 11064, 11832, 12960, 13536, - 14688, 15264, 16416, 16992, 17458, 19080, 19848, 20616, 21348, 22152, 22920, 23688, 24496, 25456, 26416, 27376, - 28336, 29296, 29296, 30576, 31704, 32856, 32856, 34008, 35160, 35160, 36696, 37888, 37888, 39232, 39232, 40576, - 40576, 42368, 42368, 43816, 43816, 45352, 46888, 46888, 46888, 48936, 48936, 51024, 51024, 52752, 52752, 52752, - 55056, 55056, 55056, 57336, 57336, 57336, 59256, 59256, 61664, 61664, 61664, 63776, 63776, 63776, 66592, 66592, - 66592, 68808, 68808, 71112, 71112, 71112, 71112, 73712, 73712, 73712, 75376, 76208, 76208, 78704, 78704, 78704, - 81176, 81176, 81176, 84760, 84760, 84760, 84760, 87936, 87936, 87936, 90816, 90816, 93800, 93800}, + 14688, 15264, 16416, 16992, 17568, 19080, 19848, 20616, 21384, 22152, 22920, 23688, 24496, 25456, 26416, 27376, + 28336, 29296, 29296, 30576, 31704, 32856, 32856, 34008, 35160, 35160, 36696, 37888, 37888, 39232, 40576, 40576, + 42368, 42368, 43816, 43816, 45352, 46888, 46888, 46888, 48936, 48936, 51024, 51024, 52752, 52752, 52752, 55056, + 55056, 57336, 57336, 57336, 59256, 59256, 61664, 61664, 61664, 63776, 63776, 63776, 66592, 66592, 66592, 68808, + 68808, 71112, 71112, 71112, 73712, 73712, 73712, 75376, 76208, 76208, 78704, 78704, 78704, 81176, 81176, 81176, + 84760, 84760, 84760, 84760, 87936, 87936, 87936, 87936, 90816, 90816, 90816, 93800, 93800, 93800}, {968, 1992, 2984, 4008, 4968, 5992, 6968, 7992, 8760, 9912, 10680, 11832, 12960, 13536, 14688, 15840, 16992, 17568, 19080, 19848, 20616, 21384, 22920, 23688, 24496, 25456, 26416, 27376, 28336, 29296, 30576, 31704, 32856, 34008, 35160, 35160, 36696, 37888, 39232, 39232, 40576, 40576, 42368, 43816, 43816, 45352, 46888, 46888, 48936, 48936, 51024, 51024, 52752, 52752, 55056, 55056, 57336, 57336, 59256, 59256, 59256, 61664, 61664, 63776, - 63776, 63776, 66592, 66592, 68808, 68808, 71112, 71112, 71112, 73712, 75376, 76208, 73208, 76208, 78704, 78704, - 81176, 81176, 81176, 81176, 84760, 84760, 84760, 87636, 87936, 87936, 90816, 90816, 90816, 93800, 93800, 93800, + 63776, 63776, 66592, 66592, 68808, 68808, 71112, 71112, 71112, 73712, 75376, 76208, 76208, 76208, 78704, 78704, + 81176, 81176, 81176, 81176, 84760, 84760, 84760, 87936, 87936, 87936, 90816, 90816, 90816, 93800, 93800, 93800, 93800, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896, 97896}}; From 95ec83433ee09e718b6c934788efaf29f5507736 Mon Sep 17 00:00:00 2001 From: Robert Falkenberg Date: Mon, 26 Aug 2019 10:18:49 +0200 Subject: [PATCH 09/25] Fixed inverted handling of fseek result value in srslte_filesource_seek --- lib/src/phy/io/filesource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/phy/io/filesource.c b/lib/src/phy/io/filesource.c index 11f4f6832..8cf6dad86 100644 --- a/lib/src/phy/io/filesource.c +++ b/lib/src/phy/io/filesource.c @@ -45,7 +45,7 @@ void srslte_filesource_free(srslte_filesource_t *q) { } void srslte_filesource_seek(srslte_filesource_t *q, int pos) { - if (!fseek(q->f, pos, SEEK_SET)){ + if (fseek(q->f, pos, SEEK_SET) != 0){ perror("srslte_filesource_seek"); } } From c84067c10cf3fecd8b8048c7825e252c6d4901b6 Mon Sep 17 00:00:00 2001 From: Mark Rohrbacher Date: Wed, 28 Aug 2019 12:15:28 +0200 Subject: [PATCH 10/25] Fixed duplex spacing for bands 65 to 70 --- lib/src/phy/common/phy_common.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/phy/common/phy_common.c b/lib/src/phy/common/phy_common.c index a626e512b..52699d06e 100644 --- a/lib/src/phy/common/phy_common.c +++ b/lib/src/phy/common/phy_common.c @@ -528,12 +528,12 @@ struct lte_band lte_bands[SRSLTE_NOF_LTE_BANDS] = { {51, 1427, 59090, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, {52, 3300, 59140, 0, 0, SRSLTE_BAND_GEO_AREA_ALL}, {64, 0, 60139, 27809, 0, SRSLTE_BAND_GEO_AREA_ALL}, - {65, 2110, 65536, 131072, 90, SRSLTE_BAND_GEO_AREA_ALL}, - {66, 2110, 66436, 131972, 90, SRSLTE_BAND_GEO_AREA_NAR}, + {65, 2110, 65536, 131072, 190, SRSLTE_BAND_GEO_AREA_ALL}, + {66, 2110, 66436, 131972, 400, SRSLTE_BAND_GEO_AREA_NAR}, {67, 738, 67336, 0, 0, SRSLTE_BAND_GEO_AREA_EMEA}, - {68, 753, 67536, 132672, 30, SRSLTE_BAND_GEO_AREA_EMEA}, - {69, 2570, 67836, 0, 50, SRSLTE_BAND_GEO_AREA_EMEA}, - {70, 1995, 68336, 132972, 25, SRSLTE_BAND_GEO_AREA_NAR}, + {68, 753, 67536, 132672, 55, SRSLTE_BAND_GEO_AREA_EMEA}, + {69, 2570, 67836, 0, 0, SRSLTE_BAND_GEO_AREA_EMEA}, + {70, 1995, 68336, 132972, 300, SRSLTE_BAND_GEO_AREA_NAR}, {71, 0, 68586, 133122, 0, SRSLTE_BAND_GEO_AREA_NAR} // dummy band to bound band 70 earfcn }; From 044d236a49e8bd049f633a4a5ccb65c15fbb2a7e Mon Sep 17 00:00:00 2001 From: Robert Falkenberg Date: Fri, 9 Aug 2019 12:25:32 +0200 Subject: [PATCH 11/25] Fixed incorrect DCI location assignment in pdsch_enodeb.c example --- lib/examples/pdsch_enodeb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index 6bb65c52f..5f6a95c92 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -917,8 +917,8 @@ int main(int argc, char **argv) { /* Encode PDCCH */ INFO("Putting DCI to location: n=%d, L=%d\n", locations[sf_idx][0].ncce, locations[sf_idx][0].L); - dci_msg.location = locations[sf_idx][0]; srslte_dci_msg_pack_pdsch(&cell, &dl_sf, NULL, &dci_dl, &dci_msg); + dci_msg.location = locations[sf_idx][0]; if (srslte_pdcch_encode(&pdcch, &dl_sf, &dci_msg, sf_symbols)) { ERROR("Error encoding DCI message\n"); exit(-1); From ecdfa579ec9f9842c4b82c1e50a18c8de58f2773 Mon Sep 17 00:00:00 2001 From: Robert Falkenberg Date: Fri, 16 Aug 2019 10:50:03 +0200 Subject: [PATCH 12/25] Fixed inverted interpretation of new data indication (ndi) field in dci_format1As_pack() function --- lib/src/phy/phch/dci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/phy/phch/dci.c b/lib/src/phy/phch/dci.c index 28b0ff0f4..03fb20d65 100644 --- a/lib/src/phy/phch/dci.c +++ b/lib/src/phy/phch/dci.c @@ -672,7 +672,7 @@ static int dci_format1As_pack( srslte_bit_unpack(dci->pid, &y, HARQ_PID_LEN); - if (SRSLTE_RNTI_ISUSER(dci->rnti)) { + if (!SRSLTE_RNTI_ISUSER(dci->rnti)) { if (nof_prb >= 50 && dci->type2_alloc.mode == SRSLTE_RA_TYPE2_DIST) { *y++ = dci->type2_alloc.n_gap; } else { From c4bcd6e287fc67bf85fb82a41d1f8f2c901ed8d5 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 3 Aug 2019 22:07:39 +0200 Subject: [PATCH 13/25] [ENB] Add CFSB support This commit introduces CSFB (circuit switched fall-back) capabilities to srsLTE. Actually, all the eNB has to do is to send a RrcConnectionRelease with the RedirectedCarrierInfo IE. The MME triggers this by the S1AP CS Fallback Indicator IE, which may be present either in the Initial Context Setup Requst or in the UE Context Modification Request. As srsLTE has no support for the UE Context Modification Request at all yet (!), basic support for this message is introduced in this patch. Both Mobile Originated and Mobile Terminated CSFB with a coupel of different UE models have been verified using this patch in a setup consisting of srsENB attached to an undisclosed EPC connected via SGsAP to a complete Osmocom 2G network. Closes: #358 Closes: #363 --- .../srslte/interfaces/enb_interfaces.h | 1 + srsenb/hdr/stack/rrc/rrc.h | 4 + srsenb/hdr/stack/upper/s1ap.h | 3 + srsenb/src/stack/rrc/rrc.cc | 91 +++++++++- srsenb/src/stack/upper/s1ap.cc | 163 ++++++++++++++++++ 5 files changed, 259 insertions(+), 3 deletions(-) diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index 3b3c16ff1..bd844fcc0 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -267,6 +267,7 @@ public: virtual void write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu) = 0; virtual void release_complete(uint16_t rnti) = 0; virtual bool setup_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPREQUEST_STRUCT *msg) = 0; + virtual bool modify_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONREQUEST_STRUCT *msg) = 0; virtual bool setup_ue_erabs(uint16_t rnti, LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT *msg) = 0; virtual bool release_erabs(uint32_t rnti) = 0; virtual void add_paging_id(uint32_t ueid, LIBLTE_S1AP_UEPAGINGID_STRUCT UEPagingID) = 0; diff --git a/srsenb/hdr/stack/rrc/rrc.h b/srsenb/hdr/stack/rrc/rrc.h index 0dd4da54f..60649e500 100644 --- a/srsenb/hdr/stack/rrc/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -156,6 +156,7 @@ public: void write_dl_info(uint16_t rnti, srslte::unique_byte_buffer_t sdu); void release_complete(uint16_t rnti); bool setup_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPREQUEST_STRUCT *msg); + bool modify_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONREQUEST_STRUCT *msg); bool setup_ue_erabs(uint16_t rnti, LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT *msg); bool release_erabs(uint32_t rnti); void add_paging_id(uint32_t ueid, LIBLTE_S1AP_UEPAGINGID_STRUCT UEPagingID); @@ -254,6 +255,8 @@ public: bool connect_notified; + bool is_csfb; + private: srslte::byte_buffer_pool *pool; @@ -378,6 +381,7 @@ private: rrc_cfg_t cfg; uint32_t nof_si_messages; asn1::rrc::sib_type2_s sib2; + asn1::rrc::sib_type7_s sib7; void run_thread(); void rem_user_thread(uint16_t rnti); diff --git a/srsenb/hdr/stack/upper/s1ap.h b/srsenb/hdr/stack/upper/s1ap.h index bdcfb016a..5ad28980e 100644 --- a/srsenb/hdr/stack/upper/s1ap.h +++ b/srsenb/hdr/stack/upper/s1ap.h @@ -118,6 +118,7 @@ private: bool handle_uectxtreleasecommand(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASECOMMAND_STRUCT *msg); bool handle_s1setupfailure(LIBLTE_S1AP_MESSAGE_S1SETUPFAILURE_STRUCT *msg); bool handle_erabsetuprequest(LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT *msg); + bool handle_uecontextmodifyrequest(LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONREQUEST_STRUCT *msg); bool send_initialuemessage(uint16_t rnti, LIBLTE_S1AP_RRC_ESTABLISHMENT_CAUSE_ENUM cause, @@ -132,6 +133,8 @@ private: bool send_initial_ctxt_setup_failure(uint16_t rnti); bool send_erab_setup_response(uint16_t rnti, LIBLTE_S1AP_MESSAGE_E_RABSETUPRESPONSE_STRUCT *res_); //bool send_ue_capabilities(uint16_t rnti, LIBLTE_RRC_UE_EUTRA_CAPABILITY_STRUCT *caps) + bool send_uectxmodifyresp(uint16_t rnti); + bool send_uectxmodifyfailure(uint16_t rnti, LIBLTE_S1AP_CAUSE_STRUCT *cause); bool find_mme_ue_id(uint32_t mme_ue_id, uint16_t *rnti, uint32_t *enb_ue_id); std::string get_cause(LIBLTE_S1AP_CAUSE_STRUCT *c); diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index d3f13aab6..f561bdc84 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -292,9 +292,6 @@ bool rrc::setup_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRE return false; } - if(msg->CSFallbackIndicator_present) { - rrc_log->warning("Not handling CSFallbackIndicator\n"); - } if(msg->AdditionalCSFallbackIndicator_present) { rrc_log->warning("Not handling AdditionalCSFallbackIndicator\n"); } @@ -343,6 +340,14 @@ bool rrc::setup_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRE liblte_pack(msg->SecurityKey.buffer, LIBLTE_S1AP_SECURITYKEY_BIT_STRING_LEN, key); users[rnti].set_security_key(key, LIBLTE_S1AP_SECURITYKEY_BIT_STRING_LEN/8); + // CSFB + if (msg->CSFallbackIndicator_present) { + if (msg->CSFallbackIndicator.e == LIBLTE_S1AP_CSFALLBACKINDICATOR_CS_FALLBACK_REQUIRED || + msg->CSFallbackIndicator.e == LIBLTE_S1AP_CSFALLBACKINDICATOR_CS_FALLBACK_HIGH_PRIORITY) { + users[rnti].is_csfb = true; + } + } + // Send RRC security mode command users[rnti].send_security_mode_command(); @@ -354,6 +359,75 @@ bool rrc::setup_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRE return true; } +bool rrc::modify_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONREQUEST_STRUCT *msg) +{ + bool err = false; + pthread_mutex_lock(&user_mutex); + + rrc_log->info("Modifying context for 0x%x\n", rnti); + + if (users.count(rnti) == 0) { + rrc_log->warning("Unrecognised rnti: 0x%x\n", rnti); + pthread_mutex_unlock(&user_mutex); + return false; + } + + if (msg->CSFallbackIndicator_present) { + if (msg->CSFallbackIndicator.e == LIBLTE_S1AP_CSFALLBACKINDICATOR_CS_FALLBACK_REQUIRED || + msg->CSFallbackIndicator.e == LIBLTE_S1AP_CSFALLBACKINDICATOR_CS_FALLBACK_HIGH_PRIORITY) { + /* Remember that we are in a CSFB right now */ + users[rnti].is_csfb = true; + } + } + + if (msg->AdditionalCSFallbackIndicator_present) { + rrc_log->warning("Not handling AdditionalCSFallbackIndicator\n"); + err = true; + } + if (msg->CSGMembershipStatus_present) { + rrc_log->warning("Not handling CSGMembershipStatus\n"); + err = true; + } + if (msg->RegisteredLAI_present) { + rrc_log->warning("Not handling RegisteredLAI\n"); + err = true; + } + if (msg->SubscriberProfileIDforRFP_present) { + rrc_log->warning("Not handling SubscriberProfileIDforRFP\n"); + err = true; + } + + if (err) { + // maybe pass a cause value? + return false; + } + + // UEAggregateMaximumBitrate + if (msg->uEaggregateMaximumBitrate_present) { + users[rnti].set_bitrates(&msg->uEaggregateMaximumBitrate); + } + + // UESecurityCapabilities + if (msg->UESecurityCapabilities_present) { + users[rnti].set_security_capabilities(&msg->UESecurityCapabilities); + } + + // SecurityKey + if (msg->SecurityKey_present) { + uint8_t key[32]; + liblte_pack(msg->SecurityKey.buffer, LIBLTE_S1AP_SECURITYKEY_BIT_STRING_LEN, key); + users[rnti].set_security_key(key, LIBLTE_S1AP_SECURITYKEY_BIT_STRING_LEN / 8); + + // Send RRC security mode command ?? + users[rnti].send_security_mode_command(); + } + + pthread_mutex_unlock(&user_mutex); + + return true; +} + + bool rrc::setup_ue_erabs(uint16_t rnti, LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT *msg) { pthread_mutex_lock(&user_mutex); @@ -739,6 +813,10 @@ uint32_t rrc::generate_sibs() log_rrc_message("SIB payload", Tx, sib_buffer[msg_index].get(), msg[msg_index]); } + if (cfg.sibs[6].type() == asn1::rrc::sys_info_r8_ies_s::sib_type_and_info_item_c_::types::sib7) { + sib7 = cfg.sibs[6].sib7(); + } + return nof_messages; } @@ -949,6 +1027,7 @@ rrc::ue::ue() integ_algo = srslte::INTEGRITY_ALGORITHM_ID_EIA0; cipher_algo = srslte::CIPHERING_ALGORITHM_ID_EEA0; nas_pending = false; + is_csfb = false; state = RRC_STATE_IDLE; pool = srslte::byte_buffer_pool::get_instance(); } @@ -1563,6 +1642,12 @@ void rrc::ue::send_connection_release() dl_dcch_msg.msg.c1().rrc_conn_release().rrc_transaction_id = (uint8_t)((transaction_id++) % 4); dl_dcch_msg.msg.c1().rrc_conn_release().crit_exts.set_c1().set_rrc_conn_release_r8(); dl_dcch_msg.msg.c1().rrc_conn_release().crit_exts.c1().rrc_conn_release_r8().release_cause = release_cause_e::other; + if (is_csfb) { + rrc_conn_release_r8_ies_s& rel_ies = dl_dcch_msg.msg.c1().rrc_conn_release().crit_exts.c1().rrc_conn_release_r8(); + rel_ies.redirected_carrier_info_present = true; + rel_ies.redirected_carrier_info.set_geran(); + rel_ies.redirected_carrier_info.geran() = parent->sib7.carrier_freqs_info_list[0].carrier_freqs; + } send_dl_dcch(&dl_dcch_msg); } diff --git a/srsenb/src/stack/upper/s1ap.cc b/srsenb/src/stack/upper/s1ap.cc index 6bfdae822..c94c3b059 100644 --- a/srsenb/src/stack/upper/s1ap.cc +++ b/srsenb/src/stack/upper/s1ap.cc @@ -435,6 +435,8 @@ bool s1ap::handle_initiatingmessage(LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *msg) return handle_paging(&msg->choice.Paging); case LIBLTE_S1AP_INITIATINGMESSAGE_CHOICE_E_RABSETUPREQUEST: return handle_erabsetuprequest(&msg->choice.E_RABSetupRequest); + case LIBLTE_S1AP_INITIATINGMESSAGE_CHOICE_UECONTEXTMODIFICATIONREQUEST: + return handle_uecontextmodifyrequest(&msg->choice.UEContextModificationRequest); default: s1ap_log->error("Unhandled intiating message: %s\n", liblte_s1ap_initiatingmessage_choice_text[msg->choice_type]); } @@ -526,6 +528,23 @@ bool s1ap::handle_initialctxtsetuprequest(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETU return false; } + /* Ideally the check below would be "if (users[rnti].is_csfb)" */ + if (msg->CSFallbackIndicator_present) { + if (msg->CSFallbackIndicator.e == LIBLTE_S1AP_CSFALLBACKINDICATOR_CS_FALLBACK_REQUIRED || + msg->CSFallbackIndicator.e == LIBLTE_S1AP_CSFALLBACKINDICATOR_CS_FALLBACK_HIGH_PRIORITY) { + // Send RRC Release (cs-fallback-triggered) to MME + LIBLTE_S1AP_CAUSE_STRUCT cause; + cause.ext = false; + cause.choice_type = LIBLTE_S1AP_CAUSE_CHOICE_RADIONETWORK; + cause.choice.radioNetwork.ext = false; + cause.choice.radioNetwork.e = LIBLTE_S1AP_CAUSERADIONETWORK_CS_FALLBACK_TRIGGERED; + + /* FIXME: This should normally probably only be sent after the SecurityMode procedure has completed! */ + ue_ctxt_map[rnti].release_requested = true; + send_uectxtreleaserequest(rnti, &cause); + } + } + return true; } @@ -568,6 +587,53 @@ bool s1ap::handle_erabsetuprequest(LIBLTE_S1AP_MESSAGE_E_RABSETUPREQUEST_STRUCT return true; } +bool s1ap::handle_uecontextmodifyrequest(LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONREQUEST_STRUCT* msg) +{ + s1ap_log->info("Received UeContextModificationRequest\n"); + if (enbid_to_rnti_map.end() == enbid_to_rnti_map.find(msg->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID)) { + s1ap_log->warning("eNB_UE_S1AP_ID not found - discarding message\n"); + return false; + } + uint16_t rnti = enbid_to_rnti_map[msg->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID]; + if (msg->MME_UE_S1AP_ID.MME_UE_S1AP_ID != ue_ctxt_map[rnti].MME_UE_S1AP_ID) { + s1ap_log->warning("MME_UE_S1AP_ID has changed - old:%d, new:%d\n", + ue_ctxt_map[rnti].MME_UE_S1AP_ID, + msg->MME_UE_S1AP_ID.MME_UE_S1AP_ID); + ue_ctxt_map[rnti].MME_UE_S1AP_ID = msg->MME_UE_S1AP_ID.MME_UE_S1AP_ID; + } + + if (!rrc->modify_ue_ctxt(rnti, msg)) { + LIBLTE_S1AP_CAUSE_STRUCT cause; + cause.ext = false; + cause.choice_type = LIBLTE_S1AP_CAUSE_CHOICE_MISC; + cause.choice.misc.ext = false; + cause.choice.misc.e = LIBLTE_S1AP_CAUSEMISC_UNSPECIFIED; + send_uectxmodifyfailure(rnti, &cause); + return true; + } + + // Send UEContextModificationResponse + send_uectxmodifyresp(rnti); + + /* Ideally the check below would be "if (users[rnti].is_csfb)" */ + if (msg->CSFallbackIndicator_present) { + if (msg->CSFallbackIndicator.e == LIBLTE_S1AP_CSFALLBACKINDICATOR_CS_FALLBACK_REQUIRED || + msg->CSFallbackIndicator.e == LIBLTE_S1AP_CSFALLBACKINDICATOR_CS_FALLBACK_HIGH_PRIORITY) { + // Send RRC Release (cs-fallback-triggered) to MME + LIBLTE_S1AP_CAUSE_STRUCT cause; + cause.ext = false; + cause.choice_type = LIBLTE_S1AP_CAUSE_CHOICE_RADIONETWORK; + cause.choice.radioNetwork.ext = false; + cause.choice.radioNetwork.e = LIBLTE_S1AP_CAUSERADIONETWORK_CS_FALLBACK_TRIGGERED; + + ue_ctxt_map[rnti].release_requested = true; + send_uectxtreleaserequest(rnti, &cause); + } + } + + return true; +} + bool s1ap::handle_uectxtreleasecommand(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASECOMMAND_STRUCT *msg) { s1ap_log->info("Received UEContextReleaseCommand\n"); @@ -982,6 +1048,103 @@ bool s1ap::send_initial_ctxt_setup_failure(uint16_t rnti) return true; } +bool s1ap::send_uectxmodifyresp(uint16_t rnti) +{ + if (!mme_connected) { + return false; + } + srslte::unique_byte_buffer_t buf = srslte::allocate_unique_buffer(*pool); + if (!buf) { + s1ap_log->error("Fatal Error: Couldn't allocate buffer in s1ap::send_uectxmodifyresp().\n"); + return false; + } + + LIBLTE_S1AP_S1AP_PDU_STRUCT tx_pdu; + tx_pdu.ext = false; + tx_pdu.choice_type = LIBLTE_S1AP_S1AP_PDU_CHOICE_SUCCESSFULOUTCOME; + + LIBLTE_S1AP_SUCCESSFULOUTCOME_STRUCT* succ = &tx_pdu.choice.successfulOutcome; + succ->procedureCode = LIBLTE_S1AP_PROC_ID_UECONTEXTMODIFICATION; + succ->choice_type = LIBLTE_S1AP_SUCCESSFULOUTCOME_CHOICE_UECONTEXTMODIFICATIONRESPONSE; + + LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONRESPONSE_STRUCT* resp = &succ->choice.UEContextModificationResponse; + resp->ext = false; + resp->CriticalityDiagnostics_present = false; + + resp->MME_UE_S1AP_ID.MME_UE_S1AP_ID = ue_ctxt_map[rnti].MME_UE_S1AP_ID; + resp->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID = ue_ctxt_map[rnti].eNB_UE_S1AP_ID; + + liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT*)buf.get()); + s1ap_log->info_hex(buf->msg, buf->N_bytes, "Sending ContextModificationFailure for RNTI:0x%x", rnti); + + ssize_t n_sent = sctp_sendmsg(socket_fd, + buf->msg, + buf->N_bytes, + (struct sockaddr*)&mme_addr, + sizeof(struct sockaddr_in), + htonl(PPID), + 0, + ue_ctxt_map[rnti].stream_id, + 0, + 0); + + if (n_sent == -1) { + s1ap_log->error("Failed to send ContextModificationFailure for RNTI:0x%x\n", rnti); + return false; + } + + return true; +} + +bool s1ap::send_uectxmodifyfailure(uint16_t rnti, LIBLTE_S1AP_CAUSE_STRUCT* cause) +{ + if (!mme_connected) { + return false; + } + srslte::unique_byte_buffer_t buf = srslte::allocate_unique_buffer(*pool); + if (!buf) { + s1ap_log->error("Fatal Error: Couldn't allocate buffer in s1ap::send_initial_ctxt_setup_failure().\n"); + return false; + } + + LIBLTE_S1AP_S1AP_PDU_STRUCT tx_pdu; + tx_pdu.ext = false; + tx_pdu.choice_type = LIBLTE_S1AP_S1AP_PDU_CHOICE_UNSUCCESSFULOUTCOME; + + LIBLTE_S1AP_UNSUCCESSFULOUTCOME_STRUCT* unsucc = &tx_pdu.choice.unsuccessfulOutcome; + unsucc->procedureCode = LIBLTE_S1AP_PROC_ID_UECONTEXTMODIFICATION; + unsucc->choice_type = LIBLTE_S1AP_UNSUCCESSFULOUTCOME_CHOICE_UECONTEXTMODIFICATIONFAILURE; + + LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIONFAILURE_STRUCT* fail = &unsucc->choice.UEContextModificationFailure; + fail->ext = false; + fail->CriticalityDiagnostics_present = false; + + fail->MME_UE_S1AP_ID.MME_UE_S1AP_ID = ue_ctxt_map[rnti].MME_UE_S1AP_ID; + fail->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID = ue_ctxt_map[rnti].eNB_UE_S1AP_ID; + + memcpy(&fail->Cause, cause, sizeof(LIBLTE_S1AP_CAUSE_STRUCT)); + + liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT*)buf.get()); + s1ap_log->info_hex(buf->msg, buf->N_bytes, "Sending UEContextModificationFailure for RNTI:0x%x", rnti); + + ssize_t n_sent = sctp_sendmsg(socket_fd, + buf->msg, + buf->N_bytes, + (struct sockaddr*)&mme_addr, + sizeof(struct sockaddr_in), + htonl(PPID), + 0, + ue_ctxt_map[rnti].stream_id, + 0, + 0); + + if (n_sent == -1) { + s1ap_log->error("Failed to send UEContextModificationFailure for RNTI:0x%x\n", rnti); + return false; + } + + return true; +} //bool s1ap::send_ue_capabilities(uint16_t rnti, LIBLTE_RRC_UE_EUTRA_CAPABILITY_STRUCT *caps) //{ From 40e688ce9b52117f613ea3b02b0c04181ec50a80 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Mon, 14 Oct 2019 16:36:52 +0100 Subject: [PATCH 14/25] Fix compilation error on GCC 8.x due to usage of strncpy in zmq_imp_rx/tx. Fixed also order in which zmq object is zero'ed out. --- lib/src/phy/rf/rf_zmq_imp_rx.c | 7 ++++--- lib/src/phy/rf/rf_zmq_imp_trx.h | 5 +++-- lib/src/phy/rf/rf_zmq_imp_tx.c | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/src/phy/rf/rf_zmq_imp_rx.c b/lib/src/phy/rf/rf_zmq_imp_rx.c index 97d99b658..e1deda04f 100644 --- a/lib/src/phy/rf/rf_zmq_imp_rx.c +++ b/lib/src/phy/rf/rf_zmq_imp_rx.c @@ -100,12 +100,13 @@ int rf_zmq_rx_open(rf_zmq_rx_t* q, char* id, void* zmq_ctx, char* sock_args) int ret = SRSLTE_ERROR; if (q) { - // Copy id - strncpy(q->id, id, 16); - // Zero object bzero(q, sizeof(rf_zmq_tx_t)); + // Copy id + strncpy(q->id, id, ZMQ_ID_STRLEN - 1); + q->id[ZMQ_ID_STRLEN - 1] = '\0'; + // Create socket q->sock = zmq_socket(zmq_ctx, ZMQ_REQ); if (!q->sock) { diff --git a/lib/src/phy/rf/rf_zmq_imp_trx.h b/lib/src/phy/rf/rf_zmq_imp_trx.h index 2f6f8727f..f73961d35 100644 --- a/lib/src/phy/rf/rf_zmq_imp_trx.h +++ b/lib/src/phy/rf/rf_zmq_imp_trx.h @@ -38,9 +38,10 @@ #define ZMQ_MAX_BUFFER_SIZE (NSAMPLES2NBYTES(3072000)) // 10 subframes at 20 MHz #define ZMQ_TIMEOUT_MS (1000) #define ZMQ_BASERATE_DEFAULT_HZ (23040000) +#define ZMQ_ID_STRLEN 16 typedef struct { - char id[16]; + char id[ZMQ_ID_STRLEN]; void* sock; uint64_t nsamples; bool running; @@ -49,7 +50,7 @@ typedef struct { } rf_zmq_tx_t; typedef struct { - char id[16]; + char id[ZMQ_ID_STRLEN]; void* sock; uint64_t nsamples; bool running; diff --git a/lib/src/phy/rf/rf_zmq_imp_tx.c b/lib/src/phy/rf/rf_zmq_imp_tx.c index ad38d2e7e..71320fc08 100644 --- a/lib/src/phy/rf/rf_zmq_imp_tx.c +++ b/lib/src/phy/rf/rf_zmq_imp_tx.c @@ -36,12 +36,13 @@ int rf_zmq_tx_open(rf_zmq_tx_t* q, const char* id, void* zmq_ctx, char* sock_arg int ret = SRSLTE_ERROR; if (q) { - // Copy id - strncpy(q->id, id, 16); - // Zero object bzero(q, sizeof(rf_zmq_tx_t)); + // Copy id + strncpy(q->id, id, ZMQ_ID_STRLEN - 1); + q->id[ZMQ_ID_STRLEN - 1] = '\0'; + // Create socket q->sock = zmq_socket(zmq_ctx, ZMQ_REP); if (!q->sock) { From 19e8f7aab51b11d873e22ded3364a62fd3b7e9bc Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 16 Oct 2019 10:35:03 +0200 Subject: [PATCH 15/25] fix type mismatch in bzero --- lib/src/phy/rf/rf_zmq_imp_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/phy/rf/rf_zmq_imp_rx.c b/lib/src/phy/rf/rf_zmq_imp_rx.c index e1deda04f..b7967483b 100644 --- a/lib/src/phy/rf/rf_zmq_imp_rx.c +++ b/lib/src/phy/rf/rf_zmq_imp_rx.c @@ -101,7 +101,7 @@ int rf_zmq_rx_open(rf_zmq_rx_t* q, char* id, void* zmq_ctx, char* sock_args) if (q) { // Zero object - bzero(q, sizeof(rf_zmq_tx_t)); + bzero(q, sizeof(rf_zmq_rx_t)); // Copy id strncpy(q->id, id, ZMQ_ID_STRLEN - 1); From 62d295671510630ea9aea1754835f6c346de6ed7 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 16 Oct 2019 15:40:30 +0200 Subject: [PATCH 16/25] SRSENB: Fixed PUCCH resource selection --- lib/src/phy/enb/enb_ul.c | 4 ++-- lib/src/phy/ue/ue_ul.c | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/src/phy/enb/enb_ul.c b/lib/src/phy/enb/enb_ul.c index 0cc695663..8ec178ce5 100644 --- a/lib/src/phy/enb/enb_ul.c +++ b/lib/src/phy/enb/enb_ul.c @@ -174,8 +174,8 @@ void srslte_enb_ul_fft(srslte_enb_ul_t *q) static int get_pucch(srslte_enb_ul_t* q, srslte_ul_sf_cfg_t* ul_sf, srslte_pucch_cfg_t* cfg, srslte_pucch_res_t* res) { - - srslte_ue_ul_pucch_resource_selection(&q->cell, cfg, &cfg->uci_cfg, NULL); + srslte_uci_value_t uci_value_default = {}; + srslte_ue_ul_pucch_resource_selection(&q->cell, cfg, &cfg->uci_cfg, &uci_value_default); // Prepare configuration if (srslte_chest_ul_estimate_pucch(&q->chest, ul_sf, cfg, q->sf_symbols, &q->chest_res)) { diff --git a/lib/src/phy/ue/ue_ul.c b/lib/src/phy/ue/ue_ul.c index db5de765d..b1ee777dc 100644 --- a/lib/src/phy/ue/ue_ul.c +++ b/lib/src/phy/ue/ue_ul.c @@ -500,11 +500,7 @@ get_format(srslte_pucch_cfg_t* cfg, srslte_uci_cfg_t* uci_cfg, srslte_uci_value_ format = SRSLTE_PUCCH_FORMAT_1B; // with channel selection if > 2 } // If UCI value is provided, use SR signal only, otherwise SR request opportunity - else if (uci_value) { - if (uci_value->scheduling_request) { - format = SRSLTE_PUCCH_FORMAT_1; - } - } else if (uci_cfg->is_scheduling_request_tti) { + else if (uci_cfg->is_scheduling_request_tti || (uci_value && uci_value->scheduling_request)) { format = SRSLTE_PUCCH_FORMAT_1; } else { fprintf(stderr, From 27e9285121002e1dcec1ca0d4325a6d144c3ee72 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 21 Oct 2019 16:41:07 +0200 Subject: [PATCH 17/25] build: fix ADD_CXX_COMPILER_FLAG_IF_AVAILABLE usages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch solves two different issues at the same time when building with gcc/g++ 9.2.0: 1) The -fvisibility=hidden support check was done using the C++ compiler only (with check_cxx_compiler_flag), inside the block corresponding to the C compiler being GNU/clang, and the result of the check was applied to both C++ (CXX_FLAGS) and C (C_FLAGS) flags. Instead of this, there should be separate checks for the C and C++ compilers, each of them modifying a single set of _FLAGS. 2) -Wincompatible-pointer-types support check was done using the C++ compiler only, and the result of the check was applied to both C++ (CXX_FLAGS) and C (C_FLAGS) flags. But, this warning is not applicable to C++ and actually breaks compilation when using g++ 9.2: [ 0%] Building CXX object lib/src/asn1/CMakeFiles/rrc_asn1.dir/rrc_asn1.cc.o cc1plus: error: ‘-Werror=’ argument ‘-Werror=incompatible-pointer-types’ is not valid for C++ [-Werror] Instead of this, there should be a check for this warning only using the C compiler, and therefore only modifying the C flags (C_FLAGS). This patch splits the macro into one specific for C++ (which modifies CXX_FLAGS) and one specific for C (which modifies C_FLAGS). And so, the macro call to check for `-Werror=incompatible-pointer-types' is made C-only, and the one for `-fvisibility=hidden` is done for both C and C++ targets (each on the correct GNU/clang compiler block). Due to how the tests are done in cmake, the '-fvisibility=hidden' check wasn't even succeding before, so the compiler option wasn't being effectively used. The cmake flags.make file contents throughout the project are updated as follows now: Before this change, we had: C_FLAGS = -Werror=incompatible-pointer-types ... CXX_FLAGS = -Werror=incompatible-pointer-types ... And after this change, we have: C_FLAGS = -Werror=incompatible-pointer-types -fvisibility=hidden ... CXX_FLAGS = -fvisibility=hidden ... --- CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f38e8b807..a161cf092 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,10 +275,18 @@ macro(ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(${flag} ${have}) if(${have}) - add_definitions(${flag}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") endif(${have}) endmacro(ADD_CXX_COMPILER_FLAG_IF_AVAILABLE) +macro(ADD_C_COMPILER_FLAG_IF_AVAILABLE flag have) + include(CheckCCompilerFlag) + check_c_compiler_flag(${flag} ${have}) + if(${have}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif(${have}) +endmacro(ADD_C_COMPILER_FLAG_IF_AVAILABLE) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-comment -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable -Wtype-limits -std=c++11") @@ -292,9 +300,13 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -mfpmath=sse -msse4.1 -DLV_HAVE_SSE") endif(HAVE_AVX) endif (HAVE_AVX2) + + if(NOT WIN32) + ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_CXX) + endif(NOT WIN32) endif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") -ADD_CXX_COMPILER_FLAG_IF_AVAILABLE("-Werror=incompatible-pointer-types" HAVE_ERROR_INCOMPATIBLE) +ADD_C_COMPILER_FLAG_IF_AVAILABLE("-Werror=incompatible-pointer-types" HAVE_ERROR_INCOMPATIBLE) if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-comment -Wno-write-strings -Winline -Wno-unused-result -Wformat -Wmissing-field-initializers -Wtype-limits -std=c99 -D_GNU_SOURCE") @@ -363,7 +375,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") endif(NOT HAVE_SSE AND NOT HAVE_NEON AND NOT DISABLE_SIMD) if(NOT WIN32) - ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN) + ADD_C_COMPILER_FLAG_IF_AVAILABLE(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_C) endif(NOT WIN32) if (ENABLE_ASAN AND ENABLE_MSAN) From c2de0c679d047acb57a9fa09e954c58ecaea67ee Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Fri, 1 Nov 2019 11:29:33 +0000 Subject: [PATCH 18/25] Updating readme with srslte.com link --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 05355c436..cb51b31a7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ srsLTE [![Build Status](https://travis-ci.org/srsLTE/srsLTE.svg?branch=master)](https://travis-ci.org/srsLTE/srsLTE) srsLTE is a free and open-source LTE software suite developed by SRS (www.softwareradiosystems.com). +See the srsLTE project pages (www.srslte.com) for documentation, guides and project news. It includes: * srsUE - a complete SDR LTE UE application featuring all layers from PHY to IP From 16517397f52491c95318d5cb5b42c9603ee1c2fd Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Thu, 28 Nov 2019 11:59:24 +0100 Subject: [PATCH 19/25] add CMake option to force usage of MKL while default is fftw --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a161cf092..0a9608c48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ option(ENABLE_TIDY "Enable clang tidy" OFF) option(USE_LTE_RATES "Use standard LTE sampling rates" OFF) option(USE_GLIBC_IPV6 "Use glibc's own ipv6.h" ON) +option(USE_MKL "Use MKL instead of fftw" OFF) set(GCC_ARCH native CACHE STRING "GCC compile for specific architecture.") @@ -96,12 +97,12 @@ set(GCC_ARCH native CACHE STRING "GCC compile for specific architecture.") find_package(Threads REQUIRED) # FFT -find_package(MKL) -if(MKL_FOUND) +if(USE_MKL) + find_package(MKL REQUIRED) include_directories(${MKL_INCLUDE_DIRS}) link_directories(${MKL_LIBRARY_DIRS}) set(FFT_LIBRARIES "${MKL_STATIC_LIBRARIES}") # Static by default -else(MKL_FOUND) +else(USE_MKL) find_package(FFTW3F REQUIRED) if(FFTW3F_FOUND) include_directories(${FFTW3F_INCLUDE_DIRS}) @@ -113,7 +114,7 @@ else(MKL_FOUND) endif(BUILD_STATIC) message(STATUS "FFT_LIBRARIES: " ${FFT_LIBRARIES}) endif(FFTW3F_FOUND) -endif(MKL_FOUND) +endif(USE_MKL) # Crypto find_package(Polarssl) From 28b36c28ef36fbd5944d6b6439ed7c16219924d9 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 27 Nov 2019 21:19:45 +0100 Subject: [PATCH 20/25] add basic lgtm config --- .lgtm.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .lgtm.yml diff --git a/.lgtm.yml b/.lgtm.yml new file mode 100644 index 000000000..3edf9c209 --- /dev/null +++ b/.lgtm.yml @@ -0,0 +1,23 @@ +extraction: + cpp: + prepare: + packages: + - build-essential + - cmake + - libfftw3-dev + - libmbedtls-dev + - libpcsclite-dev + - libboost-program-options-dev + - libconfig++-dev + - libsctp-dev + - libuhd-dev + - libzmq3-dev + configure: + command: + - mkdir build + - cd build + - cmake .. + index: + build_command: + - cd build + - make From 5d63b493b6ab7604c121aa64c46f5103162cc596 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 27 Nov 2019 13:38:13 +0100 Subject: [PATCH 21/25] fix printf parameter in asn1_utils --- lib/src/asn1/asn1_utils.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/asn1/asn1_utils.cc b/lib/src/asn1/asn1_utils.cc index d9b1da4d1..6a8104829 100644 --- a/lib/src/asn1/asn1_utils.cc +++ b/lib/src/asn1/asn1_utils.cc @@ -710,7 +710,7 @@ std::string octstring_to_string(const uint8_t* ptr, uint32_t N) void string_to_octstring(uint8_t* ptr, const std::string& str) { if (str.size() % 2 != 0) { - srsasn_log_print(LOG_LEVEL_WARN, "The provided hex string size=%d is not a multiple of 2\n.", str.size()); + srsasn_log_print(LOG_LEVEL_WARN, "The provided hex string size=%zd is not a multiple of 2\n.", str.size()); } char cstr[] = "\0\0\0"; for (uint32_t i = 0; i < str.size(); i += 2) { @@ -1071,7 +1071,7 @@ varlength_field_pack_guard::~varlength_field_pack_guard() uint32_t nof_bytes = bref_tracker->distance(bref0) / (uint32_t)8; if (nof_bytes > sizeof(buffer)) { srsasn_log_print(LOG_LEVEL_ERROR, - "The packed variable sized field is too long for the reserved buffer (%d > %d)\n", + "The packed variable sized field is too long for the reserved buffer (%d > %zd)\n", nof_bytes, sizeof(buffer)); } From 365cb2dfe25664aa752c3302c22af070f73c2b22 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 27 Nov 2019 13:38:45 +0100 Subject: [PATCH 22/25] assign msg-type to temp variable before logging ASN1 message in RRC --- srsenb/src/stack/rrc/rrc.cc | 10 +++++----- srsue/src/stack/rrc/rrc.cc | 13 +++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 63647d43e..19b7252c3 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -160,15 +160,15 @@ template void rrc::log_rrc_message(const std::string& source, const direction_t dir, const srslte::byte_buffer_t* pdu, const T& msg) { + const char* msg_type = msg.msg.c1().type().to_string().c_str(); if (rrc_log->get_level() == srslte::LOG_LEVEL_INFO) { - rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx", - msg.msg.c1().type().to_string().c_str(), pdu->N_bytes); + rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx", msg_type, pdu->N_bytes); } else if (rrc_log->get_level() >= srslte::LOG_LEVEL_DEBUG) { asn1::json_writer json_writer; msg.to_json(json_writer); - rrc_log->debug_hex(pdu->msg, pdu->N_bytes, "%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx", - msg.msg.c1().type().to_string().c_str(), pdu->N_bytes); - rrc_log->debug("Content:\n%s\n", json_writer.to_string().c_str()); + rrc_log->debug_hex( + pdu->msg, pdu->N_bytes, "%s - %s %s (%d B)\n", source.c_str(), dir == Tx ? "Tx" : "Rx", msg_type, pdu->N_bytes); + rrc_log->debug_long("Content:\n%s\n", json_writer.to_string().c_str()); } } diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 2324518ec..227b27fb1 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -78,14 +78,19 @@ void rrc::srslte_rrc_log(const char* str) template void rrc::log_rrc_message(const std::string source, const direction_t dir, const byte_buffer_t* pdu, const T& msg) { + const char* msg_type = msg.msg.c1().type().to_string().c_str(); if (rrc_log->get_level() == srslte::LOG_LEVEL_INFO) { - rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), (dir == Rx) ? "Rx" : "Tx", - msg.msg.c1().type().to_string().c_str(), pdu->N_bytes); + rrc_log->info("%s - %s %s (%d B)\n", source.c_str(), (dir == Rx) ? "Rx" : "Tx", msg_type, pdu->N_bytes); } else if (rrc_log->get_level() >= srslte::LOG_LEVEL_DEBUG) { asn1::json_writer json_writer; msg.to_json(json_writer); - rrc_log->debug_hex(pdu->msg, pdu->N_bytes, "%s - %s %s (%d B)\n", source.c_str(), (dir == Rx) ? "Rx" : "Tx", - msg.msg.c1().type().to_string().c_str(), pdu->N_bytes); + rrc_log->debug_hex(pdu->msg, + pdu->N_bytes, + "%s - %s %s (%d B)\n", + source.c_str(), + (dir == Rx) ? "Rx" : "Tx", + msg_type, + pdu->N_bytes); rrc_log->debug_long("Content:\n%s\n", json_writer.to_string().c_str()); } } From dc4976f7f695c3134d64548b7947b44f58ec4454 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Thu, 28 Nov 2019 11:53:21 +0000 Subject: [PATCH 23/25] fixed header guard of threads file --- lib/include/srslte/common/threads.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/include/srslte/common/threads.h b/lib/include/srslte/common/threads.h index e47e9c070..b171cbfd2 100644 --- a/lib/include/srslte/common/threads.h +++ b/lib/include/srslte/common/threads.h @@ -19,6 +19,9 @@ * */ +#ifndef SRSLTE_THREADS_H +#define SRSLTE_THREADS_H + #include #include #include @@ -43,9 +46,6 @@ #include -#ifndef SRSLTE_THREADS_H -#define SRSLTE_THREADS_H - class thread { public: @@ -167,8 +167,6 @@ private: } }; - +#endif // __cplusplus #endif // SRSLTE_THREADS_H - -#endif // __cplusplus \ No newline at end of file From 5f17575575cf21672ca83a09b8378837ff90ec71 Mon Sep 17 00:00:00 2001 From: Vasil Velichkov Date: Sat, 19 Oct 2019 02:41:34 +0300 Subject: [PATCH 24/25] Check the format of modified lines only Use the -U0 option to generate a patch that contains only the modified lines without any context --- run-clang-format-diff.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-clang-format-diff.sh b/run-clang-format-diff.sh index a506d0891..512a83bf2 100755 --- a/run-clang-format-diff.sh +++ b/run-clang-format-diff.sh @@ -44,7 +44,7 @@ target=$1 echo "Running code format check between ${target} and ${commit} .." # run clang-format -diff="$(git diff ${target} | clang-format-diff -p1 | python3 -c 'data = open(0).read(); print(data); exit(1 if data else 0)')" +diff="$(git diff -U0 ${target} | clang-format-diff -p1 | python3 -c 'data = open(0).read(); print(data); exit(1 if data else 0)')" # safe return code ret=$? From 0e89fa9f0d155387b338f9d99f81909f68a1df7f Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 29 Nov 2019 13:29:35 +0100 Subject: [PATCH 25/25] fixing two more issues reported by lgtm in asn1 libs --- lib/include/srslte/asn1/asn1_utils.h | 2 +- lib/src/asn1/rrc_asn1_utils.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/include/srslte/asn1/asn1_utils.h b/lib/include/srslte/asn1/asn1_utils.h index 835e63fb0..c2a95d655 100644 --- a/lib/include/srslte/asn1/asn1_utils.h +++ b/lib/include/srslte/asn1/asn1_utils.h @@ -581,7 +581,7 @@ public: { if (s.size() != N) { srsasn_log_print( - LOG_LEVEL_ERROR, "The provided string size=%d does not match the bit string size=%d\n", s.size(), N); + LOG_LEVEL_ERROR, "The provided string size=%zd does not match the bit string size=%d\n", s.size(), N); } memset(&octets_[0], 0, nof_octets()); for (uint32_t i = 0; i < N; ++i) diff --git a/lib/src/asn1/rrc_asn1_utils.cc b/lib/src/asn1/rrc_asn1_utils.cc index 919a31243..8d74b1724 100644 --- a/lib/src/asn1/rrc_asn1_utils.cc +++ b/lib/src/asn1/rrc_asn1_utils.cc @@ -151,6 +151,7 @@ srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::srb_to_add_mod_s& asn1_t } else { asn1::rrc::rrc_log_print( asn1::LOG_LEVEL_ERROR, "SRB %d does not support default initialization type\n", asn1_type.srb_id); + return rlc_config_t(); } }