Difference between revisions of "Unit Protocol"

From Ultibo.org
Jump to: navigation, search
 
(21 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
''To be documented''
+
'''Ultibo Network Protocol Interface unit'''
  
 
=== Constants ===
 
=== Constants ===
 
----
 
----
  
''To be documented''
+
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Protocol specific constants''' <code> PROTOCOL_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PROTOCOL_THREAD_NAME = 'Network Protocol';</code>
 +
| Thread name for Network protocol threads
 +
|-
 +
| <code>PROTOCOL_THREAD_PRIORITY = THREAD_PRIORITY_HIGHER;</code>
 +
| Thread priority for Network protocol threads
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Protocol timer key values''' <code> SOCKET_TIMER_KEY_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>SOCKET_TIMER_KEY_NONE = TIMER_KEY_NONE;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>SOCKET_TIMER_KEY_MAX = TIMER_KEY_MAX;</code>
 +
| &nbsp;
 +
|-
 +
| <code>SOCKET_TIMER_KEY_MIN = TIMER_KEY_MIN;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''Protocol timer flag values''' <code> SOCKET_TIMER_FLAG_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>SOCKET_TIMER_FLAG_NONE = $00000000;</code>
 +
| &nbsp;
 +
|-
 +
| <code>SOCKET_TIMER_FLAG_ACTIVE = $00000001;</code>
 +
| The socket timer item is active in a timer
 +
|-
 +
| <code>SOCKET_TIMER_FLAG_DYNAMIC = $00000002;</code>
 +
| The socket timer item was allocated dynamically
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''ICMP header type''' <code> ICMP_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>ICMP_ECHOREPLY = 0;</code>
 +
| echo reply
 +
|-
 +
| <code>ICMP_UNREACH = 3;</code>
 +
| dest unreachable
 +
|-
 +
| <code>ICMP_SOURCEQUENCH = 4;</code>
 +
| packet lost, slow down
 +
|-
 +
| <code>ICMP_REDIRECT = 5;</code>
 +
| shorter route
 +
|-
 +
| <code>ICMP_ECHO = 8;</code>
 +
| echo service
 +
|-
 +
| <code>ICMP_ROUTERADVERT = 9;</code>
 +
| router advertisement
 +
|-
 +
| <code>ICMP_ROUTERSOLICIT = 10;</code>
 +
| router solicitation
 +
|-
 +
| <code>ICMP_TIMXCEED = 11;</code>
 +
| time exceeded
 +
|-
 +
| <code>ICMP_PARAMPROB = 12;</code>
 +
| ip header bad
 +
|-
 +
| <code>ICMP_TSTAMP = 13;</code>
 +
| timestamp request
 +
|-
 +
| <code>ICMP_TSTAMPREPLY = 14;</code>
 +
| timestamp reply
 +
|-
 +
| <code>ICMP_IREQ = 15;</code>
 +
| information request
 +
|-
 +
| <code>ICMP_IREQREPLY = 16;</code>
 +
| information reply
 +
|-
 +
| <code>ICMP_MASKREQ = 17;</code>
 +
| address mask request
 +
|-
 +
| <code>ICMP_MASKREPLY = 18;</code>
 +
| address mask reply
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''ICMP header code''' <code> ICMP_UNREACH_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>ICMP_UNREACH_NET = 0;</code>
 +
| bad net
 +
|-
 +
| <code>ICMP_UNREACH_HOST = 1;</code>
 +
| bad host
 +
|-
 +
| <code>ICMP_UNREACH_PROTOCOL = 2;</code>
 +
| bad protocol
 +
|-
 +
| <code>ICMP_UNREACH_PORT = 3;</code>
 +
| bad port
 +
|-
 +
| <code>ICMP_UNREACH_NEEDFRAG = 4;</code>
 +
| IP_DF caused drop
 +
|-
 +
| <code>ICMP_UNREACH_SRCFAIL = 5;</code>
 +
| src route failed
 +
|-
 +
| <code>ICMP_UNREACH_NET_UNKNOWN = 6;</code>
 +
| unknown net
 +
|-
 +
| <code>ICMP_UNREACH_HOST_UNKNOWN = 7;</code>
 +
| unknown host
 +
|-
 +
| <code>ICMP_UNREACH_ISOLATED = 8;</code>
 +
| src host isolated
 +
|-
 +
| <code>ICMP_UNREACH_NET_PROHIB = 9;</code>
 +
| prohibited access
 +
|-
 +
| <code>ICMP_UNREACH_HOST_PROHIB = 10;</code>
 +
| ditto
 +
|-
 +
| <code>ICMP_UNREACH_TOSNET = 11;</code>
 +
| bad tos for net
 +
|-
 +
| <code>ICMP_UNREACH_TOSHOST = 12;</code>
 +
| bad tos for host
 +
|-
 +
| <code>ICMP_UNREACH_FILTER_PROHIB = 13;</code>
 +
| admin prohib
 +
|-
 +
| <code>ICMP_UNREACH_HOST_PRECEDENCE = 14;</code>
 +
| host prec vio.
 +
|-
 +
| <code>ICMP_UNREACH_PRECEDENCE_CUTOFF = 15;</code>
 +
| prec cutoff
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>ICMP_REDIRECT_NET = 0;</code>
 +
| for network
 +
|-
 +
| <code>ICMP_REDIRECT_HOST = 1;</code>
 +
| for host
 +
|-
 +
| <code>ICMP_REDIRECT_TOSNET = 2;</code>
 +
| for tos and net
 +
|-
 +
| <code>ICMP_REDIRECT_TOSHOST = 3;</code>
 +
| for tos and host
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>ICMP_TIMXCEED_INTRANS  = 0;</code>
 +
| ttl=0 in transit
 +
|-
 +
| <code>ICMP_TIMXCEED_REASS = 1;</code>
 +
| ttl=0 in reassembly
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>ICMP_PARAMPROB_OPTABSENT = 1;</code>
 +
| req. opt. absent
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''IGMP header type''' <code> IGMP_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>IGMP_VERSION = 2;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>IGMP_QUERY = $0011;</code>
 +
| &nbsp;
 +
|-
 +
| <code>IGMP_REPORTV1 = $0012;</code>
 +
| &nbsp;
 +
|-
 +
| <code>IGMP_REPORTV2 = $0016;</code>
 +
| &nbsp;
 +
|-
 +
| <code>IGMP_LEAVE = $0017;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Type definitions ===
 
=== Type definitions ===
 
----
 
----
  
''To be documented''
+
 
 +
'''Protocol statistics'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PProtocolStatistics = ^TProtocolStatistics;</code>
 +
 
 +
<code>TProtocolStatistics = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PacketsIn:Int64; </code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>PacketsOut:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>BytesIn:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>BytesOut:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ErrorsIn:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ErrorsOut:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PacketsLost:Int64;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''Socket timer item'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSocketTimerItem = ^TSocketTimerItem;</code>
 +
 
 +
<code>TSocketTimerItem = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Key:Integer;</code>
 +
| Ordering key for timer list
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Flags for this timer item
 +
|-
 +
| <code>Socket:TObject;</code>
 +
| The socket referenced by this timer list item
 +
|-
 +
| <code>Prev:PSocketTimerItem;</code>
 +
| Previous item in timer list
 +
|-
 +
| <code>Next:PSocketTimerItem;</code>
 +
| Next item in timer list
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Protocol callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TProtocolCallback = function(AProtocol:TNetworkProtocol):Boolean of object;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Filter callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TFilterCallback = function(AFilter:TNetworkFilter):Boolean of object;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Configuration callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TConfigCallback = function(AConfig:TNetworkConfig):Boolean of object; </code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
<br />
 +
 
 +
=== Class definitions ===
 +
----
 +
 
 +
 
 +
'''Protocol specific classes'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TProtocolManager|<code>TProtocolManager = class(TObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TProtocolTransport|<code>TProtocolTransport = class(TListObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TNetworkProtocol|<code>TNetworkProtocol = class(TListObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TSocketTimer|<code>TSocketTimer = class(TObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TSocketThread|<code>TSocketThread = class(TThread)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TProtocolPort|<code>TProtocolPort = class(TListObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TProtocolSocket|<code>TProtocolSocket = class(TTransportSocket)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TProtocolState|<code>TProtocolState = class(TObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TProtocolOptions|<code>TProtocolOptions = class(TObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TFilterTransport|<code>TFilterTransport = class(TListObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TNetworkFilter|<code>TNetworkFilter = class(TListObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TConfigTransport|<code>TConfigTransport = class(TListObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TNetworkConfig|<code>TNetworkConfig = class(TListObject)</code>]]
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| [[TNetworkClient|<code>TNetworkClient = class(TListObject)</code>]]
 +
|-
 +
|}
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
  
