From 068bebb2b0ca6fd6ab693e5b381f95e68b8f4a3e Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 6 Dec 2023 09:06:34 -0500 Subject: [PATCH] Fix #70, add msg integrity source file This makes the EDS MSG implementation line up with the CFE mainline again. --- cfecfs/edsmsg/CMakeLists.txt | 1 + cfecfs/edsmsg/fsw/src/cfe_msg_init.c | 25 -------- cfecfs/edsmsg/fsw/src/cfe_msg_integrity.c | 74 +++++++++++++++++++++++ 3 files changed, 75 insertions(+), 25 deletions(-) create mode 100644 cfecfs/edsmsg/fsw/src/cfe_msg_integrity.c diff --git a/cfecfs/edsmsg/CMakeLists.txt b/cfecfs/edsmsg/CMakeLists.txt index 0a0fab4..cae936f 100644 --- a/cfecfs/edsmsg/CMakeLists.txt +++ b/cfecfs/edsmsg/CMakeLists.txt @@ -16,6 +16,7 @@ # Module library add_library(${DEP} STATIC fsw/src/cfe_msg_init.c + fsw/src/cfe_msg_integrity.c fsw/src/cfe_msg_msgid.c fsw/src/cfe_msg_commonhdr.c diff --git a/cfecfs/edsmsg/fsw/src/cfe_msg_init.c b/cfecfs/edsmsg/fsw/src/cfe_msg_init.c index 8ff77a2..681d77f 100644 --- a/cfecfs/edsmsg/fsw/src/cfe_msg_init.c +++ b/cfecfs/edsmsg/fsw/src/cfe_msg_init.c @@ -64,28 +64,3 @@ CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_M return Status; } - -/*---------------------------------------------------------------- - * - * Implemented per public API - * See description in header file for argument/return detail - * - *-----------------------------------------------------------------*/ -CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt) -{ - if (MsgPtr == NULL) - { - return CFE_MSG_BAD_ARGUMENT; - } - - /* Sequence count is in the basic CCSDS Primary Hdr, so all msgs have it */ - CFE_MSG_SetSequenceCount(MsgPtr, SeqCnt); - - /* - * TLM packets have a timestamp in the secondary header. - * This may fail if this is not a TLM packet (that is OK) - */ - CFE_MSG_SetMsgTime(MsgPtr, CFE_TIME_GetTime()); - - return CFE_SUCCESS; -} \ No newline at end of file diff --git a/cfecfs/edsmsg/fsw/src/cfe_msg_integrity.c b/cfecfs/edsmsg/fsw/src/cfe_msg_integrity.c new file mode 100644 index 0000000..64e08c9 --- /dev/null +++ b/cfecfs/edsmsg/fsw/src/cfe_msg_integrity.c @@ -0,0 +1,74 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +#include "cfe_msg.h" +#include "cfe_time.h" + +/*---------------------------------------------------------------- + * + * Implemented per public API + * See description in header file for argument/return detail + * + *-----------------------------------------------------------------*/ +CFE_Status_t CFE_MSG_OriginationAction(CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable) +{ + if (MsgPtr == NULL || IsAcceptable == NULL) + { + return CFE_MSG_BAD_ARGUMENT; + } + + /* + * TLM packets have a timestamp in the secondary header. + * This may fail if this is not a TLM packet (that is OK) + */ + CFE_MSG_SetMsgTime(MsgPtr, CFE_TIME_GetTime()); + + /* + * CMD packets have a checksum in the secondary header. + * This may fail if this is not a CMD packet (that is OK) + */ + CFE_MSG_GenerateChecksum(MsgPtr); + + /* This implementation permits all outgoing messages */ + *IsAcceptable = true; + + return CFE_SUCCESS; +} +/*---------------------------------------------------------------- + * + * Implemented per public API + * See description in header file for argument/return detail + * + *-----------------------------------------------------------------*/ +CFE_Status_t CFE_MSG_VerificationAction(const CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable) +{ + if (MsgPtr == NULL || IsAcceptable == NULL) + { + return CFE_MSG_BAD_ARGUMENT; + } + + /* + * In the default implementation, there is not anything to check here. + * + * This is mainly a hook for user expansion, in case a custom implementation + * has message verification capability. + */ + *IsAcceptable = true; + + return CFE_SUCCESS; +} \ No newline at end of file