Skip to content

Commit

Permalink
Partial nasa#42, naming convention pass thru cf_cfdp_pdu.h
Browse files Browse the repository at this point in the history
Updates names of all identifiers declared in cf_cfdp_pdu.h to adhere
to naming conventions.

This also updates documentation on many of the items in cf_cfdp_pdu.h
  • Loading branch information
jphickey committed Dec 8, 2021
1 parent 68d7c79 commit b55cf70
Show file tree
Hide file tree
Showing 27 changed files with 1,839 additions and 1,612 deletions.
4 changes: 2 additions & 2 deletions fsw/platform_inc/cf_platform_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
** \par Limits
** Must be one of uint8, uint16, uint32, uint64.
*/
typedef uint8 cf_entity_id_t;
typedef uint8 CF_EntityId_t;

/**
** \cfcfg transaction sequence number size
Expand All @@ -56,7 +56,7 @@ typedef uint8 cf_entity_id_t;
** \par Limits
** Must be one of uint8, uint16, uint32, uint64.
*/
typedef uint32 cf_transaction_seq_t;
typedef uint32 CF_TransactionSeq_t;

/**
** \cfcfg CF_HW_ALIGNMENT and CF_SW_ALIGNMENT
Expand Down
18 changes: 9 additions & 9 deletions fsw/platform_inc/cf_tbldefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

typedef struct
{
uint32_t interval_sec; /* number of seconds to wait before trying a new directory.
Must be >0 or slot is inactive. */
uint8 priority; /* priority to use when placing transactions on the pending queue */
cfdp_class_t cfdp_class; /* the CFDP class to send */
cf_entity_id_t dest_eid; /* destination entity id */
char src_dir[CF_FILENAME_MAX_PATH]; /* path to source dir */
char dst_dir[CF_FILENAME_MAX_PATH]; /* path to destination dir */
uint8 enabled;
uint32_t interval_sec; /* number of seconds to wait before trying a new directory.
Must be >0 or slot is inactive. */
uint8 priority; /* priority to use when placing transactions on the pending queue */
CF_CFDP_Class_t cfdp_class; /* the CFDP class to send */
CF_EntityId_t dest_eid; /* destination entity id */
char src_dir[CF_FILENAME_MAX_PATH]; /* path to source dir */
char dst_dir[CF_FILENAME_MAX_PATH]; /* path to destination dir */
uint8 enabled;
} polldir_t;

typedef struct
Expand All @@ -64,7 +64,7 @@ typedef struct
uint32 rx_crc_calc_bytes_per_wakeup; /* max number of bytes per wakeup to calculate r2 crc for recvd file (must by
1024-byte aligned */

cf_entity_id_t local_eid; /* the local entity ID of the CF app */
CF_EntityId_t local_eid; /* the local entity ID of the CF app */

cf_channel_t chan[CF_NUM_CHANNELS];
uint32 ack_timer_s; /* in seconds */
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int32 CF_ValidateConfigTable(void *tbl_ptr)
"CF: config table has rx crc size not aligned with 1024");
ret = crc_alignment; /* must be 1024-byte aligned */
}
else if (tbl->outgoing_file_chunk_size > sizeof(pdu_fd_data_t))
else if (tbl->outgoing_file_chunk_size > sizeof(CF_CFDP_PduFileDataContent_t))
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_OUTGOING_SIZE, CFE_EVS_EventType_ERROR,
"CF: config table has outgoing file chunk size too large");
Expand Down
300 changes: 155 additions & 145 deletions fsw/src/cf_cfdp.c

Large diffs are not rendered by default.

76 changes: 38 additions & 38 deletions fsw/src/cf_cfdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ typedef enum direction_t

typedef struct
{
transaction_fnames_t fnames;
clist_node_t cl_node;
direction_t dir;
condition_code_t cc;
cf_entity_id_t src_eid; /* src_eid is always the source eid */
cf_entity_id_t peer_eid; /* peer_eid is always the "other guy", which is the same src_eid for RX */
cf_transaction_seq_t seq_num; /* stays constant for entire transfer */
transaction_fnames_t fnames;
clist_node_t cl_node;
direction_t dir;
CF_CFDP_ConditionCode_t cc;
CF_EntityId_t src_eid; /* src_eid is always the source eid */
CF_EntityId_t peer_eid; /* peer_eid is always the "other guy", which is the same src_eid for RX */
CF_TransactionSeq_t seq_num; /* stays constant for entire transfer */
} history_t;

