DMR: Fix BParm Issues Mentioned in #293

Make some tweaks to DMR BS RC_TESTING; #292

Fix Talker Alias Block Num Enumeration (+1) on Valid Blocks;

Misc Typo and Format Fixes;

Tweak for NXDN Keyloading on VCALL;
This commit is contained in:
lwvmobile
2025-05-29 14:44:37 -04:00
parent 4a1e6f1540
commit 175ccff7e9
7 changed files with 81 additions and 23 deletions

View File

@@ -303,8 +303,14 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
//check for a rc burst with bptc or 34 rate data in it (testing only)
// #define RC_TESTING //disable if not in use
#ifdef RC_TESTING
if ( (strcmp (sync, DMR_BS_DATA_SYNC) != 0) && (strcmp (sync, DMR_BS_VOICE_SYNC) != 0) &&
( (internalslot == 0 && vc1 == 6) || (internalslot == 1 && vc2 == 6) ) )
//check only if or when not daya sync, but also out of sync on vc counter
// if ( (strcmp (sync, DMR_BS_DATA_SYNC) != 0) && (strcmp (sync, DMR_BS_VOICE_SYNC) != 0) &&
// ( (internalslot == 0 && vc1 >= 7) || (internalslot == 1 && vc2 >= 7) ) )
// {
//skip the vc counter, just look at the QR and P/Pi if not voice or data sync pattern
if ( (strcmp (sync, DMR_BS_DATA_SYNC) != 0) && (strcmp (sync, DMR_BS_VOICE_SYNC) != 0) )
{
//if the QR FEC is good, and the P/PI bit is on for RC
@@ -318,7 +324,11 @@ void dmrBS (dsd_opts * opts, dsd_state * state)
dmr_data_sync (opts, state);
dmr_data_burst_handler(opts, state, (uint8_t *)dummy_bits, 0xEB);
//disabled, shouldn't occur here I don't think, voice only
// dmr_data_burst_handler(opts, state, (uint8_t *)dummy_bits, 0xEB);
for (i = 0; i < 48; i++)
state->dmr_embedded_signalling[internalslot][5][i] = syncdata[i];
dmr_sbrc (opts, state, emb_pdu[4]);

View File

@@ -3,7 +3,7 @@
* DMR Control Signal Data PDU (CSBK, MBC) Handler and Related Functions
*
* Portions of Connect+ code reworked from Boatbod OP25
* Source: https://github.com/LouisErigHerve/dsd/blob/master/src/dmr_sync.c
* Source: https://github.com/boatbod/op25/blob/master/op25/gr-op25_repeater/lib/dmr_slot.cc
*
* Portions of Capacity+ code reworked from Eric Cottrell
* Source: https://github.com/LinuxSheeple-E/dsd/blob/Feature/DMRECC/dmr_csbk.c
@@ -742,8 +742,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
uint16_t t_emerg_timer = (uint16_t)ConvertBitIntoBytes(&bpbits1[0], 9);
uint8_t t_packet_timer = (uint8_t)ConvertBitIntoBytes(&bpbits1[9], 5);
uint16_t t_msms_timer = (uint16_t)ConvertBitIntoBytes(&bpbits1[0], 9);
uint16_t t_msline_timer = (uint16_t)ConvertBitIntoBytes(&bpbits1[0], 9);
uint16_t t_msms_timer = (uint16_t)ConvertBitIntoBytes(&bpbits2[0], 9);
uint16_t t_msline_timer = (uint16_t)ConvertBitIntoBytes(&bpbits2[0], 9);
//just doing the raw values here, and not the decoded values, see clause A.1, Tables A.2, A.3, A.4, A.5
fprintf (stderr, "\n");
@@ -928,10 +928,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
uint8_t nin = (uint8_t)ConvertBitIntoBytes(&bpbits2[16], 8); //see clause 7.2.41
//the second bit of the CSI, the rest are reserved (wasteful)
uint8_t hibernate_flag = bpbits1[1];
uint8_t hibernate_flag = bpbits2[1];
//the first bit of the nin, the rest are reserved (yet again)
uint8_t reg_tg_sub = bpbits2[0]; //if the MS has to send TG during Registration Process (Zzzzzz)
uint8_t reg_tg_sub = bpbits2[16]; //if the MS has to send TG during Registration Process (Zzzzzz)
fprintf (stderr, "\n");
fprintf (stderr, " Hibernate Flag: %d; Reg Flag: %d; RES1: %d; RES2: %X; RES3: %X; BPARMS1: %X", hibernate_flag, reg_tg_sub, bpbits1[0], csi & 0x3F, nin & 0x7F, bparms1);

View File

@@ -427,7 +427,8 @@ void dmr_sbrc (dsd_opts * opts, dsd_state * state, uint8_t power)
else if (sbrc_hex == 5) fprintf (stderr, " RC: Cease Transmission Request;");
else fprintf (stderr, " RC: Reserved %02X;", sbrc_hex);
fprintf (stderr, "%s", KNRM);
if (opts->payload == 1) fprintf (stderr, "\n");
// if (opts->payload == 1)
fprintf (stderr, "\n");
}
//if the call is interruptable (TXI) and the crc3 is okay and TXI Opcode

View File

