Difference between revisions of "Unit UDP"
From Ultibo.org
Line 143: | Line 143: | ||
---- | ---- | ||
− | '' | + | |
+ | '''UDP protocol transport''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TUDPProtocolTransport = class(TProtocolTransport)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''UDP protocol''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TUDPProtocol = class(TNetworkProtocol)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>constructor Create(AManager:TProtocolManager; const AName:String);</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>destructor Destroy; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | | <code>FNextPort:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div> | ||
+ | |- | ||
+ | | <code>function AddTransport(ATransport:TNetworkTransport):Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function RemoveTransport(ATransport:TNetworkTransport):Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function OpenPort(ASocket:TProtocolSocket; APort:Word):Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function ClosePort(ASocket:TProtocolSocket):Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function FindPort(APort:Word; AWrite,ALock:Boolean):TProtocolPort; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function FindSocket(AFamily,AStruct,AProtocol:Word; ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast,AListen,ALock:Boolean; AState:LongWord):TProtocolSocket; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure FlushSockets(All:Boolean); override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function SelectCheck(ASource,ADest:PFDSet; ACode:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function SendPacket(ASocket:TProtocolSocket; ASource,ADest:Pointer; ASourcePort,ADestPort:Word; APacket:PPacketFragment; ASize,AFlags:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>function Accept(ASocket:TProtocolSocket; ASockAddr:PSockAddr; AAddrLength:PInteger):TProtocolSocket; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function Bind(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function CloseSocket(ASocket:TProtocolSocket):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function Connect(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function IoctlSocket(ASocket:TProtocolSocket; ACmd:DWORD; var AArg:u_long):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetPeerName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetSockName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function Listen(ASocket:TProtocolSocket; ABacklog:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function Recv(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function RecvFrom(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AFromAddr:TSockAddr; var AFromLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function Select(ANfds:Integer; AReadfds,AWritefds,AExceptfds:PFDSet; ATimeout:PTimeVal):LongInt; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function Send(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendTo(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AToAddr:TSockAddr; AToLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function Shutdown(ASocket:TProtocolSocket; AHow:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function Socket(AFamily,AStruct,AProtocol:Integer):TProtocolSocket; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function StartProtocol:Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function StopProtocol:Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function ProcessProtocol:Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''UDP socket''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TUDPSocket = class(TProtocolSocket)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: SOCK_DGRAM | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>constructor Create(AProtocol:TNetworkProtocol; ATransport:TNetworkTransport);</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>destructor Destroy; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | | <code>FRecvData:TUDPBuffer;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>property RecvData:TUDPBuffer read FRecvData;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function GetOption(ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SetOption(ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function IoCtl(ACommand:DWORD; var AArgument:u_long):Integer; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function IsConnected(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function IsListening(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''UDP state''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TUDPState = class(TProtocolState)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>constructor Create;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''UDP buffer''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TUDPBuffer = class(TSocketBuffer)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | | <code>constructor Create(ASocket:TTransportSocket);</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>destructor Destroy; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | | <code>FOffset:Word;</code> | ||
+ | | Offset to RemoteAddress | ||
+ | |- | ||
+ | | <code>FLength:Word;</code> | ||
+ | | Length of RemoteAddress | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FRead:Pointer;</code> | ||
+ | | Pointer to Next Read from Buffer | ||
+ | |- | ||
+ | | <code>FWrite:Pointer;</code> | ||
+ | | Pointer to Next Write to Buffer | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FCount:LongWord;</code> | ||
+ | | Number of Datagrams in Buffer | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FFirst:PUDPDatagram;</code> | ||
+ | | Pointer to First Datagram | ||
+ | |- | ||
+ | | <code>FLast:PUDPDatagram;</code> | ||
+ | | Pointer to Last Datagram | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function AddDatagram(ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function RemoveDatagram:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure FlushDatagrams;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div> | ||
+ | |- | ||
+ | | <code>procedure SetSize(ASize:LongWord); override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>function GetNext:Integer;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function ReadBuffer(var ABuffer; var ASize:Integer; ARemoteAddress:Pointer; ARemotePort:PWORD; AFlags:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function WriteBuffer(var ABuffer; ASize:Integer; ARemoteAddress:Pointer; ARemotePort:PWORD):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''UDP options''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TUDPOptions = class(TProtocolOptions)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|Note: For Get/Set Options Level = IPPROTO_UDP Option = ???? | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>constructor Create;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | | <code>FOptions:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function GetNoChecksum:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetNoChecksum(ANoChecksum:Boolean);</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>property NoChecksum:Boolean read GetNoChecksum write SetNoChecksum;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === |
Revision as of 23:06, 22 March 2017
Return to Unit Reference
Contents
[hide]Description
Ultibo UDP (User Datagram Protocol) unit
To be documented
Constants
[Expand]
UDP specific constants
UDP_*
[Expand]
UDP socket option constants
[Expand]
UDP port constants
UDP_PORT_*
Type definitions
UDP header
UDP datagram
Class definitions
UDP protocol transport
[Expand]
TUDPProtocolTransport = class(TProtocolTransport)
UDP protocol
[Expand]
TUDPProtocol = class(TNetworkProtocol)
UDP socket
[Expand]
TUDPSocket = class(TProtocolSocket)
UDP state
[Expand]
TUDPState = class(TProtocolState)
UDP buffer
[Expand]
TUDPBuffer = class(TSocketBuffer)
UDP options
[Expand]
TUDPOptions = class(TProtocolOptions)
Public variables
None defined
Function declarations
Initialization Functions
UDP functions
[Expand]
function CheckUDP(AFamily:Word; ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid UDP packet
[Expand]
function GetUDPHeaderOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
[Expand]
function GetUDPHeaderLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
[Expand]
function GetUDPDataOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
[Expand]
function GetUDPDataLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
[Expand]
function ChecksumUDPRecv(AFamily:Word; APseudo:PIPPseudo; ABuffer:Pointer; AOffset,ALength:Word):Word;
Description: Validate the Checksum of UDP Pseudo, Header and Data on Receive
[Expand]
function ChecksumUDPSend(AFamily:Word; APseudo:PIPPseudo; AHeader:PUDPHeader; AData:Pointer; ALength:Word):Word;
Description: Checksum the UDP Pseudo, Header and Data on Send
Return to Unit Reference