''To be documented''
+
 
 +
'''Protocol specific variables'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>ProtocolManager:TProtocolManager;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
<br />
  
 
=== Function declarations ===
 
=== Function declarations ===
Line 34: Line 415:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 46: Line 427:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 58: Line 439:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 73: Line 454:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-

Latest revision as of 05:29, 31 August 2021

Return to Unit Reference


Description


Ultibo Network Protocol Interface unit

Constants



Protocol specific constants PROTOCOL_*
PROTOCOL_THREAD_NAME = 'Network Protocol'; Thread name for Network protocol threads
PROTOCOL_THREAD_PRIORITY = THREAD_PRIORITY_HIGHER; Thread priority for Network protocol threads


Protocol timer key values SOCKET_TIMER_KEY_*
SOCKET_TIMER_KEY_NONE = TIMER_KEY_NONE;  
SOCKET_TIMER_KEY_MAX = TIMER_KEY_MAX;  
SOCKET_TIMER_KEY_MIN = TIMER_KEY_MIN;  


Protocol timer flag values SOCKET_TIMER_FLAG_*
SOCKET_TIMER_FLAG_NONE = $00000000;  
SOCKET_TIMER_FLAG_ACTIVE = $00000001; The socket timer item is active in a timer
SOCKET_TIMER_FLAG_DYNAMIC = $00000002; The socket timer item was allocated dynamically


ICMP header type ICMP_*
ICMP_ECHOREPLY = 0; echo reply
ICMP_UNREACH = 3; dest unreachable
ICMP_SOURCEQUENCH = 4; packet lost, slow down
ICMP_REDIRECT = 5; shorter route
ICMP_ECHO = 8; echo service
ICMP_ROUTERADVERT = 9; router advertisement
ICMP_ROUTERSOLICIT = 10; router solicitation
ICMP_TIMXCEED = 11; time exceeded
ICMP_PARAMPROB = 12; ip header bad
ICMP_TSTAMP = 13; timestamp request
ICMP_TSTAMPREPLY = 14; timestamp reply
ICMP_IREQ = 15; information request
ICMP_IREQREPLY = 16; information reply
ICMP_MASKREQ = 17; address mask request
ICMP_MASKREPLY = 18; address mask reply


ICMP header code ICMP_UNREACH_*
ICMP_UNREACH_NET = 0; bad net
ICMP_UNREACH_HOST = 1; bad host
ICMP_UNREACH_PROTOCOL = 2; bad protocol
ICMP_UNREACH_PORT = 3; bad port
ICMP_UNREACH_NEEDFRAG = 4; IP_DF caused drop
ICMP_UNREACH_SRCFAIL = 5; src route failed
ICMP_UNREACH_NET_UNKNOWN = 6; unknown net
ICMP_UNREACH_HOST_UNKNOWN = 7; unknown host
ICMP_UNREACH_ISOLATED = 8; src host isolated
ICMP_UNREACH_NET_PROHIB = 9; prohibited access
ICMP_UNREACH_HOST_PROHIB = 10; ditto
ICMP_UNREACH_TOSNET = 11; bad tos for net
ICMP_UNREACH_TOSHOST = 12; bad tos for host
ICMP_UNREACH_FILTER_PROHIB = 13; admin prohib
ICMP_UNREACH_HOST_PRECEDENCE = 14; host prec vio.
ICMP_UNREACH_PRECEDENCE_CUTOFF = 15; prec cutoff
 
ICMP_REDIRECT_NET = 0; for network
ICMP_REDIRECT_HOST = 1; for host
ICMP_REDIRECT_TOSNET = 2; for tos and net
ICMP_REDIRECT_TOSHOST = 3; for tos and host
 
ICMP_TIMXCEED_INTRANS = 0; ttl=0 in transit
ICMP_TIMXCEED_REASS = 1; ttl=0 in reassembly
 
ICMP_PARAMPROB_OPTABSENT = 1; req. opt. absent


IGMP header type IGMP_*
IGMP_VERSION = 2;  
IGMP_QUERY = $0011;  
IGMP_REPORTV1 = $0012;  
IGMP_REPORTV2 = $0016;  
IGMP_LEAVE = $0017;  


Type definitions



Protocol statistics

PProtocolStatistics = ^TProtocolStatistics;

TProtocolStatistics = record

PacketsIn:Int64;  
PacketsOut:Int64;  
BytesIn:Int64;  
BytesOut:Int64;  
ErrorsIn:Int64;  
ErrorsOut:Int64;  
PacketsLost:Int64;  

Socket timer item

PSocketTimerItem = ^TSocketTimerItem;

TSocketTimerItem = record

Key:Integer; Ordering key for timer list
Flags:LongWord; Flags for this timer item
Socket:TObject; The socket referenced by this timer list item
Prev:PSocketTimerItem; Previous item in timer list
Next:PSocketTimerItem; Next item in timer list

Protocol callback

TProtocolCallback = function(AProtocol:TNetworkProtocol):Boolean of object;

Filter callback

TFilterCallback = function(AFilter:TNetworkFilter):Boolean of object;

Configuration callback

TConfigCallback = function(AConfig:TNetworkConfig):Boolean of object;


Class definitions



Protocol specific classes

TProtocolManager = class(TObject)
TProtocolTransport = class(TListObject)
TNetworkProtocol = class(TListObject)
TSocketTimer = class(TObject)
TSocketThread = class(TThread)
TProtocolPort = class(TListObject)
TProtocolSocket = class(TTransportSocket)
TProtocolState = class(TObject)
TProtocolOptions = class(TObject)
TFilterTransport = class(TListObject)
TNetworkFilter = class(TListObject)
TConfigTransport = class(TListObject)
TNetworkConfig = class(TListObject)
TNetworkClient = class(TListObject)


Public variables



Protocol specific variables

ProtocolManager:TProtocolManager;


Function declarations



Initialization functions

procedure ProtocolInit;
Description: To be documented
Note None documented


function ProtocolStart:LongWord;
Description: To be documented
Note None documented


function ProtocolStop:LongWord;
Description: To be documented
Note None documented


Protocol helper functions

procedure ProtocolCheckTimer(Data:Pointer);
Description: To be documented
Note None documented


Return to Unit Reference