Difference between revisions of "Unit UDP"
From Ultibo.org
(6 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
'''Ultibo UDP (User Datagram Protocol) unit''' | '''Ultibo UDP (User Datagram Protocol) unit''' | ||
− | |||
− | |||
=== 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 | + | <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 | + | <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 144: | Line 142: | ||
− | '''UDP | + | '''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>]] |
− | + | ||
− | + | ||
− | | <code> | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|} | |} | ||
− | + | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
− | | | + | | [[TUDPSocket|<code>TUDPSocket = class(TProtocolSocket)</code>]] |
− | + | ||
− | + | ||
− | + | ||
− | | <code> | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|} | |} | ||
− | + | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
− | | <code> | + | | [[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>]] |
− | + | ||
− | + | ||
− | | <code> | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|} | |} | ||
− | + | {| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;" | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
− | | | + | | [[TUDPOptions|<code>TUDPOptions = class(TProtocolOptions)</code>]] |
− | + | ||
− | + | ||
− | + | ||
− | | <code> | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
|} | |} | ||
− | |||
<br /> | <br /> | ||
Line 487: | Line 185: | ||
− | '''Initialization | + | '''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 495: | Line 193: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 510: | Line 208: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| The complete packet including Transport header | | The complete packet including Transport header | ||
|- | |- | ||
− | ! | + | ! Note |
− | | If checksum is zero then no checksum was added, return True | + | | If checksum is zero then no checksum was added, return True. |
|- | |- | ||
|} | |} | ||
Line 525: | Line 223: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| The complete packet including Transport header | | The complete packet including Transport header | ||
|- | |- | ||
Line 537: | Line 235: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| The complete packet including Transport header | | The complete packet including Transport header | ||
|- | |- | ||
Line 549: | Line 247: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| The complete packet including Transport header | | The complete packet including Transport header | ||
|- | |- | ||
Line 561: | Line 259: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Buffer |
| The complete packet including Transport header | | The complete packet including Transport header | ||
|- | |- | ||
Line 573: | Line 271: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 585: | Line 283: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- |
Latest revision as of 05:33, 31 August 2021
Return to Unit Reference
Contents
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