From 6698793a241a3acfa2c2193ba363f5041b4ec22b Mon Sep 17 00:00:00 2001 From: iZsh Date: Sun, 16 Aug 2015 14:42:18 +0200 Subject: Fix issue #112 (copy messages instead of modifying the input msg) --- lib/demapping/tch_f_chans_demapper_impl.cc | 28 +++++++++++++++------- .../universal_ctrl_chans_demapper_impl.cc | 15 ++++++++---- 2 files changed, 30 insertions(+), 13 deletions(-) (limited to 'lib/demapping') diff --git a/lib/demapping/tch_f_chans_demapper_impl.cc b/lib/demapping/tch_f_chans_demapper_impl.cc index cc24b9e..a54ed3f 100644 --- a/lib/demapping/tch_f_chans_demapper_impl.cc +++ b/lib/demapping/tch_f_chans_demapper_impl.cc @@ -29,6 +29,8 @@ #include #include +#define BURST_SIZE 148 + namespace gr { namespace gsm { @@ -80,12 +82,20 @@ namespace gr { int8_t * burst_bits = (int8_t *)(pmt::blob_data(header_plus_burst))+sizeof(gsmtap_hdr); if(header->timeslot == d_timeslot){ - header->sub_type = GSMTAP_CHANNEL_TCH_F; + int8_t new_msg[sizeof(gsmtap_hdr)+BURST_SIZE]; + gsmtap_hdr * new_hdr = (gsmtap_hdr*)new_msg; + memcpy(new_msg, header, sizeof(gsmtap_hdr)+BURST_SIZE); + new_hdr->sub_type = GSMTAP_CHANNEL_TCH_F; if (fn_mod13 == 12) - { header->sub_type = GSMTAP_CHANNEL_ACCH|GSMTAP_CHANNEL_TCH_F; + pmt::pmt_t msg_binary_blob = pmt::make_blob(new_msg,sizeof(gsmtap_hdr)+BURST_SIZE); + pmt::pmt_t msg_out = pmt::cons(pmt::PMT_NIL, msg_binary_blob); + + + if (fn_mod13 == 12) + { // position of SACCH burst based on timeslot // see specification gsm 05.02 uint32_t index; @@ -104,7 +114,7 @@ namespace gr { if (is_sacch) { - d_bursts_sacch[index] = msg; + d_bursts_sacch[index] = msg_out; d_frame_numbers_sacch[index] = frame_nr; if (index == 3) @@ -135,8 +145,8 @@ namespace gr { if (fn_mod13 <= 3) { // add to b1 and b3 - d_bursts[0][fn_mod13] = msg; - d_bursts[2][fn_mod13 + 4] = msg; + d_bursts[0][fn_mod13] = msg_out; + d_bursts[2][fn_mod13 + 4] = msg_out; // set framenumber d_frame_numbers[0][fn_mod13] = frame_nr; @@ -145,8 +155,8 @@ namespace gr { else if (fn_mod13 >= 4 && fn_mod13 <= 7) { // add to b1 and b2 - d_bursts[0][fn_mod13] = msg; - d_bursts[1][fn_mod13 - 4] = msg; + d_bursts[0][fn_mod13] = msg_out; + d_bursts[1][fn_mod13 - 4] = msg_out; // set framenumber d_frame_numbers[0][fn_mod13] = frame_nr; @@ -155,8 +165,8 @@ namespace gr { else if (fn_mod13 >= 8 && fn_mod13 <= 11) { // add to b2 and b3 - d_bursts[1][fn_mod13 - 4] = msg; - d_bursts[2][fn_mod13 - 8] = msg; + d_bursts[1][fn_mod13 - 4] = msg_out; + d_bursts[2][fn_mod13 - 8] = msg_out; // set framenumber d_frame_numbers[1][fn_mod13 - 4] = frame_nr; diff --git a/lib/demapping/universal_ctrl_chans_demapper_impl.cc b/lib/demapping/universal_ctrl_chans_demapper_impl.cc index 8a6bfb5..c711928 100644 --- a/lib/demapping/universal_ctrl_chans_demapper_impl.cc +++ b/lib/demapping/universal_ctrl_chans_demapper_impl.cc @@ -30,6 +30,8 @@ #include #include +#define BURST_SIZE 148 + namespace gr { namespace gsm { @@ -140,7 +142,7 @@ namespace gr { { pmt::pmt_t header_plus_burst = pmt::cdr(msg); gsmtap_hdr * header = (gsmtap_hdr *)pmt::blob_data(header_plus_burst); - + uint32_t frame_nr = be32toh(header->frame_number); uint32_t fn_mod51 = frame_nr % 51; uint32_t fn51_start = d_starts_fn_mod51[fn_mod51]; @@ -148,14 +150,19 @@ namespace gr { uint32_t ch_type = d_channel_types[fn_mod51]; if(header->timeslot==d_timeslot){ - header->sub_type = ch_type; - header->sub_slot = d_subslots[fn_mod51 + (51 * (frame_nr % 2))]; + int8_t new_msg[sizeof(gsmtap_hdr)+BURST_SIZE]; + gsmtap_hdr * new_hdr = (gsmtap_hdr*)new_msg; + memcpy(new_msg, header, sizeof(gsmtap_hdr)+BURST_SIZE); + new_hdr->sub_type = ch_type; + new_hdr->sub_slot = d_subslots[fn_mod51 + (51 * (frame_nr % 2))]; + pmt::pmt_t msg_binary_blob = pmt::make_blob(new_msg,sizeof(gsmtap_hdr)+BURST_SIZE); + pmt::pmt_t msg_out = pmt::cons(pmt::PMT_NIL, msg_binary_blob); if(fn_mod51>=fn51_start && fn_mod51<=fn51_stop) { uint32_t ii = fn_mod51 - fn51_start; d_frame_numbers[ii] = frame_nr; - d_bursts[ii] = msg; + d_bursts[ii] = msg_out; } if(fn_mod51==fn51_stop) -- cgit v1.2.3