Difference between revisions of "Unit IP"

From Ultibo.org
Jump to: navigation, search
Line 440: Line 440:
 
----
 
----
  
''To be documented''
+
 
 +
'''IP buffer'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPBuffer = class(TTransportBufferEx)</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Different to Socket Buffer.
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>constructor Create(ATransport:TNetworkTransport);</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>destructor Destroy; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
| <code>FFirst:PIPPacket;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FLast:PIPPacket;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetFragment(APacket:PIPPacket; AOffset,ASize:Word):PIPFragment;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function AddFragment(APacket:PIPPacket; AOffset,ASize:Word):PIPFragment;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveFragment(APacket:PIPPacket):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure FlushFragments(APacket:PIPPacket);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>function GetPacket(AId:Word; AProtocol:Byte; const ASource,ADest:TInAddr; ALock:Boolean):PIPPacket;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function AddPacket(AId:Word; AProtocol:Byte; const ASource,ADest:TInAddr; ALock:Boolean):PIPPacket;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemovePacket(APacket:PIPPacket):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function UnlockPacket(APacket:PIPPacket):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure FlushPackets(All:Boolean);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function PutHeader(APacket:PIPPacket; ABuffer:Pointer; ALength:Word):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function PutFragment(APacket:PIPPacket; ABuffer:Pointer; AOffset,ASize,AFlags:Word):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP transport adapter'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPTransportAdapter = 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>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>Address:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Netmask:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Gateway:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Network:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Directed:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Server:TInAddr;</code>
 +
| DHCP Server
 +
|-
 +
| <code>LeaseTime:LongWord;</code>
 +
| DHCP Lease Time
 +
|-
 +
| <code>RetryTime:Int64;</code>
 +
| DHCP Retry Time
 +
|-
 +
| <code>ExpiryTime:Int64;</code>
 +
| DHCP Expiry Time
 +
|-
 +
| <code>RenewalTime:Int64;</code>
 +
| DHCP Renewal Time
 +
|-
 +
| <code>RebindingTime:Int64;</code>
 +
| DHCP Rebinding Time
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>ConfigDefault:Word;</code>
 +
| BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK
 +
|-
 +
| <code>ConfigAddress:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ConfigNetmask:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ConfigGateway:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ConfigServer:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP transport binding'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPTransportBinding = class(TTransportBinding)</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;">'''public'''</div>
 +
|-
 +
| <code>Address:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Netmask:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Gateway:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Network:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Directed:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>Server:TInAddr;</code>
 +
| DHCP Server
 +
|-
 +
| <code>LeaseTime:LongWord;</code>
 +
| DHCP Lease Time
 +
|-
 +
| <code>RetryTime:Int64;</code>
 +
| DHCP Retry Time
 +
|-
 +
| <code>ExpiryTime:Int64;</code>
 +
| DHCP Expiry Time
 +
|-
 +
| <code>RenewalTime:Int64;</code>
 +
| DHCP Renewal Time
 +
|-
 +
| <code>RebindingTime:Int64;</code>
 +
| DHCP Rebinding Time
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>ConfigDefault:Word;</code>
 +
| BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK
 +
|-
 +
| <code>ConfigAddress:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ConfigNetmask:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ConfigGateway:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ConfigServer:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP transport protocol'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPTransportProtocol = class(TTransportProtocol)</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP transport filter'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPTransportFilter = class(TTransportFilter)</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP transport configuration'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPTransportConfig = class(TTransportConfig)</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP transport'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPTransport = 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>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>destructor Destroy; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
| <code>FNextIPId:Word;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FNextIPLock:TMutexHandle;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FARP:TARPTransport;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FRARP:TRARPTransport;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FFragments:TIPBuffer;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FHosts:TNetworkList;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FServs:TNetworkList;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FProtos:TNetworkList;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FRoutes:TNetworkList;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FNetworks:TNetworkList;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FAddresses:TNetworkList;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FNameservers:TIPNameservers;  (Part of TNetworkList)</code>
 +
| &nbsp;
 +
|-
 +
| <code>FNameserverLock:TMutexHandle;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FForwarding:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FDefaultTTL:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FAutoRelease:Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function FragmentHandler(ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function CheckFragment(ABuffer:Pointer):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetNextIPId(AIncrement:Boolean):Word;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetIPNameserver(ACount:LongWord):TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetAdapterConfigType(const AName:String):Word;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetAdapterConfigAddress(const AName:String):TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetAdapterConfigNetmask(const AName:String):TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetAdapterConfigGateway(const AName:String):TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetAdapterConfigServer(const AName:String):TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
 +
|-
 +
| <code>function FilterPacket(ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function ForwardPacket(AAdapter:TTransportAdapter; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property Nameservers:TIPNameservers read FNameservers;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property Forwarding:LongWord read FForwarding write FForwarding;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property DefaultTTL:LongWord read FDefaultTTL write FDefaultTTL;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property AutoRelease:Boolean read FAutoRelease write FAutoRelease;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <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 AddProtocol(AProtocol:Word; APacketHandler:TTransportPacketHandler; AControlHandler:TTransportControlHandler):THandle; override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveProtocol(AHandle:THandle; AProtocol:Word):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function AddFilter(AProtocol:Word; AFilterHandler:TTransportFilterHandler):THandle; override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveFilter(AHandle:THandle; AProtocol:Word):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function AddConfig(AConfigType:Word; AConfigAuto:Boolean; AConfigHandler:TTransportConfigHandler):THandle; override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveConfig(AHandle:THandle; AConfigType:Word):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function SendPacket(ASocket:TTransportSocket; ASource,ADest:Pointer; APacket:PPacketFragment; ASize,AFlags:Integer):Integer; override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function SendControl(ASource,ADest:Pointer; AProtocol,ACommand,ACode:Word; AAddress,AData:Pointer; ASize:Integer):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetSockOpt(ASocket:TTransportSocket; ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer; override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function SetSockOpt(ASocket:TTransportSocket; ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer; 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 AddNameserver(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveNameserver(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetHostByName(const AName:String; ALock:Boolean):TIPHostEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetHostByAddress(const AAddress:TInAddr; ALock:Boolean):TIPHostEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetHostByNext(APrevious:TIPHostEntry; ALock,AUnlock:Boolean):TIPHostEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function AddHost(const AAddress:TInAddr; const AName:String; AType:Word; ALock:Boolean):TIPHostEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveHost(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure FlushHosts(All:Boolean);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetRouteByAddress(const AAddress:TInAddr; ALock:Boolean; AState:LongWord):TIPRouteEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetRouteByNetwork(const ANetwork,AAddress:TInAddr; ALock:Boolean; AState:LongWord):TIPRouteEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetRouteByNext(APrevious:TIPRouteEntry; ALock,AUnlock:Boolean; AState:LongWord):TIPRouteEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function AddRoute(const ANetwork,ANetmask,AGateway,AAddress:TInAddr; AType:Word; ALock:Boolean; AState:LongWord):TIPRouteEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveRoute(const ANetwork,AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure FlushRoutes(All:Boolean);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetAddressByAddress(const AAddress:TInAddr; ALock:Boolean; AState:LongWord):TIPAddressEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetAddressByNext(APrevious:TIPAddressEntry; ALock,AUnlock:Boolean; AState:LongWord):TIPAddressEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function AddAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter; AType:Word; ALock:Boolean; AState:LongWord):TIPAddressEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveAddress(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure FlushAddresses(All:Boolean);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetNetworkByName(const AName:String; ALock:Boolean):TIPNetworkEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetNetworkByAddress(const ANetwork:TInAddr; ALock:Boolean):TIPNetworkEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function AddNetwork(const AName:String; const ANetwork:TInAddr; ALock:Boolean):TIPNetworkEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveNetwork(const AName:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetServByName(const AName,AProtocol:String; ALock:Boolean):TIPServEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetServByPort(APort:Word; const AProtocol:String; ALock:Boolean):TIPServEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function AddServ(const AName,AProtocol:String; APort:Word; ALock:Boolean):TIPServEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveServ(const AName,AProtocol:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetProtoByName(const AName:String; ALock:Boolean):TIPProtoEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetProtoByNumber(ANumber:Word; ALock:Boolean):TIPProtoEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function AddProto(const AName:String; ANumber:Word; ALock:Boolean):TIPProtoEntry;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveProto(const AName:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function CompareLocal(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function CompareDefault(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function CompareLoopback(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function CompareDirected(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function CompareBroadcast(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function CompareMulticast(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function CompareAddress(const AAddress1,AAddress2:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function CompareSubnet(const AAddress,ANetwork,ANetmask:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP state'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPState = class(TTransportState)</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>FLocalAddress:TInAddr;</code>
 +
| Host Order
 +
|-
 +
| <code>FRemoteAddress:TInAddr;</code>
 +
| Host Order
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure SetLocalAddress(const ALocalAddress:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetRemoteAddress(const ARemoteAddress:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property LocalAddress:TInAddr read FLocalAddress write SetLocalAddress;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property RemoteAddress:TInAddr read FRemoteAddress write SetRemoteAddress;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP options'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPOptions = class(TTransportOptions)</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: For Get/Set Options Level = IP_PROTO Option = ???
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>constructor Create;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>destructor Destroy; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
| <code>FMemory:TMemoryStream;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOptions:Pointer;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FLength:Integer;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FTOS:Byte;</code>
 +
| IPTOS_LOWDELAY etc
 +
|-
 +
| <code>FTTL:Byte;</code>
 +
| Time To Live
 +
|-
 +
| <code>FFlags:Word;</code>
 +
| IP_DF etc
 +
|-
 +
| <code>FHeader:Boolean;</code>
 +
| IP_HDRINCL
 +
|-
 +
| <code>FMulticastIF:TInAddr;</code>
 +
| IP_MULTICAST_IF
 +
|-
 +
| <code>FMulticastTTL:Byte;</code>
 +
| IP_MULTICAST_TTL
 +
|-
 +
| <code>FMulticastLOOP:Boolean;</code>
 +
| IP_MULTICAST_LOOP
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure SetTOS(ATOS:Byte);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetTTL(ATTL:Byte);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetFlags(AFlags:Word);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetHeader(AHeader:Boolean);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetMulticastIF(const AMulticastIF:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetMulticastTTL(AMulticastTTL:Byte);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetMulticastLOOP(AMulticastLOOP:Boolean);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure SetLength(ALength:Integer);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property TOS:Byte read FTOS write SetTOS;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property TTL:Byte read FTTL write SetTTL;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Flags:Word read FFlags write SetFlags;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Header:Boolean read FHeader write SetHeader;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property MulticastIF:TInAddr read FMulticastIF write SetMulticastIF;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property MulticastTTL:Byte read FMulticastTTL write SetMulticastTTL;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property MulticastLOOP:Boolean read FMulticastLOOP write SetMulticastLOOP;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property Options:Pointer read FOptions;</code>
 +
| IP_OPTIONS
 +
|-
 +
| <code>property Length:Integer read FLength write SetLength;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP host entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPHostEntry = class(THostEntry)</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>FAddresses:array[0..MAX_HOST_ALIASES - 1] of TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetAddress:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetAddress(const AAddress:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetAddresses(Index:Integer):TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property Address:TInAddr read GetAddress write SetAddress;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Addresses[Index:Integer]:TInAddr read GetAddresses;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function FindAddress(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function AddAddress(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveAddress(const AAddress:TInAddr):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP route entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPRouteEntry = class(TRouteEntry)</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>FTOS:Byte;</code>
 +
| Default TOS for this Route
 +
|-
 +
| <code>FTTL:Byte;</code>
 +
| Default TTL for this Route
 +
|-
 +
| <code>FNetwork:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FNetmask:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FGateway:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FAddress:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure SetTOS(ATOS:Byte);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetTTL(ATTL:Byte);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetNetwork(const ANetwork:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetNetmask(const ANetmask:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetGateway(const AGateway:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetAddress(const AAddress:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property TOS:Byte read FTOS write SetTOS;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property TTL:Byte read FTTL write SetTTL;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Network:TInAddr read FNetwork write SetNetwork;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Netmask:TInAddr read FNetmask write SetNetmask;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Gateway:TInAddr read FGateway write SetGateway;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Address:TInAddr read FAddress write SetAddress;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP address entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPAddressEntry = class(TAddressEntry)</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Used for secondary addresses.
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>constructor Create;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
| <code>FAddress:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure SetAddress(const AAddress:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property Address:TInAddr read FAddress write SetAddress;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''IP network entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPNetworkEntry = class(TNetworkEntry)</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>FNetwork:TInAddr;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure SetNetwork(const ANetwork:TInAddr);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property Network:TInAddr read FNetwork write SetNetwork;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''IP service entry''' 
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPServEntry = class(TServEntry)</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>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''IP protocol entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
 
 +
