Difference between revisions of "Unit ARP"

From Ultibo.org
Jump to: navigation, search
Line 162: Line 162:
  
  
'''ARP transport adapter'''
+
'''ARP specific classes'''
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
  
<code>TARPTransportAdapter = class(TTransportAdapter)</code>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
| <code>constructor Create;</code>
+
| [[TARPTransportAdapter|<code>TARPTransportAdapter = class(TTransportAdapter)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>UseCount:Integer;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''ARP transport'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code> TARPTransport = class(TNetworkTransport)</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:TTransportManager; const AName:String);</code>
+
| [[TARPTransport|<code>TARPTransport = class(TNetworkTransport)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>FAddresses:TNetworkList;</code>
+
| &nbsp;
+
|-
+
| <code>FAddressAdd:TEventHandle;</code>
+
| &nbsp;
+
|-
+
| <code>FAddressRemove:TEventHandle;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function SendARPRequest(AAdapter:TARPTransportAdapter; ASource:TARPAddressEntry; const ATarget:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function SendARPReply(AAdapter:TARPTransportAdapter; ASource,ATarget:TARPAddressEntry):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function SendINARPRequest(AAdapter:TARPTransportAdapter; ASource:TARPAddressEntry; const ATarget:THardwareAddress):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function SendINARPReply(AAdapter:TARPTransportAdapter; ASource,ATarget:TARPAddressEntry):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>function AddAdapter(AAdapter:TNetworkAdapter; AConfigType:Word; AAddress,ANetmask,AGateway,AServer:Pointer):Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function StartTransport:Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function StopTransport:Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function ProcessTransport:Boolean; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function BindTransport(AAdapter:TNetworkAdapter):Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function UnbindTransport(AAdapter:TNetworkAdapter):Boolean; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function GetAddressByAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter; ALock:Boolean; AState:LongWord):TARPAddressEntry;</code>
+
| &nbsp;
+
|-
+
| <code>function GetAddressByHardware(const AHardware:THardwareAddress; AAdapter:TNetworkAdapter; ALock:Boolean; AState:LongWord):TARPAddressEntry;</code>
+
| &nbsp;
+
|-
+
| <code>function GetAddressByNext(APrevious:TARPAddressEntry; ALock,AUnlock:Boolean; AState:LongWord):TARPAddressEntry;</code>
+
| &nbsp;
+
|-
+
| <code>function AddAddress(const AAddress:TInAddr; const AHardware:THardwareAddress; AAdapter:TNetworkAdapter; AType:Word; ALock:Boolean; AState:LongWord):TARPAddressEntry;</code>
+
| &nbsp;
+
|-
+
| <code>function RemoveAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>procedure FlushAddresses(All:Boolean);</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function LoadAddress(AAdapter:TNetworkAdapter; const AAddress:TInAddr; const AHardware:THardwareAddress; AType:Word):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function UnloadAddress(AAdapter:TNetworkAdapter; const AAddress:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ResolveAddress(AAdapter:TNetworkAdapter; const ASource,AAddress:TInAddr; var AHardware:THardwareAddress):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function ResolveHardware(AAdapter:TNetworkAdapter; const ASource:TInAddr; const AHardware:THardwareAddress; var AAddress:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ConfirmAddress(AAdapter:TNetworkAdapter; const ASource,AAddress:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function AdvertiseAddress(AAdapter:TNetworkAdapter; const ASource:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function CompareDefault(const AAddress:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function CompareAddress(const AAddress1,AAddress2:TInAddr):Boolean;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''ARP address entry'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TARPAddressEntry = class(TAddressEntry)</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>
+
| [[TARPAddressEntry|<code>TARPAddressEntry = class(TAddressEntry)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>FAddress:TInAddr;</code>
+
| &nbsp;
+
|-
+
| <code>FProtocolType:Word;</code>
+
| &nbsp;
+
|-
+
| <code>FHardware:THardwareAddress;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>procedure SetAddress(const AAddress:TInAddr);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetProtocolType(AProtocolType:Word);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetHardware(const AHardware:THardwareAddress);</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>property Address:TInAddr read FAddress write SetAddress;</code>
+
| &nbsp;
+
|-
+
| <code>property ProtocolType:Word read FProtocolType write SetProtocolType;</code>
+
| &nbsp;
+
|-
+
| <code>property Hardware:THardwareAddress read FHardware write SetHardware;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''RARP transport adapter'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TRARPTransportAdapter = class(TTransportAdapter)</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>
+
| [[TRARPTransportAdapter|<code>TRARPTransportAdapter = class(TTransportAdapter)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>UseCount:Integer;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
+
'''RARP transport'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TRARPTransport = class(TNetworkTransport)</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:TTransportManager; const AName:String);</code>
+
| [[TRARPTransport|<code>TRARPTransport = class(TNetworkTransport)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>FAddresses:TNetworkList;</code>
+
| &nbsp;
+
|-
+
| <code>FAddressAdd:TEventHandle;</code>
+
| &nbsp;
+
|-
+
| <code>FAddressRemove:TEventHandle;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function SendRARPRequest(AAdapter:TRARPTransportAdapter):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function SendRARPReply(AAdapter:TRARPTransportAdapter; ASource,ATarget:TRARPAddressEntry):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>function AddAdapter(AAdapter:TNetworkAdapter; AConfigType:Word; AAddress,ANetmask,AGateway,AServer:Pointer):Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function StartTransport:Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function StopTransport:Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function ProcessTransport:Boolean; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function BindTransport(AAdapter:TNetworkAdapter):Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function UnbindTransport(AAdapter:TNetworkAdapter):Boolean; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function GetAddressByAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter; ALock:Boolean; AState:LongWord):TRARPAddressEntry; </code>
+
| &nbsp;
+
|-
+
| <code>function GetAddressByHardware(const AHardware:THardwareAddress; AAdapter:TNetworkAdapter; ALock:Boolean; AState:LongWord):TRARPAddressEntry;</code>
+
| &nbsp;
+
|-
+
| <code>function GetAddressByNext(APrevious:TRARPAddressEntry; ALock,AUnlock:Boolean; AState:LongWord):TRARPAddressEntry;</code>
+
| &nbsp;
+
|-
+
| <code>function AddAddress(const AAddress:TInAddr; const AHardware:THardwareAddress; AAdapter:TNetworkAdapter; AType:Word; ALock:Boolean; AState:LongWord):TRARPAddressEntry;</code>
+
| &nbsp;
+
|-
+
| <code>function RemoveAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>procedure FlushAddresses(All:Boolean);</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function LoadAddress(AAdapter:TNetworkAdapter; const AAddress:TInAddr; const AHardware:THardwareAddress; AType:Word):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function UnloadAddress(AAdapter:TNetworkAdapter; const AAddress:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ResolveHardware(AAdapter:TNetworkAdapter; var AAddress:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function CompareDefault(const AAddress:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function CompareAddress(const AAddress1,AAddress2:TInAddr):Boolean;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''RARP address entry'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TRARPAddressEntry = class(TAddressEntry)</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%;"|&nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>FAddress:TInAddr;</code>
+
| &nbsp;
+
|-
+
| <code>FProtocolType:Word;</code>
+
| &nbsp;
+
|-
+
| <code>FHardware:THardwareAddress;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>procedure SetAddress(const AAddress:TInAddr);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetProtocolType(AProtocolType:Word);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetHardware(const AHardware:THardwareAddress);</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>property Address:TInAddr read FAddress write SetAddress;</code>
+
| &nbsp;
+
|-
+
| <code>property ProtocolType:Word read FProtocolType write SetProtocolType;</code>
+
| &nbsp;
+
 
|-
 
|-
| <code>property Hardware:THardwareAddress read FHardware write SetHardware;</code>
+
| [[TRARPAddressEntry|<code>TRARPAddressEntry = class(TAddressEntry)</code>]]
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
 
 
<br />
 
<br />
  

Revision as of 02:33, 27 April 2018

Return to Unit Reference


Description


Ultibo ARP (Address Resolution Protocol) unit

To be documented

Constants



ARP specific constants ARP_TRANSPORT_*, RARP_TRANSPORT_*
ARP_TRANSPORT_NAME = 'ARP';  
RARP_TRANSPORT_NAME = 'RARP';  


ARP and RARP constants MIN_*, MAX_*, ARP_*, RARP_*
MIN_ARP_PACKET = 46; Not Counting Adapter Header
MAX_ARP_PACKET = 46; Not Counting Adapter Header
 
ARP_TIMEOUT = 1000; We wait for 1 second approx for reply
ARP_RETRIES = 4; We try the request 4 times
 
RARP_TIMEOUT = 4000; We wait for 4 seconds for a RARP reply
RARP_RETRIES = 4; We try the request 4 times
 
ARP_HEADER_SIZE = 46; SizeOf(TARPHeader);
RARP_HEADER_SIZE = 46; SizeOf(TRARPHeader);


ARP and RARP messages ARP_*, RARP_*, INARP_*
ARP_REQUEST = $0001; ARP/RARP op codes, Request
ARP_REPLY = $0002; ARP/RARP op codes, Reply
RARP_REQUEST = $0003;  
RARP_REPLY = $0004;  
INARP_REQUEST = $0008; Inverse ARP see RFC 1293
INARP_REPLY = $0009;  


Type definitions



ARP specific types

PARPHeader = ^TARPHeader;

TARPHeader = packed record

Note: 46 Bytes
HardwareType:Word; Hardware address space (Network Order)
ProtocolType:Word; Protocol address space (Network Order)
HardwareLength:Byte; Byte length of hardware address
ProtocolLength:Byte; Byte length of each protocol address
Opcode:Word; Op code (eg ARP_REQUEST or ARP_REPLY) (Network Order)
SourceHardware:THardwareAddress; Source hardware address (of sender)
SourceIP:TInAddr; Source protocol address (of sender) (Network Order)
TargetHardware:THardwareAddress; Target hardware address (if known)
TargetIP:TInAddr; Target protocol address (Network Order)
Reserved:array[0..17] of Word;  

RARP specific types

PRARPHeader = ^TRARPHeader;

TRARPHeader = TARPHeader;

Note: 46 Bytes
   


Class definitions



ARP specific classes

TARPTransportAdapter = class(TTransportAdapter)
TARPTransport = class(TNetworkTransport)
TARPAddressEntry = class(TAddressEntry)
TRARPTransportAdapter = class(TTransportAdapter)
TRARPTransport = class(TNetworkTransport)
TRARPAddressEntry = class(TAddressEntry)


Public variables


None defined

Function declarations



Initialization functions

procedure ARPInit;
Description: To be documented
Note None documented


ARP functions

function CheckARP(ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid ARP packet
Buffer Buffer points to the complete packet without Adapter header


function CheckRARP(ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid RARP packet
Buffer Buffer points to the complete packet without Adapter header


Return to Unit Reference