Unit UDP

From Ultibo.org
Revision as of 05:33, 31 August 2021 by Ultibo (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Return to Unit Reference


Description


Ultibo UDP (User Datagram Protocol) unit

Constants



UDP specific constants UDP_*
Note: Some UDP definitions are in the Protocol or IP modules
 
UDP_PROTOCOL_NAME = 'UDP';  
 
MIN_UDP_PACKET = 8; Not Counting Adapter and Transport Header
MAX_UDP_PACKET = 8192; Not Counting Adapter and Transport Header
 
UDP_TIMEOUT = 0; Wait forever on a UDP Read
UDP_BUFFER_SIZE = 65536; UDP Receive Buffer Size
 
UDP_MAX_PORT = 65536;  
 
UDP_HEADER_SIZE = 8; SizeOf(TUDPHeader);
 
UDP_DATAGRAM_SIZE = 8; SizeOf(TUDPDatagram)


UDP socket option
See Sockets.pas


UDP port UDP_PORT_*
UDP_PORT_START = 49152; First dynamic port (Previously 1024) As per IANA assignment
UDP_PORT_STOP = 65534; Last dynamic port (Previously 5000) Short of IANA assignment to allow for rollover


Type definitions



UDP header

PUDPHeader = ^TUDPHeader;

TUDPHeader = packed record

Note: Some UDP definitions are in the Protocol or IP modules
Note: 8 Bytes
SourcePort:Word; Network Order
DestPort:Word; Network Order
Length:Word; Network Order
Checksum:Word;  

UDP datagram

PUDPDatagram = ^TUDPDatagram;

TUDPDatagram = record

Note: 8 Bytes (Used by UDPBuffer)
Size:Word; Word to keep size even
RemotePort:Word;  
Next:PUDPDatagram; Followed by RemoteAddress (4 or 16 Bytes)


Class definitions



UDP specific classes

TUDPProtocolTransport = class(TProtocolTransport)
TUDPProtocol = class(TNetworkProtocol)
TUDPSocket = class(TProtocolSocket)
TUDPState = class(TProtocolState)
TUDPBuffer = class(TSocketBuffer)
TUDPOptions = class(TProtocolOptions)


Public variables


None defined

Function declarations



Initialization functions

procedure UDPInit;
Description: To be documented
Note None documented


UDP functions

function CheckUDP(AFamily:Word; ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid UDP packet
Buffer The complete packet including Transport header
Note If checksum is zero then no checksum was added, return True.


function GetUDPHeaderOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetUDPHeaderLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetUDPDataOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetUDPDataLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function ChecksumUDPRecv(AFamily:Word; APseudo:PIPPseudo; ABuffer:Pointer; AOffset,ALength:Word):Word;
Description: Validate the Checksum of UDP Pseudo, Header and Data on Receive
Note None documented


function ChecksumUDPSend(AFamily:Word; APseudo:PIPPseudo; AHeader:PUDPHeader; AData:Pointer; ALength:Word):Word;
Description: Checksum the UDP Pseudo, Header and Data on Send
Note None documented


Return to Unit Reference