<code>TIPProtoEntry = class(TProtoEntry)</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>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
|}
 +
</div></div> 
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===

Revision as of 04:48, 15 March 2017

Return to Unit Reference


Description


Ultibo IP (Internet Protocol) unit

To be documented

Constants



IP specific constants IP_TRANSPORT_NAME*
IP_TRANSPORT_NAME = 'IP';  


IP constants IP_*_SIZE
MIN_IP_PACKET = 20; Not Counting Adapter Header
MAX_IP_PACKET = 65536; Not Counting Adapter Header
 
MAX_FRAG_LIFE = 32000; Only wait 32 seconds for the rest of the packet
 
IP_HEADER_SIZE = 20; SizeOf(TIPHeader); (Does Not Allow for Options)
IP_OPTIONS_SIZE = 40; Maximum Allowed Options
IP_PSEUDO_SIZE = 12; SizeOf(TPseudoHeader);
 
IP_PACKET_SIZE = 56; SizeOf(TIPPacket); (Previously 46)
IP_FRAGMENT_SIZE = 12; SizeOf(TIPFragment);


IP header flags / fragment offset constants IP_*
IP_CE = $8000; Congestion Experienced
IP_DF = $4000; 1 = Don't Fragment 0 = May Fragment
IP_MF = $2000; 1 = More Fragments 0 = Last Fragment
IP_OFFMASK = $1FFF; Fragment Offset Mask


