Skip to content

Commit

Permalink
fix #759 - deprecated CFE_SB_GetLastSenderId()
Browse files Browse the repository at this point in the history
  • Loading branch information
CDKnightNASA committed Jul 31, 2020
1 parent 144798d commit 4becb88
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 236 deletions.
10 changes: 0 additions & 10 deletions docs/cFE Application Developers Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,6 @@ for extracting that field from the header:
| Total Message Length | CFE_SB_GetTotalMsgLength | Command & Telemetry |
| User Data Message Length | CFE_SB_GetUserDataLength | Command & Telemetry |
| Command Code | CFE_SB_GetCmdCode | Command Only |
| Sender ID | CFE_SB_GetLastSenderId | Command & Telemetry |
| Checksum | CFE_SB_GetChecksum | Command Only |

In addition to the function for reading the checksum field, there is
Expand All @@ -1778,15 +1777,6 @@ and compares it to the checksum in the header. The API is called
CFE_SB_ValidateChecksum() and it simply returns a success or failure
indication.

It should be noted that the function, CFE_SB_GetLastSendId, is ideal
for verifying that critical commands are arriving from a legitimate
source. This function allows the Developer(s) to define a strict ICD
between two or more Applications to ensure that an erroneous Application
does not accidentally issue a critical command. However, its use for
routine command verification is discouraged since it would increase the
cross-coupling between Applications and require multiple Applications to
be modified if a command's source changes.

If the Application's data structure definitions don't include the header
information, then the CFE_SB_GetUserData API could be used to obtain
the start address of the SB Message data.
Expand Down
14 changes: 12 additions & 2 deletions fsw/cfe-core/src/inc/cfe_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ typedef struct {
extern CFE_SB_Qos_t CFE_SB_Default_Qos;/**< \brief Defines a default priority and reliabilty for off-board routing */


/** \brief Message Sender Identification Type Definition
#ifndef CFE_OMIT_DEPRECATED_6_8

/** \brief DEPRECATED; Message Sender Identification Type Definition
** \deprecated
**
** Parameter used in #CFE_SB_GetLastSenderId API which allows the receiver of a message
** to validate the sender of the message.
Expand All @@ -218,6 +221,8 @@ typedef struct {
char AppName[OS_MAX_API_NAME];/**< \brief Application that sent the message */
} CFE_SB_SenderId_t;

#endif /* CFE_OMIT_DEPRECATED_6_8 */

/****************** Function Prototypes **********************/

/** @defgroup CFEAPISBPipe cFE Pipe Management APIs
Expand Down Expand Up @@ -1173,9 +1178,12 @@ uint16 CFE_SB_GetCmdCode(CFE_SB_MsgPtr_t MsgPtr);
**/
CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr);

#ifndef CFE_OMIT_DEPRECATED_6_8

/*****************************************************************************/
/**
** \brief Retrieve the application Info of the sender for the last message.
** \brief DEPRECATED; Retrieve the application Info of the sender for the last message.
** \deprecated
**
** \par Description
** This routine can be used after a successful #CFE_SB_RcvMsg call
Expand Down Expand Up @@ -1204,6 +1212,8 @@ CFE_TIME_SysTime_t CFE_SB_GetMsgTime(CFE_SB_MsgPtr_t MsgPtr);
**/
uint32 CFE_SB_GetLastSenderId(CFE_SB_SenderId_t **Ptr,CFE_SB_PipeId_t PipeId);

#endif /* CFE_OMIT_DEPRECATED_6_8 */

/******************************************************************************/
/**
** \brief Copies a string out of a software bus message
Expand Down
7 changes: 7 additions & 0 deletions fsw/cfe-core/src/inc/cfe_sb_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@
#define CFE_SB_CMD1_RCVD_EID 29


#ifndef CFE_OMIT_DEPRECATED_6_8

/** \brief <tt> 'SB GetLastSender Err:Rcvd Null Ptr,Pipe=%d,App=%s' </tt>
** \event <tt> 'SB GetLastSender Err:Rcvd Null Ptr,Pipe=%d,App=%s' </tt>
**
Expand All @@ -592,6 +594,8 @@
**/
#define CFE_SB_LSTSNDER_ERR2_EID 31

