From 132addc088dd6d936a3f715f8a2610d4fbf2ff7f Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 17 Dec 2021 10:27:25 -0500 Subject: [PATCH] Fix #111, make dispatch tables and functions consistent Standardize the dynamic handler functions to two basic types, one that accepts a PDU (recv) and one that does not (send). Also create several dispatch table types, one based on file directive code, one based on Tx sub state, and one based on Rx sub state. Change the dispatcher functions to use these common types and create new dispatcher functions where there was not a separate function already (this makes the pattern consistent). Make all "receive" helper functions accept a pointer to the recieved PDU and actually use that pointer to read the data. This substantially reduces reliance on the global and fixes some cases where a pointer was actually passed into a function, but ignored. This takes a significant step toward removing the global entirely, but does not do so yet. --- fsw/src/cf_cfdp.c | 189 +++++++++-------- fsw/src/cf_cfdp.h | 88 ++++++-- fsw/src/cf_cfdp_helpers.c | 25 ++- fsw/src/cf_cfdp_pdu.h | 5 +- fsw/src/cf_cfdp_r.c | 119 ++++++----- fsw/src/cf_cfdp_s.c | 171 +++++++++++----- unit-test/cf_cfdp_helpers_tests.c | 20 +- unit-test/cf_cfdp_r_tests.c | 215 ++++++++++---------- unit-test/cf_cfdp_s_tests.c | 156 +++++++------- unit-test/cf_cfdp_tests.c | 258 +++++++++++++----------- unit-test/stubs/cf_cfdp_helpers_stubs.c | 5 +- unit-test/stubs/cf_cfdp_r_stubs.c | 4 +- unit-test/stubs/cf_cfdp_s_stubs.c | 4 +- unit-test/stubs/cf_cfdp_stubs.c | 16 +- 14 files changed, 723 insertions(+), 552 deletions(-) diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index 2af3825d..5a50b3f5 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -47,8 +47,8 @@ const int CF_max_chunks[CF_Direction_NUM][CF_NUM_CHANNELS] = {CF_CHANNEL_NUM_RX_CHUNKS_PER_TRANSACTION, CF_CHANNEL_NUM_TX_CHUNKS_PER_TRANSACTION}; -static void CF_CFDP_RecvIdle(CF_Transaction_t *); -static void CF_CFDP_RecvDrop(CF_Transaction_t *); +static void CF_CFDP_RecvIdle(CF_Transaction_t *, CF_CFDP_PduHeader_t *); +static void CF_CFDP_RecvDrop(CF_Transaction_t *, CF_CFDP_PduHeader_t *); static void CF_CFDP_TxFile__(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority); @@ -142,19 +142,61 @@ static inline void CF_CFDP_ArmInactTimer(CF_Transaction_t *t) } /************************************************************************/ -/** \brief Dispatch received packet to its transaction. +/** \brief Transmit pdu processing. ** ** \par Assumptions, External Events, and Notes: -** t must not be null. It must be an initialized transaction. +** t must not be NULL. ** *************************************************************************/ -static void CF_CFDP_DispatchRecv(CF_Transaction_t *t) +static void CF_CFDP_TxStateDispatch(CF_Transaction_t *t, const CF_CFDP_TxnSendDispatchTable_t *dispatch) { - static void (*const state_fns[])(CF_Transaction_t *) = {CF_CFDP_RecvIdle, CF_CFDP_R1_Recv, CF_CFDP_S1_Recv, - CF_CFDP_R2_Recv, CF_CFDP_S2_Recv, CF_CFDP_RecvDrop}; + CF_CFDP_StateSendFunc_t selected_handler; + CF_Assert(t->state < CF_TxnState_INVALID); - state_fns[t->state](t); + selected_handler = dispatch->tx[t->state]; + if (selected_handler != NULL) + { + selected_handler(t); + } +} + +/************************************************************************/ +/** \brief Receive pdu processing. +** +** \par Assumptions, External Events, and Notes: +** t must not be NULL. +** +*************************************************************************/ +static void CF_CFDP_RxStateDispatch(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, + const CF_CFDP_TxnRecvDispatchTable_t *dispatch) +{ + CF_CFDP_StateRecvFunc_t selected_handler; + + CF_Assert(t->state < CF_TxnState_INVALID); + selected_handler = dispatch->rx[t->state]; + if (selected_handler != NULL) + { + selected_handler(t, ph); + } +} +/************************************************************************/ +/** \brief Dispatch received packet to its transaction. +** +** \par Assumptions, External Events, and Notes: +** t must not be null. It must be an initialized transaction. +** +*************************************************************************/ +static void CF_CFDP_DispatchRecv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) +{ + static const CF_CFDP_TxnRecvDispatchTable_t state_fns = {.rx = {[CF_TxnState_IDLE] = CF_CFDP_RecvIdle, + [CF_TxnState_R1] = CF_CFDP_R1_Recv, + [CF_TxnState_S1] = CF_CFDP_S1_Recv, + [CF_TxnState_R2] = CF_CFDP_R2_Recv, + [CF_TxnState_S2] = CF_CFDP_S2_Recv, + [CF_TxnState_DROP] = CF_CFDP_RecvDrop}}; + + CF_CFDP_RxStateDispatch(t, ph, &state_fns); CF_CFDP_ArmInactTimer(t); /* whenever a packet was received by the other size, always arm its inactivity timer */ } @@ -167,12 +209,10 @@ static void CF_CFDP_DispatchRecv(CF_Transaction_t *t) *************************************************************************/ static void CF_CFDP_DispatchTx(CF_Transaction_t *t) { - static void (*const state_fns[])(CF_Transaction_t *) = {NULL, NULL, CF_CFDP_S1_Tx, NULL, CF_CFDP_S2_Tx, NULL}; + static const CF_CFDP_TxnSendDispatchTable_t state_fns = { + .tx = {[CF_TxnState_S1] = CF_CFDP_S1_Tx, [CF_TxnState_S2] = CF_CFDP_S2_Tx}}; - CF_Assert(t->state < CF_TxnState_INVALID); - CF_Assert(state_fns[t->state]); - - state_fns[t->state](t); + CF_CFDP_TxStateDispatch(t, &state_fns); } /************************************************************************/ @@ -432,11 +472,10 @@ CF_CFDP_PduHeader_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *t, int silent) ** The PDU in the output buffer is ready to transmit. ** *************************************************************************/ -static void CF_CFDP_Send(uint8 chan_num, uint32 len) +static void CF_CFDP_Send(uint8 chan_num, const CF_CFDP_PduHeader_t *ph, uint32 len) { CF_Assert(chan_num < CF_NUM_CHANNELS); - CFE_SB_SetUserDataLength(&CF_AppData.engine.out.msg->Msg, - len + CF_HeaderSize(&((CF_PduSendMsg_t *)CF_AppData.engine.out.msg)->ph)); + CFE_SB_SetUserDataLength(&CF_AppData.engine.out.msg->Msg, len + CF_HeaderSize(ph)); CFE_MSG_SetMsgTime(&CF_AppData.engine.out.msg->Msg, CFE_TIME_GetTime()); /* PTFO: CFS apps typically do not check CFE_SB_Send or CFE_SB_ZeroCopySend return values. * This means the packet will be dropped, but the state machine will think it was sent. @@ -482,7 +521,7 @@ CF_CFDP_PduHeader_t *CF_CFDP_ConstructPduHeader(const CF_Transaction_t *t, uint8 !directive_code); /* directive code 0 is reserved, so use it to indicate file data */ FSV(ph->flags, CF_CFDP_PduHeader_FLAGS_MODE, !CF_CFDP_GetClass(t)); - CF_SetVariableHeader(src_eid, dst_eid, tsn); + CF_SetVariableHeader(ph, src_eid, dst_eid, tsn); /* If directive code is zero, the pdu is a file data pdu which has no directive code field. * So only set if non-zero, otherwise it will write a 0 to a byte in a file data pdu where we @@ -586,7 +625,7 @@ CF_SendRet_t CF_CFDP_SendMd(CF_Transaction_t *t) CF_CFDP_SetPduLength(ph, (offsetof(CF_CFDP_PduMd_t, filename_lvs) + lv_ret)); - CF_CFDP_Send(t->chan_num, offsetof(CF_CFDP_PduMd_t, filename_lvs) + lv_ret); + CF_CFDP_Send(t->chan_num, ph, offsetof(CF_CFDP_PduMd_t, filename_lvs) + lv_ret); err_out: return sret; @@ -605,10 +644,9 @@ CF_SendRet_t CF_CFDP_SendMd(CF_Transaction_t *t) ** \endreturns ** *************************************************************************/ -CF_SendRet_t CF_CFDP_SendFd(CF_Transaction_t *t, uint32 offset, int len) +CF_SendRet_t CF_CFDP_SendFd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, uint32 offset, int len) { - CF_CFDP_PduHeader_t *ph = &((CF_PduSendMsg_t *)CF_AppData.engine.out.msg)->ph; - CF_CFDP_PduFd_t *fd = STATIC_CAST(ph, CF_CFDP_PduFd_t); + CF_CFDP_PduFd_t *fd = STATIC_CAST(ph, CF_CFDP_PduFd_t); /* NOTE: SendFd does not need a call to CF_CFDP_MsgOutGet, as the caller already has it */ CF_SendRet_t ret = CF_SendRet_SUCCESS; @@ -622,7 +660,7 @@ CF_SendRet_t CF_CFDP_SendFd(CF_Transaction_t *t, uint32 offset, int len) /* update pdu length */ CF_CFDP_SetPduLength(ph, offsetof(CF_CFDP_PduFd_t, fdd) + len); /* does not include generic header length */ - CF_CFDP_Send(t->chan_num, offsetof(CF_CFDP_PduFd_t, fdd) + len); + CF_CFDP_Send(t->chan_num, ph, offsetof(CF_CFDP_PduFd_t, fdd) + len); err_out: return ret; @@ -693,7 +731,7 @@ CF_SendRet_t CF_CFDP_SendEof(CF_Transaction_t *t) } CF_CFDP_SetPduLength(ph, offsetof(CF_CFDP_PduEof_t, fault_location) + tlv_length); - CF_CFDP_Send(t->chan_num, offsetof(CF_CFDP_PduEof_t, fault_location) + tlv_length); + CF_CFDP_Send(t->chan_num, ph, offsetof(CF_CFDP_PduEof_t, fault_location) + tlv_length); err_out: return ret; @@ -746,7 +784,7 @@ CF_SendRet_t CF_CFDP_SendAck(CF_Transaction_t *t, CF_CFDP_AckTxnStatus_t ts, CF_ FSV(ack->cc_and_transaction_status, CF_CFDP_PduAck_TRANSACTION_STATUS, ts); CF_CFDP_SetPduLength(ph, sizeof(CF_CFDP_PduAck_t)); - CF_CFDP_Send(t->chan_num, sizeof(CF_CFDP_PduAck_t)); + CF_CFDP_Send(t->chan_num, ph, sizeof(CF_CFDP_PduAck_t)); err_out: return ret; } @@ -790,7 +828,7 @@ CF_SendRet_t CF_CFDP_SendFin(CF_Transaction_t *t, CF_CFDP_FinDeliveryCode_t dc, tlv_length += CF_CFDP_FinishEofAck((CF_CFDP_tlv_t *)fin->fault_location); } CF_CFDP_SetPduLength(ph, offsetof(CF_CFDP_PduFin_t, fault_location) + tlv_length); - CF_CFDP_Send(t->chan_num, offsetof(CF_CFDP_PduFin_t, fault_location) + tlv_length); + CF_CFDP_Send(t->chan_num, ph, offsetof(CF_CFDP_PduFin_t, fault_location) + tlv_length); err_out: return ret; @@ -809,12 +847,11 @@ CF_SendRet_t CF_CFDP_SendFin(CF_Transaction_t *t, CF_CFDP_FinDeliveryCode_t dc, ** \endreturns ** *************************************************************************/ -CF_SendRet_t CF_CFDP_SendNak(CF_Transaction_t *t, int num_segment_requests) +CF_SendRet_t CF_CFDP_SendNak(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, int num_segment_requests) { - CF_CFDP_PduHeader_t *ph = &((CF_PduSendMsg_t *)CF_AppData.engine.out.msg)->ph; - CF_CFDP_PduNak_t *nak = STATIC_CAST(ph, CF_CFDP_PduNak_t); - int index; - CF_SendRet_t ret = CF_SendRet_SUCCESS; + CF_CFDP_PduNak_t *nak = STATIC_CAST(ph, CF_CFDP_PduNak_t); + int index; + CF_SendRet_t ret = CF_SendRet_SUCCESS; if (!ph) { @@ -838,7 +875,7 @@ CF_SendRet_t CF_CFDP_SendNak(CF_Transaction_t *t, int num_segment_requests) index = offsetof(CF_CFDP_PduNak_t, segment_requests) + (index * sizeof(CF_CFDP_SegmentRequest_t)); /* calculate pdu size */ CF_CFDP_SetPduLength(ph, index); /* does not include generic header length */ - CF_CFDP_Send(t->chan_num, index); + CF_CFDP_Send(t->chan_num, ph, index); err_out: return ret; @@ -860,16 +897,16 @@ CF_SendRet_t CF_CFDP_SendNak(CF_Transaction_t *t, int num_segment_requests) ** \endreturns ** *************************************************************************/ -static int CF_CFDP_RecvPh(uint8 chan_num) +static int CF_CFDP_RecvPh(uint8 chan_num, CFE_SB_Buffer_t *msgbuf, CF_CFDP_PduHeader_t **pph) { CF_Assert(chan_num < CF_NUM_CHANNELS); - CF_Assert(CF_AppData.engine.in.msg); + CF_Assert(msgbuf); - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; + CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)msgbuf)->ph; uint16 temp; const int hsize = CF_HeaderSize(ph); - CF_AppData.engine.in.bytes_received = CFE_SB_GetUserDataLength(&CF_AppData.engine.in.msg->Msg); + CF_AppData.engine.in.bytes_received = CFE_SB_GetUserDataLength(&msgbuf->Msg); if (CF_AppData.engine.in.bytes_received < hsize) { @@ -878,7 +915,7 @@ static int CF_CFDP_RecvPh(uint8 chan_num) goto err_out; } - if (CF_GetVariableHeader()) + if (CF_GetVariableHeader(ph)) goto err_out; cfdp_get_uint16(ph->length, ph->length); @@ -893,6 +930,7 @@ static int CF_CFDP_RecvPh(uint8 chan_num) /* pdu is ok, so continue processing */ ++CF_AppData.hk.channel_hk[chan_num].counters.recv.pdu; + *pph = ph; /* going to leave two return statements in, since they are at the end of the function. * one is normal exit path, and one is error exit path */ @@ -900,6 +938,7 @@ static int CF_CFDP_RecvPh(uint8 chan_num) err_out: ++CF_AppData.hk.channel_hk[chan_num].counters.recv.error; + *pph = NULL; return -1; } @@ -915,13 +954,11 @@ static int CF_CFDP_RecvPh(uint8 chan_num) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvMd(CF_Transaction_t *t) +int CF_CFDP_RecvMd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* CF_CFDP_RecvPh() must have been called before this, so use ldst to access pdu header */ - CF_Assert(CF_AppData.engine.in.msg); - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; - CF_CFDP_PduMd_t *md = STATIC_CAST(ph, CF_CFDP_PduMd_t); - int offs = 0, lv_ret; + CF_CFDP_PduMd_t *md = STATIC_CAST(ph, CF_CFDP_PduMd_t); + int offs = 0, lv_ret; if (CF_AppData.engine.in.bytes_received < (CF_HeaderSize(ph) + sizeof(CF_CFDP_PduMd_t))) { @@ -983,13 +1020,11 @@ int CF_CFDP_RecvMd(CF_Transaction_t *t) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvFd(CF_Transaction_t *t) +int CF_CFDP_RecvFd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* CF_CFDP_RecvPh() must have been called before this, so use ldst to access pdu header */ - int ret = 0; - CF_Assert(CF_AppData.engine.in.msg); - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; - CF_CFDP_PduFd_t *fd = STATIC_CAST(ph, CF_CFDP_PduFd_t); + int ret = 0; + CF_CFDP_PduFd_t *fd = STATIC_CAST(ph, CF_CFDP_PduFd_t); if (CF_AppData.engine.in.bytes_received < (CF_HeaderSize(ph) + sizeof(CF_CFDP_PduFileDataHeader_t))) { @@ -1018,13 +1053,11 @@ int CF_CFDP_RecvFd(CF_Transaction_t *t) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvEof(void) +int CF_CFDP_RecvEof(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* CF_CFDP_RecvPh() must have been called before this, so use ldst to access pdu header */ - int ret = 0; - CF_Assert(CF_AppData.engine.in.msg); - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; - CF_CFDP_PduEof_t *eof = STATIC_CAST(ph, CF_CFDP_PduEof_t); + int ret = 0; + CF_CFDP_PduEof_t *eof = STATIC_CAST(ph, CF_CFDP_PduEof_t); if (CF_AppData.engine.in.bytes_received < (CF_HeaderSize(ph) + offsetof(CF_CFDP_PduEof_t, fault_location))) { @@ -1054,12 +1087,10 @@ int CF_CFDP_RecvEof(void) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvAck(void) +int CF_CFDP_RecvAck(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* CF_CFDP_RecvPh() must have been called before this, so use ldst to access pdu header */ int ret = 0; - CF_Assert(CF_AppData.engine.in.msg); - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; if (CF_AppData.engine.in.bytes_received < (CF_HeaderSize(ph) + sizeof(CF_CFDP_PduAck_t))) { @@ -1084,12 +1115,10 @@ int CF_CFDP_RecvAck(void) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvFin(void) +int CF_CFDP_RecvFin(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* CF_CFDP_RecvPh() must have been called before this, so use ldst to access pdu header */ int ret = 0; - CF_Assert(CF_AppData.engine.in.msg); - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; if (CF_AppData.engine.in.bytes_received < (CF_HeaderSize(ph) + offsetof(CF_CFDP_PduFin_t, fault_location))) { @@ -1115,15 +1144,13 @@ int CF_CFDP_RecvFin(void) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvNak(int *num_segment_requests) +int CF_CFDP_RecvNak(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, int *num_segment_requests) { /* CF_CFDP_RecvPh() must have been called before this, so use ldst to access pdu header */ - CF_Assert(CF_AppData.engine.in.msg); CF_Assert(num_segment_requests); - int ret = 0; - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; - CF_CFDP_PduNak_t *nak = STATIC_CAST(ph, CF_CFDP_PduNak_t); + int ret = 0; + CF_CFDP_PduNak_t *nak = STATIC_CAST(ph, CF_CFDP_PduNak_t); if (CF_AppData.engine.in.bytes_received < (CF_HeaderSize(ph) + offsetof(CF_CFDP_PduNak_t, segment_requests))) { @@ -1164,7 +1191,7 @@ int CF_CFDP_RecvNak(int *num_segment_requests) ** t must not be NULL. ** *************************************************************************/ -static void CF_CFDP_RecvDrop(CF_Transaction_t *t) +static void CF_CFDP_RecvDrop(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { ++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.dropped; } @@ -1183,12 +1210,10 @@ static void CF_CFDP_RecvDrop(CF_Transaction_t *t) ** t must not be NULL. There must be a received message. ** *************************************************************************/ -static void CF_CFDP_RecvIdle(CF_Transaction_t *t) +static void CF_CFDP_RecvIdle(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* only RX transactions dare tread here */ int ok_to_reset = 1; - CF_Assert(CF_AppData.engine.in.msg); - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; t->history->seq_num = CF_AppData.engine.in.tsn; @@ -1220,7 +1245,7 @@ static void CF_CFDP_RecvIdle(CF_Transaction_t *t) /* R2 can handle missing metadata, so go ahead and create a temp file */ t->state = CF_TxnState_R2; CF_CFDP_R_Init(t); - CF_CFDP_DispatchRecv(t); /* re-dispatch to enter r2 */ + CF_CFDP_DispatchRecv(t, ph); /* re-dispatch to enter r2 */ } } else @@ -1232,7 +1257,7 @@ static void CF_CFDP_RecvIdle(CF_Transaction_t *t) switch (fdh->directive_code) { case CF_CFDP_FileDirective_METADATA: - status = CF_CFDP_RecvMd(t); + status = CF_CFDP_RecvMd(t, ph); if (!status) { /* NOTE: whether or not class 1 or 2, get a free chunks. it's cheap, and simplifies cleanup path */ @@ -1366,30 +1391,36 @@ int32 CF_CFDP_InitEngine(void) *************************************************************************/ static void CF_CFDP_ReceiveMessage(CF_Channel_t *c) { - CF_Transaction_t *t; /* initialized below */ - uint32 count = 0; - int32 status; - const int chan_num = (c - CF_AppData.engine.channels); + CF_Transaction_t *t; /* initialized below */ + uint32 count = 0; + int32 status; + const int chan_num = (c - CF_AppData.engine.channels); + CFE_SB_Buffer_t *bufptr; + CF_CFDP_PduHeader_t *ph; + for (; count < CF_AppData.config_table->chan[chan_num].rx_max_messages_per_wakeup; ++count) { - status = CFE_SB_ReceiveBuffer(&CF_AppData.engine.in.msg, c->pipe, CFE_SB_POLL); + status = CFE_SB_ReceiveBuffer(&bufptr, c->pipe, CFE_SB_POLL); if (status != CFE_SUCCESS) { break; /* no more messages */ } + /* NOTE: this code originally stored current msg buffer in a global, but + going forward this should _NOT_ be used. It is still set just in case + some code depends on it (mostly just UT at this point). FSW should pass + the pointer to the current PDU to any function that needs it (ph here). */ + CF_AppData.engine.in.msg = bufptr; CFE_ES_PerfLogEntry(CF_PERF_ID_PDURCVD(chan_num)); - if (!CF_CFDP_RecvPh(chan_num)) + if (!CF_CFDP_RecvPh(chan_num, bufptr, &ph)) { - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; - /* got a valid pdu -- look it up by sequence number */ t = CF_CFDP_FindTransactionBySequenceNumber(c, CF_AppData.engine.in.tsn, CF_AppData.engine.in.src); if (t) { /* found one! send it to the transaction state processor */ CF_Assert(t->state > CF_TxnState_IDLE); - CF_CFDP_DispatchRecv(t); + CF_CFDP_DispatchRecv(t, ph); } else { @@ -1407,7 +1438,7 @@ static void CF_CFDP_ReceiveMessage(CF_Channel_t *c) (sizeof(CF_CFDP_PduFileDirectiveHeader_t) + CF_HeaderSize(ph))) && (STATIC_CAST(ph, CF_CFDP_PduFileDirectiveHeader_t)->directive_code == CF_CFDP_FileDirective_FIN)) { - if (!CF_CFDP_RecvFin()) + if (!CF_CFDP_RecvFin(t, ph)) { CF_Transaction_t t; const uint8 chan_num = (c - CF_AppData.engine.channels); @@ -1455,7 +1486,7 @@ static void CF_CFDP_ReceiveMessage(CF_Channel_t *c) t->state_data.r.r2.fs = CF_CFDP_FinFileStatus_DISCARDED; CF_CList_InsertBack_Ex(c, (t->flags.com.q_index = CF_QueueIdx_RX), &t->cl_node); - CF_CFDP_DispatchRecv(t); /* will enter idle state */ + CF_CFDP_DispatchRecv(t, ph); /* will enter idle state */ } } else diff --git a/fsw/src/cf_cfdp.h b/fsw/src/cf_cfdp.h index 5da94bcf..f696e343 100644 --- a/fsw/src/cf_cfdp.h +++ b/fsw/src/cf_cfdp.h @@ -335,6 +335,67 @@ typedef struct CF_Engine uint8 enabled; } CF_Engine_t; +/** + * @brief A function for dispatching actions to a handler, without existing PDU data + * + * This allows quick delegation to handler functions using dispatch tables. This version is + * used on the transmit side, where a PDU will likely be generated/sent by the handler being + * invoked. + * + * @param[inout] t The transaction object + */ +typedef void (*CF_CFDP_StateSendFunc_t)(CF_Transaction_t *t); + +/** + * @brief A function for dispatching actions to a handler, with existing PDU data + * + * This allows quick delegation of PDUs to handler functions using dispatch tables. This version is + * used on the receive side where a PDU buffer is associated with the activity, which is then + * interpreted by the handler being invoked. + * + * @param[inout] t The transaction object + * @param[inout] ph The PDU buffer currently being received/processed + */ +typedef void (*CF_CFDP_StateRecvFunc_t)(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); + +/** + * @brief A table of receive handler functions based on file directive code + * + * For PDUs identified as a "file directive" type - generally anything other + * than file data - this provides a table to branch to a different handler + * function depending on the value of the file directive code. + */ +typedef struct +{ + /* a separate recv handler for each possible file directive PDU in this state */ + CF_CFDP_StateRecvFunc_t fdirective[CF_CFDP_FileDirective_INVALID_MAX]; +} CF_CFDP_FileDirectiveDispatchTable_t; + +/** + * @brief A table of transmit handler functions based on transaction state + * + * This reflects the main dispatch table for the transmit side of a transaction. + * Each possible state has a corresponding function pointer in the table to implement + * the PDU transmit action(s) associated with that state. + */ +typedef struct +{ + CF_CFDP_StateSendFunc_t tx[CF_TxnState_INVALID]; +} CF_CFDP_TxnSendDispatchTable_t; + +/** + * @brief A table of receive handler functions based on transaction state + * + * This reflects the main dispatch table for the receive side of a transaction. + * Each possible state has a corresponding function pointer in the table to implement + * the PDU receive action(s) associated with that state. + */ +typedef struct +{ + /* a separate recv handler for each possible file directive PDU in this state */ + CF_CFDP_StateRecvFunc_t rx[CF_TxnState_INVALID]; +} CF_CFDP_TxnRecvDispatchTable_t; + /* NOTE: functions grouped together on contiguous lines are in groups that are described by * a simple comment at the top. Other comments below that apply to the whole group. */ /* reset functions */ @@ -360,9 +421,8 @@ extern CF_CFDP_PduHeader_t *CF_CFDP_ConstructPduHeader(const CF_Transaction_t *t CF_EntityId_t src_eid, CF_EntityId_t dst_eid, uint8 towards_sender, CF_TransactionSeq_t tsn, int silent); extern CF_SendRet_t CF_CFDP_SendMd(CF_Transaction_t *t); -extern CF_SendRet_t CF_CFDP_SendFd(CF_Transaction_t *t, uint32 offset, int len); - -extern CF_SendRet_t CF_CFDP_SendEof(CF_Transaction_t *t); +extern CF_SendRet_t CF_CFDP_SendFd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, uint32 offset, int len); +extern CF_SendRet_t CF_CFDP_SendEof(CF_Transaction_t *t); /* NOTE: CF_CFDP_SendAck() takes a CF_TransactionSeq_t instead of getting it from transaction history because * of the special case where a FIN-ACK must be sent for an unknown transaction. It's better for * long term maintenance to not build an incomplete CF_History_t for it. @@ -371,22 +431,22 @@ extern CF_SendRet_t CF_CFDP_SendAck(CF_Transaction_t *t, CF_CFDP_AckTxnStatus_t CF_CFDP_ConditionCode_t cc, CF_EntityId_t peer_eid, CF_TransactionSeq_t tsn); extern CF_SendRet_t CF_CFDP_SendFin(CF_Transaction_t *t, CF_CFDP_FinDeliveryCode_t dc, CF_CFDP_FinFileStatus_t fs, CF_CFDP_ConditionCode_t cc); -extern CF_SendRet_t CF_CFDP_SendNak(CF_Transaction_t *t, int num_segment_requests); +extern CF_SendRet_t CF_CFDP_SendNak(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, int num_segment_requests); /* PDU receive functions */ /* returns 0 on success */ -extern int CF_CFDP_RecvMd(CF_Transaction_t *t); -extern int CF_CFDP_RecvFd(CF_Transaction_t *t); -extern int CF_CFDP_RecvEof(void); -extern int CF_CFDP_RecvAck(void); -extern int CF_CFDP_RecvFin(void); -extern int CF_CFDP_RecvNak(int *num_segment_requests); +extern int CF_CFDP_RecvMd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); +extern int CF_CFDP_RecvFd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); +extern int CF_CFDP_RecvEof(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); +extern int CF_CFDP_RecvAck(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); +extern int CF_CFDP_RecvFin(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); +extern int CF_CFDP_RecvNak(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, int *num_segment_requests); /* Engine functional dispatch. These are all implemented in cf_cfdp_r.c or cf_cfdp_s.c */ -extern void CF_CFDP_S1_Recv(CF_Transaction_t *t); -extern void CF_CFDP_R1_Recv(CF_Transaction_t *t); -extern void CF_CFDP_S2_Recv(CF_Transaction_t *t); -extern void CF_CFDP_R2_Recv(CF_Transaction_t *t); +extern void CF_CFDP_S1_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); +extern void CF_CFDP_R1_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); +extern void CF_CFDP_S2_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); +extern void CF_CFDP_R2_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph); extern void CF_CFDP_S1_Tx(CF_Transaction_t *t); extern void CF_CFDP_S2_Tx(CF_Transaction_t *t); extern void CF_CFDP_R_Tick(CF_Transaction_t *t, int *cont); diff --git a/fsw/src/cf_cfdp_helpers.c b/fsw/src/cf_cfdp_helpers.c index 3df6c8e4..ab964b1c 100644 --- a/fsw/src/cf_cfdp_helpers.c +++ b/fsw/src/cf_cfdp_helpers.c @@ -134,13 +134,12 @@ static int CF_GetEIDSize(const CF_CFDP_PduHeader_t *ph) /* get the variable length header items out of the PDU header and store as incoming data */ /* in.msg must be valid PDU message */ -int CF_GetVariableHeader(void) +int CF_GetVariableHeader(CF_CFDP_PduHeader_t *ph) { - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; - const int eid_l = CF_GetEIDSize(ph); - const int tsn_l = CF_GetTSNSize(ph); - int offs = sizeof(*ph); - int ret = -1; + const int eid_l = CF_GetEIDSize(ph); + const int tsn_l = CF_GetTSNSize(ph); + int offs = sizeof(*ph); + int ret = -1; if ((eid_l > 0) && (tsn_l > 0)) { @@ -155,14 +154,14 @@ int CF_GetVariableHeader(void) return ret; } -void CF_SetVariableHeader(CF_EntityId_t src_eid, CF_EntityId_t dst_eid, CF_TransactionSeq_t tsn) +void CF_SetVariableHeader(CF_CFDP_PduHeader_t *ph, CF_EntityId_t src_eid, CF_EntityId_t dst_eid, + CF_TransactionSeq_t tsn) { - CF_CFDP_PduHeader_t *ph = &((CF_PduSendMsg_t *)CF_AppData.engine.out.msg)->ph; - int offs = sizeof(*ph); - const int eid_s_l = CF_GetMemcpySize((uint8 *)&src_eid, sizeof(src_eid)); - const int eid_d_l = CF_GetMemcpySize((uint8 *)&dst_eid, sizeof(dst_eid)); - const int tsn_l = CF_GetMemcpySize((uint8 *)&tsn, sizeof(tsn)); - const int csize = ((eid_s_l > eid_d_l) ? eid_s_l : eid_d_l); + int offs = sizeof(*ph); + const int eid_s_l = CF_GetMemcpySize((uint8 *)&src_eid, sizeof(src_eid)); + const int eid_d_l = CF_GetMemcpySize((uint8 *)&dst_eid, sizeof(dst_eid)); + const int tsn_l = CF_GetMemcpySize((uint8 *)&tsn, sizeof(tsn)); + const int csize = ((eid_s_l > eid_d_l) ? eid_s_l : eid_d_l); CF_MemcpyToBE(((uint8 *)ph) + offs, (uint8 *)&src_eid, sizeof(src_eid), csize); offs += csize; diff --git a/fsw/src/cf_cfdp_pdu.h b/fsw/src/cf_cfdp_pdu.h index 434a5c64..855c4f8b 100644 --- a/fsw/src/cf_cfdp_pdu.h +++ b/fsw/src/cf_cfdp_pdu.h @@ -106,8 +106,9 @@ DECLARE_FIELD(CF_CFDP_PduHeader_LENGTHS_TRANSACTION_SEQUENCE, 3, 0) extern int CF_GetMemcpySize(const uint8 *num, int size); extern void CF_MemcpyToBE(uint8 *dst, const uint8 *src, int src_size, int dst_size); -extern int CF_GetVariableHeader(void); -extern void CF_SetVariableHeader(CF_EntityId_t src_eid, CF_EntityId_t dst_eid, CF_TransactionSeq_t tsn); +extern int CF_GetVariableHeader(CF_CFDP_PduHeader_t *ph); +extern void CF_SetVariableHeader(CF_CFDP_PduHeader_t *ph, CF_EntityId_t src_eid, CF_EntityId_t dst_eid, + CF_TransactionSeq_t tsn); extern int CF_HeaderSize(const CF_CFDP_PduHeader_t *ph); #define CF_MAX_HEADER_SIZE (sizeof(CF_CFDP_PduHeader_t) + (2 * sizeof(CF_EntityId_t)) + sizeof(CF_TransactionSeq_t)) diff --git a/fsw/src/cf_cfdp_r.c b/fsw/src/cf_cfdp_r.c index 54bcf9b6..02bb8f70 100644 --- a/fsw/src/cf_cfdp_r.c +++ b/fsw/src/cf_cfdp_r.c @@ -46,6 +46,17 @@ typedef struct uint32 gap_counter; } gap_compute_args_t; +/** + * @brief A dispatch table for receive file transactions, recieve side + * + * This is used for "receive file" transactions upon receipt of a directive PDU. + * Depending on the sub-state of the transaction, a different action may be taken. + */ +typedef struct +{ + const CF_CFDP_FileDirectiveDispatchTable_t *state[CF_RxSubState_NUM_STATES]; +} CF_CFDP_R_SubstateDispatchTable_t; + /************************************************************************/ /** \brief Helper function to store condition code set send_fin flag. ** @@ -220,10 +231,9 @@ err_out:; ** \endreturns ** *************************************************************************/ -static int CF_CFDP_R_ProcessFd(CF_Transaction_t *t, CFE_MSG_Size_t *bytes_received) +static int CF_CFDP_R_ProcessFd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, CFE_MSG_Size_t *bytes_received) { - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; - *bytes_received = CF_AppData.engine.in.bytes_received; + *bytes_received = CF_AppData.engine.in.bytes_received; int ret = -1; @@ -299,11 +309,11 @@ static int CF_CFDP_R_ProcessFd(CF_Transaction_t *t, CFE_MSG_Size_t *bytes_receiv ** \endreturns ** *************************************************************************/ -static int CF_CFDP_R_SubstateRecvEof(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static int CF_CFDP_R_SubstateRecvEof(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { int ret = CF_RxEofRet_SUCCESS; - if (!CF_CFDP_RecvEof()) + if (!CF_CFDP_RecvEof(t, ph)) { uint32 size; @@ -346,7 +356,7 @@ static int CF_CFDP_R_SubstateRecvEof(CF_Transaction_t *t, const CF_CFDP_PduHeade ** \endreturns ** *************************************************************************/ -static void CF_CFDP_R1_SubstateRecvEof(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_R1_SubstateRecvEof(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { int ret = CF_CFDP_R_SubstateRecvEof(t, ph); uint32 crc; @@ -379,7 +389,7 @@ static void CF_CFDP_R1_SubstateRecvEof(CF_Transaction_t *t, const CF_CFDP_PduHea ** \endreturns ** *************************************************************************/ -static void CF_CFDP_R2_SubstateRecvEof(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_R2_SubstateRecvEof(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { if (!t->flags.rx.eof_recv) { @@ -435,12 +445,12 @@ static void CF_CFDP_R2_SubstateRecvEof(CF_Transaction_t *t, const CF_CFDP_PduHea ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_R1_SubstateRecvFileData(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_R1_SubstateRecvFileData(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { CFE_MSG_Size_t bytes_received; /* initialized in CF_CFDP_R_ProcessFd() */ /* got file data pdu? */ - if (CF_CFDP_RecvFd(t) || CF_CFDP_R_ProcessFd(t, &bytes_received)) + if (CF_CFDP_RecvFd(t, ph) || CF_CFDP_R_ProcessFd(t, ph, &bytes_received)) { goto err_out; } @@ -468,13 +478,13 @@ static void CF_CFDP_R1_SubstateRecvFileData(CF_Transaction_t *t, const CF_CFDP_P ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_R2_SubstateRecvFileData(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_R2_SubstateRecvFileData(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { CFE_MSG_Size_t bytes_received; /* initialized in CF_CFDP_R_ProcessFd() */ uint32 offset; /* got file data pdu? */ - if (CF_CFDP_RecvFd(t) || CF_CFDP_R_ProcessFd(t, &bytes_received)) + if (CF_CFDP_RecvFd(t, ph) || CF_CFDP_R_ProcessFd(t, ph, &bytes_received)) { goto err_out; } @@ -583,7 +593,7 @@ static int CF_CFDP_R_SubstateSendNak(CF_Transaction_t *t) { /* gaps are present, so let's send the nak pdu */ cfdp_ldst_uint32(nak->scope_end, 0); - sret = CF_CFDP_SendNak(t, cret); + sret = CF_CFDP_SendNak(t, ph, cret); t->flags.rx.fd_nak_sent = 1; /* latch that at least one nak has been sent requesting filedata */ CF_Assert(sret != CF_SendRet_ERROR); /* NOTE: this CF_Assert is here because CF_CFDP_SendNak() does not return CF_SendRet_ERROR, so if it's ever added to that function we @@ -607,7 +617,7 @@ static int CF_CFDP_R_SubstateSendNak(CF_Transaction_t *t) cfdp_ldst_uint32(nak->scope_end, 0); cfdp_ldst_uint32(nak->segment_requests[0].offset_start, 0); cfdp_ldst_uint32(nak->segment_requests[0].offset_end, 0); - sret = CF_CFDP_SendNak(t, 1); + sret = CF_CFDP_SendNak(t, ph, 1); CF_Assert(sret != CF_SendRet_ERROR); /* this CF_Assert is here because CF_CFDP_SendNak() does not return CF_SendRet_ERROR */ if (sret == CF_SendRet_SUCCESS) @@ -822,9 +832,9 @@ static int CF_CFDP_R2_SubstateSendFin(CF_Transaction_t *t) ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_R2_Recv_fin_ack(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_R2_Recv_fin_ack(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { - if (!CF_CFDP_RecvAck()) + if (!CF_CFDP_RecvAck(t, ph)) { /* got fin ack, so time to close the state */ CF_CFDP_R2_Reset(t); @@ -851,7 +861,7 @@ static void CF_CFDP_R2_Recv_fin_ack(CF_Transaction_t *t, const CF_CFDP_PduHeader ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* it isn't an error to get another MD pdu, right? */ if (!t->flags.rx.md_recv) @@ -866,7 +876,7 @@ static void CF_CFDP_R2_RecvMd(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph strcpy( fname, t->history->fnames.dst_filename); /* strcpy is ok, since fname is CF_FILENAME_MAX_LEN like dst_filename */ - status = CF_CFDP_RecvMd(t); + status = CF_CFDP_RecvMd(t, ph); if (!status) { /* successfully obtained md pdu */ @@ -944,15 +954,13 @@ err_out:; ** t must not be NULL. fns must not be NULL. ** *************************************************************************/ -static void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, - void (*const fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t *, const CF_CFDP_PduHeader_t *), - void (*const fd_fn)(CF_Transaction_t *, const CF_CFDP_PduHeader_t *)) +static void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, + const CF_CFDP_R_SubstateDispatchTable_t *dispatch, CF_CFDP_StateRecvFunc_t fd_fn) { CF_Assert(t->state_data.r.sub_state < CF_RxSubState_NUM_STATES); - CF_Assert(CF_AppData.engine.in.msg); + CF_CFDP_StateRecvFunc_t selected_handler; - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; + selected_handler = NULL; /* the 2d jump table is only used with file directive pdu */ if (!FGV(ph->flags, CF_CFDP_PduHeader_FLAGS_TYPE)) @@ -960,9 +968,9 @@ static void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_CFDP_PduFileDirectiveHeader_t *fdh = STATIC_CAST(ph, CF_CFDP_PduFileDirectiveHeader_t); if (fdh->directive_code < CF_CFDP_FileDirective_INVALID_MAX) { - if (fns[t->state_data.r.sub_state][fdh->directive_code]) + if (dispatch->state[t->state_data.r.sub_state] != NULL) { - fns[t->state_data.r.sub_state][fdh->directive_code](t, ph); + selected_handler = dispatch->state[t->state_data.r.sub_state]->fdirective[fdh->directive_code]; } } else @@ -978,13 +986,22 @@ static void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, { if (t->history->cc == CF_CFDP_ConditionCode_NO_ERROR) { - fd_fn(t, ph); /* if history shows error, drop filedata pdu on the floor */ + selected_handler = fd_fn; } else { ++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.dropped; } } + + /* + * NOTE: if no handler is selected, this will drop packets on the floor here, + * without incrementing any counter. This was existing behavior. + */ + if (selected_handler != NULL) + { + selected_handler(t, ph); + } } /************************************************************************/ @@ -994,19 +1011,16 @@ static void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, ** t must not be NULL. ** *************************************************************************/ -void CF_CFDP_R1_Recv(CF_Transaction_t *t) +void CF_CFDP_R1_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { - static void (*const substate_fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t * t, const CF_CFDP_PduHeader_t *) = { - {NULL, NULL, NULL, NULL, CF_CFDP_R1_SubstateRecvEof, NULL, NULL, NULL, NULL, NULL, - NULL}, /* CF_RxSubState_FILEDATA */ - {NULL, NULL, NULL, NULL, CF_CFDP_R1_SubstateRecvEof, NULL, NULL, NULL, NULL, NULL, - NULL}, /* CF_RxSubState_EOF */ - {NULL, NULL, NULL, NULL, CF_CFDP_R1_SubstateRecvEof, NULL, NULL, NULL, NULL, NULL, - NULL}, /* CF_RxSubState_WAIT_FOR_FIN_ACK */ - }; - - CF_CFDP_R_DispatchRecv(t, substate_fns, CF_CFDP_R1_SubstateRecvFileData); + static const CF_CFDP_FileDirectiveDispatchTable_t r1_fdir_handlers = { + .fdirective = {[CF_CFDP_FileDirective_EOF] = CF_CFDP_R1_SubstateRecvEof}}; + static const CF_CFDP_R_SubstateDispatchTable_t substate_fns = { + .state = {[CF_RxSubState_FILEDATA] = &r1_fdir_handlers, + [CF_RxSubState_EOF] = &r1_fdir_handlers, + [CF_RxSubState_WAIT_FOR_FIN_ACK] = &r1_fdir_handlers}}; + + CF_CFDP_R_DispatchRecv(t, ph, &substate_fns, CF_CFDP_R1_SubstateRecvFileData); } /************************************************************************/ @@ -1016,19 +1030,24 @@ void CF_CFDP_R1_Recv(CF_Transaction_t *t) ** t must not be NULL. ** *************************************************************************/ -void CF_CFDP_R2_Recv(CF_Transaction_t *t) +void CF_CFDP_R2_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { - static void (*const substate_fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t * t, const CF_CFDP_PduHeader_t *) = { - {NULL, NULL, NULL, NULL, CF_CFDP_R2_SubstateRecvEof, NULL, NULL, CF_CFDP_R2_RecvMd, NULL, NULL, - NULL}, /* CF_RxSubState_FILEDATA */ - {NULL, NULL, NULL, NULL, CF_CFDP_R2_SubstateRecvEof, NULL, NULL, CF_CFDP_R2_RecvMd, NULL, NULL, - NULL}, /* CF_RxSubState_EOF */ - {NULL, NULL, NULL, NULL, CF_CFDP_R2_SubstateRecvEof, NULL, CF_CFDP_R2_Recv_fin_ack, NULL, NULL, NULL, - NULL}, /* CF_RxSubState_WAIT_FOR_FIN_ACK */ - }; - - CF_CFDP_R_DispatchRecv(t, substate_fns, CF_CFDP_R2_SubstateRecvFileData); + static const CF_CFDP_FileDirectiveDispatchTable_t r2_fdir_handlers_normal = { + .fdirective = { + [CF_CFDP_FileDirective_EOF] = CF_CFDP_R2_SubstateRecvEof, + [CF_CFDP_FileDirective_METADATA] = CF_CFDP_R2_RecvMd, + }}; + static const CF_CFDP_FileDirectiveDispatchTable_t r2_fdir_handlers_finack = { + .fdirective = { + [CF_CFDP_FileDirective_EOF] = CF_CFDP_R2_SubstateRecvEof, + [CF_CFDP_FileDirective_ACK] = CF_CFDP_R2_Recv_fin_ack, + }}; + static const CF_CFDP_R_SubstateDispatchTable_t substate_fns = { + .state = {[CF_RxSubState_FILEDATA] = &r2_fdir_handlers_normal, + [CF_RxSubState_EOF] = &r2_fdir_handlers_normal, + [CF_RxSubState_WAIT_FOR_FIN_ACK] = &r2_fdir_handlers_finack}}; + + CF_CFDP_R_DispatchRecv(t, ph, &substate_fns, CF_CFDP_R2_SubstateRecvFileData); } /************************************************************************/ diff --git a/fsw/src/cf_cfdp_s.c b/fsw/src/cf_cfdp_s.c index 9ab7aada..b31984f1 100644 --- a/fsw/src/cf_cfdp_s.c +++ b/fsw/src/cf_cfdp_s.c @@ -39,6 +39,28 @@ #include #include "cf_assert.h" +/** + * @brief A dispatch table for send file transactions, receive side + * + * This is used for "send file" transactions upon receipt of a directive PDU. + * Depending on the sub-state of the transaction, a different action may be taken. + */ +typedef struct +{ + const CF_CFDP_FileDirectiveDispatchTable_t *substate[CF_TxSubState_NUM_STATES]; +} CF_CFDP_S_SubstateRecvDispatchTable_t; + +/** + * @brief A dispatch table for send file transactions, transmit side + * + * This is used for "send file" transactions to generate the next PDU to be sent. + * Depending on the sub-state of the transaction, a different action may be taken. + */ +typedef struct +{ + CF_CFDP_StateSendFunc_t substate[CF_TxSubState_NUM_STATES]; +} CF_CFDP_S_SubstateSendDispatchTable_t; + /************************************************************************/ /** \brief CFDP S1 transaction reset function. ** @@ -178,7 +200,7 @@ static int32 CF_CFDP_S_SendFileData(CF_Transaction_t *t, uint32 foffs, uint32 by } t->state_data.s.cached_pos += status; - status = CF_CFDP_SendFd(t, foffs, bytes_to_read); + status = CF_CFDP_SendFd(t, ph, foffs, bytes_to_read); if (status == CF_SendRet_NO_MSG) { ret = 0; /* no bytes were processed */ @@ -455,7 +477,7 @@ static void CF_CFDP_S_SubstateSendFinAck(CF_Transaction_t *t) ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_S2_EarlyFin(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_S2_EarlyFin(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* received early fin, so just cancel */ CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_EARLY_FIN, CFE_EVS_EventType_ERROR, @@ -471,9 +493,9 @@ static void CF_CFDP_S2_EarlyFin(CF_Transaction_t *t, const CF_CFDP_PduHeader_t * ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_S2_Fin(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_S2_Fin(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { - if (!CF_CFDP_RecvFin()) + if (!CF_CFDP_RecvFin(t, ph)) { t->state_data.s.s2.fin_cc = FGV(STATIC_CAST(ph, CF_CFDP_PduFin_t)->flags, CF_CFDP_PduFin_FLAGS_CC); t->state_data.s.sub_state = CF_TxSubState_SEND_FIN_ACK; @@ -498,14 +520,14 @@ static void CF_CFDP_S2_Fin(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_S2_Nak(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_S2_Nak(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* temporary function to respond to naks */ int counter; int num_sr; int bad_sr = 0; - if (!CF_CFDP_RecvNak(&num_sr) && num_sr) + if (!CF_CFDP_RecvNak(t, ph, &num_sr) && num_sr) { CF_CFDP_PduNak_t *nak = STATIC_CAST(ph, CF_CFDP_PduNak_t); CF_Assert(num_sr <= CF_NAK_MAX_SEGMENTS); // sanity check @@ -568,7 +590,7 @@ static void CF_CFDP_S2_Nak(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_S2_Nak_Arm(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_S2_Nak_Arm(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { CF_CFDP_ArmAckTimer(t); CF_CFDP_S2_Nak(t, ph); @@ -585,9 +607,9 @@ static void CF_CFDP_S2_Nak_Arm(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *p ** t must not be NULL. ph must not be NULL. ** *************************************************************************/ -static void CF_CFDP_S2_WaitForEofAck(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *ph) +static void CF_CFDP_S2_WaitForEofAck(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { - if (!CF_CFDP_RecvAck()) + if (!CF_CFDP_RecvAck(t, ph)) { /* don't send fin if error. Don't check the eof CC, just go with * the stored one we sent before */ @@ -621,30 +643,27 @@ static void CF_CFDP_S2_WaitForEofAck(CF_Transaction_t *t, const CF_CFDP_PduHeade ** t must not be NULL. fns must not be NULL. ** *************************************************************************/ -static void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, - void (*const fns[CF_TxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t *, const CF_CFDP_PduHeader_t *)) +static void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, + const CF_CFDP_S_SubstateRecvDispatchTable_t *dispatch) { CF_Assert(t->state_data.s.sub_state < CF_TxSubState_NUM_STATES); - CF_Assert(CF_AppData.engine.in.msg); + const CF_CFDP_FileDirectiveDispatchTable_t *substate_tbl; + CF_CFDP_StateRecvFunc_t selected_handler; + CF_CFDP_PduFileDirectiveHeader_t *fdh; + + selected_handler = NULL; - /* at this point, pdu header for recv message is unmarshaled */ - CF_CFDP_PduHeader_t *ph = &((CF_PduRecvMsg_t *)CF_AppData.engine.in.msg)->ph; /* send state, so we only care about file directive PDU */ if (!FGV(ph->flags, CF_CFDP_PduHeader_FLAGS_TYPE)) { - CF_CFDP_PduFileDirectiveHeader_t *fdh = STATIC_CAST(ph, CF_CFDP_PduFileDirectiveHeader_t); + fdh = STATIC_CAST(ph, CF_CFDP_PduFileDirectiveHeader_t); if (fdh->directive_code < CF_CFDP_FileDirective_INVALID_MAX) { - /* check that there's a valid function pointer. if there isn't, - * then silently ignore. We may want to discuss if it's worth - * shutting down the whole transation if a PDU is received - * that doesn't make sense to be received (For example, - * class 1 CFDP receiving a NAK PDU) but for now, we silently - * ignore the received packet and keep chugging along. */ - if (fns[t->state_data.s.sub_state][fdh->directive_code]) + /* This should be silent (no event) if no handler is defined in the table */ + substate_tbl = dispatch->substate[t->state_data.s.sub_state]; + if (substate_tbl != NULL) { - fns[t->state_data.s.sub_state][fdh->directive_code](t, ph); + selected_handler = substate_tbl->fdirective[fdh->directive_code]; } } else @@ -662,6 +681,17 @@ static void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, "CF S%d(%u:%u): received non-file directive pdu", (t->state == CF_TxnState_S2), t->history->src_eid, t->history->seq_num); } + + /* check that there's a valid function pointer. if there isn't, + * then silently ignore. We may want to discuss if it's worth + * shutting down the whole transation if a PDU is received + * that doesn't make sense to be received (For example, + * class 1 CFDP receiving a NAK PDU) but for now, we silently + * ignore the received packet and keep chugging along. */ + if (selected_handler) + { + selected_handler(t, ph); + } } /************************************************************************/ @@ -671,12 +701,11 @@ static void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, ** t must not be NULL. ** *************************************************************************/ -void CF_CFDP_S1_Recv(CF_Transaction_t *t) +void CF_CFDP_S1_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { /* s1 doesn't need to receive anything */ - static void (*const substate_fns[CF_TxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = {{NULL}}; - CF_CFDP_S_DispatchRecv(t, substate_fns); + static const CF_CFDP_S_SubstateRecvDispatchTable_t substate_fns = {{NULL}}; + CF_CFDP_S_DispatchRecv(t, ph, &substate_fns); } /************************************************************************/ @@ -686,22 +715,52 @@ void CF_CFDP_S1_Recv(CF_Transaction_t *t) ** t must not be NULL. ** *************************************************************************/ -void CF_CFDP_S2_Recv(CF_Transaction_t *t) +void CF_CFDP_S2_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { - static void (*const substate_fns[CF_TxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = { - {NULL, NULL, NULL, NULL, NULL, CF_CFDP_S2_EarlyFin, NULL, NULL, NULL, NULL, NULL}, /* CF_TxSubState_METADATA */ - {NULL, NULL, NULL, NULL, NULL, CF_CFDP_S2_EarlyFin, NULL, NULL, CF_CFDP_S2_Nak, NULL, - NULL}, /* CF_TxSubState_FILEDATA */ - {NULL, NULL, NULL, NULL, NULL, CF_CFDP_S2_EarlyFin, NULL, NULL, CF_CFDP_S2_Nak, NULL, - NULL}, /* CF_TxSubState_EOF */ - {NULL, NULL, NULL, NULL, NULL, CF_CFDP_S2_Fin, CF_CFDP_S2_WaitForEofAck, NULL, CF_CFDP_S2_Nak_Arm, NULL, - NULL}, /* CF_TxSubState_WAIT_FOR_EOF_ACK */ - {NULL, NULL, NULL, NULL, NULL, CF_CFDP_S2_Fin, NULL, NULL, CF_CFDP_S2_Nak_Arm, NULL, - NULL}, /* CF_TxSubState_WAIT_FOR_FIN */ - {NULL, NULL, NULL, NULL, NULL, CF_CFDP_S2_Fin, NULL, NULL, NULL, NULL, NULL}, /* CF_TxSubState_SEND_FIN_ACK */ - }; - CF_CFDP_S_DispatchRecv(t, substate_fns); + static const CF_CFDP_FileDirectiveDispatchTable_t s2_meta = {.fdirective = { + [CF_CFDP_FileDirective_FIN] = CF_CFDP_S2_EarlyFin, + }}; + static const CF_CFDP_FileDirectiveDispatchTable_t s2_fd_or_eof = { + .fdirective = { + [CF_CFDP_FileDirective_FIN] = CF_CFDP_S2_EarlyFin, [CF_CFDP_FileDirective_NAK] = CF_CFDP_S2_Nak}}; + static const CF_CFDP_FileDirectiveDispatchTable_t s2_wait_eof_ack = { + .fdirective = {[CF_CFDP_FileDirective_FIN] = CF_CFDP_S2_Fin, + [CF_CFDP_FileDirective_ACK] = CF_CFDP_S2_WaitForEofAck, + [CF_CFDP_FileDirective_NAK] = CF_CFDP_S2_Nak_Arm}}; + static const CF_CFDP_FileDirectiveDispatchTable_t s2_wait_fin = { + .fdirective = {[CF_CFDP_FileDirective_FIN] = CF_CFDP_S2_Fin, [CF_CFDP_FileDirective_NAK] = CF_CFDP_S2_Nak_Arm}}; + static const CF_CFDP_FileDirectiveDispatchTable_t s2_fin_ack = { + .fdirective = {[CF_CFDP_FileDirective_FIN] = CF_CFDP_S2_Fin}}; + + static const CF_CFDP_S_SubstateRecvDispatchTable_t substate_fns = { + .substate = { + [CF_TxSubState_METADATA] = &s2_meta, + [CF_TxSubState_FILEDATA] = &s2_fd_or_eof, + [CF_TxSubState_EOF] = &s2_fd_or_eof, + [CF_TxSubState_WAIT_FOR_EOF_ACK] = &s2_wait_eof_ack, + [CF_TxSubState_WAIT_FOR_FIN] = &s2_wait_fin, + [CF_TxSubState_SEND_FIN_ACK] = &s2_fin_ack, + }}; + + CF_CFDP_S_DispatchRecv(t, ph, &substate_fns); +} + +/************************************************************************/ +/** \brief Transmit pdu processing. +** +** \par Assumptions, External Events, and Notes: +** t must not be NULL. +** +*************************************************************************/ +static void CF_CFDP_S_DispatchTransmit(CF_Transaction_t *t, const CF_CFDP_S_SubstateSendDispatchTable_t *dispatch) +{ + CF_CFDP_StateSendFunc_t selected_handler; + + selected_handler = dispatch->substate[t->state_data.s.sub_state]; + if (selected_handler != NULL) + { + selected_handler(t); + } } /************************************************************************/ @@ -713,11 +772,14 @@ void CF_CFDP_S2_Recv(CF_Transaction_t *t) *************************************************************************/ void CF_CFDP_S1_Tx(CF_Transaction_t *t) { - static void (*const substate_fns[CF_TxSubState_EOF + 1])(CF_Transaction_t * t) = { - CF_CFDP_S_SubstateSendMetadata, CF_CFDP_S_SubstateSendFileData, CF_CFDP_S1_SubstateSendEof}; - - CF_Assert(t->state_data.s.sub_state <= CF_TxSubState_EOF); - substate_fns[t->state_data.s.sub_state](t); + static const CF_CFDP_S_SubstateSendDispatchTable_t substate_fns = { + .substate = { + [CF_TxSubState_METADATA] = CF_CFDP_S_SubstateSendMetadata, + [CF_TxSubState_FILEDATA] = CF_CFDP_S_SubstateSendFileData, + [CF_TxSubState_EOF] = CF_CFDP_S1_SubstateSendEof, + }}; + + CF_CFDP_S_DispatchTransmit(t, &substate_fns); } /************************************************************************/ @@ -729,11 +791,14 @@ void CF_CFDP_S1_Tx(CF_Transaction_t *t) *************************************************************************/ void CF_CFDP_S2_Tx(CF_Transaction_t *t) { - static void (*const substate_fns[CF_TxSubState_EOF + 1])(CF_Transaction_t * t) = { - CF_CFDP_S_SubstateSendMetadata, CF_CFDP_S2_SubstateSendFileData, CF_CFDP_S2_SubstateSendEof}; - - CF_Assert(t->state_data.s.sub_state <= CF_TxSubState_EOF); - substate_fns[t->state_data.s.sub_state](t); + static const CF_CFDP_S_SubstateSendDispatchTable_t substate_fns = { + .substate = { + [CF_TxSubState_METADATA] = CF_CFDP_S_SubstateSendMetadata, + [CF_TxSubState_FILEDATA] = CF_CFDP_S2_SubstateSendFileData, + [CF_TxSubState_EOF] = CF_CFDP_S2_SubstateSendEof, + }}; + + CF_CFDP_S_DispatchTransmit(t, &substate_fns); } /************************************************************************/ diff --git a/unit-test/cf_cfdp_helpers_tests.c b/unit-test/cf_cfdp_helpers_tests.c index bb78a6ba..25286e77 100644 --- a/unit-test/cf_cfdp_helpers_tests.c +++ b/unit-test/cf_cfdp_helpers_tests.c @@ -780,8 +780,6 @@ void Test_CF_GetVariableHeader_When_eid_l_AND_tsn_l_AreNotGreaterThan_0_DoesNotC memset(&dummy_ph, 0, sizeof(dummy_ph)); - CF_AppData.engine.in.msg = &dummy_ph.cfe_sb_buffer; - /* Arrange for CF_GetEIDSize */ uint32 forced_return_FGV_from_EID = sizeof(CF_EntityId_t); /* unstubbable code adds +1 to this value */ @@ -795,7 +793,7 @@ void Test_CF_GetVariableHeader_When_eid_l_AND_tsn_l_AreNotGreaterThan_0_DoesNotC forced_return_FGV_from_TSN); /* FGV + 1 > sizeof(CF_TransactionSeq_t) causes ret to be -1 */ /* Act */ - local_result = CF_GetVariableHeader(); + local_result = CF_GetVariableHeader(&dummy_ph.pdu_r_msg.ph); /* Assert */ UtAssert_True(local_result == -1, "CF_GetVariableHeader returned %d and should be -1 (fail)", local_result); @@ -811,8 +809,6 @@ void Test_CF_GetVariableHeader_WhenOnly_eid_l_IsGreaterThan_0_DoesNotCallAnyMemC memset(&dummy_ph, 0, sizeof(dummy_ph)); - CF_AppData.engine.in.msg = &dummy_ph.cfe_sb_buffer; - /* Arrange for CF_GetEIDSize */ uint32 forced_return_FGV_from_EID = sizeof(CF_EntityId_t) - 1; /* unstubbable code adds +1 to this value */ @@ -827,7 +823,7 @@ void Test_CF_GetVariableHeader_WhenOnly_eid_l_IsGreaterThan_0_DoesNotCallAnyMemC forced_return_FGV_from_TSN); /* FGV + 1 > sizeof(CF_TransactionSeq_t) causes ret to be -1 */ /* Act */ - local_result = CF_GetVariableHeader(); + local_result = CF_GetVariableHeader(&dummy_ph.pdu_r_msg.ph); /* Assert */ UtAssert_True(local_result == -1, "CF_GetVariableHeader returned %d and should be -1 (fail)", local_result); @@ -843,8 +839,6 @@ void Test_CF_GetVariableHeader_WhenOnly_tsn_l_IsGreaterThan_0_DoesNotCallAnyMemC memset(&dummy_ph, 0, sizeof(dummy_ph)); - CF_AppData.engine.in.msg = &dummy_ph.cfe_sb_buffer; - /* Arrange for CF_GetEIDSize */ uint32 forced_return_FGV_from_EID = sizeof(CF_EntityId_t); /* unstubbable code adds +1 to this value */ @@ -860,7 +854,7 @@ void Test_CF_GetVariableHeader_WhenOnly_tsn_l_IsGreaterThan_0_DoesNotCallAnyMemC sizeof(CF_TransactionSeq_t) causes ret to be sizeof(CF_TransactionSeq_t) */ /* Act */ - local_result = CF_GetVariableHeader(); + local_result = CF_GetVariableHeader(&dummy_ph.pdu_r_msg.ph); /* Assert */ UtAssert_True(local_result == -1, "CF_GetVariableHeader returned %d and should be -1 (fail)", local_result); @@ -876,8 +870,6 @@ void Test_CF_GetVariableHeader_GetsAllThreeVariableLengthItemsOutOfHeaderAndRetu memset(&dummy_ph, 0, sizeof(dummy_ph)); - CF_AppData.engine.in.msg = &dummy_ph.cfe_sb_buffer; - /* Arrange for CF_GetEIDSize */ uint32 forced_return_FGV_from_EID = Any_uint32_LessThan(sizeof(CF_EntityId_t)); /* unstubbable code adds +1 to this value */ @@ -891,7 +883,7 @@ void Test_CF_GetVariableHeader_GetsAllThreeVariableLengthItemsOutOfHeaderAndRetu UT_SetDeferredRetcode(UT_KEY(FGV), 1, forced_return_FGV_from_TSN); /* FGV + 1 <= sizeof(CF_TransactionSeq_t) */ /* Act */ - local_result = CF_GetVariableHeader(); + local_result = CF_GetVariableHeader(&dummy_ph.pdu_r_msg.ph); /* Assert */ UtAssert_True(local_result == 0, "CF_GetVariableHeader returned %d and should be 0 (success)", local_result); @@ -917,10 +909,8 @@ void Test_CF_SetVariableHeader_Call_FSV_Twice(void) memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.out.msg = &dummy_msg.cfe_sb_buffer; - /* Act */ - CF_SetVariableHeader(arg_src_eid, arg_dst_eid, arg_tsn); + CF_SetVariableHeader(&dummy_msg.pdu_s_msg.ph, arg_src_eid, arg_dst_eid, arg_tsn); /* Assert */ UtAssert_STUB_COUNT(FSV, 2); diff --git a/unit-test/cf_cfdp_r_tests.c b/unit-test/cf_cfdp_r_tests.c index 437328a5..43db18da 100644 --- a/unit-test/cf_cfdp_r_tests.c +++ b/unit-test/cf_cfdp_r_tests.c @@ -21,7 +21,7 @@ uint8 Stub_FGV(uint8 source, CF_FIELD_FIELD name); ** *******************************************************************************/ -static void Dummy_fd_fn(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *pdu) +static void Dummy_fd_fn(CF_Transaction_t *t, CF_CFDP_PduHeader_t *pdu) { UT_Stub_CopyFromLocal(UT_KEY(Dummy_fd_fn), &t, sizeof(t)); UT_Stub_CopyFromLocal(UT_KEY(Dummy_fd_fn), &pdu, sizeof(pdu)); @@ -29,7 +29,7 @@ static void Dummy_fd_fn(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *pdu) UT_DEFAULT_IMPL(Dummy_fd_fn); } -static void Dummy_fns(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *pdu) +static void Dummy_fns(CF_Transaction_t *t, CF_CFDP_PduHeader_t *pdu) { UT_Stub_CopyFromLocal(UT_KEY(Dummy_fns), &t, sizeof(t)); UT_Stub_CopyFromLocal(UT_KEY(Dummy_fns), &pdu, sizeof(pdu)); @@ -639,7 +639,6 @@ void Test_CF_CFDP_R_ProcessFd_NoCrcWhen_bytes_received_IsLessThan_size_of_pdu_fi memset(&dummy_ph, 0, sizeof(dummy_ph)); - CF_AppData.engine.in.msg = &dummy_ph.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = initial_bytes_received; UT_SetDefaultReturnValue(UT_KEY(CF_HeaderSize), 0); @@ -648,7 +647,7 @@ void Test_CF_CFDP_R_ProcessFd_NoCrcWhen_bytes_received_IsLessThan_size_of_pdu_fi arg_t->chan_num = Any_cf_chan_num(); /* Act */ - local_result = CF_CFDP_R_ProcessFd(arg_t, arg_bytes_received); + local_result = CF_CFDP_R_ProcessFd(arg_t, &dummy_ph.pdu_r_msg.ph, arg_bytes_received); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_R_ProcessFd returned %d and should be -1", local_result); @@ -672,8 +671,6 @@ void Test_CF_CFDP_R_ProcessFd_HasCrcBut_bytes_received_Minus_4_IsLessThan_size_o memset(&dummy_ph, 0, sizeof(dummy_ph)); - CF_AppData.engine.in.msg = &dummy_ph.cfe_sb_buffer; - UT_SetDefaultReturnValue(UT_KEY(CF_HeaderSize), 0); UT_SetDefaultReturnValue(UT_KEY(FGV), 1); CF_AppData.engine.in.bytes_received = initial_bytes_received; @@ -681,7 +678,7 @@ void Test_CF_CFDP_R_ProcessFd_HasCrcBut_bytes_received_Minus_4_IsLessThan_size_o arg_t->chan_num = Any_cf_chan_num(); /* Act */ - local_result = CF_CFDP_R_ProcessFd(arg_t, arg_bytes_received); + local_result = CF_CFDP_R_ProcessFd(arg_t, &dummy_ph.pdu_r_msg.ph, arg_bytes_received); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_R_ProcessFd returned %d and should be -1", local_result); @@ -709,7 +706,6 @@ void Test_CF_CFDP_R_ProcessFd_NoCrc_cached_pos_NotEqTo_offset_And_fret_NotEqTo_o memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = initial_bytes_received; UT_SetDefaultReturnValue(UT_KEY(CF_HeaderSize), sizeof(CF_CFDP_PduHeader_t)); @@ -725,7 +721,7 @@ void Test_CF_CFDP_R_ProcessFd_NoCrc_cached_pos_NotEqTo_offset_And_fret_NotEqTo_o CF_AppData.hk.channel_hk[arg_t->chan_num].counters.fault.file_seek = initial_fault_file_seek; /* Act */ - local_result = CF_CFDP_R_ProcessFd(arg_t, arg_bytes_received); + local_result = CF_CFDP_R_ProcessFd(arg_t, &dummy_msg.pdu_r_msg.ph, arg_bytes_received); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_R_ProcessFd returned %d and should be -1", local_result); @@ -759,7 +755,6 @@ void Test_CF_CFDP_R_ProcessFd_NoCrc_fret_NotEqTo_bytes_received_Value_SendEventS memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = initial_bytes_received; UT_SetDefaultReturnValue(UT_KEY(CF_HeaderSize), sizeof(CF_CFDP_PduHeader_t)); @@ -775,7 +770,7 @@ void Test_CF_CFDP_R_ProcessFd_NoCrc_fret_NotEqTo_bytes_received_Value_SendEventS CF_AppData.hk.channel_hk[arg_t->chan_num].counters.fault.file_write = initial_fault_file_write; /* Act */ - local_result = CF_CFDP_R_ProcessFd(arg_t, arg_bytes_received); + local_result = CF_CFDP_R_ProcessFd(arg_t, &dummy_msg.pdu_r_msg.ph, arg_bytes_received); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_R_ProcessFd returned %d and should be -1", local_result); @@ -813,7 +808,6 @@ void Test_CF_CFDP_R_ProcessFd_NoCrc_cached_pos_Gets_bytes_received_Plus_offset_A memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = initial_bytes_received; UT_SetDefaultReturnValue(UT_KEY(CF_HeaderSize), sizeof(CF_CFDP_PduHeader_t)); @@ -829,7 +823,7 @@ void Test_CF_CFDP_R_ProcessFd_NoCrc_cached_pos_Gets_bytes_received_Plus_offset_A CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.file_data_bytes = initial_file_data_bytes; /* Act */ - local_result = CF_CFDP_R_ProcessFd(arg_t, arg_bytes_received); + local_result = CF_CFDP_R_ProcessFd(arg_t, &dummy_msg.pdu_r_msg.ph, arg_bytes_received); /* Assert */ UtAssert_True(local_result == 0, "CF_CFDP_R_ProcessFd returned %d and should be 0", local_result); @@ -872,7 +866,6 @@ void Test_CF_CFDP_R_ProcessFd_NoCrc_cached_pos_NotEqTo_offset_But_fret_IsEqTo_of memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = initial_bytes_received; UT_SetDefaultReturnValue(UT_KEY(CF_HeaderSize), sizeof(CF_CFDP_PduHeader_t)); @@ -890,7 +883,7 @@ void Test_CF_CFDP_R_ProcessFd_NoCrc_cached_pos_NotEqTo_offset_But_fret_IsEqTo_of CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.file_data_bytes = initial_file_data_bytes; /* Act */ - local_result = CF_CFDP_R_ProcessFd(arg_t, arg_bytes_received); + local_result = CF_CFDP_R_ProcessFd(arg_t, &dummy_msg.pdu_r_msg.ph, arg_bytes_received); /* Assert */ UtAssert_True(local_result == 0, "CF_CFDP_R_ProcessFd returned %d and should be 0", local_result); @@ -1388,13 +1381,17 @@ void Test_CF_CFDP_R1_SubstateRecvFileData_CallTo_CF_CFDP_RecvFd_Returns_0_CallTo void) { /* Arrange */ - CF_Transaction_t *arg_t = NULL; - CF_CFDP_PduHeader_t *arg_ph = NULL; + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t *arg_t = NULL; + CF_CFDP_PduHeader_t *arg_ph; int forced_return_CF_CFDP_RecvFd = 0; UT_SetHandlerFunction(UT_KEY(CF_CFDP_RecvFd), Handler_int_ForcedReturnOnly, &forced_return_CF_CFDP_RecvFd); /* Arrange for CF_CFDP_R_ProcessFd */ + memset(&dummy_msg, 0, sizeof(dummy_msg)); + + arg_ph = &dummy_msg.pdu_r_msg.ph; CF_AppData.engine.in.bytes_received = 0; /* 0 = recv dropped */ /* Arrange for CF_CFDP_R2_Reset */ @@ -1420,8 +1417,8 @@ void Test_CF_CFDP_R1_SubstateRecvFileData_CallTo_CF_CFDP_RecvFd_Returns_0_CallTo void) { /* Arrange */ - CF_Transaction_t *arg_t = NULL; - CF_CFDP_PduHeader_t *arg_ph = NULL; + CF_Transaction_t *arg_t = NULL; + CF_CFDP_PduHeader_t *arg_ph; int forced_return_CF_CFDP_RecvFd = 0; UT_SetHandlerFunction(UT_KEY(CF_CFDP_RecvFd), Handler_int_ForcedReturnOnly, &forced_return_CF_CFDP_RecvFd); @@ -1442,7 +1439,7 @@ void Test_CF_CFDP_R1_SubstateRecvFileData_CallTo_CF_CFDP_RecvFd_Returns_0_CallTo memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + arg_ph = &dummy_msg.pdu_r_msg.ph; CF_AppData.engine.in.bytes_received = initial_bytes_received; @@ -1486,18 +1483,23 @@ void Test_CF_CFDP_R1_SubstateRecvFileData_CallTo_CF_CFDP_RecvFd_Returns_0_CallTo void Test_CF_CFDP_R2_SubstateRecvFileData_CallTo_CF_CFDP_RecvFd_Returns_non0_Call_CF_CFDP_R2_Reset(void) { /* Arrange */ - CF_Transaction_t *arg_t = NULL; - CF_CFDP_PduHeader_t *arg_ph = NULL; + CF_Transaction_t *arg_t = NULL; + CF_CFDP_PduHeader_t *arg_ph; + CF_UT_inmsg_buffer_t dummy_msg; int forced_return_CF_CFDP_RecvFd = Any_int_Except(0); UT_SetHandlerFunction(UT_KEY(CF_CFDP_RecvFd), Handler_int_ForcedReturnOnly, &forced_return_CF_CFDP_RecvFd); + memset(&dummy_msg, 0, sizeof(dummy_msg)); + /* Arrange for CF_CFDP_R2_Reset */ CF_Transaction_t dummy_t; arg_t = &dummy_t; arg_t->state_data.r.sub_state = Any_uint8_Except(CF_RxSubState_WAIT_FOR_FIN_ACK); + arg_ph = &dummy_msg.pdu_r_msg.ph; + /* Act */ CF_CFDP_R2_SubstateRecvFileData(arg_t, arg_ph); @@ -1514,13 +1516,17 @@ void Test_CF_CFDP_R2_SubstateRecvFileData_CallTo_CF_CFDP_RecvFd_Returns_0_CallTo void) { /* Arrange */ - CF_Transaction_t *arg_t = NULL; - CF_CFDP_PduHeader_t *arg_ph = NULL; + CF_Transaction_t *arg_t = NULL; + CF_CFDP_PduHeader_t *arg_ph = NULL; + CF_UT_inmsg_buffer_t dummy_msg; int forced_return_CF_CFDP_RecvFd = 0; UT_SetHandlerFunction(UT_KEY(CF_CFDP_RecvFd), Handler_int_ForcedReturnOnly, &forced_return_CF_CFDP_RecvFd); + memset(&dummy_msg, 0, sizeof(dummy_msg)); + /* Arrange for CF_CFDP_R_ProcessFd */ + arg_ph = &dummy_msg.pdu_r_msg.ph; CF_AppData.engine.in.bytes_received = 0; /* 0 = recv dropped */ /* Arrange for CF_CFDP_R2_Reset */ @@ -1549,8 +1555,7 @@ void Test_CF_CFDP_R2_SubstateRecvFileData_t_flags_rx_fd_nak_sent_Is_0_And_t_flag /* Arrange */ CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - CF_CFDP_PduHeader_t dummy_arg_ph; - CF_CFDP_PduHeader_t *arg_ph = &dummy_arg_ph; + CF_CFDP_PduHeader_t *arg_ph; int forced_return_CF_CFDP_RecvFd = 0; UT_SetHandlerFunction(UT_KEY(CF_CFDP_RecvFd), Handler_int_ForcedReturnOnly, &forced_return_CF_CFDP_RecvFd); @@ -1576,7 +1581,7 @@ void Test_CF_CFDP_R2_SubstateRecvFileData_t_flags_rx_fd_nak_sent_Is_0_And_t_flag memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + arg_ph = &dummy_msg.pdu_r_msg.ph; CF_AppData.engine.in.bytes_received = initial_bytes_received; @@ -1614,8 +1619,7 @@ void Test_CF_CFDP_R2_SubstateRecvFileData_t_flags_rx_fd_nak_sent_Is_1_Call_CF_CF /* Arrange */ CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - CF_CFDP_PduHeader_t dummy_arg_ph; - CF_CFDP_PduHeader_t *arg_ph = &dummy_arg_ph; + CF_CFDP_PduHeader_t *arg_ph; int forced_return_CF_CFDP_RecvFd = 0; UT_SetHandlerFunction(UT_KEY(CF_CFDP_RecvFd), Handler_int_ForcedReturnOnly, &forced_return_CF_CFDP_RecvFd); @@ -1641,7 +1645,7 @@ void Test_CF_CFDP_R2_SubstateRecvFileData_t_flags_rx_fd_nak_sent_Is_1_Call_CF_CF memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + arg_ph = &dummy_msg.pdu_r_msg.ph; CF_AppData.engine.in.bytes_received = initial_bytes_received; @@ -1682,8 +1686,7 @@ void Test_CF_CFDP_R2_SubstateRecvFileData_t_flags_rx_fd_nak_sent_Is_0_And_t_flag /* Arrange */ CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - CF_CFDP_PduHeader_t dummy_arg_ph; - CF_CFDP_PduHeader_t *arg_ph = &dummy_arg_ph; + CF_CFDP_PduHeader_t *arg_ph; int forced_return_CF_CFDP_RecvFd = 0; UT_SetHandlerFunction(UT_KEY(CF_CFDP_RecvFd), Handler_int_ForcedReturnOnly, &forced_return_CF_CFDP_RecvFd); @@ -1709,7 +1712,7 @@ void Test_CF_CFDP_R2_SubstateRecvFileData_t_flags_rx_fd_nak_sent_Is_0_And_t_flag memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + arg_ph = &dummy_msg.pdu_r_msg.ph; CF_AppData.engine.in.bytes_received = initial_bytes_received; @@ -2877,11 +2880,11 @@ void Test_CF_CFDP_R2_SubstateSendFin_CallTo_CF_CFDP_R2_CalcCrcChunk_Returns_0_Gi void Test_CF_CFDP_R2_Recv_fin_ack_GetsInvalidFinAckFrom_CF_CFDP_RecvAck_SendEventAndIncrement_recv_error(void) { /* Arrange */ - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - const CF_CFDP_PduHeader_t *arg_pdu = NULL; - uint32 initial_recv_error = Any_uint32(); + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + CF_CFDP_PduHeader_t *arg_pdu = NULL; + uint32 initial_recv_error = Any_uint32(); UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_RecvAck), -1); /* -1 indicates error from CF_CFDP_RecvAck */ @@ -2907,11 +2910,11 @@ void Test_CF_CFDP_R2_Recv_fin_ack_GetsInvalidFinAckFrom_CF_CFDP_RecvAck_SendEven void Test_CF_CFDP_R2_Recv_fin_ack_GetsValidFinAckFrom_CF_CFDP_RecvAck_Calls_CFDP_R2_Reset(void) { /* Arrange */ - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - const CF_CFDP_PduHeader_t *arg_pdu = NULL; - uint32 initial_recv_error = Any_uint32(); + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + CF_CFDP_PduHeader_t *arg_pdu = NULL; + uint32 initial_recv_error = Any_uint32(); UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_RecvAck), 0); /* 0 indicates success from CF_CFDP_RecvAck */ @@ -3271,19 +3274,17 @@ void Test_CFDP_R_DispatchRecv_AssertsBecause_msg_in_Is_NULL(void) void Test_CFDP_R_DispatchRecv_FlagsAreSetTo_PDU_HDR_FLAGS_TYPE_And_cc_DoesNotEq_CC_NO_ERROR_Increment_dropped(void) { /* Arrange */ - CF_UT_inmsg_buffer_t dummy_msg; - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - static void (*const arg_fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t * t, const CF_CFDP_PduHeader_t *) = {{NULL}}; - void (*const arg_fd_fn)(CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = {NULL}; - uint16 initial_dropped = Any_uint16(); + CF_UT_inmsg_buffer_t dummy_msg; + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + static CF_CFDP_R_SubstateDispatchTable_t arg_fns = {{NULL}}; + CF_CFDP_StateRecvFunc_t arg_fd_fn = {NULL}; + uint16 initial_dropped = Any_uint16(); memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.r.sub_state = Any_uint8_LessThan(CF_RxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; UT_SetDefaultReturnValue(UT_KEY(FGV), 1); @@ -3294,7 +3295,7 @@ void Test_CFDP_R_DispatchRecv_FlagsAreSetTo_PDU_HDR_FLAGS_TYPE_And_cc_DoesNotEq_ CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.dropped = initial_dropped; /* Act */ - CF_CFDP_R_DispatchRecv(arg_t, arg_fns, arg_fd_fn); + CF_CFDP_R_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns, arg_fd_fn); /* Assert */ UtAssert_STUB_COUNT(FGV, 1); @@ -3307,20 +3308,18 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreSetTo_PDU_HDR_FLAGS_TYPE_And_cc void) { /* Arrange */ - CF_UT_inmsg_buffer_t dummy_msg; - CF_CFDP_PduHeader_t *dummy_ph = &dummy_msg.pdu_r_msg.ph; - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - static void (*const arg_fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t * t, const CF_CFDP_PduHeader_t *) = {{NULL}}; - void (*const arg_fd_fn)(CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = Dummy_fd_fn; - Dummy_fd_fn_context_t context_Dummy_fd_fn; + CF_UT_inmsg_buffer_t dummy_msg; + CF_CFDP_PduHeader_t *dummy_ph = &dummy_msg.pdu_r_msg.ph; + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + static CF_CFDP_R_SubstateDispatchTable_t arg_fns = {{NULL}}; + CF_CFDP_StateRecvFunc_t arg_fd_fn = Dummy_fd_fn; + Dummy_fd_fn_context_t context_Dummy_fd_fn; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.r.sub_state = Any_uint8_LessThan(CF_RxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; UT_SetDefaultReturnValue(UT_KEY(FGV), 1); @@ -3330,7 +3329,7 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreSetTo_PDU_HDR_FLAGS_TYPE_And_cc UT_SetDataBuffer(UT_KEY(Dummy_fd_fn), &context_Dummy_fd_fn, sizeof(context_Dummy_fd_fn), false); /* Act */ - CF_CFDP_R_DispatchRecv(arg_t, arg_fns, arg_fd_fn); + CF_CFDP_R_DispatchRecv(arg_t, dummy_ph, &arg_fns, arg_fd_fn); /* Assert */ UtAssert_STUB_COUNT(FGV, 1); @@ -3345,19 +3344,17 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreNotSetAnd_directive_code_IsEqTo void) { /* Arrange */ - CF_UT_inmsg_buffer_t dummy_msg; - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - static void (*const arg_fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t * t, const CF_CFDP_PduHeader_t *) = {{NULL}}; - void (*const arg_fd_fn)(CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = Dummy_fd_fn; - uint16 initial_spurious = Any_uint16(); + CF_UT_inmsg_buffer_t dummy_msg; + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + static CF_CFDP_R_SubstateDispatchTable_t arg_fns = {{NULL}}; + CF_CFDP_StateRecvFunc_t arg_fd_fn = Dummy_fd_fn; + uint16 initial_spurious = Any_uint16(); memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.r.sub_state = Any_uint8_LessThan(CF_RxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; UT_SetDefaultReturnValue(UT_KEY(FGV), 0); @@ -3370,7 +3367,7 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreNotSetAnd_directive_code_IsEqTo arg_t->history = &dummy_history; /* Act */ - CF_CFDP_R_DispatchRecv(arg_t, arg_fns, arg_fd_fn); + CF_CFDP_R_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns, arg_fd_fn); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.spurious == (uint16)(initial_spurious + 1), @@ -3388,19 +3385,17 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreNotSetAnd_directive_code_IsGrea void) { /* Arrange */ - CF_UT_inmsg_buffer_t dummy_msg; - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - static void (*const arg_fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t * t, const CF_CFDP_PduHeader_t *) = {{NULL}}; - void (*const arg_fd_fn)(CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = Dummy_fd_fn; - uint16 initial_spurious = Any_uint16(); + CF_UT_inmsg_buffer_t dummy_msg; + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + static CF_CFDP_R_SubstateDispatchTable_t arg_fns = {{NULL}}; + CF_CFDP_StateRecvFunc_t arg_fd_fn = Dummy_fd_fn; + uint16 initial_spurious = Any_uint16(); memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.r.sub_state = Any_uint8_LessThan(CF_RxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; UT_SetDefaultReturnValue(UT_KEY(FGV), 0); @@ -3414,7 +3409,7 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreNotSetAnd_directive_code_IsGrea arg_t->history = &dummy_history; /* Act */ - CF_CFDP_R_DispatchRecv(arg_t, arg_fns, arg_fd_fn); + CF_CFDP_R_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns, arg_fd_fn); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.spurious == (uint16)(initial_spurious + 1), @@ -3432,19 +3427,17 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreNotSetAnd_directive_code_IsLess void) { /* Arrange */ - CF_UT_inmsg_buffer_t dummy_msg; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - static void (*const arg_fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t * t, const CF_CFDP_PduHeader_t *) = {{NULL}}; - void (*const arg_fd_fn)(CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = Dummy_fd_fn; - uint16 initial_dropped = Any_uint16(); - uint16 initial_spurious = Any_uint16(); + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + static CF_CFDP_R_SubstateDispatchTable_t arg_fns = {{NULL}}; + CF_CFDP_StateRecvFunc_t arg_fd_fn = Dummy_fd_fn; + uint16 initial_dropped = Any_uint16(); + uint16 initial_spurious = Any_uint16(); memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.r.sub_state = Any_uint8_LessThan(CF_RxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; UT_SetDefaultReturnValue(UT_KEY(FGV), 0); UT_SetDefaultReturnValue(UT_KEY(CF_HeaderSize), sizeof(CF_CFDP_PduHeader_t)); @@ -3456,7 +3449,7 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreNotSetAnd_directive_code_IsLess CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.spurious = initial_spurious; /* Act */ - CF_CFDP_R_DispatchRecv(arg_t, arg_fns, arg_fd_fn); + CF_CFDP_R_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns, arg_fd_fn); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.dropped == initial_dropped, @@ -3474,34 +3467,34 @@ void Test_CFDP_RTest_CFDP_R_DispatchRecv_FlagsAreNotSetAnd_directive_code_IsLess void) { /* Arrange */ - CF_UT_inmsg_buffer_t dummy_msg; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - void (*const arg_fns[CF_RxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])(CF_Transaction_t * t, - const CF_CFDP_PduHeader_t *); - void (*const arg_fd_fn)(CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = Dummy_fd_fn; - CF_RxSubState_t dummy_state = Any_uint8_LessThan(CF_RxSubState_NUM_STATES); - uint8 dummy_directive_code = Any_uint8_LessThan(CF_CFDP_FileDirective_INVALID_MAX); - void (*const fns_pointer)(CF_Transaction_t * t, const CF_CFDP_PduHeader_t *pdu) = Dummy_fns; - Dummy_fns_context_t context_Dummy_fns; + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + CF_CFDP_R_SubstateDispatchTable_t arg_fns = {{NULL}}; + CF_CFDP_FileDirectiveDispatchTable_t fd_fns = {NULL}; + CF_CFDP_StateRecvFunc_t arg_fd_fn = Dummy_fd_fn; + CF_RxSubState_t dummy_state = Any_uint8_LessThan(CF_RxSubState_NUM_STATES); + uint8 dummy_directive_code = Any_uint8_LessThan(CF_CFDP_FileDirective_INVALID_MAX); + CF_CFDP_StateRecvFunc_t fns_pointer = Dummy_fns; + Dummy_fns_context_t context_Dummy_fns; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.r.sub_state = Any_uint8_LessThan(CF_RxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; UT_SetDefaultReturnValue(UT_KEY(FGV), 0); UT_SetDefaultReturnValue(UT_KEY(CF_HeaderSize), sizeof(CF_CFDP_PduHeader_t)); dummy_msg.content.cfdp.secondary.fdirh.directive_code = dummy_directive_code; - arg_t->state_data.r.sub_state = dummy_state; - memcpy((void *)&arg_fns[dummy_state][dummy_directive_code], &fns_pointer, sizeof(void *)); + arg_t->state_data.r.sub_state = dummy_state; + arg_fns.state[dummy_state] = &fd_fns; + fd_fns.fdirective[dummy_directive_code] = fns_pointer; UT_SetDataBuffer(UT_KEY(Dummy_fns), &context_Dummy_fns, sizeof(context_Dummy_fns), false); /* Act */ - CF_CFDP_R_DispatchRecv(arg_t, arg_fns, arg_fd_fn); + CF_CFDP_R_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns, arg_fd_fn); /* Assert */ UtAssert_STUB_COUNT(Dummy_fns, 1); @@ -3537,7 +3530,6 @@ void Test_CF_CFDP_R1_Recv_Runs(void) arg_t->state_data.r.sub_state = Any_uint8_LessThan( CF_RxSubState_NUM_STATES); /* Any_uint8_LessThan used because small size of CF_RxSubState_NUM_STATES*/ - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; arg_t->history = &dummy_history; arg_t->history->cc = @@ -3550,7 +3542,7 @@ void Test_CF_CFDP_R1_Recv_Runs(void) UT_SetDefaultReturnValue(UT_KEY(FGV), 1); /* 1 force else */ /* Act */ - CF_CFDP_R1_Recv(arg_t); + CF_CFDP_R1_Recv(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ /* Assert for CF_CFDP_R_DispatchRecv */ @@ -3586,7 +3578,6 @@ void Test_CF_CFDP_R2_Recv_Runs(void) arg_t->state_data.r.sub_state = Any_uint8_LessThan( CF_RxSubState_NUM_STATES); /* Any_uint8_LessThan used because small size of CF_RxSubState_NUM_STATES*/ - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; arg_t->history = &dummy_history; arg_t->history->cc = @@ -3599,7 +3590,7 @@ void Test_CF_CFDP_R2_Recv_Runs(void) UT_SetDefaultReturnValue(UT_KEY(FGV), 1); /* 1 force else */ /* Act */ - CF_CFDP_R2_Recv(arg_t); + CF_CFDP_R2_Recv(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ /* Assert for CF_CFDP_R_DispatchRecv */ diff --git a/unit-test/cf_cfdp_s_tests.c b/unit-test/cf_cfdp_s_tests.c index 82606e1a..63e87600 100644 --- a/unit-test/cf_cfdp_s_tests.c +++ b/unit-test/cf_cfdp_s_tests.c @@ -70,7 +70,7 @@ void Dummy_fns_CF_CFDP_S_DispatchRecv(CF_Transaction_t* t, const CF_CFDP_PduHead UT_GenStub_Execute(Stub_FGV, Basic, NULL); } */ -void Dummy_fns_CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, const CF_CFDP_PduHeader_t *pdu) +void Dummy_fns_CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *pdu) { UT_Stub_CopyFromLocal(UT_KEY(Dummy_fns_CF_CFDP_S_DispatchRecv), &t, sizeof(t)); UT_Stub_CopyFromLocal(UT_KEY(Dummy_fns_CF_CFDP_S_DispatchRecv), &pdu, sizeof(pdu)); @@ -2067,8 +2067,8 @@ void Test_CF_CFDP_S2_EarlyFin_SendEventAndCallReset(void) CF_History_t dummy_history; CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - const CF_CFDP_PduHeader_t dummy_ph; - const CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; + CF_CFDP_PduHeader_t dummy_ph; + CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; const char *expected_Spec = "CF S%d(%u:%u): got early fin -- cancelling"; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; @@ -2115,12 +2115,12 @@ void Test_CF_CFDP_S2_EarlyFin_SendEventAndCallReset(void) void Test_CF_CFDP_S2_Fin_When_CF_CFDP_RecvFin_Returns_0_Set_fin_cc_And_sub_state(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - uint8 dummy_flags = Any_uint8(); - const CF_CFDP_PduHeader_t dummy_ph; - const CF_CFDP_PduHeader_t *arg_ph; - uint8 expected_fin_cc = FGV(dummy_flags, CF_CFDP_PduFin_FLAGS_CC); + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + uint8 dummy_flags = Any_uint8(); + CF_CFDP_PduHeader_t dummy_ph; + CF_CFDP_PduHeader_t *arg_ph; + uint8 expected_fin_cc = FGV(dummy_flags, CF_CFDP_PduFin_FLAGS_CC); memcpy((void *)&dummy_ph.flags, &dummy_flags, 1); arg_ph = &dummy_ph; @@ -2148,8 +2148,8 @@ void Test_CF_CFDP_S2_Fin_When_CF_CFDP_RecvFin_DoesNotReturn_0_SendEventAndCountR CF_History_t dummy_history; CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - const CF_CFDP_PduHeader_t dummy_ph; - const CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; + CF_CFDP_PduHeader_t dummy_ph; + CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; uint32 initial_recv_error = Any_uint32(); const char *expected_Spec = "CF S%d(%u:%u): received invalid fin pdu"; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; @@ -2198,13 +2198,15 @@ void Test_CF_CFDP_S2_Nak_CallTo_CF_CFDP_RecvNak_Returns_neg1_SendEventAndIncreme CF_History_t dummy_history; CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - CF_CFDP_PduNak_t dummy_ph; - CF_CFDP_PduHeader_t *arg_ph = (CF_CFDP_PduHeader_t *)&dummy_ph; + CF_UT_inmsg_buffer_t dummy_msg; + CF_CFDP_PduHeader_t *arg_ph = &dummy_msg.pdu_r_msg.ph; uint32 initial_recv_error = Any_uint32(); const char *expected_Spec = "CF S%d(%u:%u): received invalid nak pdu"; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; int context_CF_CFDP_RecvNak_forced_num_sr = Any_int(); + memset(&dummy_msg, 0, sizeof(dummy_msg)); + arg_t->history = &dummy_history; arg_t->chan_num = Any_cf_chan_num(); @@ -2242,13 +2244,15 @@ void Test_CF_CFDP_S2_Nak_CallTo_CF_CFDP_RecvNak_Returns_0_Set_num_sr_to_0_SendEv CF_History_t dummy_history; CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - CF_CFDP_PduNak_t dummy_ph; - CF_CFDP_PduHeader_t *arg_ph = (CF_CFDP_PduHeader_t *)&dummy_ph; + CF_UT_inmsg_buffer_t dummy_msg; + CF_CFDP_PduHeader_t *arg_ph = &dummy_msg.pdu_r_msg.ph; uint32 initial_recv_error = Any_uint32(); const char *expected_Spec = "CF S%d(%u:%u): received invalid nak pdu"; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; int context_CF_CFDP_RecvNak_forced_num_sr = 0; + memset(&dummy_msg, 0, sizeof(dummy_msg)); + arg_t->history = &dummy_history; arg_t->chan_num = Any_cf_chan_num(); @@ -2583,8 +2587,8 @@ void Test_CF_CFDP_S2_Nak_Arm_Call_CF_CFDP_ArmAckTimer_And_CF_CFDP_S2_Nak(void) CF_History_t dummy_history; CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - const CF_CFDP_PduHeader_t dummy_ph; - const CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; + CF_CFDP_PduHeader_t dummy_ph; + CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; uint32 initial_recv_error = Any_uint32(); int context_CF_CFDP_RecvNak_forced_num_sr = Any_int(); CF_Transaction_t *context_CF_CFDP_ArmAckTimer; @@ -2636,8 +2640,8 @@ void Test_CF_CFDP_S2_WaitForEofAck_CallTo_CF_CFDP_RecvAck_Returns_neg1_SendEvent CF_History_t dummy_history; CF_Transaction_t dummy_t; CF_Transaction_t *arg_t = &dummy_t; - const CF_CFDP_PduHeader_t dummy_ph; - const CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; + CF_CFDP_PduHeader_t dummy_ph; + CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; uint32 initial_recv_error = Any_uint32(); const char *expected_Spec = "CF S%d(%u:%u): received invalid eof pdu"; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; @@ -2674,11 +2678,11 @@ void Test_CF_CFDP_S2_WaitForEofAck_CallTo_CF_CFDP_RecvAck_Returns_0_And_t_histor void) { /* Arrange */ - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - const CF_CFDP_PduHeader_t dummy_ph; - const CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + CF_CFDP_PduHeader_t dummy_ph; + CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; arg_t->history = &dummy_history; arg_t->history->cc = CF_CFDP_ConditionCode_NO_ERROR; @@ -2707,11 +2711,11 @@ void Test_CF_CFDP_S2_WaitForEofAck_CallTo_CF_CFDP_RecvAck_Returns_0_And_t_histor void) { /* Arrange */ - CF_History_t dummy_history; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - const CF_CFDP_PduHeader_t dummy_ph; - const CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; + CF_History_t dummy_history; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + CF_CFDP_PduHeader_t dummy_ph; + CF_CFDP_PduHeader_t *arg_ph = &dummy_ph; arg_t->history = &dummy_history; arg_t->history->cc = Any_uint8_Except(CF_CFDP_ConditionCode_NO_ERROR); @@ -2765,27 +2769,26 @@ void Test_CF_CFDP_S_DispatchRecv_Asserts_msg_in_Is_NULL(void) void Test_CF_CFDP_S_DispatchRecv_AlreadyHas_pdu_ph_flags_SetSoSendEvent(void) { /* Arrange */ - CF_History_t dummy_history; - CF_UT_inmsg_buffer_t dummy_msg; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - const char *expected_Spec = "CF S%d(%u:%u): received non-file directive pdu"; - void *arg_fns = NULL; - CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; + CF_History_t dummy_history; + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + const char *expected_Spec = "CF S%d(%u:%u): received non-file directive pdu"; + CF_CFDP_S_SubstateRecvDispatchTable_t arg_fns = {{NULL}}; + CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; memset(&dummy_msg, 0, sizeof(dummy_msg)); + dummy_msg.pdu_r_msg.ph.flags = 0x10; /* pdu_type bit */ arg_t->state_data.s.sub_state = Any_uint8_LessThan(CF_TxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - UT_SetDefaultReturnValue(UT_KEY(FGV), 1); UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); arg_t->history = &dummy_history; /* Act */ - CF_CFDP_S_DispatchRecv(arg_t, arg_fns); + CF_CFDP_S_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -2812,15 +2815,13 @@ void Test_CF_CFDP_S_DispatchRecv_DidNotHaveFlagsSetBut_fdh_directive_code_IsEqTo uint8 dummy_flags = CF_CFDP_FileDirective_INVALID_MAX; uint16 initial_recv_spurious = Any_uint16(); const char *expected_Spec = "CF S%d(%u:%u): received pdu with invalid directive code %d for sub-state %d"; - void *arg_fns = NULL; - CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; + CF_CFDP_S_SubstateRecvDispatchTable_t arg_fns = {{NULL}}; + CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.s.sub_state = Any_uint8_LessThan(CF_TxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - UT_SetDefaultReturnValue(UT_KEY(FGV), 0); dummy_msg.pdu_r_msg.ph.flags = dummy_flags; @@ -2832,7 +2833,7 @@ void Test_CF_CFDP_S_DispatchRecv_DidNotHaveFlagsSetBut_fdh_directive_code_IsEqTo arg_t->history = &dummy_history; /* Act */ - CF_CFDP_S_DispatchRecv(arg_t, arg_fns); + CF_CFDP_S_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[dummy_chan_num].counters.recv.spurious == @@ -2865,15 +2866,13 @@ void Test_CF_CFDP_S_DispatchRecv_DidNotHaveFlagsSetBut_fdh_directive_code_IsGrea uint8 dummy_flags = Any_uint8_GreaterThan(CF_CFDP_FileDirective_INVALID_MAX); uint16 initial_recv_spurious = Any_uint16(); const char *expected_Spec = "CF S%d(%u:%u): received pdu with invalid directive code %d for sub-state %d"; - void *arg_fns = NULL; - CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; + CF_CFDP_S_SubstateRecvDispatchTable_t arg_fns = {{NULL}}; + CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.s.sub_state = Any_uint8_LessThan(CF_TxSubState_NUM_STATES); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - UT_SetDefaultReturnValue(UT_KEY(FGV), 0); dummy_msg.pdu_r_msg.ph.flags = dummy_flags; @@ -2885,7 +2884,7 @@ void Test_CF_CFDP_S_DispatchRecv_DidNotHaveFlagsSetBut_fdh_directive_code_IsGrea arg_t->history = &dummy_history; /* Act */ - CF_CFDP_S_DispatchRecv(arg_t, arg_fns); + CF_CFDP_S_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[dummy_chan_num].counters.recv.spurious == @@ -2910,29 +2909,19 @@ void Test_CF_CFDP_S_DispatchRecv_Received_msg_ph_As_fdh_Has_flags_LessThan_PDU_I void) { /* Arrange */ - CF_UT_inmsg_buffer_t dummy_msg; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - uint8 dummy_chan_num = Any_cf_chan_num(); - uint8 dummy_sub_state = 0; /* 0 = always choose Dummy_fns_CF_CFDP_S_DispatchRecv */ - uint8 dummy_flags = 0; /* 0 = always choose Dummy_fns_CF_CFDP_S_DispatchRecv */ - uint16 initial_recv_spurious = Any_uint16(); - void (*const arg_fns[CF_TxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])(CF_Transaction_t *, - const CF_CFDP_PduHeader_t *) = { - {Dummy_fns_CF_CFDP_S_DispatchRecv, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL}, /* CF_TxSubState_METADATA */ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, /* CF_TxSubState_FILEDATA */ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, /* CF_TxSubState_EOF */ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, /* CF_TxSubState_WAIT_FOR_EOF_ACK */ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, /* CF_TxSubState_WAIT_FOR_FIN */ - {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, /* CF_TxSubState_SEND_FIN_ACK */ - }; + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + uint8 dummy_chan_num = Any_cf_chan_num(); + uint8 dummy_sub_state = 0; /* 0 = always choose Dummy_fns_CF_CFDP_S_DispatchRecv */ + uint8 dummy_flags = 0; /* 0 = always choose Dummy_fns_CF_CFDP_S_DispatchRecv */ + uint16 initial_recv_spurious = Any_uint16(); + CF_CFDP_FileDirectiveDispatchTable_t fd_tbl = {.fdirective = {[0] = Dummy_fns_CF_CFDP_S_DispatchRecv}}; + CF_CFDP_S_SubstateRecvDispatchTable_t arg_fns = {.substate = {[0] = &fd_tbl}}; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.s.sub_state = dummy_sub_state; - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - UT_SetDefaultReturnValue(UT_KEY(FGV), 0); dummy_msg.pdu_r_msg.ph.flags = dummy_flags; @@ -2941,7 +2930,7 @@ void Test_CF_CFDP_S_DispatchRecv_Received_msg_ph_As_fdh_Has_flags_LessThan_PDU_I CF_AppData.hk.channel_hk[dummy_chan_num].counters.recv.spurious = initial_recv_spurious; /* Act */ - CF_CFDP_S_DispatchRecv(arg_t, arg_fns); + CF_CFDP_S_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns); /* Assert */ UtAssert_STUB_COUNT(Dummy_fns_CF_CFDP_S_DispatchRecv, 1); @@ -2956,22 +2945,19 @@ void Test_CF_CFDP_S_DispatchRecv_Received_msg_ph_As_fdh_Has_flags_LessThan_PDU_I void Test_CF_CFDP_S_DispatchRecv_Received_msg_ph_As_fdh_Has_flags_LessThan_PDU_INVALID_MAX_But_fns_NULL_DoNothing(void) { /* Arrange */ - CF_UT_inmsg_buffer_t dummy_msg; - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - uint8 dummy_chan_num = Any_cf_chan_num(); - uint8 dummy_sub_state = Any_uint8_LessThan(CF_TxSubState_NUM_STATES); - uint8 dummy_flags = Any_uint8_LessThan(CF_CFDP_FileDirective_INVALID_MAX); - uint16 initial_recv_spurious = Any_uint16(); - void (*const arg_fns[CF_TxSubState_NUM_STATES][CF_CFDP_FileDirective_INVALID_MAX])( - CF_Transaction_t *, const CF_CFDP_PduHeader_t *) = {{NULL}}; + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + uint8 dummy_chan_num = Any_cf_chan_num(); + uint8 dummy_sub_state = Any_uint8_LessThan(CF_TxSubState_NUM_STATES); + uint8 dummy_flags = Any_uint8_LessThan(CF_CFDP_FileDirective_INVALID_MAX); + uint16 initial_recv_spurious = Any_uint16(); + CF_CFDP_S_SubstateRecvDispatchTable_t arg_fns = {{NULL}}; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state_data.s.sub_state = dummy_sub_state; - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - UT_SetDefaultReturnValue(UT_KEY(FGV), 0); dummy_msg.pdu_r_msg.ph.flags = dummy_flags; @@ -2980,7 +2966,7 @@ void Test_CF_CFDP_S_DispatchRecv_Received_msg_ph_As_fdh_Has_flags_LessThan_PDU_I CF_AppData.hk.channel_hk[dummy_chan_num].counters.recv.spurious = initial_recv_spurious; /* Act */ - CF_CFDP_S_DispatchRecv(arg_t, arg_fns); + CF_CFDP_S_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph, &arg_fns); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[dummy_chan_num].counters.recv.spurious == initial_recv_spurious, @@ -3014,8 +3000,6 @@ void Test_CF_CFDP_S1_Recv_SendsAll_NULL_fns_To_CF_CFDP_S_DispatchRecv(void) arg_t->state_data.s.sub_state = dummy_sub_state; - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - UT_SetDefaultReturnValue(UT_KEY(FGV), 0); dummy_msg.pdu_r_msg.ph.flags = dummy_flags; @@ -3024,7 +3008,7 @@ void Test_CF_CFDP_S1_Recv_SendsAll_NULL_fns_To_CF_CFDP_S_DispatchRecv(void) CF_AppData.hk.channel_hk[dummy_chan_num].counters.recv.spurious = initial_recv_spurious; /* Act */ - CF_CFDP_S1_Recv(arg_t); + CF_CFDP_S1_Recv(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ /* Assert for CF_CFDP_S_DispatchRecv */ @@ -3075,8 +3059,6 @@ void Test_CF_CFDP_S2_Recv_Call_CF_CFDP_S_DispatchRecv(void) arg_t->state_data.s.sub_state = dummy_sub_state; - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - UT_SetDefaultReturnValue(UT_KEY(FGV), 0); dummy_msg.pdu_r_msg.ph.flags = dummy_flags; @@ -3085,7 +3067,7 @@ void Test_CF_CFDP_S2_Recv_Call_CF_CFDP_S_DispatchRecv(void) CF_AppData.hk.channel_hk[dummy_chan_num].counters.recv.spurious = initial_recv_spurious; /* Act */ - CF_CFDP_S2_Recv(arg_t); + CF_CFDP_S2_Recv(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ /* Assert for CF_CFDP_S_DispatchRecv */ diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index e29111a6..6105c7c4 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -672,9 +672,12 @@ void Test_CF_CFDP_DispatchRecv_AssertsBecause_t_state_EqTo_CFDP_INVALID(void) void Test_CF_CFDP_DispatchRecv_WhenStateEq_CFDP_DROP_Call_CF_CFDP_RecvDrop(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - uint16 initial_recv_dropped = Any_uint16(); + CF_Transaction_t dummy_t; + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t *arg_t = &dummy_t; + uint16 initial_recv_dropped = Any_uint16(); + + memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_t->state = CF_TxnState_DROP; @@ -686,7 +689,7 @@ void Test_CF_CFDP_DispatchRecv_WhenStateEq_CFDP_DROP_Call_CF_CFDP_RecvDrop(void) CF_AppData.config_table = &dummy_config_table; /* Act */ - CF_CFDP_DispatchRecv(arg_t); + CF_CFDP_DispatchRecv(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.dropped == (uint16)(initial_recv_dropped + 1), @@ -1745,7 +1748,7 @@ void Test_CF_CFDP_Send_InitializeMsgTimestampsItAndSendsIt(void) // CF_AppData.engine.hdl = dummy_hdl; /* Act */ - CF_CFDP_Send(arg_chan_num, arg_len); + CF_CFDP_Send(arg_chan_num, &expected_msg.pdu_s_msg.ph, arg_len); uint32 resultant_pdu = CF_AppData.hk.channel_hk[arg_chan_num].counters.sent.pdu; @@ -2230,13 +2233,16 @@ void Test_CF_CFDP_SendMd_Return_CF_SEND_SUCCESS(void) void Test_CF_CFDP_SendFd_When_len_GreaterThan_sizeof_pdu_pd_data_t_Return_CF_SEND_ERROR(void) { /* Arrange */ - CF_Transaction_t *arg_t = NULL; - uint32 arg_offset = Any_uint32(); - int arg_len = sizeof(CF_CFDP_PduFileDataContent_t) + 1; - CF_SendRet_t local_result; + CF_UT_outmsg_buffer_t dummy_msg; + CF_Transaction_t *arg_t = NULL; + uint32 arg_offset = Any_uint32(); + int arg_len = sizeof(CF_CFDP_PduFileDataContent_t) + 1; + CF_SendRet_t local_result; + + memset(&dummy_msg, 0, sizeof(dummy_msg)); /* Act */ - local_result = CF_CFDP_SendFd(arg_t, arg_offset, arg_len); + local_result = CF_CFDP_SendFd(arg_t, &dummy_msg.pdu_s_msg.ph, arg_offset, arg_len); /* Assert */ UtAssert_True(local_result == CF_SendRet_ERROR, "CF_CFDP_SendMd returned %u and should be %u (CF_SendRet_ERROR)", @@ -2264,7 +2270,7 @@ void Test_CF_CFDP_SendFd_Return_CF_SEND_SUCCESS(void) /* Arrange unstubbable: CF_CFDP_Send */ /* Act */ - local_result = CF_CFDP_SendFd(arg_t, arg_offset, arg_len); + local_result = CF_CFDP_SendFd(arg_t, &dummy_msg.pdu_s_msg.ph, arg_offset, arg_len); /* Assert */ UtAssert_True(local_result == CF_SendRet_SUCCESS, @@ -2786,7 +2792,7 @@ void Test_CF_CFDP_SendNak_Success_Return_CF_SEND_SUCCESS(void) arg_t->state = CF_TxnState_S2; /* ensures pass */ /* Act */ - local_result = CF_CFDP_SendNak(arg_t, arg_num_segment_requests); + local_result = CF_CFDP_SendNak(arg_t, &dummy_msg.pdu_s_msg.ph, arg_num_segment_requests); /* Assert */ UtAssert_True(local_result == CF_SendRet_SUCCESS, @@ -2823,6 +2829,7 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsLessThan_hsize_SendEventCount /* Arrange */ uint8 arg_chan_num = Any_cf_chan_num(); CF_UT_inmsg_buffer_t dummy_msg_in; + CF_CFDP_PduHeader_t *ph; int forced_return_CF_HeaderSize = Any_int_Positive(); /* Any_int_Positive() used because this is what the CUT sees, in practice this will be relatively small I, ASG, would think */ @@ -2834,8 +2841,6 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsLessThan_hsize_SendEventCount memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; - UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &forced_return_CF_HeaderSize); UT_SetHandlerFunction(UT_KEY(CFE_SB_GetUserDataLength), Handler_size_t_ForcedReturnOnly, @@ -2845,7 +2850,7 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsLessThan_hsize_SendEventCount CF_AppData.hk.channel_hk[arg_chan_num].counters.recv.error = expected_counters_recv_error - 1; /* Act */ - local_result = CF_CFDP_RecvPh(arg_chan_num); + local_result = CF_CFDP_RecvPh(arg_chan_num, &dummy_msg_in.cfe_sb_buffer, &ph); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_RecvPh returned %d and should be -1", local_result); @@ -2862,6 +2867,7 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsEqTo_hsize_CallTo_CF_GetVaria /* Arrange */ uint8 arg_chan_num = Any_cf_chan_num(); CF_UT_inmsg_buffer_t dummy_msg_in; + CF_CFDP_PduHeader_t *ph; int forced_return_CF_HeaderSize = Any_int_Positive(); /* Any_int_Positive() used because this is what the CUT sees, in practice this will be relatively small I, ASG, would think */ @@ -2874,8 +2880,6 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsEqTo_hsize_CallTo_CF_GetVaria memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; - UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &forced_return_CF_HeaderSize); UT_SetHandlerFunction(UT_KEY(CFE_SB_GetUserDataLength), Handler_size_t_ForcedReturnOnly, @@ -2888,7 +2892,7 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsEqTo_hsize_CallTo_CF_GetVaria &forced_return_CF_GetVariableHeader); /* Act */ - local_result = CF_CFDP_RecvPh(arg_chan_num); + local_result = CF_CFDP_RecvPh(arg_chan_num, &dummy_msg_in.cfe_sb_buffer, &ph); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_RecvPh returned %d and should be -1", local_result); @@ -2907,6 +2911,7 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsGreaterThan_hsize_CallTo_CF_G /* Arrange */ uint8 arg_chan_num = Any_cf_chan_num(); CF_UT_inmsg_buffer_t dummy_msg_in; + CF_CFDP_PduHeader_t *ph; int forced_return_CF_HeaderSize = Any_int_Positive(); /* Any_int_Positive() used because this is what the CUT sees, in practice this will be relatively small I, ASG, would think */ @@ -2919,8 +2924,6 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsGreaterThan_hsize_CallTo_CF_G memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; - UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &forced_return_CF_HeaderSize); UT_SetHandlerFunction(UT_KEY(CFE_SB_GetUserDataLength), Handler_size_t_ForcedReturnOnly, @@ -2933,7 +2936,7 @@ void Test_CF_CFDP_RecvPh_NumberOf_bytes_recieved_IsGreaterThan_hsize_CallTo_CF_G &forced_return_CF_GetVariableHeader); /* Act */ - local_result = CF_CFDP_RecvPh(arg_chan_num); + local_result = CF_CFDP_RecvPh(arg_chan_num, &dummy_msg_in.cfe_sb_buffer, &ph); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_RecvPh returned %d and should be -1", local_result); @@ -2951,6 +2954,7 @@ void Test_CF_CFDP_RecvPh_ValueOf_temp_Plus_hsize_DoesNotEq_bytes_received_SendEv /* Arrange */ uint8 arg_chan_num = Any_cf_chan_num(); CF_UT_inmsg_buffer_t dummy_msg_in; + CF_CFDP_PduHeader_t *ph; int forced_return_CF_HeaderSize = Any_int_Positive(); /* Any_int_Positive() used because this is what the CUT sees, in practice this will be relatively small I, ASG, would think */ @@ -2964,8 +2968,6 @@ void Test_CF_CFDP_RecvPh_ValueOf_temp_Plus_hsize_DoesNotEq_bytes_received_SendEv memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; - UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &forced_return_CF_HeaderSize); UT_SetHandlerFunction(UT_KEY(CFE_SB_GetUserDataLength), Handler_size_t_ForcedReturnOnly, @@ -2982,7 +2984,7 @@ void Test_CF_CFDP_RecvPh_ValueOf_temp_Plus_hsize_DoesNotEq_bytes_received_SendEv forced_return_CF_HeaderSize)); /* ensures (temp+hsize)!=CF_AppData.engine.in.bytes_received */ /* Act */ - local_result = CF_CFDP_RecvPh(arg_chan_num); + local_result = CF_CFDP_RecvPh(arg_chan_num, &dummy_msg_in.cfe_sb_buffer, &ph); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_RecvPh returned %d and should be -1", local_result); @@ -2998,6 +3000,7 @@ void Test_CF_CFDP_RecvPh_ValueOf_temp_Plus_hsize_NotEq_bytes_received_Count_pdu_ /* Arrange */ uint8 arg_chan_num = Any_cf_chan_num(); CF_UT_inmsg_buffer_t dummy_msg_in; + CF_CFDP_PduHeader_t *ph; int forced_return_CF_HeaderSize = Any_int_Positive(); /* Any_int_Positive() used because this is what the CUT sees, in practice this will be relatively small I, ASG, would think */ @@ -3011,8 +3014,6 @@ void Test_CF_CFDP_RecvPh_ValueOf_temp_Plus_hsize_NotEq_bytes_received_Count_pdu_ memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; - UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &forced_return_CF_HeaderSize); UT_SetHandlerFunction(UT_KEY(CFE_SB_GetUserDataLength), Handler_size_t_ForcedReturnOnly, @@ -3029,7 +3030,7 @@ void Test_CF_CFDP_RecvPh_ValueOf_temp_Plus_hsize_NotEq_bytes_received_Count_pdu_ forced_return_CF_HeaderSize; /* ensures equality so (temp+hsize)==CF_AppData.engine.in.bytes_received */ /* Act */ - local_result = CF_CFDP_RecvPh(arg_chan_num); + local_result = CF_CFDP_RecvPh(arg_chan_num, &dummy_msg_in.cfe_sb_buffer, &ph); /* Assert */ UtAssert_True(local_result == 0, "CF_CFDP_RecvPh returned %d and should be 0", local_result); @@ -3073,8 +3074,6 @@ void Test_CF_CFDP_RecvMd_Has_bytes_received_LessThan_sizof_ph_Plus_size_of_pdu_m memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; - CF_AppData.engine.in.bytes_received = Any_uint32_LessThan(sizeof(CF_CFDP_PduMd_t)); UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); @@ -3083,7 +3082,7 @@ void Test_CF_CFDP_RecvMd_Has_bytes_received_LessThan_sizof_ph_Plus_size_of_pdu_m CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.error = expected_counters_recv_error - 1; /* Act */ - local_result = CF_CFDP_RecvMd(arg_t); + local_result = CF_CFDP_RecvMd(arg_t, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_RecvMd returned %d and should be -1", local_result); @@ -3118,8 +3117,7 @@ void Test_CF_CFDP_RecvMd_HasFirst_lv_ret_LessThan_0_SendsEventCountErrorAndRetur memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - dummy_md = &dummy_msg.content.cfdp.secondary.md; + dummy_md = &dummy_msg.content.cfdp.secondary.md; CF_AppData.engine.in.bytes_received = sizeof(CF_CFDP_PduMd_t) + force_return_CF_HeaderSize; UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); @@ -3137,7 +3135,7 @@ void Test_CF_CFDP_RecvMd_HasFirst_lv_ret_LessThan_0_SendsEventCountErrorAndRetur CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.error = expected_counters_recv_error - 1; /* Act */ - local_result = CF_CFDP_RecvMd(arg_t); + local_result = CF_CFDP_RecvMd(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_RecvMd returned %d and should be -1", local_result); @@ -3169,8 +3167,7 @@ void Test_CF_CFDP_RecvMd_HasSecond_lv_ret_LessThan_0_BecauseLengthEqSizeSendEven memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - dummy_md = &dummy_msg.content.cfdp.secondary.md; + dummy_md = &dummy_msg.content.cfdp.secondary.md; CF_AppData.engine.in.bytes_received = sizeof(CF_CFDP_PduMd_t) + force_return_CF_HeaderSize; UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); @@ -3189,7 +3186,7 @@ void Test_CF_CFDP_RecvMd_HasSecond_lv_ret_LessThan_0_BecauseLengthEqSizeSendEven CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.error = expected_counters_recv_error - 1; /* Act */ - local_result = CF_CFDP_RecvMd(arg_t); + local_result = CF_CFDP_RecvMd(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_RecvMd returned %d and should be -1", local_result); @@ -3221,8 +3218,7 @@ void Test_CF_CFDP_RecvMd_WhenNoErrorConditions_SendEventAndReturn_0(void) memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - dummy_md = &dummy_msg.content.cfdp.secondary.md; + dummy_md = &dummy_msg.content.cfdp.secondary.md; CF_AppData.engine.in.bytes_received = sizeof(CF_CFDP_PduMd_t) + force_return_CF_HeaderSize; UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); @@ -3241,7 +3237,7 @@ void Test_CF_CFDP_RecvMd_WhenNoErrorConditions_SendEventAndReturn_0(void) CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.error = initial_counters_recv_error; /* Act */ - local_result = CF_CFDP_RecvMd(arg_t); + local_result = CF_CFDP_RecvMd(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_True(local_result == 0, "CF_CFDP_RecvMd returned %d and should be 0", local_result); @@ -3289,7 +3285,6 @@ void Test_CF_CFDP_RecvFd_When_bytes_received_LessThan_sizeof_pdu_file_data_heade memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = Any_uint32_LessThan( force_return_CF_HeaderSize + sizeof(CF_CFDP_PduFileDataHeader_t)); // TODO Any_CFE_MSG_Size_t_LessThan(); @@ -3300,7 +3295,7 @@ void Test_CF_CFDP_RecvFd_When_bytes_received_LessThan_sizeof_pdu_file_data_heade UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); /* Act */ - local_result = CF_CFDP_RecvFd(arg_t); + local_result = CF_CFDP_RecvFd(arg_t, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -3333,7 +3328,6 @@ void Test_CF_CFDP_RecvFd_When_bytes_received_EqTo_sizeof_pdu_file_data_header_t_ memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = force_return_CF_HeaderSize + sizeof(CF_CFDP_PduFileDataHeader_t); arg_t->chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); @@ -3343,7 +3337,7 @@ void Test_CF_CFDP_RecvFd_When_bytes_received_EqTo_sizeof_pdu_file_data_header_t_ UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); /* Act */ - local_result = CF_CFDP_RecvFd(arg_t); + local_result = CF_CFDP_RecvFd(arg_t, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -3365,7 +3359,6 @@ void Test_CF_CFDP_RecvFd_When_bytes_received_GreaterThan_sizeof_pdu_file_data_he memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = Any_uint32_GreaterThan(force_return_CF_HeaderSize + sizeof(CF_CFDP_PduFileDataHeader_t)); @@ -3376,7 +3369,7 @@ void Test_CF_CFDP_RecvFd_When_bytes_received_GreaterThan_sizeof_pdu_file_data_he UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); /* Act */ - local_result = CF_CFDP_RecvFd(arg_t); + local_result = CF_CFDP_RecvFd(arg_t, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -3405,6 +3398,7 @@ void Test_CF_CFDP_RecvEof_AssertsBecause_CF_AppData_engine_msg_in_Is_NULL(void) void Test_CF_CFDP_RecvEof_When_bytes_received_LessThan_offsetof_pdu_eof_t_fault_location_Returns_neg1_Fail(void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; const char *expected_Spec = "CF: eof pdu too short: %d bytes received"; int force_return_CF_HeaderSize = @@ -3412,8 +3406,8 @@ void Test_CF_CFDP_RecvEof_When_bytes_received_LessThan_offsetof_pdu_eof_t_fault_ int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = Any_uint32_LessThan(force_return_CF_HeaderSize + offsetof(CF_CFDP_PduEof_t, fault_location)); @@ -3422,7 +3416,7 @@ void Test_CF_CFDP_RecvEof_When_bytes_received_LessThan_offsetof_pdu_eof_t_fault_ UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvEof(); + local_result = CF_CFDP_RecvEof(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -3442,14 +3436,15 @@ void Test_CF_CFDP_RecvEof_BytesReceivedEq_offsetof_fault_location_Calls_cfdp_get void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; int force_return_CF_HeaderSize = Any_uint8_Except(0); /* Any_uint8_Except(0) for positive result with reasonably expected size */ int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = force_return_CF_HeaderSize + offsetof(CF_CFDP_PduEof_t, fault_location); UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); @@ -3457,7 +3452,7 @@ void Test_CF_CFDP_RecvEof_BytesReceivedEq_offsetof_fault_location_Calls_cfdp_get UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvEof(); + local_result = CF_CFDP_RecvEof(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -3470,14 +3465,15 @@ void Test_CF_CFDP_RecvEof_BytesReceivedGreaterThan_offsetof_fault_location_Calls void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; int force_return_CF_HeaderSize = Any_uint8_Except(0); /* Any_uint8_Except(0) for positive result with reasonably expected size */ int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = Any_uint32_GreaterThan(force_return_CF_HeaderSize + offsetof(CF_CFDP_PduEof_t, fault_location)); @@ -3486,7 +3482,7 @@ void Test_CF_CFDP_RecvEof_BytesReceivedGreaterThan_offsetof_fault_location_Calls UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvEof(); + local_result = CF_CFDP_RecvEof(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -3514,19 +3510,20 @@ void Test_CF_CFDP_RecvAck_AssertsBecause_CF_AppData_engine_msg_in_Is_NULL(void) void Test_CF_CFDP_RecvAck_FailsBecause_bytes_received_LessThan_sizeof_pdu_ack_t_Returns_neg1(void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; const char *expected_Spec = "CF: ack pdu too short: %d bytes received"; int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = Any_uint32_LessThan(sizeof(CF_CFDP_PduAck_t)); // Any_CFE_MSG_Size_t(); UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvAck(); + local_result = CF_CFDP_RecvAck(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -3545,18 +3542,19 @@ void Test_CF_CFDP_RecvAck_FailsBecause_bytes_received_LessThan_sizeof_pdu_ack_t_ void Test_CF_CFDP_RecvAck_SuccessBecause_bytes_received_EqTo_sizeof_pdu_ack_t_Returns_0(void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = sizeof(CF_CFDP_PduAck_t); UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvAck(); + local_result = CF_CFDP_RecvAck(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -3566,18 +3564,19 @@ void Test_CF_CFDP_RecvAck_SuccessBecause_bytes_received_EqTo_sizeof_pdu_ack_t_Re void Test_CF_CFDP_RecvAck_SuccessBecause_bytes_received_GreaterThan_sizeof_pdu_ack_t_Returns_0(void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = Any_uint32_GreaterThan(sizeof(CF_CFDP_PduAck_t)); UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvAck(); + local_result = CF_CFDP_RecvAck(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -3603,19 +3602,20 @@ void Test_CF_CFDP_RecvFin_AssertsBecause_CF_AppData_engine_msg_in_Is_NULL(void) void Test_CF_CFDP_RecvFin_FailsBecause_bytes_received_IsLessThan_offsetof_pdu_fin_t_fault_location_Returns_neg1(void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; const char *expected_Spec = "CF: fin pdu too short: %d bytes received"; int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = Any_uint32_LessThan(offsetof(CF_CFDP_PduFin_t, fault_location)); UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvFin(); + local_result = CF_CFDP_RecvFin(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -3634,19 +3634,20 @@ void Test_CF_CFDP_RecvFin_FailsBecause_bytes_received_IsLessThan_offsetof_pdu_fi void Test_CF_CFDP_RecvFin_FailsBecause_bytes_received_Is_1_LessThan_offsetof_pdu_fin_t_fault_location_Returns_neg1(void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; const char *expected_Spec = "CF: fin pdu too short: %d bytes received"; int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = offsetof(CF_CFDP_PduFin_t, fault_location) - 1; UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvFin(); + local_result = CF_CFDP_RecvFin(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -3666,18 +3667,19 @@ void Test_CF_CFDP_RecvFin_FailsBecause_bytes_received_Is_1_LessThan_offsetof_pdu void Test_CF_CFDP_RecvFin_SuccessBecause_bytes_received_IsEqTo_offsetof_pdu_fin_t_fault_location_Returns_0(void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = offsetof(CF_CFDP_PduFin_t, fault_location); UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvFin(); + local_result = CF_CFDP_RecvFin(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -3687,18 +3689,19 @@ void Test_CF_CFDP_RecvFin_SuccessBecause_bytes_received_IsEqTo_offsetof_pdu_fin_ void Test_CF_CFDP_RecvFin_SuccessBecause_bytes_received_IsGreaterThan_offsetof_pdu_fin_t_fault_location_Returns_0(void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg_in; int local_result; memset(&dummy_msg_in, 0, sizeof(dummy_msg_in)); + memset(&ut_txn, 0, sizeof(ut_txn)); - CF_AppData.engine.in.msg = &dummy_msg_in.cfe_sb_buffer; CF_AppData.engine.in.bytes_received = Any_uint32_GreaterThan(offsetof(CF_CFDP_PduFin_t, fault_location)); UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvFin(); + local_result = CF_CFDP_RecvFin(&ut_txn, &dummy_msg_in.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -3733,6 +3736,7 @@ void Test_CF_CFDP_RecvNak_FailsBecause_bytes_received_IsLessThan_CF_HeaderSize_P void) { /* Arrange */ + CF_Transaction_t ut_txn; int dummy_num_segment_requests; int *arg_num_segment_requests = &dummy_num_segment_requests; CF_UT_inmsg_buffer_t dummy_pdu_msg; @@ -3741,8 +3745,7 @@ void Test_CF_CFDP_RecvNak_FailsBecause_bytes_received_IsLessThan_CF_HeaderSize_P int local_result; memset(&dummy_pdu_msg, 0, sizeof(dummy_pdu_msg)); - - CF_AppData.engine.in.msg = &dummy_pdu_msg.cfe_sb_buffer; + memset(&ut_txn, 0, sizeof(ut_txn)); CF_AppData.engine.in.bytes_received = Any_uint32_LessThan(force_return_CF_HeaderSize + offsetof(CF_CFDP_PduNak_t, segment_requests)); @@ -3751,7 +3754,7 @@ void Test_CF_CFDP_RecvNak_FailsBecause_bytes_received_IsLessThan_CF_HeaderSize_P UT_SetHookFunction(UT_KEY(CFE_EVS_SendEvent), stub_reporter, &context_CFE_EVS_SendEvent); /* Act */ - local_result = CF_CFDP_RecvNak(arg_num_segment_requests); + local_result = CF_CFDP_RecvNak(&ut_txn, &dummy_pdu_msg.pdu_r_msg.ph, arg_num_segment_requests); /* Assert */ UtAssert_True(local_result == -1, "CF_CFDP_RecvAck returned %d and should be -1", local_result); @@ -3770,6 +3773,7 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg; int dummy_num_segment_requests; int *arg_num_segment_requests = &dummy_num_segment_requests; @@ -3782,14 +3786,13 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ int local_result; memset(&dummy_msg, 0, sizeof(dummy_msg)); - - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + memset(&ut_txn, 0, sizeof(ut_txn)); CF_AppData.engine.in.bytes_received = force_return_CF_HeaderSize + offsetof(CF_CFDP_PduNak_t, segment_requests[1]); UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); /* Act */ - local_result = CF_CFDP_RecvNak(arg_num_segment_requests); + local_result = CF_CFDP_RecvNak(&ut_txn, &dummy_msg.pdu_r_msg.ph, arg_num_segment_requests); /* Assert */ UtAssert_True(local_result == 0, "CF_CFDP_RecvAck returned %d and should be 0", local_result); @@ -3804,6 +3807,7 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg; int dummy_num_segment_requests; int *arg_num_segment_requests = &dummy_num_segment_requests; @@ -3816,14 +3820,14 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ int local_result; memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + memset(&ut_txn, 0, sizeof(ut_txn)); CF_AppData.engine.in.bytes_received = force_return_CF_HeaderSize + offsetof(CF_CFDP_PduNak_t, segment_requests[CF_NAK_MAX_SEGMENTS - 1]); UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); /* Act */ - local_result = CF_CFDP_RecvNak(arg_num_segment_requests); + local_result = CF_CFDP_RecvNak(&ut_txn, &dummy_msg.pdu_r_msg.ph, arg_num_segment_requests); /* Assert */ UtAssert_True(local_result == 0, "CF_CFDP_RecvAck returned %d and should be 0", local_result); @@ -3839,6 +3843,7 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg; int dummy_num_segment_requests; int *arg_num_segment_requests = &dummy_num_segment_requests; @@ -3851,14 +3856,14 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ int local_result; memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + memset(&ut_txn, 0, sizeof(ut_txn)); CF_AppData.engine.in.bytes_received = force_return_CF_HeaderSize + offsetof(CF_CFDP_PduNak_t, segment_requests[CF_NAK_MAX_SEGMENTS]); UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); /* Act */ - local_result = CF_CFDP_RecvNak(arg_num_segment_requests); + local_result = CF_CFDP_RecvNak(&ut_txn, &dummy_msg.pdu_r_msg.ph, arg_num_segment_requests); /* Assert */ UtAssert_True(local_result == 0, "CF_CFDP_RecvAck returned %d and should be 0", local_result); @@ -3874,6 +3879,7 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ void) { /* Arrange */ + CF_Transaction_t ut_txn; CF_UT_inmsg_buffer_t dummy_msg; int dummy_num_segment_requests; int *arg_num_segment_requests = &dummy_num_segment_requests; @@ -3886,14 +3892,14 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ int local_result; memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + memset(&ut_txn, 0, sizeof(ut_txn)); CF_AppData.engine.in.bytes_received = force_return_CF_HeaderSize + offsetof(CF_CFDP_PduNak_t, segment_requests[CF_NAK_MAX_SEGMENTS]) + segment_size; UT_SetHandlerFunction(UT_KEY(CF_HeaderSize), Handler_int_ForcedReturnOnly, &force_return_CF_HeaderSize); /* Act */ - local_result = CF_CFDP_RecvNak(arg_num_segment_requests); + local_result = CF_CFDP_RecvNak(&ut_txn, &dummy_msg.pdu_r_msg.ph, arg_num_segment_requests); /* Assert */ UtAssert_True(local_result == 0, "CF_CFDP_RecvAck returned %d and should be 0", local_result); @@ -3916,16 +3922,20 @@ void Test_CF_CFDP_RecvNak_bytes_received_IsEqTo_CF_HeaderSize_Plus_offsetof_pdu_ void Test_CF_CFDP_RecvDrop_IncrementsCounterIn_CF_AppData(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - uint16 initial_dropped_counter = Any_uint16(); + CF_Transaction_t dummy_t; + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t *arg_t = &dummy_t; + uint16 initial_dropped_counter = Any_uint16(); + + memset(&dummy_msg, 0, sizeof(dummy_msg)); + memset(&dummy_t, 0, sizeof(dummy_t)); arg_t->chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.dropped = initial_dropped_counter; /* Act */ - CF_CFDP_RecvDrop(arg_t); + CF_CFDP_RecvDrop(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.dropped == @@ -3937,16 +3947,20 @@ void Test_CF_CFDP_RecvDrop_IncrementsCounterIn_CF_AppData(void) void Test_CF_CFDP_RecvDrop_IncrementsCounterIn_CF_AppData_AndItRollsOver(void) { /* Arrange */ - CF_Transaction_t dummy_t; - CF_Transaction_t *arg_t = &dummy_t; - uint16 initial_dropped_counter = UINT16_MAX; + CF_UT_inmsg_buffer_t dummy_msg; + CF_Transaction_t dummy_t; + CF_Transaction_t *arg_t = &dummy_t; + uint16 initial_dropped_counter = UINT16_MAX; + + memset(&dummy_msg, 0, sizeof(dummy_msg)); + memset(&dummy_t, 0, sizeof(dummy_t)); arg_t->chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.dropped = initial_dropped_counter; /* Act */ - CF_CFDP_RecvDrop(arg_t); + CF_CFDP_RecvDrop(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_True(CF_AppData.hk.channel_hk[arg_t->chan_num].counters.recv.dropped == 0, @@ -3990,7 +4004,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_And_PDU_HDR_FLAGS_MODE_Are CF_UT_inmsg_buffer_t dummy_msg; memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + memset(&dummy_t, 0, sizeof(dummy_t)); arg_t->history = &dummy_history; @@ -4019,7 +4033,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_And_PDU_HDR_FLAGS_MODE_Are UT_SetDataBuffer(UT_KEY(CF_CList_Pop), &context_CF_CList_Pop, sizeof(context_CF_CList_Pop), false); /* Act */ - CF_CFDP_RecvIdle(arg_t); + CF_CFDP_RecvIdle(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(FGV, 2); @@ -4040,7 +4054,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Is_true_And_PDU_HDR_FLAGS_ CF_UT_inmsg_buffer_t dummy_msg; memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + memset(&dummy_t, 0, sizeof(dummy_t)); arg_t->history = &dummy_history; @@ -4075,7 +4089,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Is_true_And_PDU_HDR_FLAGS_ CF_AppData.config_table = &dummy_config_table; /* Act */ - CF_CFDP_RecvIdle(arg_t); + CF_CFDP_RecvIdle(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(FGV, 2); @@ -4104,7 +4118,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Is_true_And_PDU_HDR_FLAGS_ CF_UT_inmsg_buffer_t dummy_msg; memset(&dummy_msg, 0, sizeof(dummy_msg)); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + memset(&dummy_t, 0, sizeof(dummy_t)); arg_t->history = &dummy_history; @@ -4152,7 +4166,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Is_true_And_PDU_HDR_FLAGS_ fake_c->num_cmd_tx = 1; /* fake_c->num_cmd_tx = 1; bypasses CF_Assert(c->num_cmd_tx) */ /* Act */ - CF_CFDP_RecvIdle(arg_t); + CF_CFDP_RecvIdle(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(FGV, 2); @@ -4184,11 +4198,10 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_But_fdh_dire uint32 initial_recv_error = Any_uint32(); memset(&dummy_msg, 0, sizeof(dummy_msg)); + memset(&dummy_t, 0, sizeof(dummy_t)); dummy_msg.content.cfdp.secondary.fdirh.directive_code = Any_file_directive_t_Except(CF_CFDP_FileDirective_METADATA); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - arg_t->history = &dummy_history; arg_t->chan_num = Any_cf_chan_num(); @@ -4219,7 +4232,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_But_fdh_dire UT_SetDataBuffer(UT_KEY(CF_CList_Pop), &context_CF_CList_Pop, sizeof(context_CF_CList_Pop), false); /* Act */ - CF_CFDP_RecvIdle(arg_t); + CF_CFDP_RecvIdle(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(FGV, 1); @@ -4260,11 +4273,10 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_And_fdh_dire CFE_EVS_SendEvent_context_t local_context_CFE_EVS_SendEvent[2]; memset(&dummy_msg, 0, sizeof(dummy_msg)); + memset(&dummy_t, 0, sizeof(dummy_t)); dummy_msg.content.cfdp.secondary.fdirh.directive_code = CF_CFDP_FileDirective_METADATA; - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - arg_t->history = &dummy_history; arg_t->chan_num = Any_cf_chan_num(); @@ -4299,7 +4311,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_And_fdh_dire CF_AppData.engine.in.bytes_received = 0; /* force err_out */ /* Act */ - CF_CFDP_RecvIdle(arg_t); + CF_CFDP_RecvIdle(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(FGV, 1); @@ -4346,11 +4358,10 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_And_fdh_dire uint32 initial_recv_error = Any_uint32(); memset(&dummy_msg, 0, sizeof(dummy_msg)); + memset(&dummy_t, 0, sizeof(dummy_t)); dummy_msg.content.cfdp.secondary.fdirh.directive_code = CF_CFDP_FileDirective_METADATA; - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - arg_t->history = &dummy_history; arg_t->chan_num = Any_cf_chan_num(); @@ -4398,7 +4409,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_And_fdh_dire ((CF_CFDP_lv_t *)(dummy_msg_in->filename_lvs + 2))->length = 1; /* 1 gets us a success, for a non-negative return */ /* Act */ - CF_CFDP_RecvIdle(arg_t); + CF_CFDP_RecvIdle(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(FGV, 2); @@ -4437,8 +4448,6 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_And_fdh_dire dummy_msg.content.cfdp.secondary.fdirh.directive_code = CF_CFDP_FileDirective_METADATA; - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; - arg_t->history = &dummy_history; arg_t->chan_num = Any_cf_chan_num(); @@ -4484,7 +4493,7 @@ void Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_And_fdh_dire ((CF_CFDP_lv_t *)(dummy_msg_in->filename_lvs + 2))->length = 1; /* 1 gets us a success, for a non-negative return */ /* Act */ - CF_CFDP_RecvIdle(arg_t); + CF_CFDP_RecvIdle(arg_t, &dummy_msg.pdu_r_msg.ph); /* Assert */ UtAssert_STUB_COUNT(FGV, 2); @@ -4789,6 +4798,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTO_CF_CFDP_RecvPh_Returns_non0_Set_CF_AppDa CF_ConfigTable_t dummy_config_table; CF_Channel_t *arg_c; CF_UT_inmsg_buffer_t dummy_msg; + CFE_SB_Buffer_t *msgbuf; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_c = &CF_AppData.engine.channels[dummy_chan_num]; @@ -4798,7 +4808,8 @@ void Test_CF_CFDP_ReceiveMessage_CallTO_CF_CFDP_RecvPh_Returns_non0_Set_CF_AppDa UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); /* Arrange for CF_CFDP_RecvPh */ int forced_return_CF_HeaderSize = INT32_MIN; /* forces nothing to be greater than */ @@ -4828,6 +4839,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_CF_CFDP_FindTransactionBySequenceNumber_ CF_ConfigTable_t dummy_config_table; CF_Channel_t *arg_c; CF_UT_inmsg_buffer_t dummy_msg; + CFE_SB_Buffer_t *msgbuf; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_c = &CF_AppData.engine.channels[dummy_chan_num]; @@ -4837,7 +4849,8 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_CF_CFDP_FindTransactionBySequenceNumber_ UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); /* Arrange for CF_CFDP_RecvPh */ int forced_return_CF_HeaderSize = @@ -4982,6 +4995,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_src_And_dst_AreNot_config_table_local_ei CF_UT_inmsg_buffer_t dummy_msg; const char *expected_Spec = "CF: dropping packet for invalid destination eid 0x%x"; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; + CFE_SB_Buffer_t *msgbuf; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_c = &CF_AppData.engine.channels[dummy_chan_num]; @@ -4991,7 +5005,10 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_src_And_dst_AreNot_config_table_local_ei UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); + CF_AppData.config_table->local_eid = Any_uint8(); /*TODO: change to any_CF_EntityId_t */ CF_AppData.engine.in.src = Any_uint8_Except(CF_AppData.config_table->local_eid); /* for src check fail */ @@ -5075,6 +5092,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_CallTo_FGV_Returns_non0_And_dst_IsN CF_UT_inmsg_buffer_t dummy_msg; const char *expected_Spec = "CF: dropping packet for invalid destination eid 0x%x"; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; + CFE_SB_Buffer_t *msgbuf; memset(&dummy_msg, 0, sizeof(dummy_msg)); arg_c = &CF_AppData.engine.channels[dummy_chan_num]; @@ -5084,7 +5102,9 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_CallTo_FGV_Returns_non0_And_dst_IsN UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); CF_AppData.config_table->local_eid = Any_uint8(); /*TODO: change to any_CF_EntityId_t */ CF_AppData.engine.in.src = CF_AppData.config_table->local_eid; /* for src check fail */ UT_SetDefaultReturnValue(UT_KEY(FGV), 1); @@ -5168,6 +5188,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_bytes_received_IsLessThanExpected_A CF_Channel_t *arg_c; CF_UT_inmsg_buffer_t dummy_msg; const char *expected_Spec = "CF: dropping packet for invalid destination eid 0x%x"; + CFE_SB_Buffer_t *msgbuf; /* 8 arbitrary for a reasonable size but UINT16_MAX + 1 is to force a false (in CUT) */ int forced_return_CF_HeaderSize[2] = {8, UINT16_MAX + 1}; @@ -5182,7 +5203,8 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_bytes_received_IsLessThanExpected_A UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); CF_AppData.config_table->local_eid = Any_uint8(); /*TODO: change to any_CF_EntityId_t */ CF_AppData.engine.in.src = CF_AppData.config_table->local_eid; /* for src check fail */ UT_SetDefaultReturnValue(UT_KEY(FGV), 0); @@ -5262,6 +5284,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_directive_code_IsNotEqTo_PDU_FIN_An CF_Channel_t *arg_c; CF_UT_inmsg_buffer_t dummy_msg; const char *expected_Spec = "CF: dropping packet for invalid destination eid 0x%x"; + CFE_SB_Buffer_t *msgbuf; /* 8 arbitrary for a reasonable size (in CF_CFDP_RecvPh call), 8 to force a true (in CUT), offsetof() for nominal value */ @@ -5279,7 +5302,8 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_directive_code_IsNotEqTo_PDU_FIN_An UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); CF_AppData.config_table->local_eid = Any_uint8(); /*TODO: change to any_CF_EntityId_t */ CF_AppData.engine.in.src = CF_AppData.config_table->local_eid; /* for src check fail */ UT_SetDefaultReturnValue(UT_KEY(FGV), 0); @@ -5360,6 +5384,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_CallTo_CF_CFDP_RecvFin_Returns_neg1 CF_ConfigTable_t dummy_config_table; CF_Channel_t *arg_c; CF_UT_inmsg_buffer_t dummy_msg; + CFE_SB_Buffer_t *msgbuf; /* 8 arbitrary for a reasonable size (in CF_CFDP_RecvPh call), 8 to force a true (in CUT), offsetof() for nominal value, UINT16_MAX + 1 is to force a false (in CUT) */ @@ -5375,7 +5400,8 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_CallTo_CF_CFDP_RecvFin_Returns_neg1 UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); CF_AppData.config_table->local_eid = Any_uint8(); /*TODO: change to any_CF_EntityId_t */ CF_AppData.engine.in.src = CF_AppData.config_table->local_eid; /* for src check fail */ UT_SetDefaultReturnValue(UT_KEY(FGV), 0); @@ -5451,6 +5477,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_CallTo_CF_CFDP_RecvFin_Returns_0_In CF_ConfigTable_t dummy_config_table; CF_Channel_t *arg_c; CF_UT_inmsg_buffer_t dummy_msg; + CFE_SB_Buffer_t *msgbuf; /* 8 arbitrary for a reasonable size (in CF_CFDP_RecvPh call), 8 to force a true (in CUT), offsetof() for nominal value, 0 is to force a true (in CUT), 0 is arbitrary just to have a value */ @@ -5467,7 +5494,8 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_CallTo_CF_CFDP_RecvFin_Returns_0_In UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); CF_AppData.config_table->local_eid = Any_uint8(); /*TODO: change to any_CF_EntityId_t */ CF_AppData.engine.in.src = CF_AppData.config_table->local_eid; /* for src check fail */ UT_SetDefaultReturnValue(UT_KEY(FGV), 0); @@ -5551,6 +5579,7 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_CallTo_CF_CFDP_RecvFin_Returns_0_Ca CF_ConfigTable_t dummy_config_table; CF_Channel_t *arg_c; CF_UT_inmsg_buffer_t dummy_msg; + CFE_SB_Buffer_t *msgbuf; /* 0th 8 arbitrary for a reasonable size (in CF_CFDP_RecvPh call), 8 to force a true (in CUT), 0 to offsetof() for nominal value, 0 is to force a true (in CUT), remaining 0s is arbitrary just to have a value */ @@ -5568,7 +5597,8 @@ void Test_CF_CFDP_ReceiveMessage_CallTo_Then_CallTo_CF_CFDP_RecvFin_Returns_0_Ca UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); CF_AppData.config_table->local_eid = Any_uint8(); /*TODO: change to any_CF_EntityId_t */ CF_AppData.engine.in.src = CF_AppData.config_table->local_eid; /* for src check fail */ UT_SetDefaultReturnValue(UT_KEY(FGV), 0); @@ -5846,6 +5876,7 @@ void Test_2CF_CFDP_ReceiveMessage_CallTo_src_IsNotEqTo_config_table_local_eid_Bu CF_UT_inmsg_buffer_t dummy_msg; CFE_EVS_SendEvent_context_t context_CFE_EVS_SendEvent; CF_History_t dummy_history; + CFE_SB_Buffer_t *msgbuf; memset(&dummy_msg, 0, sizeof(dummy_msg)); @@ -5857,7 +5888,8 @@ void Test_2CF_CFDP_ReceiveMessage_CallTo_src_IsNotEqTo_config_table_local_eid_Bu UT_SetDefaultReturnValue(UT_KEY(CFE_SB_ReceiveBuffer), CFE_SUCCESS); - CF_AppData.engine.in.msg = &dummy_msg.cfe_sb_buffer; + msgbuf = &dummy_msg.cfe_sb_buffer; + UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), &msgbuf, sizeof(msgbuf), false); CF_AppData.config_table->local_eid = Any_uint8(); /*TODO: change to any_CF_EntityId_t */ CF_AppData.engine.in.src = Any_uint8_Except(CF_AppData.config_table->local_eid); /* for src check fail */ diff --git a/unit-test/stubs/cf_cfdp_helpers_stubs.c b/unit-test/stubs/cf_cfdp_helpers_stubs.c index b780e563..2e17f0c6 100644 --- a/unit-test/stubs/cf_cfdp_helpers_stubs.c +++ b/unit-test/stubs/cf_cfdp_helpers_stubs.c @@ -57,7 +57,7 @@ int CF_GetMemcpySize(const uint8_t *num, int size) * Generated stub function for CF_GetVariableHeader() * ---------------------------------------------------- */ -int CF_GetVariableHeader(void) +int CF_GetVariableHeader(CF_CFDP_PduHeader_t *ph) { UT_GenStub_SetupReturnBuffer(CF_GetVariableHeader, int); @@ -102,7 +102,8 @@ void CF_MemcpyToBE(uint8 *dst, const uint8 *src, int src_size, int dst_size) * Generated stub function for CF_SetVariableHeader() * ---------------------------------------------------- */ -void CF_SetVariableHeader(CF_EntityId_t src_eid, CF_EntityId_t dst_eid, CF_TransactionSeq_t tsn) +void CF_SetVariableHeader(CF_CFDP_PduHeader_t *ph, CF_EntityId_t src_eid, CF_EntityId_t dst_eid, + CF_TransactionSeq_t tsn) { UT_GenStub_AddParam(CF_SetVariableHeader, CF_EntityId_t, src_eid); UT_GenStub_AddParam(CF_SetVariableHeader, CF_EntityId_t, dst_eid); diff --git a/unit-test/stubs/cf_cfdp_r_stubs.c b/unit-test/stubs/cf_cfdp_r_stubs.c index a13b55b5..5c4e56d5 100644 --- a/unit-test/stubs/cf_cfdp_r_stubs.c +++ b/unit-test/stubs/cf_cfdp_r_stubs.c @@ -426,7 +426,7 @@ void CF_CFDP_R_Init(CF_Transaction_t *t) ** t must not be NULL. ** *************************************************************************/ -void CF_CFDP_R1_Recv(CF_Transaction_t *t) +void CF_CFDP_R1_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { UT_GenStub_AddParam(CF_CFDP_R_Init, CF_Transaction_t *, t); @@ -440,7 +440,7 @@ void CF_CFDP_R1_Recv(CF_Transaction_t *t) ** t must not be NULL. ** *************************************************************************/ -void CF_CFDP_R2_Recv(CF_Transaction_t *t) +void CF_CFDP_R2_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { UT_GenStub_AddParam(CF_CFDP_R2_Recv, CF_Transaction_t *, t); diff --git a/unit-test/stubs/cf_cfdp_s_stubs.c b/unit-test/stubs/cf_cfdp_s_stubs.c index 4230deb0..f3d06997 100644 --- a/unit-test/stubs/cf_cfdp_s_stubs.c +++ b/unit-test/stubs/cf_cfdp_s_stubs.c @@ -325,7 +325,7 @@ ** t must not be NULL. ** *************************************************************************/ -void CF_CFDP_S1_Recv(CF_Transaction_t *t) +void CF_CFDP_S1_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { UtPrintf("NOT YET IMPLEMENTED stub in \n%s:line #%d\n", __FILE__, __LINE__); exit(-86); @@ -338,7 +338,7 @@ void CF_CFDP_S1_Recv(CF_Transaction_t *t) ** t must not be NULL. ** *************************************************************************/ -void CF_CFDP_S2_Recv(CF_Transaction_t *t) +void CF_CFDP_S2_Recv(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { UtPrintf("NOT YET IMPLEMENTED stub in \n%s:line #%d\n", __FILE__, __LINE__); exit(-86); diff --git a/unit-test/stubs/cf_cfdp_stubs.c b/unit-test/stubs/cf_cfdp_stubs.c index af1ec79f..c7f5a4bc 100644 --- a/unit-test/stubs/cf_cfdp_stubs.c +++ b/unit-test/stubs/cf_cfdp_stubs.c @@ -442,7 +442,7 @@ CF_CFDP_PduHeader_t *CF_CFDP_EarlySendFd(CF_Transaction_t *t) ** \endreturns ** *************************************************************************/ -CF_SendRet_t CF_CFDP_SendFd(CF_Transaction_t *t, uint32 offset, int len) +CF_SendRet_t CF_CFDP_SendFd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, uint32 offset, int len) { CF_SendRet_t forced_return; @@ -575,7 +575,7 @@ CF_SendRet_t CF_CFDP_SendFin(CF_Transaction_t *t, CF_CFDP_FinDeliveryCode_t dc, ** \endreturns ** *************************************************************************/ -CF_SendRet_t CF_CFDP_SendNak(CF_Transaction_t *t, int num_segment_requests) +CF_SendRet_t CF_CFDP_SendNak(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, int num_segment_requests) { CF_SendRet_t forced_return; @@ -642,7 +642,7 @@ CF_CFDP_PduHeader_t *CF_CFDP_EarlySendNak(CF_Transaction_t *t) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvMd(CF_Transaction_t *t) +int CF_CFDP_RecvMd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { UT_GenStub_SetupReturnBuffer(CF_CFDP_RecvMd, int32); @@ -666,7 +666,7 @@ int CF_CFDP_RecvMd(CF_Transaction_t *t) ** *************************************************************************/ -int CF_CFDP_RecvFd(CF_Transaction_t *t) +int CF_CFDP_RecvFd(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { int forced_return = __INT_MAX__; @@ -693,7 +693,7 @@ int CF_CFDP_RecvFd(CF_Transaction_t *t) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvEof(void) +int CF_CFDP_RecvEof(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { return (int)UT_DEFAULT_IMPL(CF_CFDP_RecvEof); } @@ -710,7 +710,7 @@ int CF_CFDP_RecvEof(void) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvAck(void) +int CF_CFDP_RecvAck(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { return (int)UT_DEFAULT_IMPL(CF_CFDP_RecvAck); } @@ -727,7 +727,7 @@ int CF_CFDP_RecvAck(void) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvFin(void) +int CF_CFDP_RecvFin(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph) { return UT_DEFAULT_IMPL(CF_CFDP_RecvFin); } @@ -744,7 +744,7 @@ int CF_CFDP_RecvFin(void) ** \endreturns ** *************************************************************************/ -int CF_CFDP_RecvNak(int *num_segment_requests) +int CF_CFDP_RecvNak(CF_Transaction_t *t, CF_CFDP_PduHeader_t *ph, int *num_segment_requests) { UT_Stub_CopyToLocal(UT_KEY(CF_CFDP_RecvNak), num_segment_requests, sizeof(int));