Difference between revisions of "Unit ICMPv6"
From Ultibo.org
Line 107: | Line 107: | ||
---- | ---- | ||
− | '' | + | |
+ | '''ICMPv6 protocol transport''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TICMP6ProtocolTransport = class(TProtocolTransport)</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%;"| | ||
+ | |- | ||
+ | | <code>destructor Destroy; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>Socket:TICMP6Socket;</code> | ||
+ | | Socket for sending replies | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''ICMPv6 protocol''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TICMP6Protocol = 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>FNextICMP6Id:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FNextICMP6Lock:TMutexHandle;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function ControlHandler(AHandle:THandle; ASource,ADest:Pointer; AProtocol,ACommand,ACode:Word; AAddress,AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function GetNextICMP6Id(AIncrement:Boolean):Word;</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 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> | ||
+ | |||
+ | '''ICMPv6 socket''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TICMP6Socket = 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_RAW | ||
+ | |- | ||
+ | |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:TICMP6Buffer;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>property RecvData:TICMP6Buffer read FRecvData;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <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> | ||
+ | |||
+ | '''ICMPv6 buffer''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TICMP6Buffer = 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 Packets in Buffer | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FFirst:PICMP6Packet;</code> | ||
+ | | Pointer to First Packet | ||
+ | |- | ||
+ | | <code>FLast:PICMP6Packet;</code> | ||
+ | | Pointer to Last Packet | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function AddPacket(ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function RemovePacket:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure FlushPackets;</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; AFlags:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function WriteBuffer(var ABuffer; ASize:Integer; ARemoteAddress:Pointer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === |
Revision as of 00:52, 15 March 2017
Return to Unit Reference
Contents
Description
Ultibo ICMPv6 (Internet Control Message Protocol version 6) unit
To be documented
Constants
ICMPv6 specific constants
ICMP6_PROTOCOL_*
Note: Some ICMPV6 definitions are in the Protocol or IPv6 modules | |
ICMP6_PROTOCOL_NAME = 'ICMPV6';
|
ICMPv6 constants
ICMP6_*
ICMP6_TIMEOUT = 0;
|
Wait forever on a ICMP6 Read |
ICMP6_BUFFER_SIZE = 65536;
|
ICMP6 Receive Buffer Size |
ICMP6_HEADER_SIZE = 5;
|
SizeOf(TICMP6Header); |
ICMP6_PACKET_SIZE = 8;
|
SizeOf(TICMP6Packet) |
Type definitions
ICMPv6 header
PICMP6Header = ^TICMP6Header;
TICMP6Header = packed record
Note: Some ICMPv6 definitions are in the Protocol or IPv6 modules | |
ICMP6Type:Byte;
|
ICMP_UNREACH etc |
Code:Byte;
|
ICMP_UNREACH_NET,ICMP_UNREACH_PORT etc |
Checksum:Word;
|
1s Compliment checksum of Structure |
CurrentHopLimit:Byte;
|
ICMPv6 packet
PICMP6Packet = ^TICMP6Packet;
TICMP6Packet = record
Note: 8 Bytes (Used by ICMP6Buffer) | |
Size:LongWord;
|
LongWord to keep size even |
Next:PICMP6Packet;
|
Followed by RemoteAddress (4 or 16 Bytes) |
Class definitions
ICMPv6 protocol transport
TICMP6ProtocolTransport = class(TProtocolTransport)
constructor Create;
|
|
destructor Destroy; override;
|
|
public
| |
Socket:TICMP6Socket;
|
Socket for sending replies |
ICMPv6 protocol
TICMP6Protocol = class(TNetworkProtocol)
constructor Create(AManager:TProtocolManager; const AName:String);
|
|
destructor Destroy; override;
|
|
private
| |
FNextICMP6Id:Word;
|
|
FNextICMP6Lock:TMutexHandle;
|
|
function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;
|
|
function ControlHandler(AHandle:THandle; ASource,ADest:Pointer; AProtocol,ACommand,ACode:Word; AAddress,AData:Pointer; ASize:Integer):Boolean;
|
|
function GetNextICMP6Id(AIncrement:Boolean):Word;
|
|
protected
| |
function AddTransport(ATransport:TNetworkTransport):Boolean; override;
|
|
function RemoveTransport(ATransport:TNetworkTransport):Boolean; override;
|
|
function FindSocket(AFamily,AStruct,AProtocol:Word; ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast,AListen,ALock:Boolean; AState:LongWord):TProtocolSocket; override;
|
|
procedure FlushSockets(All:Boolean); override;
|
|
function SelectCheck(ASource,ADest:PFDSet; ACode:Integer):Integer; override;
|
|
function SendPacket(ASocket:TProtocolSocket; ASource,ADest:Pointer; ASourcePort,ADestPort:Word; APacket:PPacketFragment; ASize,AFlags:Integer):Integer; override;
|
|
public
| |
function Accept(ASocket:TProtocolSocket; ASockAddr:PSockAddr; AAddrLength:PInteger):TProtocolSocket; override;
|
|
function Bind(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer; override;
|
|
function CloseSocket(ASocket:TProtocolSocket):Integer; override;
|
|
function Connect(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer; override;
|
|
function IoctlSocket(ASocket:TProtocolSocket; ACmd:DWORD; var AArg:u_long):Integer; override;
|
|
function GetPeerName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer; override;
|
|
function GetSockName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer; override;
|
|
function GetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer; override;
|
|
function Listen(ASocket:TProtocolSocket; ABacklog:Integer):Integer; override;
|
|
function Recv(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer; override;
|
|
function RecvFrom(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AFromAddr:TSockAddr; var AFromLength:Integer):Integer; override;
|
|
function Select(ANfds:Integer; AReadfds,AWritefds,AExceptfds:PFDSet; ATimeout:PTimeVal):LongInt; override;
|
|
function Send(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer; override;
|
|
function SendTo(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AToAddr:TSockAddr; AToLength:Integer):Integer; override;
|
|
function SetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer; override;
|
|
function Shutdown(ASocket:TProtocolSocket; AHow:Integer):Integer; override;
|
|
function Socket(AFamily,AStruct,AProtocol:Integer):TProtocolSocket; override;
|
|
function StartProtocol:Boolean; override;
|
|
function StopProtocol:Boolean; override;
|
|
function ProcessProtocol:Boolean; override;
|
ICMPv6 socket
TICMP6Socket = class(TProtocolSocket)
Note: SOCK_RAW | |
constructor Create(AProtocol:TNetworkProtocol; ATransport:TNetworkTransport);
|
|
destructor Destroy; override;
|
|
private
| |
FRecvData:TICMP6Buffer;
|
|
public
| |
property RecvData:TICMP6Buffer read FRecvData;
|
|
function IoCtl(ACommand:DWORD; var AArgument:u_long):Integer; override;
|
|
function IsConnected(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;
|
|
function IsListening(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;
|
ICMPv6 buffer
TICMP6Buffer = class(TSocketBuffer)
constructor Create(ASocket:TTransportSocket);
|
|
destructor Destroy; override;
|
|
private
| |
FOffset:Word;
|
Offset to RemoteAddress |
FLength:Word;
|
Length of RemoteAddress |
FRead:Pointer;
|
Pointer to Next Read from Buffer |
FWrite:Pointer;
|
Pointer to Next Write to Buffer |
FCount:LongWord;
|
Number of Packets in Buffer |
FFirst:PICMP6Packet;
|
Pointer to First Packet |
FLast:PICMP6Packet;
|
Pointer to Last Packet |
function AddPacket(ASize:Integer):Boolean;
|
|
function RemovePacket:Boolean;
|
|
procedure FlushPackets;
|
|
protected
| |
procedure SetSize(ASize:LongWord); override;
|
|
public
| |
function GetNext:Integer;
|
|
function GetCount:LongWord;
|
|
function ReadBuffer(var ABuffer; var ASize:Integer; ARemoteAddress:Pointer; AFlags:Integer):Boolean;
|
|
function WriteBuffer(var ABuffer; ASize:Integer; ARemoteAddress:Pointer):Boolean;
|
Public variables
None defined
Function declarations
Initialization functions
procedure ICMP6Init;
Description: To be documented
Note | None documented |
---|
ICMPv6 functions
function CheckICMP6(AFamily:Word; ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid ICMP6 packet
Buffer | The complete packet including Transport header |
---|
function GetICMP6HeaderOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer | The complete packet including Transport header |
---|
function GetICMP6HeaderLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer | The complete packet including Transport header |
---|
function GetICMP6DataOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer | The complete packet including Transport header |
---|
function GetICMP6DataLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer | The complete packet including Transport header |
---|
function ChecksumICMP6(AFamily:Word; ABuffer:Pointer; AOffset,ALength:Word):Word;
Description: Checksum the ICMP6 Header on Send / Validate the Checksum on Receive
Note | None documented |
---|
Return to Unit Reference