#endif /* CFE_OMIT_DEPRECATED_6_8 */


/** \brief <tt> 'Software Bus Statistics packet sent' </tt>
** \event <tt> 'Software Bus Statistics packet sent' </tt>
Expand Down Expand Up @@ -712,6 +716,8 @@
#define CFE_SB_SND_RTG_ERR1_EID 40


#ifndef CFE_OMIT_DEPRECATED_6_8

/** \brief <tt> 'SB GetLastSender Err:Caller(\%s) is not the owner of pipe \%d' </tt>
** \event <tt> 'SB GetLastSender Err:Caller(\%s) is not the owner of pipe \%d' </tt>
**
Expand All @@ -724,6 +730,7 @@
**/
#define CFE_SB_GLS_INV_CALLER_EID 41

#endif /* CFE_OMIT_DEPRECATED_6_8 */

/** \brief <tt> 'Invalid Cmd, Unexpected Command Code \%d' </tt>
** \event <tt> 'Invalid Cmd, Unexpected Command Code \%d' </tt>
Expand Down
6 changes: 6 additions & 0 deletions fsw/cfe-core/src/sb/cfe_sb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,12 +1320,14 @@ int32 CFE_SB_SendMsgFull(CFE_SB_Msg_t *MsgPtr,
RtgTblPtr->SeqCnt);
}/* end if */

#ifndef CFE_OMIT_DEPRECATED_6_8
/* store the sender information */
if(CFE_SB.SenderReporting != 0)
{
BufDscPtr->Sender.ProcessorId = CFE_PSP_GetProcessorId();
strncpy(&BufDscPtr->Sender.AppName[0],CFE_SB_GetAppTskName(TskId,FullName),OS_MAX_API_NAME);
}
#endif /* CFE_OMIT_DEPRECATED_6_8 */

/* At this point there must be at least one destination for pkt */

Expand Down Expand Up @@ -1620,6 +1622,8 @@ int32 CFE_SB_RcvMsg(CFE_SB_MsgPtr_t *BufPtr,
}/* end CFE_SB_RcvMsg */


#ifndef CFE_OMIT_DEPRECATED_6_8

/*
* Function: CFE_SB_GetLastSenderId - See API and header file for details
*/
Expand Down Expand Up @@ -1685,6 +1689,8 @@ uint32 CFE_SB_GetLastSenderId(CFE_SB_SenderId_t **Ptr,CFE_SB_PipeId_t PipeId)

}/* end CFE_SB_GetLastSenderId */

#endif /* CFE_OMIT_DEPRECATED_6_8 */


/*
* Function: CFE_SB_ZeroCopyGetPtr - See API and header file for details
Expand Down
2 changes: 2 additions & 0 deletions fsw/cfe-core/src/sb/cfe_sb_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ typedef struct {
uint16 UseCount;
uint32 Size;
void *Buffer;
#ifndef CFE_OMIT_DEPRECATED_6_8
CFE_SB_SenderId_t Sender;
#endif /* CFE_OMIT_DEPRECATED_6_8 */
} CFE_SB_BufferD_t;


Expand Down
116 changes: 0 additions & 116 deletions fsw/cfe-core/unit-test/sb_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -3332,11 +3332,6 @@ void Test_RcvMsg_API(void)
SB_UT_ADD_SUBTEST(Test_RcvMsg_InvalidPipeId);
SB_UT_ADD_SUBTEST(Test_RcvMsg_InvalidTimeout);
SB_UT_ADD_SUBTEST(Test_RcvMsg_Poll);
SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderNull);
SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderInvalidPipe);
SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderInvalidCaller);
SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderNoValidSender);
SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderSuccess);
SB_UT_ADD_SUBTEST(Test_RcvMsg_Timeout);
SB_UT_ADD_SUBTEST(Test_RcvMsg_PipeReadError);
SB_UT_ADD_SUBTEST(Test_RcvMsg_PendForever);
Expand Down Expand Up @@ -3405,117 +3400,6 @@ void Test_RcvMsg_Poll(void)

} /* end Test_RcvMsg_Poll */

