From 49f81da4df94d82ad4b54e4fda2dd0df68f82dbd Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Wed, 21 Dec 2022 21:20:57 -0500 Subject: [PATCH] Trunking White List, Private and Data Calls; --- README.md | 6 ++++++ include/dsd.h | 9 +++++++++ src/dmr_csbk.c | 26 +++++++++++++++++++++++++- src/dsd_main.c | 35 +++++++++++++++++++++++++++++++++-- src/edacs-fme.c | 8 ++++++++ src/nxdn_element.c | 4 ++++ src/p25p2_vpdu.c | 9 +++++++++ 7 files changed, 94 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 813a750..5202b07 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ sudo make install -G Import Group List Allow/Block and Label from csv file. (See group.csv for example) -T Enable Trunking Features (NXDN/P25/EDACS/DMR) with RIGCTL/TCP or RTL Input + -W Use Imported Group List as a Trunking Allow/White List -- Only Tune with Mode A + -p Don't Tune to Private Calls (DMR TIII and P25) + -e Enable Tune to Data Calls (DMR TIII) + (NOTE: DMR Con+ and P25 Data Channels Not Enabled (no handling) -U Enable RIGCTL/TCP; Set TCP Port for RIGCTL. (4532 on SDR++) -B Set RIGCTL Setmod Bandwidth in Hertz (0 - default - OFF) P25 - 7000; NXDN48 - 4000; DMR - 7000; EDACS/PV - 12500; May vary based on system stregnth, etc. @@ -202,6 +206,8 @@ spacebar - replay last symbol capture bin (captures must be stopped first) s - stop playing symbol capture bin or wav input file P - start per call decoded wav files p - stop per call decoded wav files +1 - Lockout Tuning/Playback of TG in Slot 1 or Conventional (Current Session Only) +2 - Lockout Tuning/Playback of TG in Slot 2 (Current Session Only) ``` diff --git a/include/dsd.h b/include/dsd.h index 620c417..cb7fbe2 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -336,6 +336,15 @@ typedef struct uint8_t dmr_dmrla_is_set; //flag to tell us dmrla is set by the user uint8_t dmr_dmrla_n; //n value for dmrla + //Trunking - Use Group List as Allow List + uint8_t trunk_use_allow_list; + + //Trunking - Tune Private Calls + uint8_t trunk_tune_private_calls; + + //Trunking - Tune Data Calls...why? + uint8_t trunk_tune_data_calls; + } dsd_opts; typedef struct diff --git a/src/dmr_csbk.c b/src/dmr_csbk.c index e49d613..48393e8 100644 --- a/src/dmr_csbk.c +++ b/src/dmr_csbk.c @@ -136,8 +136,17 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 { freq = state->trunk_chan_map[lpchannum]; (stderr, "\n Frequency [%.6lf] MHz", (double)freq/1000000); - } + } + //Skip tuning private calls if private calls are disabled + if (opts->trunk_tune_private_calls == 0 && csbk_o != 49) goto SKIPCALL; + + //Allow tuning of data calls if user wishes by flipping the csbk_o to a group voice call + if (csbk_o == 51 || csbk_o == 52 || csbk_o == 54) + { + if (opts->trunk_tune_data_calls == 1) csbk_o = 49; + } + //if not a data channel grant (only tuning to voice channel grants) if (csbk_o == 48 || csbk_o == 49 || csbk_o == 50 || csbk_o == 53) //48, 49, 50 are voice grants, 51 and 52 are data grants, 53 Duplex Private Voice, 54 Duplex Private Data { @@ -154,6 +163,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 { char mode[8]; //allow, block, digital, enc, etc + //if we are using allow/whitelist mode, then write 'B' to mode for block + //comparison below will look for an 'A' to write to mode if it is allowed + if (opts->trunk_use_allow_list == 1) sprintf (mode, "%s", "B"); + for (int i = 0; i < state->group_tally; i++) { if (state->group_array[i].groupNumber == target) @@ -189,6 +202,8 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 } } + + SKIPCALL: ; //do nothing } @@ -609,6 +624,11 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 for (j = 0; j < 8; j++) //go through the channels stored looking for active ones to tune to { char mode[8]; //allow, block, digital, enc, etc + + //if we are using allow/whitelist mode, then write 'B' to mode for block + //comparison below will look for an 'A' to write to mode if it is allowed + if (opts->trunk_use_allow_list == 1) sprintf (mode, "%s", "B"); + for (int i = 0; i < state->group_tally; i++) { if (state->group_array[i].groupNumber == t_tg[j]) @@ -718,6 +738,10 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8 char mode[8]; //allow, block, digital, enc, etc + //if we are using allow/whitelist mode, then write 'B' to mode for block + //comparison below will look for an 'A' to write to mode if it is allowed + if (opts->trunk_use_allow_list == 1) sprintf (mode, "%s", "B"); + for (int i = 0; i < state->group_tally; i++) { if (state->group_array[i].groupNumber == grpAddr) diff --git a/src/dsd_main.c b/src/dsd_main.c index b4b10b6..55117ea 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -487,6 +487,15 @@ initOpts (dsd_opts * opts) opts->dmr_dmrla_is_set = 0; opts->dmr_dmrla_n = 0; + //Trunking - Use Group List as Allow List + opts->trunk_use_allow_list = 0; //disabled by default + + //Trunking - Tune Private Calls + opts->trunk_tune_private_calls = 1; //enabled by default + + //Trunking - Tune Data Calls + opts->trunk_tune_data_calls = 0; //disabled by default + } //initopts void @@ -939,6 +948,10 @@ usage () printf (" -G Import Group List Allow/Block and Label from csv file.\n"); printf (" (See group.csv for example)\n"); printf (" -T Enable Trunking Features (NXDN/P25/EDACS/DMR) with RIGCTL/TCP or RTL Input\n"); + printf (" -W Use Imported Group List as a Trunking Allow/White List -- Only Tune with Mode A\n"); + printf (" -p Don't Tune to Private Calls (DMR TIII and P25)\n"); + printf (" -e Enable Tune to Data Calls (DMR TIII)\n"); + printf (" (NOTE: DMR Con+ and P25 Data Channels Not Enabled (no handling) \n"); printf (" -U Enable RIGCTL/TCP; Set TCP Port for RIGCTL. (4532 on SDR++)\n"); printf (" -B Set RIGCTL Setmod Bandwidth in Hertz (0 - default - OFF)\n"); printf (" P25 - 7000; NXDN48 - 4000; DMR - 7000; EDACS/PV - 12500; May vary based on system stregnth, etc.\n"); @@ -1155,7 +1168,7 @@ main (int argc, char **argv) exitflag = 0; // signal (SIGINT, sigfun); - while ((c = getopt (argc, argv, "haep:Pqs:t:v:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:Y:K:H:X:NQWrlZTF1:2:345:6:7:89:")) != -1) + while ((c = getopt (argc, argv, "haepPqs:t:v:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:U:Y:K:H:X:NQWrlZTF1:2:345:6:7:89:")) != -1) { opterr = 0; switch (c) @@ -1167,12 +1180,30 @@ main (int argc, char **argv) opts.call_alert = 1; break; - //Free'd up switches include e,p,v,Q,V,Y,z + //Free'd up switches include v,Q,V,Y,z //make sure to put a colon : after each if they need an argument //or remove colon if no argument required //Disabled the Serial Port Dev and Baud Rate, etc, If somebody uses that function, sorry... + //Trunking - Use Group List as Allow List + case 'W': + opts.trunk_use_allow_list = 1; + fprintf (stderr, "Using Group List as Allow/White List. \n"); + break; + + //Trunking - Tune Private Calls + case 'p': + opts.trunk_tune_private_calls = 0; //disable + fprintf (stderr, "Disable Tuning to Private Calls. \n"); + break; + + //Trunking - Tune Data Calls + case 'e': + opts.trunk_tune_data_calls = 1; //enable + fprintf (stderr, "Enable Tuning to Data Calls. \n"); + break; + case 'D': //user set DMRLA n value sscanf (optarg, "%c", &opts.dmr_dmrla_n); if (opts.dmr_dmrla_n > 10) opts.dmr_dmrla_n = 10; //max out at 10; diff --git a/src/edacs-fme.c b/src/edacs-fme.c index 7dbd735..e87f16f 100644 --- a/src/edacs-fme.c +++ b/src/edacs-fme.c @@ -255,6 +255,10 @@ void edacs(dsd_opts * opts, dsd_state * state) char mode[8]; //allow, block, digital enc + //if we are using allow/whitelist mode, then write 'B' to mode for block + //comparison below will look for an 'A' to write to mode if it is allowed + if (opts->trunk_use_allow_list == 1) sprintf (mode, "%s", "B"); + for (int i = 0; i < state->group_tally; i++) { if (state->group_array[i].groupNumber == group) @@ -380,6 +384,10 @@ void edacs(dsd_opts * opts, dsd_state * state) char mode[8]; //allow, block, digital enc + //if we are using allow/whitelist mode, then write 'B' to mode for block + //comparison below will look for an 'A' to write to mode if it is allowed + if (opts->trunk_use_allow_list == 1) sprintf (mode, "%s", "B"); + for (int i = 0; i < state->group_tally; i++) { if (state->group_array[i].groupNumber == afs) diff --git a/src/nxdn_element.c b/src/nxdn_element.c index 1a42f7d..984de7b 100644 --- a/src/nxdn_element.c +++ b/src/nxdn_element.c @@ -260,6 +260,10 @@ void NXDN_decode_VCALL_ASSGN(dsd_opts * opts, dsd_state * state, uint8_t * Messa //group list mode so we can look and see if we need to block tuning any groups, etc char mode[8]; //allow, block, digital, enc, etc + //if we are using allow/whitelist mode, then write 'B' to mode for block + //comparison below will look for an 'A' to write to mode if it is allowed + if (opts->trunk_use_allow_list == 1) sprintf (mode, "%s", "B"); + for (int i = 0; i < state->group_tally; i++) { if (state->group_array[i].groupNumber == DestinationID) //source, or destination? diff --git a/src/p25p2_vpdu.c b/src/p25p2_vpdu.c index d646985..0ba1cce 100644 --- a/src/p25p2_vpdu.c +++ b/src/p25p2_vpdu.c @@ -77,6 +77,10 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon //group list mode so we can look and see if we need to block tuning any groups, etc char mode[8]; //allow, block, digital, enc, etc + //if we are using allow/whitelist mode, then write 'B' to mode for block + //comparison below will look for an 'A' to write to mode if it is allowed + if (opts->trunk_use_allow_list == 1) sprintf (mode, "%s", "B"); + for (int i = 0; i < 2; i++) { @@ -399,6 +403,9 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon fprintf (stderr, "\n CHAN [%04X] Source [%d] Target [%d]", channel, source, target); freq = process_channel_to_freq (opts, state, channel); + //Skip tuning private calls if private calls is disabled + if (opts->trunk_tune_private_calls == 0) goto SKIPCALL; + //unit to unit needs work, may fail under certain conditions (first blocked, second allowed, etc) (labels should still work though) for (int i = 0; i < state->group_tally; i++) { @@ -452,6 +459,8 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon else state->p25_vc_freq[0] = state->p25_vc_freq[1] = freq; } } + + SKIPCALL: ; //do nothing } //Group Voice Channel Grant Update Multiple - Explicit