Skip to content

Commit

Permalink
Update GetField API for AcfCommon.h/c
Browse files Browse the repository at this point in the history
Signed-off-by: Adriaan Niess <[email protected]>
  • Loading branch information
adriaan-niess committed Aug 25, 2024
1 parent 7777a6c commit 998e3c0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
18 changes: 10 additions & 8 deletions include/avtp/acf/Common.h → include/avtp/acf/AcfCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,22 @@ typedef enum {
* Returns the value of an an ACF common header field as specified in the IEEE 1722 Specification.
*
* @param pdu Pointer to the first bit of an 1722 ACF PDU.
* @param field Specifies the position of the data field to be read
* @param value Pointer to location to store the value.
* @returns This function returns 0 if the data field was successfully read from
* the 1722 ACF PDU.
* @param field Specifies the position of the data field to be read.
* @returns Returns the field of the PDU.
*/
int Avtp_AcfCommon_GetField(Avtp_AcfCommon_t* acf_pdu, Avtp_AcfCommonFields_t field, uint64_t* value);
uint64_t Avtp_AcfCommon_GetField(Avtp_AcfCommon_t* pdu, Avtp_AcfCommonFields_t field);

uint8_t Avtp_AcfCommon_GetAcfMsgType(Avtp_AcfCommon_t* pdu);
uint16_t Avtp_AcfCommon_GetAcfMsgLength(Avtp_AcfCommon_t* pdu);

/**
* Sets the value of an an ACF common header field as specified in the IEEE 1722 Specification.
*
* @param pdu Pointer to the first bit of an 1722 ACF PDU.
* @param field Specifies the position of the data field to be read
* @param value Pointer to location to store the value.
* @returns This function returns 0 if the data field was successfully set in
* the 1722 ACF PDU.
*/
int Avtp_AcfCommon_SetField(Avtp_AcfCommon_t* acf_pdu, Avtp_AcfCommonFields_t field, uint64_t value);
void Avtp_AcfCommon_SetField(Avtp_AcfCommon_t* pdu, Avtp_AcfCommonFields_t field, uint64_t value);

void Avtp_AcfCommon_SetAcfMsgType(Avtp_AcfCommon_t* pdu, uint8_t value);
void Avtp_AcfCommon_SetAcfMsgLength(Avtp_AcfCommon_t* pdu, uint16_t value);
37 changes: 31 additions & 6 deletions src/avtp/acf/Common.c → src/avtp/acf/AcfCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@
#include <errno.h>
#include <string.h>

#include "avtp/acf/Common.h"
#include "avtp/acf/AcfCommon.h"
#include "avtp/Utils.h"
#include "avtp/Defines.h"

#define GET_FIELD(field) \
(Avtp_GetField(Avtp_AcfCommonFieldDesc, AVTP_ACF_COMMON_FIELD_MAX, (uint8_t*)pdu, field))
#define SET_FIELD(field, value) \
(Avtp_SetField(Avtp_AcfCommonFieldDesc, AVTP_ACF_COMMON_FIELD_MAX, (uint8_t*)pdu, field, value))

/**
* This table maps all IEEE 1722 ACF common header fields to a descriptor.
*/
Expand All @@ -44,12 +49,32 @@ static const Avtp_FieldDescriptor_t Avtp_AcfCommonFieldDesc[AVTP_ACF_COMMON_FIEL
[AVTP_ACF_FIELD_ACF_MSG_LENGTH] = { .quadlet = 0, .offset = 7, .bits = 9 },
};

int Avtp_AcfCommon_GetField(Avtp_AcfCommon_t* acf_pdu, Avtp_AcfCommonFields_t field, uint64_t* value)
{
return Avtp_GetField(Avtp_AcfCommonFieldDesc, AVTP_ACF_COMMON_FIELD_MAX, (uint8_t*)acf_pdu, (uint8_t)field, value);
uint64_t Avtp_AcfCommon_GetField(Avtp_AcfCommon_t* pdu, Avtp_AcfCommonFields_t field)
{
return GET_FIELD(field);
}

uint8_t Avtp_AcfCommon_GetAcfMsgType(Avtp_AcfCommon_t* pdu)
{
return GET_FIELD(AVTP_ACF_FIELD_ACF_MSG_TYPE);
}

uint16_t Avtp_AcfCommon_GetAcfMsgLength(Avtp_AcfCommon_t* pdu)
{
return GET_FIELD(AVTP_ACF_FIELD_ACF_MSG_LENGTH);
}

void Avtp_AcfCommon_SetField(Avtp_AcfCommon_t* pdu, Avtp_AcfCommonFields_t field, uint64_t value)
{
SET_FIELD(field, value);
}

void Avtp_AcfCommon_SetAcfMsgType(Avtp_AcfCommon_t* pdu, uint8_t value)
{
SET_FIELD(AVTP_ACF_FIELD_ACF_MSG_TYPE, value);
}

int Avtp_AcfCommon_SetField(Avtp_AcfCommon_t* acf_pdu, Avtp_AcfCommonFields_t field, uint64_t value)
void Avtp_AcfCommon_SetAcfMsgLength(Avtp_AcfCommon_t* pdu, uint16_t value)
{
return Avtp_SetField(Avtp_AcfCommonFieldDesc, AVTP_ACF_COMMON_FIELD_MAX, (uint8_t*)acf_pdu, (uint8_t)field, value);
SET_FIELD(AVTP_ACF_FIELD_ACF_MSG_LENGTH, value);
}

0 comments on commit 998e3c0

Please sign in to comment.