Difference between revisions of "Unit IGMP"

From Ultibo.org
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
  
 
'''Ultibo IGMP (Internet Group Management Protocol) unit'''
 
'''Ultibo IGMP (Internet Group Management Protocol) unit'''
 
''To be documented''
 
  
 
=== Constants ===
 
=== Constants ===
Line 121: Line 119:
  
  
'''IGMP protocol transport'''
+
'''IGMP specific classes'''
  
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
<code>TIGMPProtocolTransport = class(TProtocolTransport)</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>
+
| [[TIGMPProtocolTransport|<code>TIGMPProtocolTransport = class(TProtocolTransport)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>Socket:TIGMPSocket;</code>
+
| Socket for sending replies
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''IGMP protocol'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TIGMPProtocol = class(TNetworkProtocol)</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:TProtocolManager; const AName:String);</code>
+
| [[TIGMPProtocol|<code>TIGMPProtocol = class(TNetworkProtocol)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>FGroups:TNetworkList;</code>
+
| List of TIGMPGroup objects
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function PacketHandler(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function ControlHandler(AHandle:THandle; ASource,ADest:Pointer; AProtocol,ACommand,ACode:Word; AAddress,AData:Pointer; ASize:Integer):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function SendIGMP1Report(ASocket:TIGMPSocket; ASource,ADest,AAddress:Pointer):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function SendIGMP2Report(ASocket:TIGMPSocket; ASource,ADest,AAddress:Pointer):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function SendIGMP2Leave(ASocket:TIGMPSocket; ASource,ADest,AAddress:Pointer):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function SendIGMP1Query(ASocket:TIGMPSocket; ASource,ADest,AAddress:Pointer):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function SendIGMP2Query(ASocket:TIGMPSocket; ASource,ADest,AAddress:Pointer):Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function GetGroup(ATransport:TIGMPProtocolTransport; const AAddress:TInAddr; ALock:Boolean):TIGMPGroup;</code>
+
| &nbsp;
+
|-
+
| <code>function GetGroupByNext(APrevious:TIGMPGroup; ALock,AUnlock:Boolean):TIGMPGroup;</code>
+
| &nbsp;
+
|-
+
| <code>function AddGroup(ATransport:TIGMPProtocolTransport; const AAddress:TInAddr; const AHardware:THardwareAddress; ALock:Boolean):TIGMPGroup;</code>
+
| &nbsp;
+
|-
+
| <code>function RemoveGroup(ATransport:TIGMPProtocolTransport; const AAddress:TInAddr):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>procedure FlushGroups(All:Boolean);</code>
+
| &nbsp;
+
|-
+
| <code>function ProcessGroups:Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
+
|-
+
| <code>function SelectCheck(ASource,ADest:PFDSet; ACode:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function SelectWait(ASocket:TProtocolSocket;ACode:Integer;ATimeout:LongWord):Integer; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function SendPacket(ASocket:TProtocolSocket; ASource,ADest:Pointer; ASourcePort,ADestPort:Word; APacket:PPacketFragment; ASize,AFlags:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>function Accept(ASocket:TProtocolSocket; ASockAddr:PSockAddr; AAddrLength:PInteger):TProtocolSocket; override;</code>
+
| &nbsp;
+
|-
+
| <code>function Bind(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function CloseSocket(ASocket:TProtocolSocket):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function Connect(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; AAddrLength:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function IoctlSocket(ASocket:TProtocolSocket; ACmd:DWORD; var AArg:u_long):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function GetPeerName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function GetSockName(ASocket:TProtocolSocket; var ASockAddr:TSockAddr; var AAddrLength:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function GetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; var AOptLength:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function Listen(ASocket:TProtocolSocket; ABacklog:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function Recv(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function RecvFrom(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AFromAddr:TSockAddr; var AFromLength:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function Select(ANfds:Integer; AReadfds,AWritefds,AExceptfds:PFDSet; ATimeout:PTimeVal):LongInt; override;</code>
+
| &nbsp;
+
|-
+
| <code>function Send(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function SendTo(ASocket:TProtocolSocket; var ABuffer; ALength,AFlags:Integer; var AToAddr:TSockAddr; AToLength:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function SetSockOpt(ASocket:TProtocolSocket; ALevel,AOptName:Integer; AOptValue:PChar; AOptLength:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <code>function Shutdown(ASocket:TProtocolSocket; AHow:Integer):Integer; override;</code>
+
| &nbsp;
+
|-
+
| <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;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function StartProtocol:Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function StopProtocol:Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function ProcessProtocol:Boolean; override;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''IGMP group'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TIGMPGroup = class(TListObject)</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>
+
| [[TIGMPGroup|<code>TIGMPGroup = class(TListObject)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>FLock:TCriticalSectionHandle;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>FCount:Word;</code>
+
| Number of memberships
+
|-
+
| <code>FQueryTime:Int64;</code>
+
| IGMP query reply timer
+
|-
+
| <code>FReportTime:Int64;</code>
+
| IGMP report reply/transmit timer
+
|-
+
| <code>FTransmitCount:Word;</code>
+
| IGMP report transmit counter
+
|-
+
| <code>FAddress:TInAddr;</code>
+
| IP address of group
+
|-
+
| <code>FHardware:THardwareAddress;</code>
+
| Hardware address of group
+
|-
+
| <code>FTransport:TNetworkTransport;</code>
+
| Transport provider for group
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>procedure SetCount(ACount:Word);</code>
+
| &nbsp;
+
|-
+
| <code>function GetActive:Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetQueryTime(const AQueryTime:Int64);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetReportTime(const AReportTime:Int64);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetTransmitCount(ATransmitCount:Word);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetAddress(const AAddress:TInAddr);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetHardware(const AHardware:THardwareAddress);</code>
+
| &nbsp;
+
|-
+
| <code>procedure SetTransport(ATransport:TNetworkTransport);</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>property Count:Word read FCount write SetCount;</code>
+
| &nbsp;
+
|-
+
| <code>property Active:Boolean read GetActive;</code>
+
| &nbsp;
+
|-
+
| <code>property QueryTime:Int64 read FQueryTime write SetQueryTime;</code>
+
| &nbsp;
+
|-
+
| <code>property ReportTime:Int64 read FReportTime write SetReportTime;</code>
+
| &nbsp;
+
|-
+
| <code>property TransmitCount:Word read FTransmitCount write SetTransmitCount;</code>
+
| &nbsp;
+
|-
+
| <code>property Address:TInAddr read FAddress write SetAddress;</code>
+
| &nbsp;
+
|-
+
| <code>property Hardware:THardwareAddress read FHardware write SetHardware;</code>
+
| &nbsp;
+
|-
+
| <code>property Transport:TNetworkTransport read FTransport write SetTransport;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function AcquireLock:Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function ReleaseLock:Boolean;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>procedure IncrementCount;</code>
+
| &nbsp;
+
|-
+
| <code>procedure DecrementCount;</code>
+
| &nbsp;
+
|-
+
| <code>procedure IncrementTransmitCount;</code>
+
| &nbsp;
+
|-
+
| <code>procedure DecrementTransmitCount;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''IGMP socket'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TIGMPSocket = class(TProtocolSocket)</code>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
|colspan="2"|Note: SOCK_RAW
+
| [[TIGMPSocket|<code>TIGMPSocket = class(TProtocolSocket)</code>]]
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>constructor Create(AProtocol:TNetworkProtocol; ATransport:TNetworkTransport);</code>
+
| style="width: 50%;"|&nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>FRecvData:TIGMPBuffer;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>property RecvData:TIGMPBuffer read FRecvData;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function IoCtl(ACommand:DWORD; var AArgument:u_long):Integer; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function IsConnected(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;</code>
+
| &nbsp;
+
|-
+
| <code>function IsListening(ALocalAddress,ARemoteAddress:Pointer; ALocalPort,ARemotePort:Word; ABroadcast:Boolean):Boolean; override;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div>
+
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
+
'''IGMP buffer'''
+
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
+
 
+
<code>TIGMPBuffer = class(TSocketBuffer)</code>
+
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
+
{| class="wikitable" style="font-size: 14px; background: white;"
+
 
|-
 
|-
| <code>constructor Create(ASocket:TTransportSocket);</code>
+
| [[TIGMPBuffer|<code>TIGMPBuffer = class(TSocketBuffer)</code>]]
| style="width: 50%;"|&nbsp;
+
|-
+
| <code>destructor Destroy; override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
+
|-
+
| <code>FOffset:Word;</code>
+
| Offset to RemoteAddress
+
|-
+
| <code>FLength:Word;</code>
+
| Length of RemoteAddress
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>FRead:Pointer;</code>
+
| Pointer to Next Read from Buffer
+
|-
+
| <code>FWrite:Pointer;</code>
+
| Pointer to Next Write to Buffer
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>FCount:LongWord;</code>
+
| Number of Packets in Buffer
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>FFirst:PIGMPPacket;</code>
+
| Pointer to First Packet
+
|-
+
| <code>FLast:PIGMPPacket;</code>
+
| Pointer to Last Packet
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function AddPacket(ASize:Integer):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function RemovePacket:Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>procedure FlushPackets;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
+
|-
+
| <code>procedure SetSize(ASize:LongWord); override;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
+
|-
+
| <code>function GetNext:Integer;</code>
+
| &nbsp;
+
|-
+
| <code>function GetCount:LongWord;</code>
+
| &nbsp;
+
|-
+
|colspan="2"|&nbsp;
+
|-
+
| <code>function ReadBuffer(var ABuffer; var ASize:Integer; ARemoteAddress:Pointer; AFlags:Integer):Boolean;</code>
+
| &nbsp;
+
|-
+
| <code>function WriteBuffer(var ABuffer; ASize:Integer; ARemoteAddress:Pointer):Boolean;</code>
+
| &nbsp;
+
 
|-
 
|-
 
|}
 
|}
</div></div> 
 
 
<br />
 
<br />
  

Latest revision as of 05:24, 31 August 2021

Return to Unit Reference


Description


Ultibo IGMP (Internet Group Management Protocol) unit

Constants



IGMP protocol IGMP_PROTOCOL_*
Note: Some IGMP definitions are in the Protocol or IP modules
 
IGMP_PROTOCOL_NAME = 'IGMP';  


IGMP specific constants IGMP_*
IGMP_TIMEOUT = 0; Wait forever on a IGMP Read
IGMP_BUFFER_SIZE = 65536; IGMP Receive Buffer Size
 
IGMP_HEADER_SIZE = 8; SizeOf(TIGMPHeader);
 
IGMP_PACKET_SIZE = 8; SizeOf(TIGMPPacket)
 
IGMP_QUERY_TIMEOUT = 5000;  
IGMP_REPORT_TIMEOUT = 5000;  
 
IGMP_TRANSMIT_COUNT = 3;  


Type definitions



IGMP header

PIGMPHeader = ^TIGMPHeader;

TIGMPHeader = packed record

Note: Some IGMP definitions are in the Protocol or IP modules
IGMPType:Byte; type of IGMP message
RespTime:Byte; Query only otherwise 0 (Always zero in Version 1 (Assume 100))
Checksum:Word; 1s Compliment IP-style checksum
Address:TInAddr; group address being reported or queried (zero for "General" queries)

IGMP packet

PIGMPPacket = ^TIGMPPacket;

TIGMPPacket = record

Note: 8 Bytes (Used by IGMPBuffer)
Size:LongWord; LongWord to keep size even
Next:PIGMPPacket; Followed by RemoteAddress (4 or 16 Bytes)


Class definitions



IGMP specific classes

TIGMPProtocolTransport = class(TProtocolTransport)
TIGMPProtocol = class(TNetworkProtocol)
TIGMPGroup = class(TListObject)
TIGMPSocket = class(TProtocolSocket)
TIGMPBuffer = class(TSocketBuffer)


Public variables


None defined

Function declarations



Initialization functions

procedure IGMPInit;
Description: To be documented
Note None documented


IGMP functions

function CheckIGMP(AFamily:Word; ABuffer:Pointer):Boolean;
Description: Verify that the packet is a valid IGMP packet
Buffer The complete packet including Transport header


function GetIGMPHeaderOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetIGMPHeaderLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetIGMPDataOffset(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function GetIGMPDataLength(AFamily:Word; ABuffer:Pointer):Word;
Description: To be documented
Buffer The complete packet including Transport header


function ChecksumIGMP(AFamily:Word; ABuffer:Pointer; AOffset,ALength:Word):Word;
Description: Checksum the IGMP Header on Send/Validate the Checksum on Receive
Note Checksum is calculated on the whole packet (Header and Data)


Return to Unit Reference