Difference between revisions of "Unit RAW"

From Ultibo.org
Jump to: navigation, search
Line 120: Line 120:
 
|-
 
|-
 
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
 
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
|-
 
| <code>function AddTransport(ATransport:TNetworkTransport):Boolean; override;</code>
 
| &nbsp;
 
|-
 
| <code>function RemoveTransport(ATransport:TNetworkTransport):Boolean; override;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
|-
 
| <code>function FindSocket(AFamily,AStruct,AProtocol:Word; ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast,AListen,ALock:Boolean; AState:LongWord):TProtocolSocket; override;</code>
 
| &nbsp;
 
|-
 
| <code>procedure FlushSockets(All:Boolean); override;</code>
 
| &nbsp;
 
|-
 
|colspan="2"|&nbsp;
 
 
|-
 
|-
 
| <code>function SelectCheck(ASource,ADest:PFDSet; ACode:Integer):Integer; override;</code>
 
| <code>function SelectCheck(ASource,ADest:PFDSet; ACode:Integer):Integer; override;</code>
Line 199: Line 183:
 
|-
 
|-
 
| <code>function Socket(AFamily,AStruct,AProtocol:Integer):TProtocolSocket; override;</code>
 
| <code>function Socket(AFamily,AStruct,AProtocol:Integer):TProtocolSocket; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function AddTransport(ATransport:TNetworkTransport):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function RemoveTransport(ATransport:TNetworkTransport):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function FindSocket(AFamily,AStruct,AProtocol:Word; ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast,AListen,ALock:Boolean; AState:LongWord):TProtocolSocket; override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure FlushSockets(All:Boolean); override;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-

Revision as of 06:06, 28 July 2017

Return to Unit Reference


Description


Ultibo Raw Socket Protocol unit

To be documented

Constants



Raw specific constants RAW_*
Note: Some RAW definitions are in the Protocol or IP modules
 
IP_PROTOCOL_NAME = 'IP';  
RAW_PROTOCOL_NAME = 'RAW';  
 
RAW_TIMEOUT = 0; Wait forever on a RAW Read
RAW_BUFFER_SIZE = 65536; RAW Receive Buffer Size
 
RAW_HEADER_SIZE = 0; No Header for RAW
 
RAW_PACKET_SIZE = 8; SizeOf(TRAWPacket)


Type definitions



Raw packet

PRAWPacket = ^TRAWPacket;

TRAWPacket = record

Note: Some RAW definitions are in the Protocol or IP modules
Note: 8 Bytes (Used by RAWBuffer)
Size:LongWord; LongWord to keep size even
Next:PRAWPacket; Followed by RemoteAddress (4 or 16 Bytes)


Class definitions



RAW protocol transport

TRAWProtocolTransport = class(TProtocolTransport)

private
 
public
 

RAW protocol

TRAWProtocol = class(TNetworkProtocol)

constructor Create(AManager:TProtocolManager; const AName:String);  
destructor Destroy; override;  
private
function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;  
protected
function SelectCheck(ASource,ADest:PFDSet; ACode:Integer):Integer; override;  
function SelectWait(ASocket:TProtocolSocket; ACode:Integer; ATimeout:LongWord):Integer; override;  
 
function SendPacket(ASocket:TProtocolSocket; ASource,ADest:Pointer; ASourcePort,ADestPort:Word; APacket:PPacketFragment; ASize,AFlags:Integer):Integer; override;  
public
function Accept(ASocket:TProtocolSocket; ASockAddr:PSockAddr; AAddrLength:PInteger):TProtocolSocket; override;  
function Bind(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer; override;  
function CloseSocket(ASocket:TProtocolSocket):Integer; override;  
function Connect(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer; override;  
function IoctlSocket(ASocket:TProtocolSocket; ACmd:DWORD; var AArg:u_long):Integer; override;  
function GetPeerName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer; override;  
function GetSockName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer; override;  
function GetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer; override;  
function Listen(ASocket:TProtocolSocket; ABacklog:Integer):Integer; override;  
function Recv(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer; override;  
function RecvFrom(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AFromAddr:TSockAddr; var AFromLength:Integer):Integer; override;  
function Select(ANfds:Integer; AReadfds,AWritefds,AExceptfds:PFDSet; ATimeout:PTimeVal):LongInt; override;  
function Send(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer; override;  
function SendTo(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AToAddr:TSockAddr; AToLength:Integer):Integer; override;  
function SetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer; override;  
function Shutdown(ASocket:TProtocolSocket; AHow:Integer):Integer; override;  
function Socket(AFamily,AStruct,AProtocol:Integer):TProtocolSocket; override;  
 
function AddTransport(ATransport:TNetworkTransport):Boolean; override;  
function RemoveTransport(ATransport:TNetworkTransport):Boolean; override;  
 
function FindSocket(AFamily,AStruct,AProtocol:Word; ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast,AListen,ALock:Boolean; AState:LongWord):TProtocolSocket; override;  
procedure FlushSockets(All:Boolean); override;  
 
function StartProtocol:Boolean; override;  
function StopProtocol:Boolean; override;  
function ProcessProtocol:Boolean; override;  

RAW socket

TRAWSocket = class(TProtocolSocket)

Note: SOCK_RAW
 
constructor Create(AProtocol:TNetworkProtocol; ATransport:TNetworkTransport);  
destructor Destroy; override;  
private
FRecvData:TRAWBuffer;  
public
property RecvData:TRAWBuffer read FRecvData;  
 
function IoCtl(ACommand:DWORD; var AArgument:u_long):Integer; override;  
 
function IsConnected(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;  
function IsListening(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;  

RAW buffer

TRAWBuffer = class(TSocketBuffer)

constructor Create(ASocket:TTransportSocket);  
destructor Destroy; override;  
private
FOffset:Word; Offset to RemoteAddress
FLength:Word; Length of RemoteAddress
 
FRead:Pointer; Pointer to Next Read from Buffer
FWrite:Pointer; Pointer to Next Write to Buffer
 
FCount:LongWord; Number of Packets in Buffer
 
FFirst:PRAWPacket; Pointer to First Packet
FLast:PRAWPacket; Pointer to Last Packet
 
function AddPacket(ASize:Integer):Boolean;  
function RemovePacket:Boolean;  
procedure FlushPackets;  
protected
procedure SetSize(ASize:LongWord); override;  
public
function GetNext:Integer;  
function GetCount:LongWord;  
 
function ReadBuffer(var ABuffer; var ASize:Integer; ARemoteAddress:Pointer; AFlags:Integer):Boolean;  
function WriteBuffer(var ABuffer; ASize:Integer; ARemoteAddress:Pointer):Boolean;  


Public variables


None defined

Function declarations



Initialization functions

procedure RAWInit;
Description: To be documented
Note None documented


Return to Unit Reference