Skip to content

Commit

Permalink
Merge pull request COVESA#54 from boschglobal/feat/cpp-api
Browse files Browse the repository at this point in the history
Make API compatible with C++
  • Loading branch information
adriaan-niess authored Dec 3, 2024
2 parents f9f56ff + 104c7d9 commit a0be7bb
Show file tree
Hide file tree
Showing 25 changed files with 200 additions and 4 deletions.
10 changes: 9 additions & 1 deletion include/avtp/CommonHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

#include "avtp/Defines.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_COMMON_HEADER_LEN (1 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -176,4 +180,8 @@ int avtp_pdu_get(const struct avtp_common_pdu *pdu, Avtp_CommonHeaderField_t fie
* -EINVAL: If any argument is invalid.
*/
int avtp_pdu_set(struct avtp_common_pdu *pdu, Avtp_CommonHeaderField_t field,
uint32_t val);
uint32_t val);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/Crf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

#include "avtp/Utils.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_CRF_HEADER_LEN (5 * AVTP_QUADLET_SIZE)

typedef struct Avtp_Cvf {
Expand Down Expand Up @@ -162,3 +166,7 @@ int avtp_crf_pdu_set(void *pdu, Avtp_CrfField_t field, uint64_t val);
* -EINVAL: If any argument is invalid.
*/
int avtp_crf_pdu_init(void *pdu);

#ifdef __cplusplus
}
#endif
8 changes: 7 additions & 1 deletion include/avtp/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

#include <stdint.h>