IP header option constants IPOPT_*
IPOPT_EOL = 0; end-of-option list
IPOPT_NOP = 1; no-operation
IPOPT_RR = 7; record packet route
IPOPT_TS = 68; timestamp
IPOPT_SECURITY = 130; provide s,c,h,tcc
IPOPT_LSRR = 131; loose source route
IPOPT_SATID = 136; satnet id
IPOPT_SSRR = 137; strict source route
IPOPT_RA = 148; router alert


IP offset option constants IPOPT_OFFSET*
Offsets to fields in IP Options other than EOL and NOP
 
IPOPT_OPTVAL = 0; option ID
IPOPT_OLEN = 1; option length
IPOPT_OFFSET = 2; offset within option
IPOPT_MINOFF = 4; min value of above


IP TS flag option constants IPOPT_TS_*
Flags for IPOPT_TS Flags
 
IPOPT_TS_TSONLY = 0; timestamps only
IPOPT_TS_TSANDADDR = 1; timestamps and addresses
IPOPT_TS_PRESPEC = 3; specified modules only


IP security flag constants IPOPT_SECUR_*
Flags for IPOPT_SECURITY Flags (Network Order)
 
IPOPT_SECUR_UNCLASS = $0000;  
IPOPT_SECUR_CONFID = $F135;  
IPOPT_SECUR_EFTO = $789A;  
IPOPT_SECUR_MMMM = $BC4D;  
IPOPT_SECUR_RESTR = $AF13;  
IPOPT_SECUR_SECRET = $D788;  
IPOPT_SECUR_TOPSECRET = $6BC5;  


