Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
hdtuanss committed Apr 29, 2023
1 parent 607fed8 commit 57afffd
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/include/DL_Sniffer_PDSCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class PDSCH_Decoder
uint32_t sf_idx);
void unpack_pdsch_message(uint8_t* sdu_ptr, int length);
int decode_rrc_connection_setup(uint8_t* sdu_ptr, int length, ltesniffer_ue_spec_config_t *ue_config);
int decode_imsi_paging(uint8_t* sdu_ptr, int length);
int decode_imsi_tmsi_paging(uint8_t* sdu_ptr, int length);

int run_decode(int &mimo_ret,
srsran_dci_format_t cur_format,
Expand Down
1 change: 1 addition & 0 deletions src/include/PcapWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class LTESniffer_pcap_writer
/*Function for api*/
void write_ul_crnti_api(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t crnti, uint32_t tti);
void write_dl_crnti_api(uint8_t *pdu, uint32_t pdu_len_bytes, uint16_t crnti, bool crc_ok, uint32_t tti, bool retx); //C RNTI
void write_dl_paging_api(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, bool crc_ok, uint32_t tti, bool retx);
private:
std::mutex pcap_mutex;
bool enable_write;
Expand Down
1 change: 1 addition & 0 deletions src/include/Sniffer_dependency.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define MSG_ATT_REQ 2
#define MSG_ID_RES 3
#define MSG_UE_CAP 4
#define MSG_PAGING 5

struct DCI_BASE {
DCI_BASE();
Expand Down
26 changes: 24 additions & 2 deletions src/src/DL_Sniffer_PDSCH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int PDSCH_Decoder::init_pdsch_decoder(falcon_ue_dl_t *_falcon_ue_dl,
return SRSRAN_SUCCESS;
}

int PDSCH_Decoder::decode_imsi_paging(uint8_t* sdu_ptr, int length){
int PDSCH_Decoder::decode_imsi_tmsi_paging(uint8_t* sdu_ptr, int length){
int ret = SRSRAN_ERROR;
pcch_msg_s pcch_msg;
asn1::cbit_ref bref(sdu_ptr, length);
Expand All @@ -90,8 +90,24 @@ int PDSCH_Decoder::decode_imsi_paging(uint8_t* sdu_ptr, int length){
for (int record = 0; record < record_size; record++){
paging_record_s paging_record = paging_record_list[record];
if (paging_record.ue_id.type() == paging_ue_id_c::types_opts::imsi){
std::string imsi_str;
for (int k = 0; k < 15; k++){
uint8_t temp_imsi = paging_record.ue_id.imsi()[k];
imsi_str.append(std::to_string(temp_imsi));
print_api_dl(dl_sf->tti, 65534, ID_IMSI, imsi_str , MSG_PAGING);
mcs_tracking->increase_nof_api_msg();
ret = SRSRAN_SUCCESS;
}
//printf("Found IMSI paging\n");
ret = SRSRAN_SUCCESS;
}else if (paging_record.ue_id.type() == paging_ue_id_c::types_opts::s_tmsi){
uint32_t m_tmsi = paging_record.ue_id.s_tmsi().m_tmsi.to_number();
std::stringstream ss;
ss << std::hex << m_tmsi;
std::string m_tmsi_str = ss.str();
print_api_dl(dl_sf->tti, 65534, ID_TMSI, m_tmsi_str , MSG_PAGING);
mcs_tracking->increase_nof_api_msg();
ret = SRSRAN_SUCCESS;
}
}
}
Expand Down Expand Up @@ -181,7 +197,10 @@ int PDSCH_Decoder::run_decode(int &mimo_ret,
write_pcap(RNTI_name, pdsch_res[tb].payload, result_length, cur_rnti, tti, false);

if (RNTI_name == "P_RNTI" && (api_mode == 2 || api_mode == 3)){ //IMSI catching modes
decode_imsi_paging(pdsch_res[tb].payload, result_length);
int paging_ret = decode_imsi_tmsi_paging(pdsch_res[tb].payload, result_length);
if (paging_ret == SRSRAN_SUCCESS){
pcapwriter->write_dl_paging_api(pdsch_res[tb].payload, result_length, cur_rnti, true, tti, false);
}
}
/*Unpack PDSCH msg to receive SDU, SDU and then decode RRC Connection Setup*/
srsran::sch_pdu pdu(20, srslog::fetch_basic_logger("MAC"));
Expand Down Expand Up @@ -1109,6 +1128,9 @@ std::string convert_msg_name_dl(int msg){
case 4:
ret = "UECapability";
break;
case 5:
ret = "Paging";
break;
default:
ret = "-";
break;
Expand Down
5 changes: 5 additions & 0 deletions src/src/PcapWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,8 @@ void LTESniffer_pcap_writer::write_dl_crnti_api(uint8_t* pdu, uint32_t pdu_len_b
{
pack_and_write_api(pdu, pdu_len_bytes, retx, crc_ok, tti, rnti, DIRECTION_DOWNLINK, C_RNTI);
}

void LTESniffer_pcap_writer::write_dl_paging_api(uint8_t* pdu, uint32_t pdu_len_bytes, uint16_t rnti, bool crc_ok, uint32_t tti, bool retx)
{
pack_and_write_api(pdu, pdu_len_bytes, retx, crc_ok, tti, SRSRAN_PRNTI, DIRECTION_DOWNLINK, P_RNTI);
}

0 comments on commit 57afffd

Please sign in to comment.