Difference between revisions of "Unit ICMP"

From Ultibo.org
Jump to: navigation, search
 
(9 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
 
'''Ultibo ICMP (Internet Control Message Protocol) unit'''
 
'''Ultibo ICMP (Internet Control Message Protocol) unit'''
 
''To be documented''
 
  
 
=== Constants ===
 
=== Constants ===
Line 14: Line 12:
  
 
<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;">'''ICMP specific constants''' <code> ICMP_PROTOCOL_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''ICMP protocol''' <code> ICMP_PROTOCOL_* </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 29: Line 27:
 
<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;">'''ICMP constants''' <code> ICMP_* </code></div>
+
<div style="font-size: 14px; padding-left: 12px;">'''ICMP specific constants''' <code> ICMP_* </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 197: Line 195:
 
</div></div>  
 
</div></div>  
  
'''ICMP Ip header
+
'''ICMP IP header
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
Line 533: Line 531:
 
----
 
----
  
''To be documented''
 
  
 +
'''ICMP specific classes'''
 +
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TICMPProtocolTransport|<code>TICMPProtocolTransport = class(TProtocolTransport)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TICMPProtocol|<code>TICMPProtocol = class(TNetworkProtocol)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TICMPSocket|<code>TICMPSocket = class(TProtocolSocket)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TICMPBuffer|<code>TICMPBuffer = class(TSocketBuffer)</code>]]
 +
|-
 +
|}
 +
<br />
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
Line 552: Line 572:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 567: Line 587:
 
