Unit Transport
Return to Unit Reference
Contents
Description
Ultibo Network Transport interface unit
Notes:
Includes all global transport definitions plus base class for Network transports.
Currently supported transports are IP, ARP, RARP, IPX and IP6.
All HostToNetwork swaps occur at the level where they are appropriate (ie the level of their header).
Bindings is provided to support Transports (such as IP) which can provide multiple addresses on a single adapter. It is not used by the Protocol or Winsock layer and is only used by the transport where appropriate. In such cases the ConfigType in the Adapter object is not used and the Binding is used instead.
Constants
*_TYPE_*
HOST_TYPE_DYNAMIC = 0;
|
|
HOST_TYPE_STATIC = 1;
|
|
HOST_TYPE_LOOPBACK = 2;
|
|
ROUTE_TYPE_DYNAMIC = 0;
|
|
ROUTE_TYPE_STATIC = 1;
|
|
ROUTE_TYPE_LOOPBACK = 2;
|
Loopback Route |
ROUTE_TYPE_GATEWAY = 3;
|
Default Route |
ROUTE_TYPE_MULTICAST = 4;
|
Multicast Route |
ROUTE_TYPE_BROADCAST = 5;
|
Broadcast Route |
ADDRESS_TYPE_DYNAMIC = 0;
|
Remote Dynamic Address |
ADDRESS_TYPE_STATIC = 1;
|
Remote Static Address |
ADDRESS_TYPE_LOCAL = 2;
|
Local Address (ARP/RARP Only) |
ADDRESS_TYPE_LOOPBACK = 3;
|
Local Loopback |
ADDRESS_TYPE_MULTICAST = 4;
|
Local Multicast |
ADDRESS_TYPE_BROADCAST = 5;
|
Local Broadcast |
ADDRESS_TYPE_PRIMARY = 6;
|
Same as Local but used by IP/IP6 |
ADDRESS_TYPE_SECONDARY = 7;
|
Same as Local but used by IP/IP6 |
*_HOST_*
MAX_HOST_LIFE = 600000;
|
10 Minute Host lifespan |
*_ROUTE_*
MAX_ROUTE_LIFE = 600000;
|
10 min Route lifespan |
*_ADDRESS_*
MAX_ADDRESS_LIFE = 300000;
|
5 min Address (ARP) lifespan |
IP_ADDRESS_SIZE = 4;
|
SizeOf(TInAddr) |
IP6_ADDRESS_SIZE = 16;
|
SizeOf(TIn6Addr) |
IPX_ADDRESS_SIZE = 12;
|
SizeOf(TIpxAddr) |
TTL_*
TTL_DEFAULT = 128;
|
Default to 128 Seconds/Hops (Defined as 64) |
TOS_DEFAULT = 0;
|
|
HOPLIMIT_DEFAULT = 255;
|
Default to 255 Hops (Defined as 64) |
ID_INCREMENT = 1;
|
Default Increment for ID Numbers |
TTL_DECREMENT = 1;
|
Default Decrement for TTL when Forwarding |
SEND_TIMEOUT = 0;
|
Default to wait forever on Send |
RECV_TIMEOUT = 0;
|
Default to wait forever on Recv |
CLOSE_TIMEOUT = 3000;
|
Time that Socket is kept before destruction |
LINGER_TIMEOUT = 60000;
|
Time that Socket goes into Linger state for |
CONNECT_TIMEOUT = 5000;
|
Time that Socket waits for connect completion |
TIMEWAIT_TIMEOUT = 240000;
|
Time that Socket goes into TimeWait state for (2 x MSL) |
SHUTDOWN_*
SHUTDOWN_RECV = 0;
|
|
SHUTDOWN_SEND = 1;
|
|
SHUTDOWN_BOTH = 2;
|
SELECT_*
SELECT_READ = 0;
|
|
SELECT_WRITE = 1;
|
|
SELECT_ERROR = 2;
|
|
SELECT_UNKNOWN = -1;
|
SS_*
SS_NOFDREF = $0001;
|
no file table ref any more |
SS_UNCONNECTED = SS_NOFDREF;
|
or just created socket |
SS_ISCONNECTED = $0002;
|
socket connected to a peer |
SS_ISCONNECTING = $0004;
|
in process of connecting |
SS_ISDISCONNECTING = $0008;
|
in process of disconnecting |
SS_CANTSENDMORE = $0010;
|
can't send more data |
SS_CANTRCVMORE = $0020;
|
can't receive more data |
SS_RCVATMARK = $0040;
|
at mark on input |
SS_PRIV = $0080;
|
privileged for broadcast |
SS_NBIO = $0100;
|
non-blocking ops |
SS_ASYNC = $0200;
|
async i/o notify |
SS_ISCONFIRMING = $0400;
|
accepting connection req |
SS_ISLISTENING = SS_ISCONFIRMING;
|
non standard |
SS_LOCAL_ADDR = $0800;
|
has local address/port (not used) |
SS_REMOTE_ADDR = $1000;
|
has remote address/port (not used) |
SS_CONN_REFUSED = $2000;
|
connection refused (ICMP_UNREACH) |
SS_CLOSED = $4000;
|
socket has been closed |
IP_*
IP_LOOPBACK_ADDRESS:TInAddr = (S_addr: $7F000001);
|
127.0.0.1 |
IP_LOOPBACK_NETWORK:TInAddr = (S_addr: $7F000000);
|
127.0.0.0 |
IP_LOOPBACK_NETMASK:TInAddr = (S_addr: $FF000000);
|
255.0.0.0 |
IP_BROADCAST_ADDRESS:TInAddr = (S_addr: $FFFFFFFF);
|
255.255.255.255 |
IP_BROADCAST_NETWORK:TInAddr = (S_addr: $FFFFFFFF);
|
255.255.255.255 |
IP_BROADCAST_NETMASK:TInAddr = (S_addr: $FFFFFFFF);
|
255.255.255.255 |
IP_DEFAULT_ADDRESS:TInAddr = (S_addr: $00000000);
|
0.0.0.0 |
IP_DEFAULT_NETWORK:TInAddr = (S_addr: $00000000);
|
0.0.0.0 |
IP_DEFAULT_NETMASK:TInAddr = (S_addr: $00000000);
|
0.0.0.0 |
IP_MULTICAST_HOSTS:TInAddr = (S_addr: $E0000001);
|
224.0.0.1 (All Hosts) |
IP_MULTICAST_ROUTERS:TInAddr = (S_addr: $E0000002);
|
224.0.0.2 (All Routers) |
IP_MULTICAST_NETWORK:TInAddr = (S_addr: $E0000000);
|
224.0.0.0 |
IP_MULTICAST_NETMASK:TInAddr = (S_addr: $F0000000);
|
240.0.0.0 |
Note: The recommended range for general use is 234.0.0.0 to 238.255.255.255 | |
IP_CLASSA_NETMASK:TInAddr = (S_addr: $FF000000);
|
255.0.0.0 |
IP_CLASSB_NETMASK:TInAddr = (S_addr: $FFFF0000);
|
255.255.0.0 |
IP_CLASSC_NETMASK:TInAddr = (S_addr: $FFFFFF00);
|
255.255.255.0 |
IP_CLASSD_NETMASK:TInAddr = (S_addr: $F0000000);
|
240.0.0.0 |
IP_CLASSE_NETMASK:TInAddr = (S_addr: $F0000000);
|
240.0.0.0 |
IP6_*
IP6_LOOPBACK_ADDRESS:TIn6Addr = (S6_addr: ($00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01));
|
|
IP6_DEFAULT_ADDRESS:TIn6Addr = (S6_addr: ($00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00));
|
Type definitions
Transport statistics
PTransportStatistics = ^TTransportStatistics;
TTransportStatistics = record
Note: Generic Transport | |
PacketsIn:Int64;
|
|
PacketsOut:Int64;
|
|
BytesIn:Int64;
|
|
BytesOut:Int64;
|
|
ErrorsIn:Int64;
|
|
ErrorsOut:Int64;
|
|
PacketsLost:Int64;
|
IPv4 nameservers
PIPNameservers = ^TIPNameservers;
TIPNameservers = array[0..MAX_NAME_SERVERS - 1] of TInAddr;
Note: IP4 Transport | |
IPv6 nameservers
PIP6Nameservers = ^TIP6Nameservers;
TIP6Nameservers = array[0..MAX_NAME_SERVERS - 1] of TIn6Addr;
Note: IP6 Transport | |
Transport callback
TTransportCallback = function(ATransport:TNetworkTransport):Boolean of object;
|
Monitor callback
TMonitorCallback = function(AMonitor:TNetworkMonitor):Boolean of object;
|
Authenticator callback
TAuthenticatorCallback = function(AAuthenticator:TNetworkAuthenticator):Boolean of object;
|
Transport packet handler
TTransportPacketHandler = function(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean of object;
|
Transport control handler
TTransportControlHandler = function(AHandle:THandle; ASource,ADest:Pointer; AProtocol,ACommand,ACode:Word; AAddress,AData:Pointer; ASize:Integer):Boolean of object;
|
Transport filter handler
TTransportFilterHandler = function(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean of object;
|
Transport configuration handler
TTransportConfigHandler = function(AHandle:THandle; AAdapter:TTransportAdapter; ACommand:Word):Boolean of object;
|
Class definitions
Transport manager
TTransportManager = class(TObject)
constructor Create(ASettings:TNetworkSettings; AAdapters:TAdapterManager);
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TSynchronizerHandle;
|
|
FSettings:TNetworkSettings;
|
|
FAdapters:TAdapterManager;
|
|
FTransports:TNetworkList;
|
List of TNetworkTransport objects |
FMonitors:TNetworkList;
|
List of TNetworkMonitor objects |
FAuthenticators:TNetworkList;
|
List of TNetworkAuthenticator objects |
function ReaderLock:Boolean;
|
|
function ReaderUnlock:Boolean;
|
|
function WriterLock:Boolean;
|
|
function WriterUnlock:Boolean;
|
|
public
| |
property Settings:TNetworkSettings read FSettings;
|
|
property Adapters:TAdapterManager read FAdapters;
|
|
function AddTransport(ATransport:TNetworkTransport):Boolean;
|
|
function RemoveTransport(ATransport:TNetworkTransport):Boolean;
|
|
function GetTransportByName(const AName:String; ALock:Boolean; AState:LongWord):TNetworkTransport;
|
|
function GetTransportByType(AFamily,APacketType:Word; ALock:Boolean; AState:LongWord):TNetworkTransport;
|
|
function GetTransportByTransport(ATransport:TNetworkTransport; ALock:Boolean; AState:LongWord):TNetworkTransport;
|
|
function GetTransportByNext(APrevious:TNetworkTransport; ALock,AUnlock:Boolean; AState:LongWord):TNetworkTransport;
|
|
function AddMonitor(AMonitor:TNetworkMonitor):Boolean;
|
|
function RemoveMonitor(AMonitor:TNetworkMonitor):Boolean;
|
|
function GetMonitorByMonitor(AMonitor:TNetworkMonitor; ALock:Boolean; AState:LongWord):TNetworkMonitor;
|
|
function GetMonitorByNext(APrevious:TNetworkMonitor; ALock,AUnlock: Boolean; AState:LongWord):TNetworkMonitor;
|
|
function AddAuthenticator(AAuthenticator:TNetworkAuthenticator):Boolean;
|
|
function RemoveAuthenticator(AAuthenticator:TNetworkAuthenticator):Boolean;
|
|
function GetAuthenticatorByType(AAuthType:Word; ALock:Boolean; AState:LongWord):TNetworkAuthenticator;
|
|
function GetAuthenticatorByAuthenticator(AAuthenticator:TNetworkAuthenticator; ALock:Boolean; AState:LongWord):TNetworkAuthenticator;
|
|
function GetAuthenticatorByNext(APrevious:TNetworkAuthenticator; ALock,AUnlock:Boolean; AState:LongWord):TNetworkAuthenticator;
|
|
function StartTransports:Boolean;
|
|
function StopTransports:Boolean;
|
|
function ProcessTransports:Boolean;
|
|
function EnumerateTransports(ACallback:TTransportCallback):Boolean;
|
|
function BindTransports(AAdapter:TNetworkAdapter):Boolean;
|
|
function UnbindTransports(AAdapter:TNetworkAdapter):Boolean;
|
|
function StartMonitors:Boolean;
|
|
function StopMonitors:Boolean;
|
|
function ProcessMonitors:Boolean;
|
|
function EnumerateMonitors(ACallback:TMonitorCallback):Boolean;
|
|
function BindMonitors(AAdapter:TNetworkAdapter):Boolean;
|
|
function UnbindMonitors(AAdapter:TNetworkAdapter):Boolean;
|
|
function StartAuthenticators:Boolean;
|
|
function StopAuthenticators:Boolean;
|
|
function ProcessAuthenticators:Boolean;
|
|
function EnumerateAuthenticators(ACallback:TAuthenticatorCallback):Boolean;
|
|
function BindAuthenticators(AAdapter:TNetworkAdapter):Boolean;
|
|
function UnbindAuthenticators(AAdapter:TNetworkAdapter):Boolean;
|
Transport buffer
TTransportBuffer = class(TObject)
constructor Create(ATransport:TNetworkTransport);
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TCriticalSectionHandle;
|
|
protected
| |
FTransport:TNetworkTransport;
|
|
function AcquireLock:Boolean;
|
|
function ReleaseLock:Boolean;
|
Transport buffer extended
TTransportBufferEx = class(TObject)
constructor Create(ATransport:TNetworkTransport);
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TSynchronizerHandle;
|
|
protected
| |
FTransport:TNetworkTransport;
|
|
function ReaderLock:Boolean;
|
|
function ReaderUnlock:Boolean;
|
|
function ReaderConvert:Boolean;
|
|
function WriterLock:Boolean;
|
|
function WriterUnlock:Boolean;
|
|
function WriterConvert:Boolean;
|
|
function WriterOwner:Boolean;
|
Transport adapter
TTransportAdapter = class(TListObject)
Note: Downstream | |
constructor Create;
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TSynchronizerHandle;
|
|
public
| |
Name:String;
|
|
Index:LongWord;
|
|
Handle:THandle;
|
|
PacketType:Word;
|
|
Adapter:TNetworkAdapter;
|
|
Hardware:THardwareAddress;
|
|
Broadcast:THardwareAddress;
|
|
MTU:Word;
|
|
ConfigType:Word;
|
BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK |
Configured:Boolean;
|
Adapter has been configured |
Configuring:Boolean;
|
Adapter is being configured |
function ReaderLock:Boolean;
|
|
function ReaderUnlock:Boolean;
|
|
function ReaderConvert:Boolean;
|
|
function WriterLock:Boolean;
|
|
function WriterUnlock:Boolean;
|
|
function WriterConvert:Boolean;
|
Transport binding
TTransportBinding = class(TListObject)
Note: Midstream | |
constructor Create;
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TSynchronizerHandle;
|
|
public
| |
Name:String;
|
|
Index:LongWord;
|
|
Adapter:TTransportAdapter;
|
|
ConfigType:Word;
|
BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK |
Configured:Boolean;
|
Adapter has been configured |
Configuring:Boolean;
|
Adapter is being configured |
function ReaderLock:Boolean;
|
|
function ReaderUnlock:Boolean;
|
|
function ReaderConvert:Boolean;
|
|
function WriterLock:Boolean;
|
|
function WriterUnlock:Boolean;
|
|
function WriterConvert:Boolean;
|
Transport protocol
TTransportProtocol = class(TListObject)
Note: Upstream | |
constructor Create;
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TSynchronizerHandle;
|
|
public
| |
Protocol:Word;
|
|
PacketHandler:TTransportPacketHandler;
|
|
ControlHandler:TTransportControlHandler;
|
|
function ReaderLock:Boolean;
|
|
function ReaderUnlock:Boolean;
|
|
function WriterLock:Boolean;
|
|
function WriterUnlock:Boolean;
|
Transport filter
TTransportFilter = class(TListObject)
Note: Upstream | |
constructor Create;
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TSynchronizerHandle;
|
|
public
| |
Protocol:Word;
|
|
FilterHandler:TTransportFilterHandler;
|
|
function ReaderLock:Boolean;
|
|
function ReaderUnlock:Boolean;
|
|
function WriterLock:Boolean;
|
|
function WriterUnlock:Boolean;
|
Transport configuration
TTransportConfig = class(TListObject)
Note: Upstream | |
constructor Create;
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TSynchronizerHandle;
|
|
public
| |
ConfigType:Word;
|
BOOTP/DHCP/RARP/STATIC/PSEUDO/LOOPBACK |
ConfigAuto:Boolean;
|
Supports Auto Configuration |
ConfigHandler:TTransportConfigHandler;
|
|
function ReaderLock:Boolean;
|
|
function ReaderUnlock:Boolean;
|
|
function WriterLock:Boolean;
|
|
function WriterUnlock:Boolean;
|
Network transport
TNetworkTransport = class(TListObject)
constructor Create(AManager:TTransportManager; const AName:String);
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TSynchronizerHandle;
|
|
FLocalLock:TMutexHandle;
|
|
protected
| |
FManager:TTransportManager;
|
|
FName:String;
|
TTransportManager = class(TObject)
|
TTransportBuffer = class(TObject)
|
TTransportBufferEx = class(TObject)
|
TTransportAdapter = class(TListObject)
|
TTransportBinding = class(TListObject)
|
TTransportProtocol = class(TListObject)
|
TTransportFilter = class(TListObject)
|
TTransportConfig = class(TListObject)
|
TNetworkTransport = class(TListObject)
|
TMonitorAdapter = class(TListObject)
|
TNetworkMonitor = class(TListObject)
|
TAuthenticatorAdapter = class(TListObject)
|
TNetworkAuthenticator = class(TListObject)
|
TTransportSocket = class(TListObject)
|
TSocketList = class(TObject)
|
TSocketState = class(TObject)
|
TSocketBuffer = class(TObject)
|
TSocketOptions = class(TObject)
|
TTransportState = class(TObject)
|
TTransportOptions = class(TObject)
|
THostEntry = class(TListObject)
|
TRouteEntry = class(TListObject)
|
TAddressEntry = class(TListObject)
|
TNetworkEntry = class(TListObject)
|
TServEntry = class(TListObject)
|
TProtoEntry = class(TListObject)
|
Public variables
Transport specific variables
TransportManager:TTransportManager;
|
Function declarations
Initialization functions
procedure TransportInit;
Note | None documented |
---|
function TransportStart:LongWord;
Note | None documented |
---|
function TransportStop:LongWord;
Note | None documented |
---|
function TransportBind:LongWord;
Note | None documented |
---|
function TransportUnbind:LongWord;
Note | None documented |
---|
Transport functions
function InAddrToHost(const AAddress:TInAddr):TInAddr; inline;
Note | None documented |
---|
function InAddrToNetwork(const AAddress:TInAddr):TInAddr; inline;
Note | None documented |
---|
function InAddrToString(const AAddress:TInAddr):String;
Note | Expects Address to be in Network order |
---|
function StringToInAddr(const AAddress:String):TInAddr;
Note | Returns Address in Network order |
---|
function InAddrIsEqual(const AAddress1,AAddress2:TInAddr):Boolean;
Note | Expects Address to be in Host order |
---|
function InAddrIsNone(const AAddress:TInAddr):Boolean;
Note | Expects Address to be in Host order |
---|
function InAddrIsDefault(const AAddress:TInAddr):Boolean;
Note | Expects Address to be in Host order |
---|
function InAddrIsLoopback(const AAddress:TInAddr):Boolean;
Note | Expects Address to be in Host order |
---|
function InAddrIsBroadcast(const AAddress:TInAddr):Boolean;
Note | Expects Address to be in Host order |
---|
function InAddrIsMulticast(const AAddress:TInAddr):Boolean;
Note | Expects Address to be in Host order |
---|
function In6AddrToString(const AAddress:TIn6Addr):String;
Note | None documented |
---|
function StringToIn6Addr(const AAddress:String):TIn6Addr;
Note | None documented |
---|
function In6AddrIsEqual(const AAddress1,AAddress2:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsDefault(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsLoopback(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsLinkLocal(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsSiteLocal(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsV4Mapped(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsV4Compatible(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsMulticast(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsMulticastNodeLocal(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsMulticastLinkLocal(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsMulticastSiteLocal(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsMulticastOrgLocal(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function In6AddrIsMulticastGlobal(const AAddress:TIn6Addr):Boolean;
Note | None documented |
---|
function IpxAddrToString(const AAddress:TIpxAddr):String;
Note | None documented |
---|
function StringToIpxAddr(const AAddress:String):TIpxAddr;
Note | None documented |
---|
function GetChecksum(ABuffer:Pointer; AOffset,ALength:Word):Word;
Note | None documented |
---|
function GetChecksum2(APseudo,ABuffer:Pointer; APseudoLength,ABufferOffset,ABufferLength:Word):Word;
Note | Pseudo is expected to start from Offset 0 |
---|
function GetChecksum3(APseudo,AHeader,AData:Pointer; APseudoLength,AHeaderLength,ADataOffset,ADataLength:Word):Word;
Note | Pseudo and Header are expected to start from Offset 0 |
---|
function GetChecksum4(APseudo,AHeader,AOptions,AData:Pointer; APseudoLength,AHeaderLength,AOptionsLength,ADataOffset,ADataLength:Word):Word;
Note | Pseudo, Header and Options are expected to start from Offset 0. |
---|
Transport helper functions
function HostTypeToString(AType:Word):String;
Note | None documented |
---|
function RouteTypeToString(AType:Word):String;
Note | None documented |
---|
function AddressTypeToString(AType:Word):String;
Note | None documented |
---|
function ProtocolToString(AProtocol:Word):String;
Note | None documented |
---|
function SocketTypeToString(ASocketType:Word):String;
Note | None documented |
---|
function AddressFamilyToString(AFamily:Word):String;
Note | None documented |
---|