IP type of service constants IPTOS_*
IPTOS_LOWDELAY = $10;  
IPTOS_THROUGHPUT = $08;  
IPTOS_RELIABILITY = $04;  
IPTOS_MINCOST = $02;  


Type definitions



IP header

PIPHeader = ^TIPHeader;

TIPHeader = packed record

Note: 20 Bytes unless IP Options are added
VersionLength:Byte; $45 for IPv4 and 20-byte header
TOS:Byte; throughput type of service
TotalLength:Word; Total Size of the Packet (Max 65535) (Network Order)
Id:Word; Incremented with each Packet (Network Order)
FragOffset:Word; and IP Header Flags DF, MF etc (Network Order)
TTL:Byte; Time to Live Seconds / Hops
Protocol:Byte; IPPROTO_IP, IPPROTO_TCP etc
Checksum:Word; 1s Compliment checksum
SourceIP:TInAddr; Source IP (Network Order)
DestIP:TInAddr; Destination IP (Network Order)

IP timestamp address

PIPTimestampAddress = ^TIPTimestampAddress;

TIPTimestampAddress = packed record

Address:TInAddr;  
Timestamp:LongWord;  

IP timestamp

PIPTimestamp = ^TIPTimestamp;

TIPTimestamp = packed record

Code:Byte; IPOPT_TS
Length:Byte; Size of structure (Variable)
Index:Byte; Index of current entry
FlagsOverflow:Byte; Flags (4 Bits) Overflow counter (4 Bits)
case Integer of  
0:(Timestamp:LongWord);  
1:(TimestampAddress:TIPTimestampAddress);  

IP pseudo

PIPPseudo = ^TIPPseudo;

TIPPseudo = packed record