{| 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 579: Line 599:
 
{| 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 591: Line 611:
 
{| 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 603: Line 623:
 
{| 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 615: Line 635:
 
{| 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 623: Line 643:
 
<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;">
 
<pre style="border: 0; padding-bottom:0px;">function ChecksumICMP(AFamily:Word; ABuffer:Pointer; AOffset,ALength:Word):Word;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function ChecksumICMP(AFamily:Word; ABuffer:Pointer; AOffset,ALength:Word):Word;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Checksum the ICMP Header on Send / Validate the Checksum on Receive</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Checksum the ICMP Header on Send/Validate the Checksum on Receive</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;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-

Latest revision as of 05:24, 31 August 2021

Return to Unit Reference


Description


Ultibo ICMP (Internet Control Message Protocol) unit

Constants



ICMP protocol ICMP_PROTOCOL_*
Note: Some ICMP definitions are in the Protocol or IP modules
 
ICMP_PROTOCOL_NAME = 'ICMP';  


ICMP specific constants ICMP_*
ICMP_TIMEOUT = 0; Wait forever on a ICMP Read
ICMP_BUFFER_SIZE = 65536; ICMP Receive Buffer Size
 
ICMP_HEADER_SIZE = 8; SizeOf(TICMPHeader); ICMP.Solicit
 
ICMP_PACKET_SIZE = 8; SizeOf(TICMPPacket)
 
ICMP_ROUTER_TIMEOUT = 60000;  


Type definitions



ICMP unused header

PICMPUnusedHeader = ^TICMPUnusedHeader;

TICMPUnusedHeader = packed record {Unreachable, TimeExceeded, SourceQuench etc}

Note: Some ICMP definitions are in the Protocol or IP modules
ICMPType:Byte; ICMP_UNREACH etc
Code:Byte; ICMP_UNREACH_NET,ICMP_UNREACH_PORT etc
Checksum:Word; 1s Compliment checksum of Structure
Unused:LongWord; 4 Bytes Unused Must be Zero
IP:TIPHeader; IP Header from Original IP Packet
Data:array[0..7] of Byte; 8 Bytes of Original IP Packet Data

ICMP unreach header

PICMPUnreachHeader = ^TICMPUnreachHeader;

TICMPUnreachHeader = TICMPUnusedHeader;

Note: ICMP_UNREACH
   

ICMP expire header

PICMPExpireHeader = ^TICMPExpireHeader;

TICMPExpireHeader = TICMPUnusedHeader;

Note: ICMP_TIMXCEED
   

ICMP quench header

PICMPQuenchHeader = ^TICMPQuenchHeader;

TICMPQuenchHeader = TICMPUnusedHeader;

Note: ICMP_SOURCEQUENCH
   

ICMP pointer header

PICMPPointerHeader = ^TICMPPointerHeader;

TICMPPointerHeader = packed record

Note: Param Problem
ICMPType:Byte; ICMP_PARAMPROB etc
Code:Byte; ICMP_PARAMPROB_OPTABSENT etc
Checksum:Word; 1s Compliment checksum of Structure
Pointer:Byte; If Code = 0 Pointer to Byte where Error Occured
Unused:array[0..2] of Byte; 3 Bytes Unused Must be Zero
IP:TIPHeader; IP Header from Original IP Packet
Data:array[0..7] of Byte; 8 Bytes of Original IP Packet Data

ICMP param header

PICMPParamHeader = ^TICMPParamHeader;

TICMPParamHeader = TICMPPointerHeader;

Note: ICMP_PARAMPROB
   

ICMP IP header

PICMPIpHeader = ^TICMPIpHeader;

TICMPIpHeader = packed record

Note: Redirect
ICMPType:Byte; ICMP_REDIRECT etc
Code:Byte; ICMP_REDIRECT_NET,ICMP_REDIRECT_HOST etc
Checksum:Word; 1s Compliment checksum of Structure
Gateway:TInAddr; Redirect Gateway Address
IP:TIPHeader; IP Header from Original IP Packet
Data:array[0..7] of Byte; 8 Bytes of Original IP Packet Data

ICMP redirect header

PICMPRedirectHeader = ^TICMPRedirectHeader;

TICMPRedirectHeader = TICMPIpHeader

Note: ICMP_REDIRECT
   

ICMP echo header

PICMPEchoHeader = ^TICMPEchoHeader;

TICMPEchoHeader = packed record

Note: Echo Request/Reply
ICMPType:Byte; ICMP_ECHO,ICMP_ECHOREPLY
Code:Byte; Always 0
Checksum:Word; 1s Compliment checksum of Structure
Identifier:Word; Increments with each ICMP_ECHO
Sequence:Word; Sequence within an ICMP_ECHO set
Data:array[0..((MAX_IP_PACKET - 1) - SizeOf(TIPHeader)) - 8] of Byte;  

ICMP time stamp header

PICMPTimestampHeader = ^TICMPTimestampHeader;

TICMPTimestampHeader = packed record

Note: Timestamp Request/Reply
ICMPType:Byte; ICMP_TSTAMP,ICMP_TSTAMPREPLY
Code:Byte; Always 0
Checksum:Word; 1s Compliment checksum of Structure
Identifier:Word; Increments with each ICMP_TSTAMP
Sequence:Word; Sequence within an ICMP_TSTAMP set
Original:LongWord; Original Timestamp
Receive:LongWord; Receive Timestamp
Transmit:LongWord; Transmit Timestamp (A sort of Round Trip Time Echo)

ICMP info header

PICMPInfoHeader = ^TICMPInfoHeader;

TICMPInfoHeader = packed record

Note: Info Request/Reply
ICMPType:Byte; ICMP_IREQ,ICMP_IREQREPLY
Code:Byte; Always 0
Checksum:Word; 1s Compliment checksum of Structure
Identifier:Word; Increments with each ICMP_IREQ
Sequence:Word; Sequence within an ICMP_IREQ set (Used to determine Network Number of Local Subnet)

ICMP mask header

PICMPMaskHeader = ^TICMPMaskHeader;

TICMPMaskHeader = packed record

Note: Mask Request/Reply
ICMPType:Byte; ICMP_MASKREQ,ICMP_MASKREPLY
Code:Byte; Always 0
Checksum:Word; 1s Compliment checksum of Structure
Identifier:Word; Increments with each ICMP_MASKREQ
Sequence:Word; Sequence within an ICMP_MASKREQ set
Mask:TInAddr; Subnet Mask of Local Subnet (Used to determine Subnet Mask of Local Subnet)

ICMP router address

PICMPRouterAddress = ^TICMPRouterAddress;

TICMPRouterAddress = packed record

Address:TInAddr; The address of the Router on this subnet
Level:LongInt; The level of preference, higher is better

ICMP advert header

PICMPAdvertHeader = ^TICMPAdvertHeader;

TICMPAdvertHeader = packed record

ICMPType:Byte; ICMP_ROUTERADVERT
Code:Byte; Always 0
Checksum:Word; 1s Compliment checksum of Structure
EntryCount:Byte; Number of Router Address entries
EntrySize:Byte; Size of each Router Address entry
Lifetime:Word; Lifetime of entries in seconds
Routers:array[1..EntryCount] of TICMPRouterAddress; Used to advertise routers

ICMP solicit header

PICMPSolicitHeader = ^TICMPSolicitHeader;

TICMPSolicitHeader = packed record

ICMPType:Byte; ICMP_ROUTERSOLICIT
Code:Byte; Always 0
Checksum:Word; 1s Compliment checksum of Structure
Reserved:LongWord; Always 0 (Used to solicit routers)

ICMP header

PICMPHeader = ^TICMPHeader;

TICMPHeader = packed record

case Integer of  
0:(Unused:TICMPUnusedHeader);  
1:(Unreach:TICMPUnreachHeader);  
2:(Expire:TICMPExpireHeader);  
3:(Quench:TICMPQuenchHeader);  
4:(Pointer:TICMPPointerHeader);  
5:(Param:TICMPParamHeader);  
6:(Ip:TICMPIpHeader);  
7:(Redirect:TICMPRedirectHeader);  
8:(Echo:TICMPEchoHeader);  
9:(Timestamp:TICMPTimestampHeader);  
10:(Info:TICMPInfoHeader);  
11:(Mask:TICMPMaskHeader);  
12:(Advert:TICMPAdvertHeader);  
13:(Solicit:TICMPSolicitHeader);  

ICMP packet

PICMPPacket = ^TICMPPacket;

TICMPPacket = record

Note: 8 Bytes (Used by ICMPBuffer)
Size:LongWord; LongWord to keep size even
Next:PICMPPacket; Followed by RemoteAddress (4 or 16 Bytes)


Class definitions



ICMP specific classes

TICMPProtocolTransport = class(TProtocolTransport)
TICMPProtocol = class(TNetworkProtocol)
TICMPSocket = class(TProtocolSocket)
TICMPBuffer = class(TSocketBuffer)


Public variables


None defined

Function declarations



Initialization functions

procedure ICMPInit;
Description: To be documented
Note None documented


ICMP functions

function CheckICMP(AFamily:Word; ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid ICMP packet
Buffer The complete packet including Transport header


function GetICMPHeaderOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetICMPHeaderLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetICMPDataOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetICMPDataLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function ChecksumICMP(AFamily:Word; ABuffer:Pointer; AOffset,ALength:Word):Word;
Description: Checksum the ICMP Header on Send/Validate the Checksum on Receive
Note None documented


Return to Unit Reference