Difference between revisions of "Unit UDP"

From Ultibo.org
Jump to: navigation, search
 
(7 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
 
'''Ultibo UDP (User Datagram Protocol) unit'''
 
'''Ultibo UDP (User Datagram Protocol) unit'''
 
''To be documented''
 
  
 
=== Constants ===
 
=== Constants ===
Line 60: Line 58:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
<div style="font-size: 14px; padding-left: 12px;">'''UDP socket option constants'''</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''UDP socket option'''</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 70: Line 68:
 
<br />  
 
<br />  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
<div style="font-size: 14px; padding-left: 12px;">'''UDP port constants''' <code> UDP_PORT_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''UDP port''' <code> UDP_PORT_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 143: Line 141:
 
----
 
----
  
''To be documented''
+
 
 +
'''UDP specific classes'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TUDPProtocolTransport|<code>TUDPProtocolTransport = class(TProtocolTransport)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TUDPProtocol|<code>TUDPProtocol = class(TNetworkProtocol)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TUDPSocket|<code>TUDPSocket = class(TProtocolSocket)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TUDPState|<code>TUDPState = class(TProtocolState)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TUDPBuffer|<code>TUDPBuffer = class(TSocketBuffer)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TUDPOptions|<code>TUDPOptions = class(TProtocolOptions)</code>]]
 +
|-
 +
|}
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
Line 154: Line 185:
  
  
'''Initialization Functions'''
+
'''Initialization functions'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
Line 162: Line 193:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 177: Line 208:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| The complete packet including Transport header
 
| The complete packet including Transport header
 
|-
 
|-
! '''Note'''
+
! Note
| If checksum is zero then no checksum was added, return True
+
| If checksum is zero then no checksum was added, return True.
 
|-
 
|-
 
|}
 
|}
Line 192: Line 223:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| The complete packet including Transport header
 
| The complete packet including Transport header
 
|-
 
|-
Line 204: Line 235:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| The complete packet including Transport header
 
| The complete packet including Transport header
 
|-
 
|-
Line 216: Line 247:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| The complete packet including Transport header
 
| The complete packet including Transport header
 
|-
 
|-
Line 228: Line 259:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| The complete packet including Transport header
 
| The complete packet including Transport header
 
|-
 
|-
Line 240: Line 271:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 252: Line 283:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-

Latest revision as of 05:33, 31 August 2021

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