Note: 12 Bytes (Used by UDP/TCP Checksum)
SourceIP:TInAddr; Source IP Network Order
DestIP:TInAddr; Destination IP Network Order
Mbz:Byte; Must Be Zero
Protocol:Byte; IP Protocol Type IPPROTO_UDP, IPPROTO_TCP etc
Length:Word; Length of UDP/TCP Header and Data

IP fragment

PIPFragment = ^TIPFragment;

TIPFragment = record

Note: 12 Bytes (Used by Fragment Buffer)
Offset:Word; Offset of this Fragment in the Packet
Size:Word; Size of this Fragment
 
Prev:PIPFragment; Pointer to Prev Fragment
Next:PIPFragment; Pointer to Next Fragment

IP packet

PIPPacket = ^TIPPacket;

TIPPacket = record

Note: 56 Bytes (Used by Fragment Buffer)
Lock:TMutexHandle; Packet Lock
 
Id:Word; IP Id
Protocol:Word; IP Protocol
Dest:TInAddr; IP Dest
Source:TInAddr; IP Source
 
Data:Pointer; Pointer to Data
Timeout:Int64; Packet Timeout
Total:Word; IP Total Length
Length:Word; IP Header Length
Received:Word; Received Bytes
 
Prev:PIPPacket; Pointer to Prev Packet
Next:PIPPacket; Pointer to Next Packet
 
First:PIPFragment; Pointer to First Fragment
Last:PIPFragment; Pointer to Last Fragment


Class definitions



IP buffer

TIPBuffer = class(TTransportBufferEx)

Note: Different to Socket Buffer.
 
constructor Create(ATransport:TNetworkTransport);  
destructor Destroy; override;  
private
FFirst:PIPPacket;  
FLast:PIPPacket;  
 
function GetFragment(APacket:PIPPacket; AOffset,ASize:Word):PIPFragment;  
function AddFragment(APacket:PIPPacket; AOffset,ASize:Word):PIPFragment;  
function RemoveFragment(APacket:PIPPacket):Boolean;  
procedure FlushFragments(APacket:PIPPacket);  
public
function GetPacket(AId:Word; AProtocol:Byte; const ASource,ADest:TInAddr; ALock:Boolean):PIPPacket;  
function AddPacket(AId:Word; AProtocol:Byte; const ASource,ADest:TInAddr; ALock:Boolean):PIPPacket;  
function RemovePacket(APacket:PIPPacket):Boolean;  
function UnlockPacket(APacket:PIPPacket):Boolean;  
procedure FlushPackets(All:Boolean);  
 
function PutHeader(APacket:PIPPacket; ABuffer:Pointer; ALength:Word):Boolean;  
function PutFragment(APacket:PIPPacket; ABuffer:Pointer; AOffset,ASize,AFlags:Word):Boolean;  

IP transport adapter

TIPTransportAdapter = class(TTransportAdapter)

constructor Create;  
public
Address:TInAddr;  
Netmask:TInAddr;  
Gateway:TInAddr;  
Network:TInAddr;  
Directed:TInAddr;  
 
Server:TInAddr; DHCP Server
LeaseTime:LongWord; DHCP Lease Time
RetryTime:Int64; DHCP Retry Time
ExpiryTime:Int64; DHCP Expiry Time
RenewalTime:Int64; DHCP Renewal Time
RebindingTime:Int64; DHCP Rebinding Time
 
ConfigDefault:Word; BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK
ConfigAddress:TInAddr;  
ConfigNetmask:TInAddr;  
ConfigGateway:TInAddr;  
ConfigServer:TInAddr;  

IP transport binding

TIPTransportBinding = class(TTransportBinding)

constructor Create;  
public
Address:TInAddr;  
Netmask:TInAddr;  
Gateway:TInAddr;  
Network:TInAddr;  
Directed:TInAddr;  
 
Server:TInAddr; DHCP Server
LeaseTime:LongWord; DHCP Lease Time
RetryTime:Int64; DHCP Retry Time
ExpiryTime:Int64; DHCP Expiry Time
RenewalTime:Int64; DHCP Renewal Time
RebindingTime:Int64; DHCP Rebinding Time
 
ConfigDefault:Word; BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK
ConfigAddress:TInAddr;  
ConfigNetmask:TInAddr;  
ConfigGateway:TInAddr;  
ConfigServer:TInAddr;  

IP transport protocol

TIPTransportProtocol = class(TTransportProtocol)

private
 
public
 

IP transport filter

TIPTransportFilter = class(TTransportFilter)

