OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
udp_protocol.c File Reference
#include "udp_protocol.h"
Include dependency graph for udp_protocol.c:

Go to the source code of this file.

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...
 

Function Documentation

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.

Parameters
udp_packetthe UDP packet including the UDP header
udp_packet_lengthUPD packet length
source_addrThe IP source address
destination_addrThe IP destination address
Returns
The calculated checksum

Definition at line 61 of file udp_protocol.c.

Referenced by SendUdpData().

Here is the caller graph for this function:

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

Parameters
headerThe UDP header struct instance
messageThe message buffer

Definition at line 49 of file udp_protocol.c.

References UDPHeaderGetChecksum(), UDPHeaderGetDestinationPort(), UDPHeaderGetPacketLength(), and UDPHeaderGetSourcePort().

Referenced by SendUdpData().

Here is the call graph for this function:

Here is the caller graph for this function:

uint16_t UDPHeaderGetChecksum ( const UDPHeader *const  header)

Gets checksum field.

Parameters
headerThe UDP header struct instance
Returns
The packet length

Definition at line 45 of file udp_protocol.c.

References UDPHeader::checksum.

Referenced by UDPHeaderGenerate().

Here is the caller graph for this function:

uint16_t UDPHeaderGetDestinationPort ( const UDPHeader *const  header)

Gets destination port field.

Parameters
headerThe header struct instance
Returns
The destination port

Definition at line 27 of file udp_protocol.c.

References UDPHeader::destination_port.

Referenced by UDPHeaderGenerate().

Here is the caller graph for this function:

uint16_t UDPHeaderGetPacketLength ( const UDPHeader *const  header)

Gets packet length field.

Parameters
headerThe header struct instance
Returns
The packet length

Definition at line 36 of file udp_protocol.c.

References UDPHeader::packet_length.

Referenced by UDPHeaderGenerate().

Here is the caller graph for this function:

uint16_t UDPHeaderGetSourcePort ( const UDPHeader *const  header)

Gets source port field.

Parameters
headerThe header struct instance
Returns
The source port

Definition at line 18 of file udp_protocol.c.

References UDPHeader::source_port.

Referenced by UDPHeaderGenerate().

Here is the caller graph for this function:

void UDPHeaderSetChecksum ( UDPHeader *const  header,
const uint16_t  checksum 
)

Sets checksum field.

Parameters
headerThe UDP header struct instance
checksumChecksum value to be set

Definition at line 40 of file udp_protocol.c.

References UDPHeader::checksum.

Referenced by SendUdpData().

Here is the caller graph for this function:

void UDPHeaderSetDestinationPort ( UDPHeader *const  header,
const uint16_t  destination_port 
)

Sets destination port field.

Parameters
headerThe UDP header struct instance
destination_portDestination 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.

Parameters
headerThe UDP header struct instance
packet_lengthLength 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.

Parameters
headerThe UDP header struct instance
source_portSource port value to be set

Definition at line 13 of file udp_protocol.c.

References UDPHeader::source_port.