From daecac16126ccdb71d5d3e6d4dd726611a79a591 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Tue, 26 Sep 2023 08:44:57 -0400 Subject: [PATCH] P25 -- Check MFID 90/A4 Opcode/Payload; Tweaks; --- src/p25_12.c | 2 +- src/p25p1_mdpu.c | 22 ++++++++++++++++++++++ src/p25p1_tsbk.c | 35 ++++++++++++++++++++++++++++++++++- src/p25p2_vpdu.c | 25 +++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) diff --git a/src/p25_12.c b/src/p25_12.c index 8aa7690..918ea18 100644 --- a/src/p25_12.c +++ b/src/p25_12.c @@ -153,7 +153,7 @@ int p25_12(uint8_t * input, uint8_t treturn[12]) if (min != 15) //unique value returned { tdibits[i] = state = min; - irr_err--; //decrement 'corrected' point err + // irr_err--; //decrement 'corrected' point err } //use the predicted correct state/value at output instead -- last resort diff --git a/src/p25p1_mdpu.c b/src/p25p1_mdpu.c index 4b64b22..4c0a6d6 100644 --- a/src/p25p1_mdpu.c +++ b/src/p25p1_mdpu.c @@ -478,6 +478,28 @@ void processMPDU(dsd_opts * opts, dsd_state * state) } } + //look at Harris Opcodes and payload portion of TSBK + else if (MFID == 0xA4) + { + //TODO: Add Known Opcodes from Manual (all one of them) + fprintf (stderr, "%s",KCYN); + fprintf (stderr, "\n MFID A4 (Harris); Opcode: %02X; ", opcode); + for (i = 0; i < (12*(blks+1)%37); i++) + fprintf (stderr, "%02X", mpdu_byte[i]); + fprintf (stderr, " %s",KNRM); + } + + //look at Motorola Opcodes and payload portion of TSBK + else if (MFID == 0x90) + { + //TODO: Add Known Opcodes from Manual + fprintf (stderr, "%s",KCYN); + fprintf (stderr, "\n MFID 90 (Moto); Opcode: %02X; ", mpdu_byte[0] & 0x3F); + for (i = 0; i < (12*(blks+1)%37); i++) + fprintf (stderr, "%02X", mpdu_byte[i]); + fprintf (stderr, " %s",KNRM); + } + else { //convert mpdu_byte to vPDU format and get indication of what the message was diff --git a/src/p25p1_tsbk.c b/src/p25p1_tsbk.c index 54756fd..7b948a5 100644 --- a/src/p25p1_tsbk.c +++ b/src/p25p1_tsbk.c @@ -142,8 +142,41 @@ void processTSBK(dsd_opts * opts, dsd_state * state) fprintf (stderr, "%s",KNRM); } + //look at Harris Opcodes and payload portion of TSBK + else if (MFID == 0xA4 && protectbit == 0 && err == 0) + { + //TODO: Add Known Opcodes from Manual (all one of them) + fprintf (stderr, "%s",KCYN); + fprintf (stderr, "\n MFID A4 (Harris); Opcode: %02X; ", tsbk_byte[0] & 0x3F); + for (i = 2; i < 10; i++) + fprintf (stderr, "%02X", tsbk_byte[i]); + fprintf (stderr, " %s",KNRM); + + //This seems to follow the same structure as the MFID 90 Group Regroup Add Command + + //MFID A4 Opcode 1 on TSBK / Opcode 0x41 on vPDU + // P25 PDU Payload #1 [81][A4] [11][0D] [83][4E] [84][2A] [84][EE] -------[39][30] + // MFID A4 Protected: 0 Last Block: 1 + + //these values do seem to change, but not often, but seem to pair up into 16-bit values + // P25 PDU Payload #1 [81][A4] [11][0D] [84][2A] [84][EE] [FF][FF] -------[4D][2F] + // MFID A4 Protected: 0 Last Block: 1 + + } + + //look at Motorola Opcodes and payload portion of TSBK + else if (MFID == 0x90 && protectbit == 0 && err == 0) + { + //TODO: Add Known Opcodes from Manual -- will probably want to add the voice grants + fprintf (stderr, "%s",KCYN); + fprintf (stderr, "\n MFID 90 (Moto); Opcode: %02X; ", tsbk_byte[0] & 0x3F); + for (i = 2; i < 10; i++) + fprintf (stderr, "%02X", tsbk_byte[i]); + fprintf (stderr, " %s",KNRM); + } + //set our WACN and SYSID here now that we have valid ec and crc/checksum - else if (protectbit == 0 && err == 0 && ec == 0 && (tsbk_byte[0] & 0x3F) == 0x3B) + else if (protectbit == 0 && err == 0 && (tsbk_byte[0] & 0x3F) == 0x3B) { long int wacn = (tsbk_byte[3] << 12) | (tsbk_byte[4] << 4) | (tsbk_byte[5] >> 4); int sysid = ((tsbk_byte[5] & 0xF) << 8) | tsbk_byte[6]; diff --git a/src/p25p2_vpdu.c b/src/p25p2_vpdu.c index c0aab2a..e7a4166 100644 --- a/src/p25p2_vpdu.c +++ b/src/p25p2_vpdu.c @@ -1167,6 +1167,31 @@ void process_MAC_VPDU(dsd_opts * opts, dsd_state * state, int type, unsigned lon // fprintf (stderr, "\n Telephone Interconnect Voice Channel Grant Update "); // } + //TODO: Restructure this function to group standard Opcodes away from MFID 90 and MFID A4, and Unknown MFID + //or just go to if-elseif-else layout (probably easier that way) + //Unknown Harris A4 Opcodes + if (MAC[1+len_a] != 0xB0 && MAC[2+len_a] == 0xA4) + { + // 6.2.36 Manufacturer Specific regarding octet 3 as len + int len = MAC[3+len_a] & 0x3F; + int res = MAC[3+len_a] >> 6; + if (len > 24) + len = 24; //should never exceed this len, but just in case it does + fprintf (stderr, "\n MFID A4 (Harris); Res: %d; Len: %d; Opcode: %02X; ", res, len, MAC[1+len_a]); + for (i = 1; i < len; i++) + fprintf (stderr, "%02X", MAC[i+len_a]); //might not be a good idea to run this, or it may overflow + + } + + /* + Maybe this is why some of these SYNC_BCST PDUs have zeroes in most fields + + Information provided in the SYNC_BCST message may be used for purposes other + than providing synchronization to a TDMA voice channel. These purposes are beyond + the scope of this document. SUs not interested in synchronization with the TDMA voice + channel may ignore the status of the US bit. + */ + //Synchronization Broadcast (SYNC_BCST) if (MAC[1+len_a] == 0x70) {