#define AVTP_API extern "C" __attribute__((visibility("default")))
#ifdef __cplusplus
extern "C" {
#endif

/**
* Max bits that the parser supports for a single data field within a 1722
Expand All @@ -56,3 +58,7 @@ typedef struct Avtp_FieldDescriptor {
uint8_t offset;
uint8_t bits;
} Avtp_FieldDescriptor_t;

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/Rvf.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

#include "avtp/Utils.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_RVF_HEADER_LEN (8 * AVTP_QUADLET_SIZE)

typedef struct Avtp_Rvf {
Expand Down Expand Up @@ -256,3 +260,7 @@ int avtp_rvf_pdu_set(void* pdu, Avtp_RvfField_t field, uint64_t val);
* -EINVAL: If any argument is invalid.
*/
int avtp_rvf_pdu_init(void* pdu);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/Udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@

#include "avtp/Defines.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_UDP_HEADER_LEN (1 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -84,3 +88,7 @@ uint32_t Avtp_Udp_GetEncapsulationSeqNo(Avtp_Udp_t* pdu);
void Avtp_Udp_SetField(Avtp_Udp_t* pdu, Avtp_UdpFields_t field, uint64_t value);

void Avtp_Udp_SetEncapsulationSeqNo(Avtp_Udp_t* pdu, uint32_t value);

#ifdef __cplusplus
}
#endif
7 changes: 7 additions & 0 deletions include/avtp/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#include "avtp/Defines.h"
#include "avtp/Byteorder.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* Extracts a data field from a 1722 frame and handles necessary byte-order
Expand All @@ -64,3 +67,7 @@ uint64_t Avtp_GetField(const Avtp_FieldDescriptor_t* fieldDescriptors,
*/
void Avtp_SetField(const Avtp_FieldDescriptor_t* fieldDescriptors,
uint8_t numFields, uint8_t* pdu, uint8_t field, uint64_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/aaf/Aaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@

#include "avtp/Defines.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_AAF_HEADER_LEN (6 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -114,3 +118,7 @@ void Avtp_Aaf_SetStreamDataLength(Avtp_Aaf_t* pdu, uint16_t value);
void Avtp_Aaf_SetAfsd(Avtp_Aaf_t* pdu, uint8_t value);
void Avtp_Aaf_SetSp(Avtp_Aaf_t* pdu, uint8_t value);
void Avtp_Aaf_SetEvt(Avtp_Aaf_t* pdu, uint8_t value);

#ifdef __cplusplus
}
#endif
10 changes: 9 additions & 1 deletion include/avtp/aaf/Pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

#include "avtp/Defines.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_PCM_HEADER_LEN (6 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -212,4 +216,8 @@ int avtp_aaf_pdu_set(void *pdu, Avtp_PcmFields_t field,
* 0: Success.
* -EINVAL: If any argument is invalid.
*/
int avtp_aaf_pdu_init(void *pdu);
int avtp_aaf_pdu_init(void *pdu);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/AcfCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
#include <stdint.h>
#include "avtp/Defines.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_ACF_COMMON_HEADER_LEN (1 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -97,3 +101,7 @@ void Avtp_AcfCommon_SetField(Avtp_AcfCommon_t* pdu, Avtp_AcfCommonFields_t field

void Avtp_AcfCommon_SetAcfMsgType(Avtp_AcfCommon_t* pdu, Avtp_AcfMsgType_t value);
void Avtp_AcfCommon_SetAcfMsgLength(Avtp_AcfCommon_t* pdu, uint16_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/Can.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include "avtp/Defines.h"
#include "avtp/acf/AcfCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_CAN_HEADER_LEN (4 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -174,3 +178,7 @@ void Avtp_Can_Finalize(Avtp_Can_t* can_pdu, uint16_t payload_length);
* @return Length of CAN payload in bytes
*/
uint8_t Avtp_Can_GetCanPayloadLength(Avtp_Can_t* pdu);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/CanBrief.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include "avtp/acf/AcfCommon.h"
#include "avtp/acf/Can.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_CAN_BRIEF_HEADER_LEN (2 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -142,3 +146,7 @@ int Avtp_CanBrief_SetPayload(Avtp_CanBrief_t* can_pdu, uint32_t frame_id , uint8
* @returns Returns number of processed bytes (header + payload + padding)
*/
int Avtp_CanBrief_Finalize(Avtp_CanBrief_t* can_pdu, uint16_t payload_length);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/FlexRay.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "avtp/Defines.h"
#include "avtp/acf/AcfCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

/** Length of ACF FlexRay header. */
#define AVTP_FLEXRAY_HEADER_LEN (4 * AVTP_QUADLET_SIZE)

Expand Down Expand Up @@ -125,3 +129,7 @@ void Avtp_FlexRay_SetNfi(Avtp_FlexRay_t* pdu, uint8_t value);
void Avtp_FlexRay_SetMessageTimestamp(Avtp_FlexRay_t* pdu, uint64_t value);
void Avtp_FlexRay_SetFrFrameId(Avtp_FlexRay_t* pdu, uint16_t value);
void Avtp_FlexRay_SetCycle(Avtp_FlexRay_t* pdu, uint8_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/Gpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "avtp/Defines.h"
#include "avtp/acf/AcfCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_GPC_HEADER_LEN (2 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -93,3 +97,7 @@ void Avtp_Gpc_SetField(Avtp_Gpc_t* pdu, Avtp_GpcFields_t field, uint64_t value);
void Avtp_Gpc_SetAcfMsgType(Avtp_Gpc_t* pdu, uint8_t value);
void Avtp_Gpc_SetAcfMsgLength(Avtp_Gpc_t* pdu, uint16_t value);
void Avtp_Gpc_SetGpcMsgId(Avtp_Gpc_t* pdu, uint64_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/Lin.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "avtp/Defines.h"
#include "avtp/acf/AcfCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

/** Length of ACF Lin header. */
#define AVTP_LIN_HEADER_LEN (3 * AVTP_QUADLET_SIZE)

Expand Down Expand Up @@ -104,3 +108,7 @@ void Avtp_Lin_SetMtv(Avtp_Lin_t* pdu, uint8_t value);
void Avtp_Lin_SetLinBusId(Avtp_Lin_t* pdu, uint8_t value);
void Avtp_Lin_SetLinIdentifier(Avtp_Lin_t* pdu, uint8_t value);
void Avtp_Lin_SetMessageTimestamp(Avtp_Lin_t* pdu, uint64_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/Most.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "avtp/Defines.h"
#include "avtp/acf/AcfCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

/** Length of ACF Most header. */
#define AVTP_MOST_HEADER_LEN (4 * AVTP_QUADLET_SIZE)

Expand Down Expand Up @@ -117,3 +121,7 @@ void Avtp_Most_SetFblockId(Avtp_Most_t* pdu, uint8_t value);
void Avtp_Most_SetInstId(Avtp_Most_t* pdu, uint8_t value);
void Avtp_Most_SetFuncId(Avtp_Most_t* pdu, uint16_t value);
void Avtp_Most_SetOpType(Avtp_Most_t* pdu, uint8_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/Ntscf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@

#include "avtp/Defines.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_NTSCF_HEADER_LEN (3 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -97,3 +101,7 @@ void Avtp_Ntscf_SetVersion(Avtp_Ntscf_t* pdu, uint8_t value);
void Avtp_Ntscf_SetNtscfDataLength(Avtp_Ntscf_t* pdu, uint16_t value);
void Avtp_Ntscf_SetSequenceNum(Avtp_Ntscf_t* pdu, uint8_t value);
void Avtp_Ntscf_SetStreamId(Avtp_Ntscf_t* pdu, uint64_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include "avtp/Defines.h"
#include "avtp/acf/AcfCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_SENSOR_HEADER_LEN (3 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -104,3 +108,7 @@ void Avtp_Sensor_SetNumSensor(Avtp_Sensor_t* pdu, uint8_t value);
void Avtp_Sensor_SetSz(Avtp_Sensor_t* pdu, uint8_t value);
void Avtp_Sensor_SetSensorGroup(Avtp_Sensor_t* pdu, uint8_t value);
void Avtp_Sensor_SetMessageTimestamp(Avtp_Sensor_t* pdu, uint64_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/SensorBrief.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include "avtp/Defines.h"
#include "avtp/acf/AcfCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_SENSOR_HEADER_LEN (1 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -98,3 +102,7 @@ void Avtp_SensorBrief_SetMtv(Avtp_SensorBrief_t* pdu, uint8_t value);
void Avtp_SensorBrief_SetNumSensor(Avtp_SensorBrief_t* pdu, uint8_t value);
void Avtp_SensorBrief_SetSz(Avtp_SensorBrief_t* pdu, uint8_t value);
void Avtp_SensorBrief_SetSensorGroup(Avtp_SensorBrief_t* pdu, uint8_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/Tscf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@

#include "avtp/Defines.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_TSCF_HEADER_LEN (6 * AVTP_QUADLET_SIZE)

typedef struct {
Expand Down Expand Up @@ -114,3 +118,7 @@ void Avtp_Tscf_SetTu(Avtp_Tscf_t* pdu, uint8_t value);
void Avtp_Tscf_SetStreamId(Avtp_Tscf_t* pdu, uint64_t value);
void Avtp_Tscf_SetAvtpTimestamp(Avtp_Tscf_t* pdu, uint32_t value);
void Avtp_Tscf_SetStreamDataLength(Avtp_Tscf_t* pdu, uint16_t value);

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions include/avtp/acf/custom/Vss.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include "avtp/Defines.h"
#include "avtp/acf/AcfCommon.h"

#ifdef __cplusplus
extern "C" {
#endif

#define AVTP_VSS_FIXED_HEADER_LEN (3 * AVTP_QUADLET_SIZE)
#define AVTP_ACF_TYPE_VSS 0x42

Expand Down Expand Up @@ -272,3 +276,7 @@ void Avtp_Vss_SetVssData(Avtp_Vss_t* pdu, VssData_t* val);
void Avtp_Vss_SerializeStringArray(VssDataStringArray_t* vss_data_string_array,
VssDataString_t* strings[],
uint16_t num_strings);

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit a0be7bb

Please sign in to comment.