Skip to content

Commit

Permalink
Merge pull request #71 from jphickey/fix-70-msgintegrity
Browse files Browse the repository at this point in the history
Fix #70, add msg integrity source file
  • Loading branch information
jphickey authored Dec 14, 2023
2 parents 72f6cfc + 068bebb commit 7d58f5b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 25 deletions.
1 change: 1 addition & 0 deletions cfecfs/edsmsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 0 additions & 25 deletions cfecfs/edsmsg/fsw/src/cfe_msg_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
74 changes: 74 additions & 0 deletions cfecfs/edsmsg/fsw/src/cfe_msg_integrity.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 7d58f5b

Please sign in to comment.