diff --git a/include/avtp/acf/Common.h b/include/avtp/acf/AcfCommon.h similarity index 86% rename from include/avtp/acf/Common.h rename to include/avtp/acf/AcfCommon.h index ae83019..2733c8a 100644 --- a/include/avtp/acf/Common.h +++ b/include/avtp/acf/AcfCommon.h @@ -78,12 +78,13 @@ 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. @@ -91,7 +92,8 @@ int Avtp_AcfCommon_GetField(Avtp_AcfCommon_t* acf_pdu, Avtp_AcfCommonFields_t fi * @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); \ No newline at end of file +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); diff --git a/src/avtp/acf/Common.c b/src/avtp/acf/AcfCommon.c similarity index 66% rename from src/avtp/acf/Common.c rename to src/avtp/acf/AcfCommon.c index f644310..81e84b4 100644 --- a/src/avtp/acf/Common.c +++ b/src/avtp/acf/AcfCommon.c @@ -30,10 +30,15 @@ #include #include -#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. */ @@ -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); }