Difference between revisions of "Unit ICMP"
Line 533: | Line 533: | ||
---- | ---- | ||
− | '' | + | |
+ | '''ICMP protocol transport''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TICMPProtocolTransport = 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:TICMPSocket;</code> | ||
+ | | Socket for sending replies | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''ICMP protocol''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TICMPProtocol = 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>FNextICMPId:Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FNextICMPLock: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 GetNextICMPId(AIncrement:Boolean):Word;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function SendICMPUnreach(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPRedirect(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AAddress,AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPTimeExceeded(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPSourceQuench(ASocket:TICMPSocket; ASource,ADest:Pointer; AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPParamProblem(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode,APointer:Byte; AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function SendICMPEchoReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPInfoReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPMaskReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPTimestampReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function SendICMPEchoRequest(ASocket:TICMPSocket ;ASource,ADest:Pointer; ASize:Integer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPInfoRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPMaskRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPTimestampRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function SendICMPRouterAdvert(ASocket:TICMPSocket; ASource,ADest,AAddress:Pointer):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendICMPRouterSolicit(ASocket:TICMPSocket; ASource,ADest:Pointer):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 FindSocket(AFamily,AStruct,AProtocol:Word; ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast,AListen,ALock:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>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> | ||
+ | |||
+ | '''ICMP socket''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TICMPSocket = 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:TICMPBuffer;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>property RecvData:TICMPBuffer 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> | ||
+ | |||
+ | '''ICMP buffer''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TICMPBuffer = 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:PICMPPacket;</code> | ||
+ | | Pointer to First Packet | ||
+ | |- | ||
+ | | <code>FLast:PICMPPacket;</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:26, 15 March 2017
Return to Unit Reference
Contents
Description
Ultibo ICMP (Internet Control Message Protocol) unit
To be documented
Constants
ICMP_PROTOCOL_*
Note: Some ICMP definitions are in the Protocol or IP modules | |
ICMP_PROTOCOL_NAME = 'ICMP';
|
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 protocol transport
TICMPProtocolTransport = class(TProtocolTransport)
constructor Create;
|
|
destructor Destroy; override;
|
|
public
| |
Socket:TICMPSocket;
|
Socket for sending replies |
ICMP protocol
TICMPProtocol = class(TNetworkProtocol)
constructor Create(AManager:TProtocolManager; const AName:String);
|
|
destructor Destroy; override;
|
|
private
| |
FNextICMPId:Word;
|
|
FNextICMPLock: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 GetNextICMPId(AIncrement:Boolean):Word;
|
|
function SendICMPUnreach(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPRedirect(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AAddress,AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPTimeExceeded(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPSourceQuench(ASocket:TICMPSocket; ASource,ADest:Pointer; AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPParamProblem(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode,APointer:Byte; AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPEchoReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPInfoReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPMaskReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPTimestampReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPEchoRequest(ASocket:TICMPSocket ;ASource,ADest:Pointer; ASize:Integer):Boolean;
|
|
function SendICMPInfoRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;
|
|
function SendICMPMaskRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;
|
|
function SendICMPTimestampRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;
|
|
function SendICMPRouterAdvert(ASocket:TICMPSocket; ASource,ADest,AAddress:Pointer):Boolean;
|
|
function SendICMPRouterSolicit(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;
|
|
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;
|
ICMP socket
TICMPSocket = class(TProtocolSocket)
Note: SOCK_RAW | |
constructor Create(AProtocol:TNetworkProtocol; ATransport:TNetworkTransport);
|
|
destructor Destroy; override;
|
|
private
| |
FRecvData:TICMPBuffer;
|
|
public
| |
property RecvData:TICMPBuffer 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;
|
ICMP buffer
TICMPBuffer = 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:PICMPPacket;
|
Pointer to First Packet |
FLast:PICMPPacket;
|
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 ICMPInit;
Note | None documented |
---|
ICMP functions
function CheckICMP(AFamily:Word; ABuffer:Pointer):Boolean;
Buffer | The complete packet including Transport header |
---|
function GetICMPHeaderOffset(AFamily:Word; ABuffer:Pointer):Word;
Buffer | The complete packet including Transport header |
---|
function GetICMPHeaderLength(AFamily:Word; ABuffer:Pointer):Word;
Buffer | The complete packet including Transport header |
---|
function GetICMPDataOffset(AFamily:Word; ABuffer:Pointer):Word;
Buffer | The complete packet including Transport header |
---|
function GetICMPDataLength(AFamily:Word; ABuffer:Pointer):Word;
Buffer | The complete packet including Transport header |
---|
function ChecksumICMP(AFamily:Word; ABuffer:Pointer; AOffset,ALength:Word):Word;
Note | None documented |
---|
Return to Unit Reference