From ab186da2f38a3b32e3de75d1d2a48888b5fb1039 Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Thu, 24 Feb 2022 20:05:32 -0500 Subject: [PATCH 1/2] P25P1 Information P25P1 Information -added fprintf and printw for algid, keyid, mfid, errs, etc --- include/dsd.h | 3 +++ src/dsd_file.c | 6 +++++- src/dsd_main.c | 1 + src/dsd_ncurses.c | 49 +++++++++++++++++++++-------------------------- src/p25p1_hdu.c | 14 ++++++++++++-- src/p25p1_ldu1.c | 5 +++++ src/p25p1_ldu2.c | 17 ++++++++++++++-- src/p25p1_tdulc.c | 7 ++++++- 8 files changed, 69 insertions(+), 33 deletions(-) diff --git a/include/dsd.h b/include/dsd.h index ed6b271..9f423b3 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -309,6 +309,9 @@ typedef struct mbe_parms *prev_mp; mbe_parms *prev_mp_enhanced; int p25kid; + int payload_algid; + int payload_keyid; + int payload_mfid; unsigned int debug_audio_errors; unsigned int debug_header_errors; diff --git a/src/dsd_file.c b/src/dsd_file.c index 5b25780..c4a74e8 100644 --- a/src/dsd_file.c +++ b/src/dsd_file.c @@ -31,6 +31,7 @@ saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d) if (opts->payload == 1) //make opt variable later on to toggle this { fprintf(stderr, "\n"); + //fprintf(stderr, "ALGID=%X KEYID=%X\n", state->payload_algid, state->payload_keyid); } for (i = 0; i < 11; i++) @@ -49,7 +50,10 @@ saveImbe4400Data (dsd_opts * opts, dsd_state * state, char *imbe_d) } fputc (b, opts->mbe_out_f); } - //fprintf(stderr, "\n"); + if (opts->payload == 1) + { + fprintf(stderr, " err = [%X] [%X] ", state->errs, state->errs2); + } fflush (opts->mbe_out_f); } diff --git a/src/dsd_main.c b/src/dsd_main.c index f7210c1..71e7621 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -199,6 +199,7 @@ initOpts (dsd_opts * opts) opts->pulse_flush = 1; //set 0 to flush, 1 for flushed opts->use_ncurses_terminal = 0; //ncurses terminal disabled by default, call with -N + opts->payload = 0; //initialize with 0 so can pass == 0 arguments } void diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index cd2ee61..13fc49e 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -53,31 +53,6 @@ char * FM_bannerN[9] = { "https://github.com/lwvmobile/dsd-fme/tree/pulseaudio " }; -/* -char * SyncTypes[20] = { - "P25P1_SYNC", - "INV_P25P1_SYNC", - "X2TDMA_BS/MS_DATA_SYNC", - "INV_X2TDMA_BS/MS_DATA_SYNC", - "X2TDMA_BS/MS_VOICE_SYNC", - "INV_X2TDMA_BS/MS_VOICE_SYNC", - "DSTAR_SYNC", - "INV_DSTAR_SYNC", - "NXDN_BS_VOICE_SYNC", //8 - "INV_NXDN_BS_VOICE_SYNC", //9 - "DMR_BS/MS_DATA_SYNC", //10 - "DMR_MS/BS_VOICE_SYNC", //11 - "DMR_MS/BS_DATA_SYNC", //12 - "INV_DMR_BS/MS_VOICE_SYNC", //13 - "PROVOICE_SYNC", //14 - "INV_PROVOICE_SYNC", //15 - "NXDN_BS_DATA_SYNC", //16 - "INV_NXDN_BS_DATA_SYNC", //17 - "DSTAR_HD", - "INV_DSTAR_HD" - -}; -*/ char * SyncTypes[20] = { "+P25P1", "-P25P1", @@ -159,6 +134,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) //printw ("| Press CTRL+C twice to exit\n"); printw ("------------------------------------------------------------------------------\n"); + if (state->carrier == 0) //reset these to 0 when no carrier + { + //state->payload_algid = 0; + //state->payload_keyid = 0; + //state->payload_mfid = 0; + } if ( (lls == 14 || lls == 15) && (time(NULL) - call_matrix[9][5] > 5) && state->carrier == 1) //honestly have no idea how to do this for pV, just going time based? only update on carrier == 1. { @@ -356,8 +337,22 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) } if ((lls == 0 || lls == 1)) //1 for P25 P1 Audio { - printw("| TID:[%i] \n| RID:[%i] \n", tg, rd); - printw("| NAC: [0x%X] \n", nc); + //printw("| TID:[%i] | RID:[%i] \n", tg, rd); + //printw("| NAC: [0x%X] \n", nc); + printw("| TID:[%i] RID:[%i] ", tg, rd); + printw("NAC: [0x%X] \n", nc); + printw("| ALG: [0x%02X] ", state->payload_algid); + printw("KEY: [0x%04X] ", state->payload_keyid); + //printw("MFG: [0x%X] ", state->payload_mfid); //no way of knowing if this is accurate info yet + if (state->payload_keyid != 0 && state->carrier == 1) + { + attron(COLOR_PAIR(2)); + printw("**ENC**"); + attroff(COLOR_PAIR(2)); + attron(COLOR_PAIR(3)); + } + printw("\n"); + //printw("| System Type: %s \n", ALGIDS[state->payload_keyid] ); } //if (state->lastsynctype == 12 || state->lastsynctype == 13) //DMR Voice Types if (lls == 12 || lls == 13) //DMR Voice Types diff --git a/src/p25p1_hdu.c b/src/p25p1_hdu.c index bf2d9e2..8cc9af2 100644 --- a/src/p25p1_hdu.c +++ b/src/p25p1_hdu.c @@ -452,12 +452,22 @@ processHDU(dsd_opts* opts, dsd_state* state) skipDibit (opts, state, 5); status = getDibit (opts, state); //TODO: Do something useful with the status bits... + /* + algidhex = strtol (algid, NULL, 2); + kidhex = strtol (kid, NULL, 2); - if (opts->p25enc == 1) + state->payload_algid = algidhex; + state->payload_keyid = kidhex; + if (opts->payload == 1) + { + fprintf (stderr, "ALG ID: 0x%X KEY ID: 0x%X\n", algidhex, kidhex); + } + */ + if (opts->p25enc == 1 && opts->payload == 0) { algidhex = strtol (algid, NULL, 2); kidhex = strtol (kid, NULL, 2); - fprintf (stderr, "mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); + //fprintf (stderr, "mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); } if (opts->p25lc == 1) { diff --git a/src/p25p1_ldu1.c b/src/p25p1_ldu1.c index afe15eb..d804855 100644 --- a/src/p25p1_ldu1.c +++ b/src/p25p1_ldu1.c @@ -330,5 +330,10 @@ processLDU1 (dsd_opts* opts, dsd_state* state) lcinfo[54] = hex_data[ 0][4] + '0'; lcinfo[55] = hex_data[ 0][5] + '0'; + if (state->carrier == 1 && state->errs == 0) //only update when carrier is present, otherwise, garbage values may be collected + { + state->payload_mfid = strtol (mfid, NULL, 2); + } + processP25lcw (opts, state, lcformat, mfid, lcinfo); } diff --git a/src/p25p1_ldu2.c b/src/p25p1_ldu2.c index ee631dd..d2ab00d 100644 --- a/src/p25p1_ldu2.c +++ b/src/p25p1_ldu2.c @@ -360,11 +360,24 @@ processLDU2 (dsd_opts * opts, dsd_state * state) kid[14] = hex_data[ 0][4] + '0'; kid[15] = hex_data[ 0][5] + '0'; + if (state->carrier == 1 && state->errs2 == 0) //only update when carrier is present, and no errors + { + //state->payload_mi = strtol (mi, NULL, 2); //no idea what this value is? + algidhex = strtol (algid, NULL, 2); + kidhex = strtol (kid, NULL, 2); + state->payload_algid = algidhex; + state->payload_keyid = kidhex; + } - if (opts->p25enc == 1) + if (opts->payload == 1 && state->errs2 == 0) + { + fprintf (stderr, "ALG ID: 0x%X KEY ID: 0x%X\n", algidhex, kidhex); + //fprintf (stderr, "MI: %s\n", mi); + } + if (opts->p25enc == 1 && opts->payload == 0) { algidhex = strtol (algid, NULL, 2); kidhex = strtol (kid, NULL, 2); - fprintf (stderr, "mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); + //fprintf (stderr, "mi: %s algid: $%x kid: $%x\n", mi, algidhex, kidhex); } } diff --git a/src/p25p1_tdulc.c b/src/p25p1_tdulc.c index 181f6b3..1f5152a 100644 --- a/src/p25p1_tdulc.c +++ b/src/p25p1_tdulc.c @@ -386,6 +386,11 @@ processTDULC (dsd_opts* opts, dsd_state* state) lcinfo[53] = dodeca_data[0][ 9] + '0'; lcinfo[54] = dodeca_data[0][10] + '0'; lcinfo[55] = dodeca_data[0][11] + '0'; - + /* + if (state->carrier == 1) //only update when carrier is present, otherwise, garbage values may be collected + { + state->payload_mfid = strtol (mfid, NULL, 2); //wonder if this is accurate info or not + } + */ processP25lcw (opts, state, lcformat, mfid, lcinfo); } From 568a8521c0b1102459428fa45b5c7c899c985232 Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Thu, 24 Feb 2022 20:19:11 -0500 Subject: [PATCH 2/2] Informational Print to Main fprintf Unmute P25 Encrypted Audio --- src/dsd_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dsd_main.c b/src/dsd_main.c index 71e7621..9e2f45a 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -659,6 +659,7 @@ main (int argc, char **argv) else if (optarg[0] == 'u') { opts.unmute_encrypted_p25 = 1; + fprintf(stderr, "P25 Encrypted Audio Unmuted\n"); } break; case 'P':