From f2312e63ebf82576798bff2f4f1f8f80b477a87c Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Thu, 13 Jun 2024 16:21:25 -0400 Subject: [PATCH] M17: Disable Duplicate (Debug) LSF and Change Default DST Value; M17: Fix Examples in Usage; M17: Disable Nonce/IV Warning; M17: Add Support For OTAKD Recognition (skip decode); --- examples/Example_Usage.md | 4 ++-- src/dsd_main.c | 8 ++++---- src/m17.c | 26 ++++++++++++++++++++------ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/examples/Example_Usage.md b/examples/Example_Usage.md index c030761..ed04c07 100644 --- a/examples/Example_Usage.md +++ b/examples/Example_Usage.md @@ -330,9 +330,9 @@ Decode (Lower z): NOTE: When using tcp input for M17 decoding, DSD-FME will keep the TCP connection alive with constant retries, so no need to restart the decoding session on connection failure. -SMS Packet Encoder: +SMS Packet Encoder (Text Only): -`dsd-fme -fP -S "This is a sample message sent over M17 Packet Data using DSD-FME to encode it."` +`dsd-fme -fP -8 -S "This is a sample message sent over M17 Packet Data using DSD-FME to encode it."` SMS Packet Encoder (over SOCAT TCP): diff --git a/src/dsd_main.c b/src/dsd_main.c index 3fb0893..1dd46d3 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -1357,17 +1357,17 @@ usage () printf ("\n"); printf ("Encoder options:\n"); printf (" -fZ M17 Stream Voice Encoder\n"); - printf (" Example: dsd-fme -fZ -M M17:9:DSD-FME:LWVMOBILE -i pulse -6 m17signal.wav -N 2> m17encoderlog.ans\n"); + printf (" Example: dsd-fme -fZ -M M17:9:DSD-FME:LWVMOBILE -i pulse -6 m17signal.wav -8 -N 2> m17encoderlog.ans\n"); printf (" Run M17 Encoding, listening to pulse audio server, with internal decode/playback and output to 48k/1 wav file\n"); printf ("\n"); - printf (" Example: dsd-fme -fZ -M M17:9:DSD-FME:LWVMOBILE -i tcp -8 -o pulse -N 2> m17encoderlog.ans\n"); + printf (" Example: dsd-fme -fZ -M M17:9:DSD-FME:LWVMOBILE -i tcp -o pulse -8 -N 2> m17encoderlog.ans\n"); printf (" Run M17 Encoding, listening to default tcp input, without internal decode/playback and output to 48k/1 analog output device\n"); printf ("\n"); printf (" -fP M17 Packet Encoder\n"); - printf (" Example: dsd-fme -fP -M M17:9:DSD-FME:LWVMOBILE -6 m17pkt.wav -S 'Hello World'\n"); + printf (" Example: dsd-fme -fP -M M17:9:DSD-FME:LWVMOBILE -6 m17pkt.wav -8 -S 'Hello World'\n"); printf ("\n"); printf (" -fB M17 BERT Encoder\n"); - printf (" Example: dsd-fme -fB -M M17:9:DSD-FME:LWVMOBILE -6 m17bert.wav\n"); + printf (" Example: dsd-fme -fB -M M17:9:DSD-FME:LWVMOBILE -6 m17bert.wav -8\n"); printf ("\n"); printf (" -M M17 Encoding User Configuration String: M17:CAN:SRC:DST:INPUT_RATE:VOX (see examples above).\n"); printf (" CAN 1-15; SRC and DST have to be no more than 9 UPPER base40 characters.\n"); diff --git a/src/m17.c b/src/m17.c index 03e67e8..95722b0 100644 --- a/src/m17.c +++ b/src/m17.c @@ -166,7 +166,7 @@ void M17decodeLSF(dsd_state * state) if (lsf_dt == 3) fprintf (stderr, " Voice (1600bps)"); if (lsf_rs != 0) fprintf (stderr, " RS: %02X", lsf_rs); - + fprintf (stderr, "\n"); if (lsf_et != 0) fprintf (stderr, " ENC:"); if (lsf_et == 2) fprintf (stderr, " AES-CTR"); if (lsf_et == 1) fprintf (stderr, " Scrambler - %d", lsf_es); @@ -174,8 +174,20 @@ void M17decodeLSF(dsd_state * state) state->m17_enc = lsf_et; state->m17_enc_st = lsf_es; + if (lsf_rs != 0) + { + if (lsf_rs == 0x10) + fprintf (stderr, " OTAKD Data Packet;"); + else if (lsf_rs == 0x11) + { + fprintf (stderr, " OTAKD Embedded LSF;\n"); + goto LSF_END; + } + } + //compare incoming META/IV value on AES, if timestamp 32-bits are not within a time 5 minute window, then throw a warning - uint32_t tsn = (time(NULL) & 0xFFFFFFFF); //current LSB 32-bit value + long long int epoch = 1577836800LL; //Jan 1, 2020, 00:00:00 UTC + uint32_t tsn = ( (time(NULL)-epoch) & 0xFFFFFFFF); //current LSB 32-bit value uint32_t tsi = (uint32_t)ConvertBitIntoBytes(&state->m17_lsf[112], 32); //OTA LSB 32-bit value uint32_t dif = abs(tsn-tsi); if (lsf_et == 2 && dif > 3600) fprintf (stderr, " \n Warning! Time Difference > %d secs; Potential NONCE/IV Replay!\n", dif); @@ -212,6 +224,8 @@ void M17decodeLSF(dsd_state * state) for (i = 0; i < 16; i++) fprintf (stderr, "%02X", state->m17_meta[i]); } + + LSF_END: ; //do nothing } @@ -1475,7 +1489,7 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state) unsigned long long int dst = 0; unsigned long long int src = 0; //DST and SRC Callsign Data (pick up to 9 characters from the b40 char array) - char d40[50] = "DSD-FME "; //DST + char d40[50] = "BROADCAST"; //DST char s40[50] = "DSD-FME "; //SRC //end User Defined Variables @@ -2140,7 +2154,7 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state) //convert bit array into symbols and RF/Audio memset (nil, 0, sizeof(nil)); encodeM17RF (opts, state, nil, 11); //Preamble - for (i = 0; i < 2; i++) + // for (i = 0; i < 2; i++) encodeM17RF (opts, state, m17_lsfs, 1); //LSF //flag off after sending @@ -2617,7 +2631,7 @@ void encodeM17PKT(dsd_opts * opts, dsd_state * state) unsigned long long int dst = 0; unsigned long long int src = 0; //DST and SRC Callsign Data (pick up to 9 characters from the b40 char array) - char d40[50] = "DSD-FME "; //DST + char d40[50] = "BROADCAST"; //DST char s40[50] = "DSD-FME "; //SRC //Default @@ -3039,7 +3053,7 @@ void encodeM17PKT(dsd_opts * opts, dsd_state * state) //convert bit array into symbols and RF/Audio memset (nil, 0, sizeof(nil)); encodeM17RF (opts, state, nil, 11); //Preamble - for (i = 0; i < 2; i++) + // for (i = 0; i < 2; i++) encodeM17RF (opts, state, m17_lsfs, 1); //LSF //flag off after sending