private
 
public
 

IP transport configuration

TIPTransportConfig = class(TTransportConfig)

private
 
public
 

IP transport

TIPTransport = class(TNetworkTransport)

constructor Create(AManager:TTransportManager; const AName:String);  
destructor Destroy; override;  
private
FNextIPId:Word;  
FNextIPLock:TMutexHandle;  
 
FARP:TARPTransport;  
FRARP:TRARPTransport;  
FFragments:TIPBuffer;  
 
FHosts:TNetworkList;  
FServs:TNetworkList;  
FProtos:TNetworkList;  
FRoutes:TNetworkList;  
FNetworks:TNetworkList;  
FAddresses:TNetworkList;  
 
FNameservers:TIPNameservers; (Part of TNetworkList)  
FNameserverLock:TMutexHandle;  
 
FForwarding:LongWord;  
FDefaultTTL:LongWord;  
FAutoRelease:Boolean;  
 
function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;  
function FragmentHandler(ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;  
 
function CheckFragment(ABuffer:Pointer):Boolean;  
 
function GetNextIPId(AIncrement:Boolean):Word;  
 
function GetIPNameserver(ACount:LongWord):TInAddr;  
 
function GetAdapterConfigType(const AName:String):Word;  
function GetAdapterConfigAddress(const AName:String):TInAddr;  
function GetAdapterConfigNetmask(const AName:String):TInAddr;  
function GetAdapterConfigGateway(const AName:String):TInAddr;  
function GetAdapterConfigServer(const AName:String):TInAddr;  
protected
function FilterPacket(ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean; override;  
function ForwardPacket(AAdapter:TTransportAdapter; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean; override;  
public
property Nameservers:TIPNameservers read FNameservers;  
 
property Forwarding:LongWord read FForwarding write FForwarding;  
property DefaultTTL:LongWord read FDefaultTTL write FDefaultTTL;  
property AutoRelease:Boolean read FAutoRelease write FAutoRelease;  
 
function AddAdapter(AAdapter:TNetworkAdapter; AConfigType:Word; AAddress,ANetmask,AGateway,AServer:Pointer):Boolean; override;  
function RemoveAdapter(AAdapter:TNetworkAdapter):Boolean; override;  
 
function AddProtocol(AProtocol:Word; APacketHandler:TTransportPacketHandler; AControlHandler:TTransportControlHandler):THandle; override;  
function RemoveProtocol(AHandle:THandle; AProtocol:Word):Boolean; override;  
 
function AddFilter(AProtocol:Word; AFilterHandler:TTransportFilterHandler):THandle; override;  
function RemoveFilter(AHandle:THandle; AProtocol:Word):Boolean; override;  
 
function AddConfig(AConfigType:Word; AConfigAuto:Boolean; AConfigHandler:TTransportConfigHandler):THandle; override;  
function RemoveConfig(AHandle:THandle; AConfigType:Word):Boolean; override;  
 
function SendPacket(ASocket:TTransportSocket; ASource,ADest:Pointer; APacket:PPacketFragment; ASize,AFlags:Integer):Integer; override;  
function SendControl(ASource,ADest:Pointer; AProtocol,ACommand,ACode:Word; AAddress,AData:Pointer; ASize:Integer):Boolean; override;  
 
function GetSockOpt(ASocket:TTransportSocket; ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer; override;  
function SetSockOpt(ASocket:TTransportSocket; ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer; 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 AddNameserver(const AAddress:TInAddr):Boolean;  
function RemoveNameserver(const AAddress:TInAddr):Boolean;  
 
function GetHostByName(const AName:String; ALock:Boolean):TIPHostEntry;  
function GetHostByAddress(const AAddress:TInAddr; ALock:Boolean):TIPHostEntry;  
function GetHostByNext(APrevious:TIPHostEntry; ALock,AUnlock:Boolean):TIPHostEntry;  
function AddHost(const AAddress:TInAddr; const AName:String; AType:Word; ALock:Boolean):TIPHostEntry;  
function RemoveHost(const AAddress:TInAddr):Boolean;  
procedure FlushHosts(All:Boolean);  
 
function GetRouteByAddress(const AAddress:TInAddr; ALock:Boolean; AState:LongWord):TIPRouteEntry;  
function GetRouteByNetwork(const ANetwork,AAddress:TInAddr; ALock:Boolean; AState:LongWord):TIPRouteEntry;  
function GetRouteByNext(APrevious:TIPRouteEntry; ALock,AUnlock:Boolean; AState:LongWord):TIPRouteEntry;  
function AddRoute(const ANetwork,ANetmask,AGateway,AAddress:TInAddr; AType:Word; ALock:Boolean; AState:LongWord):TIPRouteEntry;  
function RemoveRoute(const ANetwork,AAddress:TInAddr):Boolean;  
procedure FlushRoutes(All:Boolean);  
 
function GetAddressByAddress(const AAddress:TInAddr; ALock:Boolean; AState:LongWord):TIPAddressEntry;  
function GetAddressByNext(APrevious:TIPAddressEntry; ALock,AUnlock:Boolean; AState:LongWord):TIPAddressEntry;  
function AddAddress(const AAddress:TInAddr; AAdapter:TNetworkAdapter; AType:Word; ALock:Boolean; AState:LongWord):TIPAddressEntry;  
function RemoveAddress(const AAddress:TInAddr):Boolean;  
procedure FlushAddresses(All:Boolean);  
 
function GetNetworkByName(const AName:String; ALock:Boolean):TIPNetworkEntry;  
function GetNetworkByAddress(const ANetwork:TInAddr; ALock:Boolean):TIPNetworkEntry;  
function AddNetwork(const AName:String; const ANetwork:TInAddr; ALock:Boolean):TIPNetworkEntry;  
function RemoveNetwork(const AName:String):Boolean;  
 
function GetServByName(const AName,AProtocol:String; ALock:Boolean):TIPServEntry;  
function GetServByPort(APort:Word; const AProtocol:String; ALock:Boolean):TIPServEntry;  
function AddServ(const AName,AProtocol:String; APort:Word; ALock:Boolean):TIPServEntry;  
function RemoveServ(const AName,AProtocol:String):Boolean;  
 
function GetProtoByName(const AName:String; ALock:Boolean):TIPProtoEntry;  
function GetProtoByNumber(ANumber:Word; ALock:Boolean):TIPProtoEntry;  
function AddProto(const AName:String; ANumber:Word; ALock:Boolean):TIPProtoEntry;  
function RemoveProto(const AName:String):Boolean;  
 
function CompareLocal(const AAddress:TInAddr):Boolean;  
function CompareDefault(const AAddress:TInAddr):Boolean;  
function CompareLoopback(const AAddress:TInAddr):Boolean;  
function CompareDirected(const AAddress:TInAddr):Boolean;  
function CompareBroadcast(const AAddress:TInAddr):Boolean;  
function CompareMulticast(const AAddress:TInAddr):Boolean;  
function CompareAddress(const AAddress1,AAddress2:TInAddr):Boolean;  
function CompareSubnet(const AAddress,ANetwork,ANetmask:TInAddr):Boolean;  

IP state

TIPState = class(TTransportState)

constructor Create;  
private
FLocalAddress:TInAddr; Host Order
FRemoteAddress:TInAddr; Host Order
 
procedure SetLocalAddress(const ALocalAddress:TInAddr);  
procedure SetRemoteAddress(const ARemoteAddress:TInAddr);  
public
property LocalAddress:TInAddr read FLocalAddress write SetLocalAddress;  
property RemoteAddress:TInAddr read FRemoteAddress write SetRemoteAddress;  

IP options

TIPOptions = class(TTransportOptions)

Note: For Get/Set Options Level = IP_PROTO Option = ???
 
constructor Create;  
destructor Destroy; override;  
private
FMemory:TMemoryStream;  
FOptions:Pointer;  
FLength:Integer;  
 
FTOS:Byte; IPTOS_LOWDELAY etc
FTTL:Byte; Time To Live
FFlags:Word; IP_DF etc
FHeader:Boolean; IP_HDRINCL
FMulticastIF:TInAddr; IP_MULTICAST_IF
FMulticastTTL:Byte; IP_MULTICAST_TTL
FMulticastLOOP:Boolean; IP_MULTICAST_LOOP
 
procedure SetTOS(ATOS:Byte);  
procedure SetTTL(ATTL:Byte);  
procedure SetFlags(AFlags:Word);  
procedure SetHeader(AHeader:Boolean);  
procedure SetMulticastIF(const AMulticastIF:TInAddr);  
procedure SetMulticastTTL(AMulticastTTL:Byte);  
procedure SetMulticastLOOP(AMulticastLOOP:Boolean);  
 
procedure SetLength(ALength:Integer);  
public
property TOS:Byte read FTOS write SetTOS;  
property TTL:Byte read FTTL write SetTTL;  
property Flags:Word read FFlags write SetFlags;  
property Header:Boolean read FHeader write SetHeader;  
property MulticastIF:TInAddr read FMulticastIF write SetMulticastIF;  
property MulticastTTL:Byte read FMulticastTTL write SetMulticastTTL;  
property MulticastLOOP:Boolean read FMulticastLOOP write SetMulticastLOOP;  
 
property Options:Pointer read FOptions; IP_OPTIONS
property Length:Integer read FLength write SetLength;  

IP host entry

TIPHostEntry = class(THostEntry)

constructor Create;  
private
FAddresses:array[0..MAX_HOST_ALIASES - 1] of TInAddr;  
 
function GetAddress:TInAddr;  
procedure SetAddress(const AAddress:TInAddr);  
function GetAddresses(Index:Integer):TInAddr;  
public
property Address:TInAddr read GetAddress write SetAddress;  
property Addresses[Index:Integer]:TInAddr read GetAddresses;  
 
function FindAddress(const AAddress:TInAddr):Boolean;  
 
function AddAddress(const AAddress:TInAddr):Boolean;  
function RemoveAddress(const AAddress:TInAddr):Boolean;  

IP route entry

TIPRouteEntry = class(TRouteEntry)

constructor Create;  
private
FTOS:Byte; Default TOS for this Route
FTTL:Byte; Default TTL for this Route
FNetwork:TInAddr;  
FNetmask:TInAddr;  
FGateway:TInAddr;  
FAddress:TInAddr;  
 
procedure SetTOS(ATOS:Byte);  
procedure SetTTL(ATTL:Byte);  
procedure SetNetwork(const ANetwork:TInAddr);  
procedure SetNetmask(const ANetmask:TInAddr);  
procedure SetGateway(const AGateway:TInAddr);  
procedure SetAddress(const AAddress:TInAddr);  
public
property TOS:Byte read FTOS write SetTOS;  
property TTL:Byte read FTTL write SetTTL;  
property Network:TInAddr read FNetwork write SetNetwork;  
property Netmask:TInAddr read FNetmask write SetNetmask;  
property Gateway:TInAddr read FGateway write SetGateway;  
property Address:TInAddr read FAddress write SetAddress;  

IP address entry

TIPAddressEntry = class(TAddressEntry)

Note: Used for secondary addresses.
 
constructor Create;  
private
FAddress:TInAddr;  
 
procedure SetAddress(const AAddress:TInAddr);  
public
property Address:TInAddr read FAddress write SetAddress;  

IP network entry

TIPNetworkEntry = class(TNetworkEntry)

constructor Create;  
private
FNetwork:TInAddr;  
 
procedure SetNetwork(const ANetwork:TInAddr);  
public
property Network:TInAddr read FNetwork write SetNetwork;  

IP service entry

TIPServEntry = class(TServEntry)

constructor Create;  
private
 
public
 

IP protocol entry

TIPProtoEntry = class(TProtoEntry)

constructor Create;  
private
 
public
 


Public variables


None defined

Function declarations



Initialization functions

procedure IPInit;
Description: To be documented
Note None documented


IP functions

function CheckIP(ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid IP packet
Buffer Complete packet without Adapter header


function GetIPHeaderOffset(ABuffer:Pointer):Word;
Description: Return Start of the IP Header (Start of Packet)
Buffer Complete packet including Transport header


function GetIPHeaderLength(ABuffer:Pointer):Word;
Description: Return Size of IP Header (Including Options)
Buffer Complete packet including Transport header


function GetIPOptionsLength(ABuffer:Pointer):Word;
Description: Return Size of IP Options (Header - IP_HEADER_SIZE)
Buffer Complete packet including Transport header


function GetIPDataOffset(ABuffer:Pointer):Word;
Description: Return Start of IP Packet Data (Length of IP Header)
Buffer Complete packet including Transport header


function GetIPDataLength(ABuffer:Pointer):Word;
Description: Return Size of IP Packet Data (IP TotalLength - IP Header)
Buffer Complete packet including Transport header


function ChecksumIPRecv(ABuffer:Pointer; AOffset,ALength:Word):Word;
Description: Validate the IP Header and Options Checksum on Receive
Buffer Complete packet including Transport header


function ChecksumIPSend(AHeader,AOptions:Pointer; ALength:Word):Word;
Description: Checksum the IP Header and Options on Send
Buffer Complete packet including Transport header


Return to Unit Reference