typedef struct
Expand All @@ -117,11 +117,11 @@ struct transaction_t;
typedef struct
{
uint32 dir_id;
cfdp_class_t cfdp_class;
CF_CFDP_Class_t cfdp_class;
transaction_fnames_t fnames;
uint16 num_ts; /* number of transactions -- 16 bit should be enough */
uint8 priority;
cf_entity_id_t dest_id;
CF_EntityId_t dest_id;
unsigned busy : 1;
unsigned diropen : 1;
unsigned keep : 1;
Expand Down Expand Up @@ -157,13 +157,13 @@ typedef struct

typedef struct
{
uint32 eof_crc;
uint32 eof_size;
uint32 rx_crc_calc_bytes;
fin_delivery_code_t dc;
fin_file_status_t fs;
uint8 eof_cc; /* remember the cc in the received eof pdu to echo in eof-ack */
rxtx_counters_t counter;
uint32 eof_crc;
uint32 eof_size;
uint32 rx_crc_calc_bytes;
CF_CFDP_FinDeliveryCode_t dc;
CF_CFDP_FinFileStatus_t fs;
uint8 eof_cc; /* remember the cc in the received eof pdu to echo in eof-ack */
rxtx_counters_t counter;
} rx_r2_data_t;

typedef struct
Expand Down Expand Up @@ -316,19 +316,19 @@ typedef struct

typedef struct
{
CFE_SB_Buffer_t *msg;
CFE_MSG_Size_t bytes_received;
cf_entity_id_t src;
cf_entity_id_t dst;
cf_transaction_seq_t tsn;
CFE_SB_Buffer_t *msg;
CFE_MSG_Size_t bytes_received;
CF_EntityId_t src;
CF_EntityId_t dst;
CF_TransactionSeq_t tsn;
} in_t;

/* An engine represents a pairing to a local EID
*
* Each engine can have at most CF_MAX_SIMULTANEOUS_TRANSACTIONS */
typedef struct
{
cf_transaction_seq_t seq_num; /* keep track of the next sequence number to use for sends */
CF_TransactionSeq_t seq_num; /* keep track of the next sequence number to use for sends */

out_t out;
in_t in;
Expand Down Expand Up @@ -359,28 +359,28 @@ extern void CF_CFDP_DisableEngine(void);
/* ground commands into the engine */
/* returns NULL on err */
extern int32 CF_CFDP_TxFile(const char src_filename[CF_FILENAME_MAX_LEN], const char dst_filename[CF_FILENAME_MAX_LEN],
cfdp_class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority, cf_entity_id_t dest_id);
CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority, CF_EntityId_t dest_id);
extern int32 CF_CFDP_PlaybackDir(const char src_filename[CF_FILENAME_MAX_LEN],
const char dst_filename[CF_FILENAME_MAX_LEN], cfdp_class_t cfdp_class, uint8 keep,
const char dst_filename[CF_FILENAME_MAX_LEN], CF_CFDP_Class_t cfdp_class, uint8 keep,
uint8 chan, uint8 priority, uint16 dest_id);

/* PDU send functions */
/* CF_CFDP_ConstructPduHeader sets length of 0. Must set it after building packet */
extern pdu_header_t *CF_CFDP_ConstructPduHeader(const transaction_t *t, uint8 directive_code, cf_entity_id_t src_eid,
cf_entity_id_t dst_eid, uint8 towards_sender, cf_transaction_seq_t tsn,
int silent);
extern cfdp_send_ret_t CF_CFDP_SendMd(transaction_t *t);
extern cfdp_send_ret_t CF_CFDP_SendFd(transaction_t *t, uint32 offset, int len);
extern CF_CFDP_PduHeader_t *CF_CFDP_ConstructPduHeader(const transaction_t *t, uint8 directive_code,
CF_EntityId_t src_eid, CF_EntityId_t dst_eid,
uint8 towards_sender, CF_TransactionSeq_t tsn, int silent);
extern cfdp_send_ret_t CF_CFDP_SendMd(transaction_t *t);
extern cfdp_send_ret_t CF_CFDP_SendFd(transaction_t *t, uint32 offset, int len);

extern cfdp_send_ret_t CF_CFDP_SendEof(transaction_t *t);
/* NOTE: CF_CFDP_SendAck() takes a cf_transaction_seq_t instead of getting it from transaction history because
/* 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 history_t for it.
*/
extern cfdp_send_ret_t CF_CFDP_SendAck(transaction_t *t, ack_transaction_status_t ts, file_directive_t dir_code,
condition_code_t cc, cf_entity_id_t peer_eid, cf_transaction_seq_t tsn);
extern cfdp_send_ret_t CF_CFDP_SendFin(transaction_t *t, fin_delivery_code_t dc, fin_file_status_t fs,
condition_code_t cc);
extern cfdp_send_ret_t CF_CFDP_SendAck(transaction_t *t, CF_CFDP_AckTxnStatus_t ts, CF_CFDP_FileDirective_t dir_code,
CF_CFDP_ConditionCode_t cc, CF_EntityId_t peer_eid, CF_TransactionSeq_t tsn);
extern cfdp_send_ret_t CF_CFDP_SendFin(transaction_t *t, CF_CFDP_FinDeliveryCode_t dc, CF_CFDP_FinFileStatus_t fs,
CF_CFDP_ConditionCode_t cc);
extern cfdp_send_ret_t CF_CFDP_SendNak(transaction_t *t, int num_segment_requests);

/* PDU receive functions */
Expand Down Expand Up @@ -408,18 +408,18 @@ extern void CF_CFDP_R_Init(transaction_t *t);

extern void CF_CFDP_CancelTransaction(transaction_t *t);

extern pdu_header_t *CF_CFDP_MsgOutGet(const transaction_t *t, int silent);
extern CF_CFDP_PduHeader_t *CF_CFDP_MsgOutGet(const transaction_t *t, int silent);

/* functions to handle LVs (length-value, cfdp spec) */
/* returns number of bytes copied, or -1 on error */
extern int CF_CFDP_CopyDataToLv(lv_t *dest_lv, const uint8 *data, uint32 len);
extern int CF_CFDP_CopyDataFromLv(uint8 buf[CF_FILENAME_MAX_LEN], const lv_t *dest_lv);
extern int CF_CFDP_CopyDataToLv(CF_CFDP_lv_t *dest_lv, const uint8 *data, uint32 len);
extern int CF_CFDP_CopyDataFromLv(uint8 buf[CF_FILENAME_MAX_LEN], const CF_CFDP_lv_t *dest_lv);

extern const int CF_max_chunks[CF_DIR_NUM][CF_NUM_CHANNELS];

extern void CF_CFDP_ArmAckTimer(transaction_t *);

extern transaction_t *CF_CFDP_FindTransactionBySequenceNumber(channel_t *c, uint32 transaction_sequence_number,
cf_entity_id_t src_eid);
CF_EntityId_t src_eid);

