Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Avtp_UDP_t to Avtp_Udp_t #27

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/acf-can/acf-can-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int new_packet(int sk_fd, int can_socket) {
uint8_t pdu[MAX_PDU_SIZE];
uint8_t* cf_pdu;
uint8_t* acf_pdu;
Avtp_UDP_t *udp_pdu;
Avtp_Udp_t *udp_pdu;
char stdout_string[1000] = "\0";
struct can_frame frame;
uint64_t eff;
Expand All @@ -191,8 +191,8 @@ static int new_packet(int sk_fd, int can_socket) {
}

if (use_udp) {
udp_pdu = (Avtp_UDP_t *) pdu;
Avtp_UDP_GetField(udp_pdu, AVTP_UDP_FIELD_ENCAPSULATION_SEQ_NO, &udp_seq_num);
udp_pdu = (Avtp_Udp_t *) pdu;
Avtp_Udp_GetField(udp_pdu, AVTP_UDP_FIELD_ENCAPSULATION_SEQ_NO, &udp_seq_num);
cf_pdu = pdu + AVTP_UDP_HEADER_LEN;
proc_bytes += AVTP_UDP_HEADER_LEN;
} else {
Expand Down
6 changes: 3 additions & 3 deletions examples/acf-can/acf-can-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ int main(int argc, char *argv[])
pdu_length = 0;

if (use_udp) {
Avtp_UDP_t *udp_pdu = (Avtp_UDP_t *) pdu;
Avtp_UDP_SetField(udp_pdu, AVTP_UDP_FIELD_ENCAPSULATION_SEQ_NO,
Avtp_Udp_t *udp_pdu = (Avtp_Udp_t *) pdu;
Avtp_Udp_SetField(udp_pdu, AVTP_UDP_FIELD_ENCAPSULATION_SEQ_NO,
seq_num);
cf_pdu = &pdu[sizeof(Avtp_UDP_t)];
cf_pdu = &pdu[sizeof(Avtp_Udp_t)];
} else {
cf_pdu = pdu;
}
Expand Down
10 changes: 5 additions & 5 deletions include/avtp/Udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
typedef struct {
uint8_t header[AVTP_UDP_HEADER_LEN];
uint8_t payload[0];
} Avtp_UDP_t;
} Avtp_Udp_t;

typedef enum {

Expand All @@ -53,14 +53,14 @@ typedef enum {

/* Count number of fields for bound checks */
AVTP_UDP_FIELD_MAX
} Avtp_UDPFields_t;
} Avtp_UdpFields_t;

/**
* Initializes a UDP PDU as specified in the IEEE 1722-2016 Specification.
*
* @param pdu Pointer to the first bit of an IEEE 1722 UDP PDU.
*/
int Avtp_UDP_Init(Avtp_UDP_t* pdu);
int Avtp_Udp_Init(Avtp_Udp_t* pdu);

/**
* Returns the value of an an AVTP UDP field as specified in the IEEE 1722 Specification.
Expand All @@ -71,7 +71,7 @@ int Avtp_UDP_Init(Avtp_UDP_t* pdu);
* @returns This function returns 0 if the data field was successfully read from
* the 1722 AVTP PDU.
*/
int Avtp_UDP_GetField(Avtp_UDP_t* pdu, Avtp_UDPFields_t field, uint64_t* value);
int Avtp_Udp_GetField(Avtp_Udp_t* pdu, Avtp_UdpFields_t field, uint64_t* value);

/**
* Sets the value of an an AVTP UDP field as specified in the IEEE 1722 Specification.
Expand All @@ -82,5 +82,5 @@ int Avtp_UDP_GetField(Avtp_UDP_t* pdu, Avtp_UDPFields_t field, uint64_t* value);
* @returns This function returns 0 if the data field was successfully set in
* the 1722 AVTP PDU.
*/
int Avtp_UDP_SetField(Avtp_UDP_t* pdu, Avtp_UDPFields_t field, uint64_t value);
int Avtp_Udp_SetField(Avtp_Udp_t* pdu, Avtp_UdpFields_t field, uint64_t value);

20 changes: 10 additions & 10 deletions src/avtp/Udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,32 @@
/**
* This table maps all IEEE 1722 UDP-specific header fields to a descriptor.
*/
static const Avtp_FieldDescriptor_t Avtp_UDPFieldDesc[AVTP_UDP_FIELD_MAX] = {
static const Avtp_FieldDescriptor_t Avtp_UdpFieldDesc[AVTP_UDP_FIELD_MAX] = {

[AVTP_UDP_FIELD_ENCAPSULATION_SEQ_NO] = { .quadlet = 0, .offset = 0, .bits = 32 },
};

int Avtp_UDP_Init(Avtp_UDP_t* pdu) {
int Avtp_Udp_Init(Avtp_Udp_t* pdu) {

int res = 0;

if (!pdu)
return -EINVAL;

memset(pdu, 0, sizeof(Avtp_UDP_t));
memset(pdu, 0, sizeof(Avtp_Udp_t));

res = Avtp_SetField(Avtp_UDPFieldDesc, AVTP_UDP_FIELD_MAX, (uint8_t*) pdu,
res = Avtp_SetField(Avtp_UdpFieldDesc, AVTP_UDP_FIELD_MAX, (uint8_t*) pdu,
AVTP_UDP_FIELD_ENCAPSULATION_SEQ_NO, 0);

return res;
}

int Avtp_UDP_GetField(Avtp_UDP_t* pdu,
Avtp_UDPFields_t field, uint64_t* value) {
return Avtp_GetField(Avtp_UDPFieldDesc, AVTP_UDP_FIELD_MAX, (uint8_t*) pdu, (uint8_t) field, value);
int Avtp_Udp_GetField(Avtp_Udp_t* pdu,
Avtp_UdpFields_t field, uint64_t* value) {
return Avtp_GetField(Avtp_UdpFieldDesc, AVTP_UDP_FIELD_MAX, (uint8_t*) pdu, (uint8_t) field, value);
}

int Avtp_UDP_SetField(Avtp_UDP_t* pdu,
Avtp_UDPFields_t field, uint64_t value) {
return Avtp_SetField(Avtp_UDPFieldDesc, AVTP_UDP_FIELD_MAX, (uint8_t*) pdu, (uint8_t) field, value);
int Avtp_Udp_SetField(Avtp_Udp_t* pdu,
Avtp_UdpFields_t field, uint64_t value) {
return Avtp_SetField(Avtp_UdpFieldDesc, AVTP_UDP_FIELD_MAX, (uint8_t*) pdu, (uint8_t) field, value);
}