TARPTransport

From Ultibo.org
Jump to: navigation, search

Return to Unit ARP


Description


To be documented

Class definitions



TARPTransport = class(TNetworkTransport)

constructor Create(AManager:TTransportManager; const AName:String);  
destructor Destroy; override;  
private
FAddresses:TNetworkList;  
FAddressAdd:TEventHandle;  
FAddressRemove:TEventHandle;  
 
function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;  
 
function SendARPRequest(AAdapter:TARPTransportAdapter; ASource:TARPAddressEntry; const ATarget:TInAddr):Boolean;  
function SendARPReply(AAdapter:TARPTransportAdapter; ASource,ATarget:TARPAddressEntry):Boolean;  
 
function SendINARPRequest(AAdapter:TARPTransportAdapter; ASource:TARPAddressEntry; const ATarget:THardwareAddress):Boolean;  
function SendINARPReply(AAdapter:TARPTransportAdapter; ASource,ATarget:TARPAddressEntry):Boolean;  
protected
 
public
function AddAdapter(AAdapter:TNetworkAdapter; AConfigType:Word; AAddress,ANetmask,AGateway,AServer:Pointer):Boolean; override;  
function RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; override;  
 
function StartTransport:Boolean; override;  
function StopTransport:Boolean; override;  
function ProcessTransport:Boolean; override;  
 
function BindTransport(AAdapter:TNetworkAdapter):Boolean; override;  
function UnbindTransport(AAdapter:TNetworkAdapter):Boolean; override;  
 
function GetAddressByAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter; ALock:Boolean; AState:LongWord):TARPAddressEntry;  
function GetAddressByHardware(const AHardware:THardwareAddress; AAdapter:TNetworkAdapter; ALock:Boolean; AState:LongWord):TARPAddressEntry;  
function GetAddressByNext(APrevious:TARPAddressEntry; ALock,AUnlock:Boolean; AState:LongWord):TARPAddressEntry;  
function AddAddress(const AAddress:TInAddr; const AHardware:THardwareAddress; AAdapter:TNetworkAdapter; AType:Word; ALock:Boolean; AState:LongWord):TARPAddressEntry;  
function RemoveAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter):Boolean;  
procedure FlushAddresses(All:Boolean);  
 
function LoadAddress(AAdapter:TNetworkAdapter; const AAddress:TInAddr; const AHardware:THardwareAddress; AType:Word):Boolean;  
function UnloadAddress(AAdapter:TNetworkAdapter; const AAddress:TInAddr):Boolean;  
 
function ResolveAddress(AAdapter:TNetworkAdapter; const ASource,AAddress:TInAddr; var AHardware:THardwareAddress):Boolean;  
function ResolveHardware(AAdapter:TNetworkAdapter; const ASource:TInAddr; const AHardware:THardwareAddress; var AAddress:TInAddr):Boolean;  
 
function ConfirmAddress(AAdapter:TNetworkAdapter; const ASource,AAddress:TInAddr):Boolean;  
function AdvertiseAddress(AAdapter:TNetworkAdapter; const ASource:TInAddr):Boolean;  
 
function CompareDefault(const AAddress:TInAddr):Boolean;  
function CompareAddress(const AAddress1,AAddress2:TInAddr):Boolean;  


Function declarations



constructor TARPTransport.Create(AManager:TTransportManager; const AName:String);
Description: To be documented
Note None documented


destructor TARPTransport.Destroy;
Description: To be documented
Note None documented


function TARPTransport.PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;
Description: Process a packet received by an Adapter
Handle The Handle of the Transport Adapter the packet was received from
Source The source hardware address of the received packet (Set by Adapter)
Dest The destination hardware address of the received packet (Set by Adapter)
Packet The received packet (The complete packet without Adapter header)
Size The size of the received packet in bytes
Broadcast True if the destination address is a broadcast address


function TARPTransport.SendARPRequest(AAdapter:TARPTransportAdapter; ASource:TARPAddressEntry; const ATarget:TInAddr):Boolean;
Description: Send an ARP request packet
Adapter The transport adapter to send the request on
Source The source hardware and IP address to send the request with
Target The target IP address to send the request to
Note Caller must hold Adapter lock and Source lock


function TARPTransport.SendARPReply(AAdapter:TARPTransportAdapter; ASource,ATarget:TARPAddressEntry):Boolean;
Description: Send an ARP reply packet
Adapter The transport adapter to send the reply on
Source The source hardware and IP address to send the reply with
Target The target harware and IP address to send the reply to
Note Caller must hold Adapter lock, Source and Target locks.


function TARPTransport.SendINARPRequest(AAdapter:TARPTransportAdapter; ASource:TARPAddressEntry; const ATarget:THardwareAddress):Boolean;
Description: Send an Inverse ARP request packet
Adapter The transport adapter to send the request on
Source The source hardware and IP address to send the request with
Target The target hardware address to send the request to
Note Caller must hold Adapter lock and Source lock


function TARPTransport.SendINARPReply(AAdapter:TARPTransportAdapter; ASource,ATarget:TARPAddressEntry):Boolean;
Description: Send an Inverse ARP reply packet
Adapter The transport adapter to send the reply on
Source The source hardware and IP address to send the reply with
Target The target harware and IP address to send the reply to
Note Caller must hold Adapter lock, Source and Target locks.


