16 #ifndef SRC_PORTS_UDP_PROTOCOL_H_
17 #define SRC_PORTS_UDP_PROTOCOL_H_
22 #include <netinet/in.h>
24 typedef uint32_t in_addr_t;
27 static size_t kUpdHeaderLength = 8U;
104 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);
uint16_t UDPHeaderGetPacketLength(const UDPHeader *const header)
Gets packet length field.
uint16_t UDPHeaderGetSourcePort(const UDPHeader *const header)
Gets source port field.
void UDPHeaderGenerate(const UDPHeader *header, char *message)
Generate the UDP header in the message according to the header.
uint16_t UDPHeaderGetDestinationPort(const UDPHeader *const header)
Gets destination port field.
void UDPHeaderSetPacketLength(UDPHeader *const header, const uint16_t packet_length)
Sets packet length field.
void UDPHeaderSetChecksum(UDPHeader *const header, const uint16_t checksum)
Sets checksum field.
void UDPHeaderSetDestinationPort(UDPHeader *const header, const uint16_t destination_port)
Sets destination port field.
uint16_t UDPHeaderGetChecksum(const UDPHeader *const header)
Gets checksum field.
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.
void UDPHeaderSetSourcePort(UDPHeader *const header, const uint16_t source_port)
Sets source port field.