From aede664b5a91a013aeadab186f2fc1373b39600e Mon Sep 17 00:00:00 2001 From: cesaaargm Date: Wed, 3 Jul 2024 18:45:40 +0200 Subject: [PATCH] [TAS-232 ] [FEAT] verify tag m0 * add new constructor to Tag for Tag0 * minor reporting and comments. * forgot an include from fix5 merge * gitignore release folder --- .gitignore | 3 ++- src/core/libs/osnma_msg_receiver.cc | 21 +++++++------------ src/core/system_parameters/osnma_data.h | 18 ++++++++++++++-- .../osnma/osnma_msg_receiver_test.cc | 2 ++ 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index c16e1f808..dd9645f6d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ cmake-build-debug/ .vscode/ .vs/ Testing/ -/build/* \ No newline at end of file +/build/* +/cmake-build-release/* \ No newline at end of file diff --git a/src/core/libs/osnma_msg_receiver.cc b/src/core/libs/osnma_msg_receiver.cc index d9726e269..7b5fbe51b 100644 --- a/src/core/libs/osnma_msg_receiver.cc +++ b/src/core/libs/osnma_msg_receiver.cc @@ -601,14 +601,10 @@ void osnma_msg_receiver::read_and_process_mack_block(const std::shared_ptrPRN,osnma_msg->TOW_sf0,d_osnma_data.d_nav_data); // TODO change place - // DEBUG PARSING MACK MESSAGES WHEN DSM-KROOT NOT YET AVAILABLE - // d_osnma_data.d_dsm_kroot_message.ts = 9; - // d_osnma_data.d_dsm_kroot_message.ks = 4; - // d_osnma_data.d_dsm_kroot_message.kroot = std::vector(16); + d_osnma_data.d_nav_data.init(osnma_msg); + if (d_kroot_verified || d_tesla_key_verified || d_osnma_data.d_dsm_kroot_message.ts != 0 /*mack parser needs to know the tag size, otherwise cannot parse mack messages*/) // C: 4 ts < ts < 10 - { // TODO - correct? with this, MACK would not be processed unless a Kroot is available -- no, if TK available MACK sould go on, this has to change in future + {// TODO - correct? with this, MACK would not be processed unless a Kroot is available -- no, if TK available MACK sould go on, this has to change in future read_mack_header(); d_osnma_data.d_mack_message.PRNa = osnma_msg->PRN; // FIXME this is ugly. d_osnma_data.d_mack_message.TOW = osnma_msg->TOW_sf0; @@ -911,6 +907,9 @@ void osnma_msg_receiver::process_mack_message() { if (d_tesla_keys.find(mack->TOW + 30) != d_tesla_keys.end()) { + // add tag0 first + Tag tag0 (*mack); + d_tags_awaiting_verify.insert(std::pair(mack->TOW, tag0)); bool ret = verify_macseq(*mack); if (ret || d_flag_debug) { @@ -1001,6 +1000,7 @@ void osnma_msg_receiver::process_mack_message() } else if (it.second.TOW > d_osnma_data.d_nav_data.TOW_sf0) { + // TODO - I dont understand logic. This needs to be reviewed. // case 1: adkd=12 and t.Tow + 300 < current TOW // case 2: adkd=0/4 and t.Tow + 30 < current TOW // case 3: any adkd and t.Tow > current TOW @@ -1087,7 +1087,6 @@ bool osnma_msg_receiver::verify_tag(Tag& tag) // << tag.tag_id // << ", value=0x" << std::setfill('0') << std::setw(10) << std::hex << std::uppercase // << tag.received_tag << std::dec; - // TODO case tag0, to be verified here?, PRNd not needed for it // build message std::vector m = build_message(tag); @@ -1428,10 +1427,6 @@ bool osnma_msg_receiver::verify_macseq(const MACK_message& mack) { applicable_sequence = sq2; } - else - { - LOG(WARNING) << "Galileo OSNMA: Mismatch in the GST verification."; - } if (mack.tag_and_info.size() != applicable_sequence.size() - 1) { LOG(WARNING) << "Galileo OSNMA: Number of retrieved tags does not match MACLT sequence size!"; @@ -1450,7 +1445,7 @@ bool osnma_msg_receiver::verify_macseq(const MACK_message& mack) else if (mack.tag_and_info[i].tag_info.ADKD != std::stoi(applicable_sequence[i + 1])) { LOG(WARNING) << "Galileo OSNMA: MACSEQ verification :: FAILURE :: ADKD mismatch against MAC Look-up table."; - return false; // C: suffices one incorrect to abort and not process the rest of the tags + return false; // TODO macseq shall be individual to each tag, a wrongly verified macseq should not discard the whole MACK tags } } diff --git a/src/core/system_parameters/osnma_data.h b/src/core/system_parameters/osnma_data.h index b27f6dfb3..aed9ae685 100644 --- a/src/core/system_parameters/osnma_data.h +++ b/src/core/system_parameters/osnma_data.h @@ -171,7 +171,7 @@ public: SUCCESS, FAIL, UNVERIFIED}; - Tag(const MACK_tag_and_info& MTI, uint32_t TOW,uint32_t WN, uint32_t PRNa,uint8_t CTR) + Tag(const MACK_tag_and_info& MTI, uint32_t TOW,uint32_t WN, uint32_t PRNa,uint8_t CTR) // standard tag constructor, for tags within Tag&Info field : tag_id(id_counter++), TOW(TOW), // TODO missing for build_message WN for GST computation, CTR, NMAS, NavData missing WN(WN), @@ -186,7 +186,21 @@ public: skipped(0) { } - + Tag(const MACK_message& mack) // constructor for Tag0 + : tag_id(id_counter++), + TOW(mack.TOW), // TODO missing for build_message WN for GST computation, CTR, NMAS, NavData missing + WN(mack.WN), + PRNa(mack.PRNa), + CTR(1), + status(UNVERIFIED), + received_tag(mack.header.tag0), + computed_tag(0), + PRN_d(mack.PRNa), // Tag0 are self-authenticating + ADKD(0), + cop(mack.header.cop), + skipped(0) + { + } const uint32_t tag_id; uint32_t TOW; uint32_t WN; diff --git a/src/tests/unit-tests/signal-processing-blocks/osnma/osnma_msg_receiver_test.cc b/src/tests/unit-tests/signal-processing-blocks/osnma/osnma_msg_receiver_test.cc index f001bab72..f7ff50fe7 100644 --- a/src/tests/unit-tests/signal-processing-blocks/osnma/osnma_msg_receiver_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/osnma/osnma_msg_receiver_test.cc @@ -7,6 +7,7 @@ #if USE_GLOG_AND_GFLAGS #include // for LOG +#include #else #include #endif @@ -557,6 +558,7 @@ void OsnmaMsgReceiverTest::initializeGoogleLog() FLAGS_log_dir = "/home/cgm/CLionProjects/osnma/build/src/tests/logs"; if (FLAGS_log_dir.empty()) { + std::cout << "Logging will be written at " << std::filesystem::temp_directory_path() << '\n'