Difference between revisions of "Unit UDP"
From Ultibo.org
(11 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
---- | ---- | ||
− | '' | + | '''Ultibo UDP (User Datagram Protocol) unit''' |
=== Constants === | === Constants === | ||
Line 58: | 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 68: | 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 85: | Line 85: | ||
---- | ---- | ||
− | '' | + | |
+ | '''UDP header''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PUDPHeader = ^TUDPHeader;</code> | ||
+ | |||
+ | <code>TUDPHeader = packed record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: Some UDP definitions are in the Protocol or IP modules | ||
+ | |- | ||
+ | |colspan="2"|Note: 8 Bytes | ||
+ | |- | ||
+ | | <code>SourcePort:Word;</code> | ||
+ | | Network Order | ||
+ | |- | ||
+ | | <code>DestPort:Word;</code> | ||
+ | | Network Order | ||
+ | |- | ||
+ | | <code>Length:Word;</code> | ||
+ | | Network Order | ||
+ | |- | ||
+ | | <code>Checksum:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''UDP datagram''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | <code>PUDPDatagram = ^TUDPDatagram;</code> | ||
+ | |||
+ | <code>TUDPDatagram = record</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: 8 Bytes (Used by UDPBuffer) | ||
+ | |- | ||
+ | | <code>Size:Word;</code> | ||
+ | | Word to keep size even | ||
+ | |- | ||
+ | | <code>RemotePort:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>Next:PUDPDatagram;</code> | ||
+ | | Followed by RemoteAddress (4 or 16 Bytes) | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | |||
+ | === Class definitions === | ||
+ | ---- | ||
+ | |||
+ | |||
+ | '''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 === | ||
---- | ---- | ||
− | '' | + | ''None defined'' |
=== Function declarations === | === Function declarations === | ||
Line 96: | 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 104: | Line 193: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 119: | 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 134: | 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 146: | 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 158: | 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 170: | 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 182: | Line 271: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 194: | 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