function TARPTransport.AddAdapter(AAdapter:TNetworkAdapter; AConfigType:Word; AAddress,ANetmask,AGateway,AServer:Pointer):Boolean;
Description: Add an adapter to this transport
Adapter The adapter to add
ConfigType The configuration type to use for configuring the adapter (eg CONFIG_TYPE_AUTO)
Address The transport address to use for this adapter (or nil if supplied during configuration)
Netmask The transport netmask to use for this adapter (or nil if supplied during configuration)
Gateway The transport default gateway to use for this adapter (or nil if supplied during configuration)
Server The transport configuration server to use for this adapter (or nil if supplied during configuration)


function TARPTransport.RemoveAdapter(AAdapter:TNetworkAdapter):Boolean;
Description: Remove an adapter from this transport
Adapter The adapter to remove


function TARPTransport.StartTransport:Boolean;
Description: Start this transport ready for sending and receiving
Note None documented


function TARPTransport.StopTransport:Boolean;
Description: Stop this transport ready for removal
Note None documented


function TARPTransport.ProcessTransport:Boolean;
Description: Process periodic tasks for this transport
Note None documented


function TARPTransport.BindTransport(AAdapter:TNetworkAdapter):Boolean;
Description: Bind this transport to an adapter if appropriate
Adapter The adapter to bind to
Note ARP binds to adapters only on request from other transports (eg IP)


function TARPTransport.UnbindTransport(AAdapter:TNetworkAdapter):Boolean;
Description: Unbind this transport from an adapter if appropriate
Adapter The adapter to unbind from
Note ARP unbinds from adapters only on request from other transports (eg IP)


function TARPTransport.GetAddressByAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter; ALock:Boolean; AState:LongWord):TARPAddressEntry;
Description: Find the IP address entry in the address cache
Address The IP address to find
Adapter The adapter which the address should be on
Lock If True then lock the found entry before returning


function TARPTransport.GetAddressByHardware(const AHardware:THardwareAddress; AAdapter:TNetworkAdapter; ALock:Boolean; AState:LongWord):TARPAddressEntry;
Description: Find the hardware address entry in the address cache
Address The hardware address to find
Adapter The adapter which the address should be on
Lock If True then lock the found entry before returning


function TARPTransport.GetAddressByNext(APrevious:TARPAddressEntry; ALock,AUnlock:Boolean; AState:LongWord):TARPAddressEntry;
Description: To be documented
Note None documented


function TARPTransport.AddAddress(const AAddress:TInAddr; const AHardware:THardwareAddress; AAdapter:TNetworkAdapter; AType:Word; ALock:Boolean; AState:LongWord):TARPAddressEntry;
Description: Add an IP and hardware address pair to the address cache
Address The IP address to add
Hardware The hardware address to add
Adapter The adapter the address is on
Type The type of the added entry (eg ADDRESS_TYPE_DYNAMIC)
Lock If True then lock the added entry before returning


function TARPTransport.RemoveAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter):Boolean;
Description: Remove an IP and hardware address pair from the address cache
Address The IP address to remove
Adapter The adapter the address is on


procedure TARPTransport.FlushAddresses(All:Boolean);
Description: Flush addresses from the address cache
All If True flush all addresses, otherwise flush expired addresses


function TARPTransport.LoadAddress(AAdapter:TNetworkAdapter; const AAddress:TInAddr; const AHardware:THardwareAddress; AType:Word):Boolean;
Description: Add an IP and hardware address pair to the address cache
Adapter The adapter the address is on
Address The IP address to add
Hardware The hardware address to add
Type The type of the added entry (eg ADDRESS_TYPE_LOCAL)


function TARPTransport.UnloadAddress(AAdapter:TNetworkAdapter; const AAddress:TInAddr):Boolean;
Description: Remove an IP and hardware address pair from the address cache
Adapter The adapter the address is on
Address The IP address to remove


function TARPTransport.ResolveAddress(AAdapter:TNetworkAdapter; const ASource,AAddress:TInAddr; var AHardware:THardwareAddress):Boolean;
Description: Resolve the hardware address for the given IP address either from cache or by sending an ARP request
Adapter The adapter to use for resolving the hardware address
Source The source IP address to use for resolving the hardware address
Address The IP address to resolve
Hardware The returned hardware address


function TARPTransport.ResolveHardware(AAdapter:TNetworkAdapter; const ASource:TInAddr; const AHardware:THardwareAddress; var AAddress:TInAddr):Boolean;
Description: Resolve the IP address for the given hardware address either from cache or by sending an ARP request
Adapter The adapter to use for resolving the IP address
Source The source IP address to use for resolving the IP address
Hardware The hardware address to resolve
Address The returned IP address


function TARPTransport.ConfirmAddress(AAdapter:TNetworkAdapter; const ASource,AAddress:TInAddr):Boolean;
Description: Confirm that the supplied Address is not in use on this network
Adapter The adapter to use for confirming the IP address
Source The source IP address to use for confirming the IP address
Address The IP address to confirm
Note Confirm only tries once to resolve the Address


function TARPTransport.AdvertiseAddress(AAdapter:TNetworkAdapter; const ASource:TInAddr):Boolean;
Description: Send a Broadcast ARP reply to allow others to update their cache
Adapter The adapter to use for advertising the IP address
Source The IP address to advertise


function TARPTransport.CompareDefault(const AAddress:TInAddr):Boolean;
Description: Compare the supplied address with the IP default address
Note None documented


function TARPTransport.CompareAddress(const AAddress1,AAddress2:TInAddr):Boolean;
Description: Compare the supplied addresses to see if they are the same
Note None documented


Return to Unit Reference