aboutsummaryrefslogtreecommitdiffstats
path: root/lib/misc_utils
diff options
context:
space:
mode:
authorptrkrysik <ptrkrysik@gmail.com>2015-01-18 10:00:36 +0100
committerptrkrysik <ptrkrysik@gmail.com>2015-01-18 10:00:36 +0100
commit8c6e6ac918e4817ea60eb960a3b4f96e033f54c2 (patch)
treefee1014b5e25bb04e01d6b56b0f008054efc1f4f /lib/misc_utils
parent03da5c6b2a3ddb2edfdb81e530fa2ba41a1a91c3 (diff)
Addition of processing of Pagin Requests Type 2 and 3
Signed-off-by: banjaxbanjo <paulkinsella29@yahoo.ie>
Diffstat (limited to 'lib/misc_utils')
-rw-r--r--lib/misc_utils/tmsi_dumper_impl.cc181
1 files changed, 114 insertions, 67 deletions
diff --git a/lib/misc_utils/tmsi_dumper_impl.cc b/lib/misc_utils/tmsi_dumper_impl.cc
index adb6871..ee3e48f 100644
--- a/lib/misc_utils/tmsi_dumper_impl.cc
+++ b/lib/misc_utils/tmsi_dumper_impl.cc
@@ -37,7 +37,7 @@ void tmsi_dumper_impl::dump_tmsi(pmt::pmt_t msg)
{
time_t t = time(0);
tm *now = localtime(&t);
-
+
pmt::pmt_t message_plus_header_blob = pmt::cdr(msg);
uint8_t * message_plus_header = (uint8_t *)pmt::blob_data(message_plus_header_blob);
gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header;
@@ -48,71 +48,118 @@ void tmsi_dumper_impl::dump_tmsi(pmt::pmt_t msg)
uint8_t msg_type = m[2];
if( direction_and_protocol == 0x06 && //direction from originating site, transaction id==0, Radio Resouce Management protocol
- (msg_type==0x21 || msg_type==0x22 || msg_type==0x24) //types corresponding to paging requests
- )
+ (msg_type==0x21 || msg_type==0x22 || msg_type==0x24) //types corresponding to paging requests
+ )
{
+ //write timestamp
switch(msg_type) {
- case 0x21: //Paging Request Type 1
+ case 0x21: //Paging Request Type 1
+ {
+ uint8_t mobile_identity_type = m[5] & 0x07;
+ unsigned int next_element_index = 0; //position of the next element
+ bool found_id_element = false;
+
+ if(mobile_identity_type == 0x04) //identity type: TMSI
{
- uint8_t mobile_identity_type = m[5] & 0x07;
- unsigned int next_element = 0; //position of the next element
- bool found_id_element = false;
-
- if(mobile_identity_type == 0x04) //identity type: TMSI
- {
- write_tmsi(m+6);
- dump_file << "-";
- write_timestamp(now);
- dump_file << "-0";
- dump_file << std::endl;
-
- next_element = 10;
- found_id_element = true;
- } else
- if(mobile_identity_type == 0x01) //identity type: IMSI
- {
- dump_file << "0-";
- write_timestamp(now);
- dump_file << "-";
- write_imsi(m+5);
- dump_file << std::endl;
-
- next_element = 13;
- found_id_element = true;
- }
-
- if(found_id_element == true)
- {
- //check if there is additional id element
- uint8_t element_id = m[next_element];
- if((next_element < (msg_len+1)) && (element_id == 0x17)){
- uint8_t element_len = m[next_element+1];
- mobile_identity_type = m[next_element+2] & 0x07;
- if(mobile_identity_type == 0x04) //identity type: TMSI
- {
- write_tmsi(m+next_element+3); //write starting from position of the TMSI in the message
- dump_file << "-";
- write_timestamp(now);
- dump_file << "-0";
- dump_file << std::endl;
- } else
- if(mobile_identity_type == 0x01) //identity type: IMSI
- {
- dump_file << "0-";
- write_timestamp(now);
- dump_file << "-";
- write_imsi(m+next_element+2); //write starting from position of the IMSI in the message
- dump_file << std::endl;
- }
+ write_tmsi(m+6);
+ dump_file << "-";
+ write_timestamp(now);
+ dump_file << "-0";
+ dump_file << std::endl;
+
+ next_element_index = 10;
+ found_id_element = true;
+ } else if(mobile_identity_type == 0x01) //identity type: IMSI
+ {
+ dump_file << "0-";
+ write_timestamp(now);
+ dump_file << "-";
+ write_imsi(m+5);
+ dump_file << std::endl;
+
+ next_element_index = 13;
+ found_id_element = true;
+ }
+
+ if(found_id_element == true)
+ {
+ //check if there is additional id element
+ uint8_t element_id = m[next_element_index];
+ if((next_element_index < (msg_len+1)) && (element_id == 0x17)) {
+ //check if there is another element
+ uint8_t element_len = m[next_element_index+1];
+ mobile_identity_type = m[next_element_index+2] & 0x07;
+
+ if(mobile_identity_type == 0x04) //identity type: TMSI
+ {
+ write_tmsi(m+next_element_index+3); //write starting from position of the TMSI in the message
+ dump_file << "-";
+ write_timestamp(now);
+ dump_file << "-0";
+ dump_file << std::endl;
+ } else if(mobile_identity_type == 0x01) //identity type: IMSI
+ {
+ dump_file << "0-";
+ write_timestamp(now);
+ dump_file << "-";
+ write_imsi(m+next_element_index+2); //write starting from position of the IMSI in the message
+ dump_file << std::endl;
}
- int ii;
- }
+ }
+ int ii;
+ }
+ }
+ break;
+ case 0x22: //Paging Request Type 2
+ {
+ uint8_t mobile_identity_type = m[14] & 0x07;
+
+ write_tmsi(m+4);//1st tmsi location
+ dump_file << "-";
+ write_timestamp(now);
+ dump_file << "-0";
+ dump_file << std::endl;
+
+ write_tmsi(m+8);//2nd tmsi location
+ dump_file << "-";
+ write_timestamp(now);
+ dump_file << "-0";
+ dump_file << std::endl;
+
+ if(mobile_identity_type == 0x04) //identity type: TMSI
+ {
+ write_tmsi(m+15);
+ dump_file << "-";
+ write_timestamp(now);
+ dump_file << "-0";
+ dump_file << std::endl;
+
+ } else if(mobile_identity_type == 0x01) //identity type: IMSI
+ {
+ dump_file << "0-";
+ write_timestamp(now);
+ dump_file << "-";
+ write_imsi(m+14);
+ dump_file << std::endl;
+
+ }
+ }
+ break;
+ case 0x24: //Paging Request Type 3
+ {
+ int TMSI_INDEX[4] = {4,8,12,16}; // indexes of the 4 tmsi's
+
+ for(int x =0; x < 4; x++)
+ {
+ write_tmsi(m+TMSI_INDEX[x]);
+ dump_file << "-";
+ write_timestamp(now);
+ dump_file << "-0";
+ dump_file << std::endl;
}
- break;
- case 0x22: //Paging Request Type 2
- break;
- case 0x24: //Paging Request Type 3
- break;
+
+ }
+ break;
}
}
}
@@ -120,10 +167,10 @@ void tmsi_dumper_impl::dump_tmsi(pmt::pmt_t msg)
inline void tmsi_dumper_impl::write_timestamp(tm * now)
{
dump_file << boost::format("%d%02d%02d%02d%02d%02d")
- % (now->tm_year + 1900) //year
- % (now->tm_mon + 1) //month
- % now->tm_mday //day
- % now->tm_hour % now->tm_min % now->tm_sec; //time of day
+ % (now->tm_year + 1900-2000) //year -2000 here after the 1900 leaves you with 15 instead of 2015 (delivery reports format is 150112223501)
+ % (now->tm_mon + 1) //month
+ % now->tm_mday //day
+ % now->tm_hour % now->tm_min % now->tm_sec; //time of day
return;
}
@@ -133,7 +180,7 @@ inline int swap(uint8_t c)
temp1 = c & 0x0F;
temp2 = c & 0xF0;
temp1=temp1 << 4;
- temp2=temp2 >> 4;
+ temp2=temp2 >> 4;
return(temp2|temp1);
}
@@ -168,7 +215,7 @@ tmsi_dumper_impl::tmsi_dumper_impl()
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0))
{
- dump_file.open("tmsicount.txt", std::ios_base::out);
+ dump_file.open("tmsicount.txt", std::ios_base::app);
message_port_register_in(pmt::mp("msgs"));
set_msg_handler(pmt::mp("msgs"), boost::bind(&tmsi_dumper_impl::dump_tmsi, this, _1));
}