#endif /* !CF_CFDP__H */
58 changes: 29 additions & 29 deletions fsw/src/cf_cfdp_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,37 +95,37 @@ static void CF_MemcpyFromBE(uint8 *dst, const uint8 *src, int src_size, int dst_
#endif
}

static int CF_GetTSNSize(const pdu_header_t *ph)
static int CF_GetTSNSize(const CF_CFDP_PduHeader_t *ph)
{
uint8 field;
int ret;

cfdp_get_uint8(field, ph->eid_tsn_lengths);
ret = FGV(field, PDU_LENGTHS_TRANSACTION_SEQUENCE) + 1;
ret = FGV(field, CF_CFDP_PduHeader_LENGTHS_TRANSACTION_SEQUENCE) + 1;

if (ret > sizeof(cf_transaction_seq_t))
if (ret > sizeof(CF_TransactionSeq_t))
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_GET_TSN_SIZE, CFE_EVS_EventType_ERROR,
"received TSN size %d too large for compiled max of %d", ret,
(uint32)sizeof(cf_transaction_seq_t));
(uint32)sizeof(CF_TransactionSeq_t));
return -1;
}

return ret;
}

static int CF_GetEIDSize(const pdu_header_t *ph)
static int CF_GetEIDSize(const CF_CFDP_PduHeader_t *ph)
{
uint8 field;
int ret;

cfdp_get_uint8(field, ph->eid_tsn_lengths);
ret = FGV(field, PDU_LENGTHS_ENTITY) + 1;
ret = FGV(field, CF_CFDP_PduHeader_LENGTHS_ENTITY) + 1;

if (ret > sizeof(cf_entity_id_t))
if (ret > sizeof(CF_EntityId_t))
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_GET_EID_SIZE, CFE_EVS_EventType_ERROR,
"received EID size %d too large for compiled max of %d", ret, (uint32)sizeof(cf_entity_id_t));
"received EID size %d too large for compiled max of %d", ret, (uint32)sizeof(CF_EntityId_t));
return -1;
}

