OpENer - Open Source EtherNet/IP(TM) I/O Target Stack
2.1
|
Includes a basic set of operations for UDP header creation and checksum calculation. More...
#include <stdint.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | UDPHeader |
Representing the needed information for the UDP header. More... | |
Functions | |
uint16_t | UDPHeaderCalculateChecksum (const void *udp_packet, const size_t udp_packet_length, const in_addr_t source_addr, const in_addr_t destination_addr) |
Calculates the checksum based on the set UDP packet data and pseudo IP header. More... | |
void | UDPHeaderGenerate (const UDPHeader *header, char *message) |
Generate the UDP header in the message according to the header. More... | |
uint16_t | UDPHeaderGetChecksum (const UDPHeader *const header) |
Gets checksum field. More... | |
uint16_t | UDPHeaderGetDestinationPort (const UDPHeader *const header) |
Gets destination port field. More... | |
uint16_t | UDPHeaderGetPacketLength (const UDPHeader *const header) |
Gets packet length field. More... | |
uint16_t | UDPHeaderGetSourcePort (const UDPHeader *const header) |
Gets source port field. More... | |
void | UDPHeaderSetChecksum (UDPHeader *const header, const uint16_t checksum) |
Sets checksum field. More... | |
void | UDPHeaderSetDestinationPort (UDPHeader *const header, const uint16_t destination_port) |
Sets destination port field. More... | |
void | UDPHeaderSetPacketLength (UDPHeader *const header, const uint16_t packet_length) |
Sets packet length field. More... | |
void | UDPHeaderSetSourcePort (UDPHeader *const header, const uint16_t source_port) |
Sets source port field. More... | |
Includes a basic set of operations for UDP header creation and checksum calculation.
Definition in file udp_protocol.h.
uint16_t UDPHeaderCalculateChecksum | ( | const void * | udp_packet, |
const size_t | udp_packet_length, | ||
const in_addr_t | source_addr, | ||
const in_addr_t | destination_addr | ||
) |
Calculates the checksum based on the set UDP packet data and pseudo IP header.
udp_packet | the UDP packet including the UDP header |
udp_packet_length | UPD packet length |
source_addr | The IP source address |
destination_addr | The IP destination address |
Definition at line 61 of file udp_protocol.c.
Referenced by SendUdpData().
void UDPHeaderGenerate | ( | const UDPHeader * | header, |
char * | message | ||
) |
Generate the UDP header in the message according to the header.
The function generates the UDP header according to the header struct overwriting the first 8 bytes
header | The UDP header struct instance |
message | The message buffer |
Definition at line 49 of file udp_protocol.c.
References UDPHeaderGetChecksum(), UDPHeaderGetDestinationPort(), UDPHeaderGetPacketLength(), and UDPHeaderGetSourcePort().
Referenced by SendUdpData().
uint16_t UDPHeaderGetChecksum | ( | const UDPHeader *const | header | ) |
Gets checksum field.
header | The UDP header struct instance |
Definition at line 45 of file udp_protocol.c.
References UDPHeader::checksum.
Referenced by UDPHeaderGenerate().
uint16_t UDPHeaderGetDestinationPort | ( | const UDPHeader *const | header | ) |
Gets destination port field.
header | The header struct instance |
Definition at line 27 of file udp_protocol.c.
References UDPHeader::destination_port.
Referenced by UDPHeaderGenerate().
uint16_t UDPHeaderGetPacketLength | ( | const UDPHeader *const | header | ) |
Gets packet length field.
header | The header struct instance |
Definition at line 36 of file udp_protocol.c.
References UDPHeader::packet_length.
Referenced by UDPHeaderGenerate().
uint16_t UDPHeaderGetSourcePort | ( | const UDPHeader *const | header | ) |
Gets source port field.
header | The header struct instance |
Definition at line 18 of file udp_protocol.c.
References UDPHeader::source_port.
Referenced by UDPHeaderGenerate().
void UDPHeaderSetChecksum | ( | UDPHeader *const | header, |
const uint16_t | checksum | ||
) |
Sets checksum field.
header | The UDP header struct instance |
checksum | Checksum value to be set |
Definition at line 40 of file udp_protocol.c.
References UDPHeader::checksum.
Referenced by SendUdpData().
void UDPHeaderSetDestinationPort | ( | UDPHeader *const | header, |
const uint16_t | destination_port | ||
) |
Sets destination port field.
header | The UDP header struct instance |
destination_port | Destination port value to be set |
Definition at line 22 of file udp_protocol.c.
References UDPHeader::destination_port.
void UDPHeaderSetPacketLength | ( | UDPHeader *const | header, |
const uint16_t | packet_length | ||
) |
Sets packet length field.
header | The UDP header struct instance |
packet_length | Length value to be set |
Definition at line 31 of file udp_protocol.c.
References UDPHeader::packet_length.
void UDPHeaderSetSourcePort | ( | UDPHeader *const | header, |
const uint16_t | source_port | ||
) |
Sets source port field.
header | The UDP header struct instance |
source_port | Source port value to be set |
Definition at line 13 of file udp_protocol.c.
References UDPHeader::source_port.