@@ -732,12 +732,12 @@ void dmr_talker_alias_lc_blocks (dsd_opts * opts, dsd_state * state, uint8_t slo
}
}
//Deocde partial or comppleted alias
//Decode partial or completed alias
void dmr_talker_alias_lc_decode (dsd_opts * opts, dsd_state * state, uint8_t slot, uint8_t block_num, uint8_t char_size, uint16_t end)
{
UNUSED(opts);
uint16_t i = 0;
fprintf (stderr, " Slot %d - Talker Alias Block Num: %d; Valid Block;", slot, block_num);
fprintf (stderr, " Slot %d - Talker Alias Block Num: %d; Valid Block;", slot, block_num+1);
fprintf (stderr, " Talker Alias: ");
char alias_string[500]; memset (alias_string, 0, sizeof(alias_string));
@@ -774,7 +774,7 @@ void dmr_talker_alias_lc_decode (dsd_opts * opts, dsd_state * state, uint8_t slo
uint8_t character = (uint8_t)ConvertBitIntoBytes(&state->dmr_pdu_sf[slot][(i*8)], 8);
char ch[2]; ch[0] = character; ch[1] = 0;
// if (character >= 0x20 && character <= 0x7E) //Standard ASCII Set
if (character >= 0x20 && character != 0x7F) //allow some extended UTF discritical characters as well
if (character >= 0x20 && character != 0x7F) //allow some extended UTF diacritical characters as well
{
fprintf (stderr, "%c", character);
strcat (alias_string, ch);

View File

@@ -1280,17 +1280,64 @@ void NXDN_decode_VCALL(dsd_opts * opts, dsd_state * state, uint8_t * Message)
fprintf (stderr, "%s", KNRM);
//check the rkey array for a scrambler key value
//check by keyid first, then by tgt id
//TGT ID and Key ID could clash though if csv or system has both with different keys
if (state->rkey_array[KeyID] != 0) state->R = state->rkey_array[KeyID];
else if (state->rkey_array[DestinationID] != 0) state->R = state->rkey_array[DestinationID];
//if using the keyloader, then check for a key value first by the key id,
//and then if not available, check by the destination (TG) id value
//also, for DES and AES, set the nxdn_key varialbe to the DestID for IV and KS gen
if (state->keyloader == 1)
{
//if Scrambler Key (and not running NXDN96 since that has VCALL in the non-voice frames)
//NOTE: The scrambler seed carries on the state->R variable so that will reset incorrectly on NXDN96
//NOTE: Observed on system with scrambler and AES keys on same TG, disabling loading DES and AES key by DestID
if (CipherType == 1 && opts->frame_nxdn48 == 1 && opts->frame_nxdn96 == 0)
{
if (state->rkey_array[KeyID] != 0) state->R = state->rkey_array[KeyID];
else if (state->rkey_array[DestinationID] != 0) state->R = state->rkey_array[DestinationID];
}
//Don't zero key if no keyloader, if we need this, do it when its nots NXDN96, causes issue when 96 VCALL comes in on all data frames
// if (CipherType != 0x1 && state->keyloader == 1) state->R = 0; //what did this do again? for mont system or something?
//if DES Key
else if (CipherType == 2)
{
if (state->rkey_array[KeyID] != 0) state->R = state->rkey_array[KeyID];
// else if (state->rkey_array[DestinationID] != 0)
// {
// state->R = state->rkey_array[DestinationID];
// state->nxdn_key = DestinationID;
// }
}
//safe alternative?
if (CipherType == 0 && state->keyloader == 1) state->R = 0;
//if AES Key
else if (CipherType == 3)
{
uint32_t kidx = 0;
if (state->rkey_array[KeyID] != 0) kidx = KeyID;
// else if (state->rkey_array[DestinationID] != 0)
// {
// kidx = DestinationID;
// state->nxdn_key = DestinationID;
// }
state->A1[0] = state->rkey_array[kidx+0x000];
state->A2[0] = state->rkey_array[kidx+0x101];
state->A3[0] = state->rkey_array[kidx+0x201];
state->A4[0] = state->rkey_array[kidx+0x301];
//check to see if there is a value loaded or not
if (state->A1[0] == 0 && state->A2[0] == 0 && state->A3[0] == 0 && state->A4[0] == 0)
state->aes_key_loaded[0] = 0;
else state->aes_key_loaded[0] = 1;
for (int i = 0; i < 8; i++)
{
state->aes_key[i+0] = (state->A1[0] >> (56-(i*8))) & 0xFF;
state->aes_key[i+8] = (state->A2[0] >> (56-(i*8))) & 0xFF;
state->aes_key[i+16] = (state->A3[0] >> (56-(i*8))) & 0xFF;
state->aes_key[i+24] = (state->A4[0] >> (56-(i*8))) & 0xFF;
}
state->R = state->A1[0]; //display KS stub
}
} //end state->keyloader == 1
/* Print the "Cipher Type" */
if(CipherType != 0 && MessageType == 0x1)

View File

@@ -142,7 +142,7 @@ void p25_decode_pdu_trunking(dsd_opts * opts, dsd_state * state, uint8_t * mpdu_
freq2 = process_channel_to_freq (opts, state, channelr);
//add active channel to string for ncurses display
sprintf (state->active_channel[0], "Active Ch: %04X TG: %d ", channelt, group);
sprintf (state->active_channel[0], "Active Ch: %04X TG: %d; ", channelt, group);
state->last_active_time = time(NULL);
for (int i = 0; i < state->group_tally; i++)

View File

@@ -214,7 +214,7 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon
freq = process_channel_to_freq (opts, state, channel);
//add active channel to string for ncurses display
sprintf (state->active_channel[0], "MFID90 Active Ch: %04X SG: %d ", channel, sgroup);
sprintf (state->active_channel[0], "MFID90 Active Ch: %04X SG: %d; ", channel, sgroup);
state->last_active_time = time(NULL);
for (int i = 0; i < state->group_tally; i++)