Expand All @@ -136,54 +136,54 @@ static int CF_GetEIDSize(const pdu_header_t *ph)
/* in.msg must be valid PDU message */
int CF_GetVariableHeader(void)
{
pdu_header_t *ph = &((pdu_r_msg_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;
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;

if ((eid_l > 0) && (tsn_l > 0))
{
CF_MemcpyFromBE((uint8 *)&CF_AppData.engine.in.src, ((uint8 *)ph) + offs, eid_l, sizeof(cf_entity_id_t));
CF_MemcpyFromBE((uint8 *)&CF_AppData.engine.in.src, ((uint8 *)ph) + offs, eid_l, sizeof(CF_EntityId_t));
offs += eid_l;
CF_MemcpyFromBE((uint8 *)&CF_AppData.engine.in.tsn, ((uint8 *)ph) + offs, tsn_l, sizeof(cf_transaction_seq_t));
CF_MemcpyFromBE((uint8 *)&CF_AppData.engine.in.tsn, ((uint8 *)ph) + offs, tsn_l, sizeof(CF_TransactionSeq_t));
offs += tsn_l;
CF_MemcpyFromBE((uint8 *)&CF_AppData.engine.in.dst, ((uint8 *)ph) + offs, eid_l, sizeof(cf_entity_id_t));
CF_MemcpyFromBE((uint8 *)&CF_AppData.engine.in.dst, ((uint8 *)ph) + offs, eid_l, sizeof(CF_EntityId_t));
ret = 0;
}

return ret;
}

void CF_SetVariableHeader(cf_entity_id_t src_eid, cf_entity_id_t dst_eid, cf_transaction_seq_t tsn)
void CF_SetVariableHeader(CF_EntityId_t src_eid, CF_EntityId_t dst_eid, CF_TransactionSeq_t tsn)
{
pdu_header_t *ph = &((pdu_s_msg_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);
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);

CF_MemcpyToBE(((uint8 *)ph) + offs, (uint8 *)&src_eid, sizeof(src_eid), csize);
offs += csize;
CF_MemcpyToBE(((uint8 *)ph) + offs, (uint8 *)&tsn, sizeof(tsn), tsn_l);
offs += tsn_l;
CF_MemcpyToBE(((uint8 *)ph) + offs, (uint8 *)&dst_eid, sizeof(dst_eid), csize);

FSV(ph->eid_tsn_lengths, PDU_LENGTHS_ENTITY, csize - 1);
FSV(ph->eid_tsn_lengths, PDU_LENGTHS_TRANSACTION_SEQUENCE, tsn_l - 1);
FSV(ph->eid_tsn_lengths, CF_CFDP_PduHeader_LENGTHS_ENTITY, csize - 1);
FSV(ph->eid_tsn_lengths, CF_CFDP_PduHeader_LENGTHS_TRANSACTION_SEQUENCE, tsn_l - 1);
}

int CF_HeaderSize(const pdu_header_t *ph)
int CF_HeaderSize(const CF_CFDP_PduHeader_t *ph)
{
uint8 temp;

/* NOTE: assume header size is correct here (packet already validated via CF_GetVariableHeader, or
* set by CF for outgoing PDU */
cfdp_ldst_uint8(temp, ph->eid_tsn_lengths);
const int eid_l = 1 + FGV(temp, PDU_LENGTHS_ENTITY);
const int tsn_l = 1 + FGV(temp, PDU_LENGTHS_TRANSACTION_SEQUENCE);
const int eid_l = 1 + FGV(temp, CF_CFDP_PduHeader_LENGTHS_ENTITY);
const int tsn_l = 1 + FGV(temp, CF_CFDP_PduHeader_LENGTHS_TRANSACTION_SEQUENCE);

CF_Assert((eid_l > 0) && (tsn_l > 0));
return sizeof(pdu_header_t) + (2 * eid_l) + tsn_l;
return sizeof(CF_CFDP_PduHeader_t) + (2 * eid_l) + tsn_l;
}
Loading

0 comments on commit b55cf70

Please sign in to comment.