TICMPProtocol
Return to Unit ICMP
Description
To be documented
Class definitions
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 SelectCheck(ASource,ADest:PFDSet; ACode:Integer):Integer; override;
|
|
function SelectWait(ASocket:TProtocolSocket; ACode:Integer; ATimeout:LongWord):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 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 StartProtocol:Boolean; override;
|
|
function StopProtocol:Boolean; override;
|
|
function ProcessProtocol:Boolean; override;
|
Function declarations
constructor TICMPProtocol.Create(AManager:TProtocolManager; const AName:String);
Note | None documented |
---|
destructor TICMPProtocol.Destroy;
Note | None documented |
---|
function TICMPProtocol.PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;
Handle | The Handle of the Protocol Transport the packet was received from |
---|---|
Source | The source address of the received packet (Set by Transport) |
Dest | The destination address of the received packet (Set by Transport) |
Packet | The received packet (The complete packet including Transport header) |
Size | The size of the received packet in bytes |
Broadcast | True if the destination address is a broadcast address |
function TICMPProtocol.ControlHandler(AHandle:THandle; ASource,ADest:Pointer; AProtocol,ACommand,ACode:Word; AAddress,AData:Pointer; ASize:Integer):Boolean;
Handle | The Handle of the Protocol Transport the control request is from |
---|---|
Source | The source address of the control request (Set by Transport) |
Dest | The destination address of the control request (Set by Transport) |
Protocol | The control protocol requested |
Command | The control command to send |
Code | The control code to send |
Address | The control address to send |
Data | The control data to send |
Size | The size of the control data in bytes |
function TICMPProtocol.GetNextICMPId(AIncrement:Boolean):Word;
Increment | If True increment the next id |
---|
function TICMPProtocol.SendICMPUnreach(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Code | The unreachable message code |
Data | The data to send for the message (The original packet including Transport Header) |
Size | The size of the data in bytes |
Note | Caller must ensure Source and Dest are not Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPRedirect(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AAddress,AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Code | The redirect message code |
Address | The address to send for the message |
Data | The data to send for the message (The original packet including Transport Header) |
Size | The size of the data in bytes |
Note | Caller must ensure Source and Dest are not Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPTimeExceeded(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode:Byte; AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Code | The time exceeded message code |
Data | The data to send for the message (The original packet including Transport Header) |
Size | The size of the data in bytes |
Note | Caller must ensure Source and Dest are not Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPSourceQuench(ASocket:TICMPSocket; ASource,ADest:Pointer; AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Data | The data to send for the message (The original packet including Transport Header) |
Size | The size of the data in bytes |
Note | Caller must ensure Source and Dest are not Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPParamProblem(ASocket:TICMPSocket; ASource,ADest:Pointer; ACode,APointer:Byte; AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Code | The param problem message code |
Data | The data to send for the message (The original packet including Transport Header) |
Size | The size of the data in bytes |
Note | Caller must ensure Source and Dest are not Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPEchoReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Data | The data to send for the message (The ICMP packet without Transport Header) |
Size | The size of the data in bytes |
Note | Caller must ensure Source and Dest are not Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPInfoReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Data | The data to send for the message (The ICMP packet without Transport Header) |
Size | The size of the data in bytes |
Note | Source and Dest may be Default and Source may be Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPMaskReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Data | The data to send for the message (The ICMP packet without Transport Header) |
Size | The size of the data in bytes |
Note | Source will usually be Broadcast, Dest should be valid.
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPTimestampReply(ASocket:TICMPSocket; ASource,ADest,AData:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Data | The data to send for the message (The ICMP packet without Transport Header) |
Size | The size of the data in bytes |
Note | Source will usually be Broadcast, Dest should be valid.
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPEchoRequest(ASocket:TICMPSocket; ASource,ADest:Pointer; ASize:Integer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Size | The Size of the Data to Send not including the ICMP Header |
Note | It is assumed Source and Dest are not Broadcast / Default
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPInfoRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Note | It is assumed Source and Dest are not Broadcast / Default
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPMaskRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Note | It is assumed Source and Dest are not Broadcast / Default
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPTimestampRequest(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Note | It is assumed Source and Dest are not Broadcast / Default
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPRouterAdvert(ASocket:TICMPSocket; ASource,ADest,AAddress:Pointer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Address | The address to send for the message |
Note | Source will usually be Default and Dest will usually be Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SendICMPRouterSolicit(ASocket:TICMPSocket; ASource,ADest:Pointer):Boolean;
Socket | The socket to use for sending the message |
---|---|
Source | The source address to use for the message |
Dest | The destination address to use for the message |
Note | Source will usually be Default and Dest will usually be Broadcast
Caller must hold the Socket lock |
function TICMPProtocol.SelectCheck(ASource,ADest:PFDSet; ACode:Integer):Integer;
Source | Source is the working set to check |
---|---|
Dest | Dest is the set passed to Select |
function TICMPProtocol.SelectWait(ASocket:TProtocolSocket; ACode:Integer; ATimeout:LongWord):Integer;
Socket | Socket is the single socket to check |
---|---|
Code | Code is the type of check |
Timeout | Timeout is how long to wait |
function TICMPProtocol.SendPacket(ASocket:TProtocolSocket; ASource,ADest:Pointer; ASourcePort,ADestPort:Word; APacket:PPacketFragment; ASize,AFlags:Integer):Integer;
Socket | The socket to use for sending the packet |
---|---|
Source | The source address of the packet (Host Order) |
Dest | The destination address of the packet (Host Order) |
SourcePort | The source port of the packet (Host Order) |
DestPort | The destination port of the packet (Host Order) |
Packet | The packet data to send |
Size | The size of the packet data in bytes |
Flags | Any protocol specific flags for sending |
Note | For ICMP the Data is the Header so the packet is not changed
Caller must hold the Socket lock |
function TICMPProtocol.Accept(ASocket:TProtocolSocket; ASockAddr:PSockAddr; AAddrLength:PInteger):TProtocolSocket;
Socket | The socket to accept from |
---|---|
SockAddr | The socket address (Network Order) |
AddrLength | The socket address length |
Note | Caller must hold the Socket lock |
function TICMPProtocol.Bind(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer;
Socket | The socket to bind |
---|---|
SockAddr | The socket address (Network Order) |
AddrLength | The socket address length |
Note | Sets the LocalAddress for future Sends and Receives, Address can be specified as INADDR_ANY which allows Listening or auto assignment.
Caller must hold the Socket lock |
function TICMPProtocol.CloseSocket(ASocket:TProtocolSocket):Integer;
Socket | The socket to close |
---|---|
Note | Closes and removes the socket, does not perform Linger.
Caller must hold the Socket lock |
function TICMPProtocol.Connect(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer;
Socket | The socket to connect |
---|---|
SockAddr | The socket address (Network Order) |
AddrLength | The socket address length |
Note | Sets the RemoteAddress of future Sends and Receives, if Bind has not been called then the LocalAddress will be set appropriately as well based on the route to the RemoteAddress.
Caller must hold the Socket lock |
function TICMPProtocol.IoctlSocket(ASocket:TProtocolSocket; ACmd:DWORD; var AArg:u_long):Integer;
Socket | The socket to control |
---|---|
Cmd | The socket command |
Arg | The command argument |
Note | Caller must hold the Socket lock |
function TICMPProtocol.GetPeerName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer;
Socket | The socket to get from |
---|---|
SockAddr | The socket address (Network Order) |
AddrLength | The socket address length |
Note | Caller must hold the Socket lock |
function TICMPProtocol.GetSockName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer;
Socket | The socket to get from |
---|---|
SockAddr | The socket address (Network Order) |
AddrLength | The socket address length |
Note | Caller must hold the Socket lock |
function TICMPProtocol.GetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer;
Socket | The socket to get the option from |
---|---|
Level | The protocol level for the option |
OptName | The name of the option to get |
OptValue | The value of the option |
OptLength | The length of the option |
Note | Caller must hold the Socket lock |
function TICMPProtocol.Listen(ASocket:TProtocolSocket; ABacklog:Integer):Integer;
Socket | The socket to listen on |
---|---|
Backlog | Queue depth for accepted connections |
Note | Caller must hold the Socket lock |
function TICMPProtocol.Recv(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer;
Socket | The socket to receive from |
---|---|
Buffer | Buffer for received data |
Length | Length of buffer in bytes |
Flags | Protocol specific receive flags |
Note | Caller must hold the Socket lock |
function TICMPProtocol.RecvFrom(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AFromAddr:TSockAddr; var AFromLength:Integer):Integer;
Socket | The socket to receive from |
---|---|
Buffer | Buffer for received data |
Length | Length of buffer in bytes |
Flags | Protocol specific receive flags |
FromAddr | The address the data was received from (Network Order) |
FromLength | The length of the address |
Note | Caller must hold the Socket lock |
function TICMPProtocol.Send(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer;
Socket | The socket to send to |
---|---|
Buffer | Buffer for data to send |
Length | Length of buffer in bytes |
Flags | Protocol specific send flags |
Note | Caller must hold the Socket lock |
function TICMPProtocol.SendTo(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AToAddr:TSockAddr; AToLength:Integer):Integer;
Socket | The socket to send to |
---|---|
Buffer | Buffer for data to send |
Length | Length of buffer in bytes |
Flags | Protocol specific send flags |
ToAddr | The socket address to send to (Network Order) |
ToLength | The length of the socket address |
Note | Caller must hold the Socket lock |
function TICMPProtocol.SetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer;
Socket | The socket to set the option for |
---|---|
Level | The protocol level for the option |
OptName | The name of the option to set |
OptValue | The value of the option |
OptLength | The length of the option |
Note | Caller must hold the Socket lock |
function TICMPProtocol.Shutdown(ASocket:TProtocolSocket; AHow:Integer):Integer;
Socket | The socket to shutdown |
---|---|
How | The direction to shutdown the socket |
Note | Shutdown does not result in CloseSocket so Closed must not get set
Caller must hold the Socket lock |
function TICMPProtocol.Socket(AFamily,AStruct,AProtocol:Integer):TProtocolSocket;
Family | Socket address family (eg AF_INET) |
---|---|
Struct | Socket type (eg SOCK_DGRAM) |
Protocol | Socket protocol (eg IPPROTO_UDP) |
function TICMPProtocol.AddTransport(ATransport:TNetworkTransport):Boolean;
Transport | The transport to add |
---|
function TICMPProtocol.RemoveTransport(ATransport:TNetworkTransport):Boolean;
Transport | The transport to remove |
---|
function TICMPProtocol.FindSocket(AFamily,AStruct,AProtocol:Word; ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast,AListen,ALock:Boolean; AState:LongWord):TProtocolSocket;
Family | Socket address family (eg AF_INET) |
---|---|
Struct | Socket type (eg SOCK_DGRAM) |
Protocol | Socket protocol (eg IPPROTO_UDP) |
LocalAddress | Local transport address to match (Host Order) |
RemoteAddress | Remote transport address to match (Host Order) |
LocalPort | Local port to match (Host Order) |
RemotePort | Remote port to match (Host Order) |
Broadcast | If True then match broadcast addresses |
Listen | If True then match only listening sockets |
Lock | If True then lock the found entry before returning |
procedure TICMPProtocol.FlushSockets(All:Boolean);
All | If True flush all sockets, otherwise flush expired sockets. |
---|
function TICMPProtocol.StartProtocol:Boolean;
Note | None documented |
---|
function TICMPProtocol.StopProtocol:Boolean;
Note | None documented |
---|
function TICMPProtocol.ProcessProtocol:Boolean;
Note | None documented |
---|
Return to Unit Reference