/*
** Test receive last message response to a null sender ID
*/
void Test_RcvMsg_GetLastSenderNull(void)
{
CFE_SB_PipeId_t PipeId;
uint32 PipeDepth = 10;

SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"));

ASSERT_EQ(CFE_SB_GetLastSenderId(NULL, PipeId), CFE_SB_BAD_ARGUMENT);

EVTCNT(2);

EVTSENT(CFE_SB_LSTSNDER_ERR1_EID);

TEARDOWN(CFE_SB_DeletePipe(PipeId));

} /* end Test_RcvMsg_GetLastSenderNull */

/*
** Test receive last message response to an invalid pipe ID
*/
void Test_RcvMsg_GetLastSenderInvalidPipe(void)
{
CFE_SB_PipeId_t PipeId;
CFE_SB_PipeId_t InvalidPipeId = 250;
CFE_SB_SenderId_t *GLSPtr;
uint32 PipeDepth = 10;

SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"));

ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, InvalidPipeId), CFE_SB_BAD_ARGUMENT);

EVTCNT(2);

EVTSENT(CFE_SB_LSTSNDER_ERR2_EID);

TEARDOWN(CFE_SB_DeletePipe(PipeId));

} /* end Test_RcvMsg_GetLastSenderInvalidPipe */

/*
** Test receive last message response to an invalid owner ID
*/
void Test_RcvMsg_GetLastSenderInvalidCaller(void)
{
CFE_SB_PipeId_t PipeId;
CFE_SB_SenderId_t *GLSPtr;
uint32 PipeDepth = 10;
uint32 OrigPipeOwner;

SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"));

/* Change pipe owner ID to execute 'invalid caller' code */
OrigPipeOwner = CFE_SB.PipeTbl[PipeId].AppId;
CFE_SB.PipeTbl[PipeId].AppId = OrigPipeOwner + 1;
ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, PipeId), CFE_SB_BAD_ARGUMENT);

EVTCNT(2);

EVTSENT(CFE_SB_GLS_INV_CALLER_EID);

/* Restore original pipe owner apid */
CFE_SB.PipeTbl[PipeId].AppId = OrigPipeOwner;
TEARDOWN(CFE_SB_DeletePipe(PipeId));

} /* end Test_RcvMsg_GetLastSenderInvalidCaller */


void Test_RcvMsg_GetLastSenderNoValidSender(void)
{
CFE_SB_PipeId_t PipeId;
CFE_SB_SenderId_t *GLSPtr;
uint32 PipeDepth = 10;

SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"));
ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, PipeId), CFE_SB_NO_MSG_RECV);

EVTCNT(1);

TEARDOWN(CFE_SB_DeletePipe(PipeId));

} /* end Test_RcvMsg_GetLastSenderNoValidSender */


/*
** Test successful receive last message request
*/
void Test_RcvMsg_GetLastSenderSuccess(void)
{
CFE_SB_PipeId_t PipeId;
CFE_SB_SenderId_t *GLSPtr;
SB_UT_Test_Tlm_t TlmPkt;
CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt;
CFE_SB_MsgPtr_t PtrToMsg;
uint32 PipeDepth = 10;

SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"));
CFE_SB_InitMsg(&TlmPkt, SB_UT_TLM_MID, sizeof(TlmPkt), true);
SETUP(CFE_SB_Subscribe(SB_UT_TLM_MID, PipeId));
SETUP(CFE_SB_SendMsg(TlmPktPtr));
SETUP(CFE_SB_RcvMsg(&PtrToMsg, PipeId,CFE_SB_PEND_FOREVER));
ASSERT(CFE_SB_GetLastSenderId(&GLSPtr, PipeId));

EVTCNT(3);

TEARDOWN(CFE_SB_DeletePipe(PipeId));

} /* end Test_RcvMsg_GetLastSenderSuccess */

/*
** Test receiving a message response to a timeout
*/
Expand Down
109 changes: 1 addition & 108 deletions fsw/cfe-core/unit-test/sb_UT.h
Original file line number Diff line number Diff line change
Expand Up @@ -2825,10 +2825,7 @@ void Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy(void);
** This function does not return a value.
**
** \sa #UT_Text, #Test_RcvMsg_InvalidPipeId, #Test_RcvMsg_InvalidTimeout,
** \sa #Test_RcvMsg_Poll, #Test_RcvMsg_GetLastSenderNull,
** \sa #Test_RcvMsg_GetLastSenderInvalidPipe,
** \sa #Test_RcvMsg_GetLastSenderInvalidCaller,
** \sa #Test_RcvMsg_GetLastSenderSuccess, #Test_RcvMsg_Timeout,
** \sa #Test_RcvMsg_Poll, #Test_RcvMsg_Timeout,
** \sa #Test_RcvMsg_PipeReadError, #Test_RcvMsg_PendForever
**
******************************************************************************/
Expand Down Expand Up @@ -2898,110 +2895,6 @@ void Test_RcvMsg_InvalidTimeout(void);
******************************************************************************/
void Test_RcvMsg_Poll(void);

/*****************************************************************************/
/**
** \brief Test receive last message response to a null sender ID
**
** \par Description
** This function tests the receive last message response to a null
** sender ID.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** This function does not return a value.
**
** \sa #UT_Text, #SB_ResetUnitTest, #CFE_SB_CreatePipe,
** \sa #CFE_SB_GetLastSenderId, #UT_GetNumEventsSent, #UT_EventIsInHistory,
** \sa #CFE_SB_DeletePipe, #UT_Report
**
******************************************************************************/
void Test_RcvMsg_GetLastSenderNull(void);

/*****************************************************************************/
/**
** \brief Test receive last message response to an invalid pipe ID
**
** \par Description
** This function tests the receive last message response to an invalid
** pipe ID.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** This function does not return a value.
**
** \sa #UT_Text, #SB_ResetUnitTest, #CFE_SB_CreatePipe,
** \sa #CFE_SB_GetLastSenderId, #UT_GetNumEventsSent, #UT_EventIsInHistory,
** \sa #CFE_SB_DeletePipe, #UT_Report
**
******************************************************************************/
void Test_RcvMsg_GetLastSenderInvalidPipe(void);

/*****************************************************************************/
/**
** \brief Test receive last message response to an invalid owner ID
**
** \par Description
** This function tests the receive last message response to an invalid
** owner ID.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** This function does not return a value.
**
** \sa #UT_Text, #SB_ResetUnitTest, #CFE_SB_CreatePipe,
** \sa #CFE_SB_GetLastSenderId, #UT_GetNumEventsSent, #UT_EventIsInHistory,
** \sa #CFE_SB_DeletePipe, #UT_Report
**
******************************************************************************/
void Test_RcvMsg_GetLastSenderInvalidCaller(void);

/*****************************************************************************/
/**
** \brief Test receive last message response when there is no last sender
**
** \par Description
** This function tests the receive last message response when no last
** sender.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** This function does not return a value.
**
** \sa #UT_Text, #SB_ResetUnitTest, #CFE_SB_CreatePipe,
** \sa #CFE_SB_GetLastSenderId, #UT_GetNumEventsSent, #UT_EventIsInHistory,
** \sa #CFE_SB_DeletePipe, #UT_Report
**
******************************************************************************/
void Test_RcvMsg_GetLastSenderNoValidSender(void);

/*****************************************************************************/
/**
** \brief Test successful receive last message request
**
** \par Description
** This function tests the successful receive last message request.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** This function does not return a value.
**
** \sa #UT_Text, #SB_ResetUnitTest, #CFE_SB_CreatePipe,
** \sa #CFE_SB_GetLastSenderId, #UT_GetNumEventsSent, #CFE_SB_DeletePipe,
** \sa #UT_Report
**
******************************************************************************/
void Test_RcvMsg_GetLastSenderSuccess(void);

/*****************************************************************************/
/**
** \brief Test receiving a message response to a timeout
Expand Down
Loading

0 comments on commit 4becb88

Please sign in to comment.