Difference between revisions of "Unit Network"

From Ultibo.org
Jump to: navigation, search
 
(7 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Ultibo Network interface unit'''
+
'''Ultibo Network Interface unit'''
 
+
''To be documented''
+
  
 
=== Constants ===
 
=== Constants ===
Line 688: Line 686:
 
</div></div>
 
</div></div>
 
<br />  
 
<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;">'''Ethernet 802.3 network''' <code> LLC_HEADER_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|colspan="2"|FRAME_TYPE_ETHERNET_8022
 
|-
 
| <code>LLC_HEADER_SIZE = 3;</code>
 
| SizeOf(TLLCHeader); Optionally can be 4 if Control is 2 octets
 
|-
 
|}
 
</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;">'''Ethernet SNAP network''' <code> SNAP_HEADER_* </code></div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|colspan="2"|FRAME_TYPE_ETHERNET_SNAP
 
|-
 
| <code>SNAP_HEADER_SIZE = 5;</code>
 
| SizeOf(TSNAPHeader);
 
|-
 
|}
 
</div></div>
 
<br />
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 
<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;">'''Generic MII registers (Management Interface)''' <code> MII_* </code></div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Generic MII registers (Management Interface)''' <code> MII_* </code></div>
Line 1,097: Line 1,069:
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>LPA_1000MSFAIL = $8000;</code>
 +
| Master/Slave resolution failure
 
|-
 
|-
 
| <code>LPA_1000LOCALRXOK = $2000;</code>
 
| <code>LPA_1000LOCALRXOK = $2000;</code>
Line 1,146: Line 1,121:
 
| <code>MII_MMD_CTRL_INCR_ON_WT = $C000;</code>
 
| <code>MII_MMD_CTRL_INCR_ON_WT = $C000;</code>
 
| Post increment on writes only
 
| Post increment on writes only
 +
|-
 +
|}
 +
</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;">'''PHY link state''' <code> PHY_LINK_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PHY_LINK_DOWN = 0;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>PHY_LINK_UP = 1;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>PHY_LINK_UNKNOWN = -1;</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;">'''PHY interface mode''' <code> PHY_INTERFACE_MODE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PHY_INTERFACE_MODE_NONE = 0;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_INTERNAL = 1;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_MII = 2;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_GMII = 3;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_SGMII = 4;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_TBI = 5;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_REVMII = 6;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_RMII = 7;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_RGMII = 8;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_RGMII_ID = 9;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_RGMII_RXID = 10;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_RGMII_TXID = 11;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_RTBI = 12;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_SMII = 13;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_XGMII = 14;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_MOCA = 15;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_QSGMII = 16;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_TRGMII = 17;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_1000BASEX = 18;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_2500BASEX = 19;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_RXAUI = 20;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_XAUI = 21;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_INTERFACE_MODE_10GKR = 22;</code>
 +
| 10GBASE-KR, XFI, SFI - single lane 10G Serdes
 +
|-
 +
| <code>PHY_INTERFACE_MODE_USXGMII = 23;</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;">'''PHY link speed''' <code> PHY_SPEED_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PHY_SPEED_10 = 10;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>PHY_SPEED_100 = 100;</code>
 +
| &nbsp;
 +
|-
 +
| <code>PHY_SPEED_1000 = 1000;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>PHY_SPEED_UNKNOWN = -1;</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;">'''PHY duplex mode''' <code> PHY_DUPLEX_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>PHY_DUPLEX_HALF = 0;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>PHY_DUPLEX_FULL = 1;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>PHY_DUPLEX_UNKNOWN = -1;</code>
 +
| &nbsp;
 
|-
 
|-
 
|}
 
|}
Line 1,205: Line 1,320:
 
|-
 
|-
 
| <code>ETHERNET_HEADER_SIZE = 14;</code>
 
| <code>ETHERNET_HEADER_SIZE = 14;</code>
| SizeOf(TEthernetHeader);
+
| SizeOf(TEthernetHeader)
 
|-
 
|-
 
| <code>ETHERNET_VLAN_SIZE = 4;</code>
 
| <code>ETHERNET_VLAN_SIZE = 4;</code>
Line 1,251: Line 1,366:
 
| <code>ETHERNET_TRANSMIT_BUFFER_SIZE = ETHERNET_MAX_PACKET_SIZE;</code>
 
| <code>ETHERNET_TRANSMIT_BUFFER_SIZE = ETHERNET_MAX_PACKET_SIZE;</code>
 
| &nbsp;
 
| &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;">'''Ethernet 802.3 network''' <code> LLC_HEADER_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|FRAME_TYPE_ETHERNET_8022
 +
|-
 +
| <code>LLC_HEADER_SIZE = 3;</code>
 +
| SizeOf(TLLCHeader); Optionally can be 4 if Control is 2 octets
 +
|-
 +
|}
 +
</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;">'''Ethernet SNAP network''' <code> SNAP_HEADER_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|FRAME_TYPE_ETHERNET_SNAP
 +
|-
 +
| <code>SNAP_HEADER_SIZE = 5;</code>
 +
| SizeOf(TSNAPHeader);
 
|-
 
|-
 
|}
 
|}
Line 1,273: Line 1,414:
 
|-
 
|-
 
|}
 
|}
</div></div>  
+
</div></div>
  
 
'''Hardware addresses'''
 
'''Hardware addresses'''
Line 1,288: Line 1,429:
 
|-
 
|-
 
|}
 
|}
</div></div>
+
</div></div>  
  
'''Multicast addresses'''
+
'''Multicast address'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
Line 1,303: Line 1,444:
 
|-
 
|-
 
|}
 
|}
</div></div>  
+
</div></div> 
 +
 
 +
'''Packet fragment'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PPacketFragment = ^TPacketFragment;</code>
 +
 
 +
<code>TPacketFragment = packed record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Size:Integer;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>Data:Pointer;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Next:PPacketFragment;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Adapter statistics'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PAdapterStatistics = ^TAdapterStatistics;</code>
 +
 
 +
<code>TAdapterStatistics = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| PacketsIn:UInt64;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| PacketsOut:UInt64;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| BytesIn:UInt64;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| BytesOut:UInt64;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| ErrorsIn:UInt64;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| ErrorsOut:UInt64;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| PacketsLost:UInt64;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
  
 
'''Network packet'''
 
'''Network packet'''
Line 1,725: Line 1,920:
 
</div></div>
 
</div></div>
  
'''Packet fragment'''
+
'''Ethernet address'''
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
<code>PPacketFragment = ^TPacketFragment;</code>
+
<code>PEthernetAddress = ^TEthernetAddress;</code>
  
<code>TPacketFragment = packed record</code>
+
<code>TEthernetAddress = array[0..ETHERNET_ADDRESS_SIZE - 1] of Byte;</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
| <code>Size:Integer;</code>
+
| &nbsp;
 
| style="width: 50%;"|&nbsp;
 
| style="width: 50%;"|&nbsp;
 
|-
 
|-
| <code>Data:Pointer;</code>
+
|}
 +
</div></div>
 +
 
 +
'''Ethernet header'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PEthernetHeader = ^TEthernetHeader;</code>
 +
 
 +
<code>TEthernetHeader = packed record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>DestAddress:THardwareAddress;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
| <code>Next:PPacketFragment;</code>
+
| <code>SourceAddress:THardwareAddress;</code>
 
| &nbsp;
 
| &nbsp;
 +
|-
 +
| <code>TypeLength:Word;</code>
 +
| Length or Type (IEEE 802.3 or BlueBook/DIX Ethernet)
 +
|-
 +
| <code>Data:array[0..0] of Byte;</code>
 +
| Not part of header, included to provide a pointer to the start of data
 
|-
 
|-
 
|}
 
|}
</div></div>  
+
</div></div>
  
 
'''Ethernet 802.3 network'''
 
'''Ethernet 802.3 network'''
Line 1,788: Line 2,001:
 
| <code>ProtocolID:Word;</code>
 
| <code>ProtocolID:Word;</code>
 
| &nbsp;
 
| &nbsp;
|-
 
| <code>Data:array[0..0] of Byte;</code>
 
| Not part of header, included to provide a pointer to the start of data
 
|-
 
|}
 
</div></div> 
 
 
'''Token ring network'''
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
<code>PTokenRingAddress = ^TTokenRingAddress;</code>
 
 
<code>TTokenRingAddress = array[0..5] of Byte;</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
| &nbsp;
 
| style="width: 50%;"|&nbsp;
 
|-
 
|}
 
</div></div>
 
 
'''Token ring header'''
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
<code>PTokenRingHeader = ^TTokenRingHeader;</code>
 
 
<code>TTokenRingHeader = packed record</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
| &nbsp;
 
| style="width: 50%;"|&nbsp;
 
|-
 
|}
 
</div></div>
 
 
'''Adapter statistics'''
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
<code>PAdapterStatistics = ^TAdapterStatistics;</code>
 
 
<code>TAdapterStatistics = record</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
| <code>PacketsIn:UInt64;</code>
 
| style="width: 50%;"|&nbsp;
 
|-
 
| <code>PacketsOut:UInt64;</code>
 
| &nbsp;
 
|-
 
| <code>BytesIn:UInt64;</code>
 
| &nbsp;
 
|-
 
| <code>BytesOut:UInt64;</code>
 
| &nbsp;
 
|-
 
| <code>ErrorsIn:UInt64;</code>
 
| &nbsp;
 
|-
 
| <code>ErrorsOut:UInt64;</code>
 
| &nbsp;
 
|-
 
| <code>PacketsLost:UInt64;</code>
 
| &nbsp;
 
|-
 
|}
 
</div></div>
 
 
'''Ethernet address'''
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
<code>PEthernetAddress = ^TEthernetAddress;</code>
 
 
<code>TEthernetAddress = array[0..ETHERNET_ADDRESS_SIZE - 1] of Byte;</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
| &nbsp;
 
| style="width: 50%;"|&nbsp;
 
|-
 
|}
 
</div></div>
 
 
'''Ethernet header'''
 
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 
<code>PEthernetHeader = ^TEthernetHeader;</code>
 
 
<code>TEthernetHeader = packed record</code>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
| <code>DestAddress:THardwareAddress;</code>
 
| &nbsp;
 
|-
 
| <code>SourceAddress:THardwareAddress;</code>
 
| &nbsp;
 
|-
 
| <code>TypeLength:Word;</code>
 
| Length or Type (IEEE 802.3 or BlueBook/DIX Ethernet)
 
 
|-
 
|-
 
| <code>Data:array[0..0] of Byte;</code>
 
| <code>Data:array[0..0] of Byte;</code>
Line 2,160: Line 2,271:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function NetworkBufferAllocate(Network:PNetworkDevice; var Entry:PNetworkEntry):LongWord;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function NetworkBufferAllocate(Network:PNetworkDevice; var Entry:PNetworkEntry):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Allocate a transmit buffer from the specified network device, the returned entry will include a buffer for writing data to as well as an offfset value to allow the driver data to be written to the start of the buffer. When the data has been copied to the buffer, pass the entry to NetworkBufferTransmit.</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Allocate a transmit buffer from the specified network device, the returned entry will include a buffer for writing data to as well as an offset value to allow the driver data to be written to the start of the buffer. When the data has been copied to the buffer, pass the entry to NetworkBufferTransmit.</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 2,379: Line 2,490:
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function NetworkEventRelease(Event:PNetworkEvent):LongWord;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function NetworkEventRelease(Event:PNetworkEvent):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister and Destroy a Event from the Event table</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister and Destroy an Event from the Event table</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
Line 2,480: Line 2,591:
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function NetworkGetLastError:LongInt; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function NetworkGetLastError:LongInt;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the last network error value for the current Thread</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the last network error value for the current Thread</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
Line 2,492: Line 2,603:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">procedure NetworkSetLastError(Error:LongInt); inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">procedure NetworkSetLastError(Error:LongInt);</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the last network error value for the current Thread</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the last network error value for the current Thread</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
Line 2,504: Line 2,615:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function NetworkGetCount:LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function NetworkGetCount:LongWord;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current network count</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current network count</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
Line 2,660: Line 2,771:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function HardwareAddressToString(const AAddress:THardwareAddress):String;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function HardwareAddressToString(const AAddress:THardwareAddress; const ASeparator: String = ''):String;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">

Latest revision as of 04:46, 10 October 2023

Return to Unit Reference


Description


Ultibo Network Interface unit

Constants



Network specific constants NETWORK_*
NETWORK_NAME_PREFIX = 'Network'; Name prefix for Network Devices
 
Generic Network
HARDWARE_DEFAULT:THardwareAddress = ($00,$00,$00,$00,$00,$00);  
HARDWARE_LOOPBACK:THardwareAddress = ($00,$00,$00,$00,$00,$01);  
HARDWARE_BROADCAST:THardwareAddress = ($FF,$FF,$FF,$FF,$FF,$FF);  


Network device type NETWORK_TYPE_*
NETWORK_TYPE_NONE = 0;  
NETWORK_TYPE_ETHERNET = 1;  
NETWORK_TYPE_TOKENRING = 2;  
NETWORK_TYPE_80211 = 3; IEEE 802.11 Wireless (WiFi) network
 
NETWORK_TYPE_MAX = 3;  


Network device state NETWORK_STATE_*
NETWORK_STATE_CLOSED = 0;  
NETWORK_STATE_CLOSING = 1;  
NETWORK_STATE_OPENING = 2;  
NETWORK_STATE_OPEN = 3;  
 
NETWORK_STATE_MAX = 3;  


Network device status NETWORK_STATUS_*
NETWORK_STATUS_DOWN = 0;  
NETWORK_STATUS_UP = 1;  
 
NETWORK_STATUS_MAX = 1;  


Network device flag NETWORK_FLAG_*
NETWORK_FLAG_NONE = $00000000;  
NETWORK_FLAG_RX_BUFFER = $00000001; Device supports Receive Buffer (NetworkBufferReceive/NetworkBufferRelease)
NETWORK_FLAG_TX_BUFFER = $00000002; Device supports Transmit Buffer (NetworkBufferAllocate/NetworkBufferTransmit)
NETWORK_FLAG_RX_MULTIPACKET = $00000004; Device supports multiple packets in the same Receive entry
NETWORK_FLAG_TX_MULTIPACKET = $00000008; Device supports multiple packets in the same Transmit entry


Network device control code NETWORK_CONTROL_*
NETWORK_CONTROL_CLEAR_STATS = 1; Clear Statistics
NETWORK_CONTROL_SET_MAC = 2; Set the MAC for this device
NETWORK_CONTROL_GET_MAC = 3; Get the MAC for this device
NETWORK_CONTROL_SET_LOOPBACK = 4; Set Loopback Mode
NETWORK_CONTROL_RESET = 5; Reset the device
NETWORK_CONTROL_DISABLE = 6; Disable the device
NETWORK_CONTROL_GET_BROADCAST = 8; Get Broadcast address for this device
NETWORK_CONTROL_GET_MTU = 9; Get MTU for this device
NETWORK_CONTROL_GET_HEADERLEN = 10; Get Header length for this device
NETWORK_CONTROL_GET_LINK = 11; Get link status for this device
NETWORK_CONTROL_GET_SPEED = 12; Get link speed for this device
NETWORK_CONTROL_GET_DUPLEX = 13; Get link speed for this device
NETWORK_CONTROL_RESET_LINK = 14; Reset link for this device
NETWORK_CONTROL_GET_STATS = 15; Get statistics for this device
NETWORK_CONTROL_ADD_MULTICAST = 16; Add a multicast address to this device
NETWORK_CONTROL_DEL_MULTICAST = 17; Delete a multicast address from this device
NETWORK_CONTROL_GET_MULTICAST = 18; Get the list of multicast address for this device


Network link state NETWORK_LINK_*
NETWORK_LINK_DOWN = NETWORK_STATUS_DOWN;  
NETWORK_LINK_UP = NETWORK_STATUS_UP;  


Network speed state NETWORK_SPEED_*
NETWORK_SPEED_NONE = 0;  
NETWORK_SPEED_10 = 10;  
NETWORK_SPEED_100 = 100;  
NETWORK_SPEED_1000 = 1000;  


Network duplex state NETWORK_DUPLEX_*
NETWORK_DUPLEX_NONE = 0;  
NETWORK_DUPLEX_HALF = 1;  
NETWORK_DUPLEX_FULL = 2;  


Network lock state NETWORK_LOCK_*
NETWORK_LOCK_NONE = 0;  
NETWORK_LOCK_READ = 1;  
NETWORK_LOCK_WRITE = 2;  


Network buffer size NETWORK_BUFFER_*
NETWORK_BUFFER_SIZE = 1024;  


Network event NETWORK_EVENT_*
NETWORK_EVENT_NONE = $00000000;  
NETWORK_EVENT_SYSTEM_START = $00000001; The network sub system is starting
NETWORK_EVENT_SYSTEM_STOP = $00000002; The network sub system has stopped
NETWORK_EVENT_ADAPTERS_START = $00000004; All network adapters are being started
NETWORK_EVENT_ADAPTERS_STOP = $00000008; All network adapters have been stopped
NETWORK_EVENT_TRANSPORTS_START = $00000010; All network transports are being started
NETWORK_EVENT_TRANSPORTS_STOP = $00000020; All network transports have been stopped
NETWORK_EVENT_PROTOCOLS_START = $00000040; All network protocols are being started
NETWORK_EVENT_PROTOCOLS_STOP = $00000080; All network protocols have been stopped


Network event signature NETWORK_EVENT_SIGNATURE*
NETWORK_EVENT_SIGNATURE = $BE1D50C2;  


Network event state NETWORK_EVENT_STATE_*
NETWORK_EVENT_STATE_UNREGISTERED = 0;  
NETWORK_EVENT_STATE_REGISTERED = 1;  


Network event flag NETWORK_EVENT_FLAG_*
NETWORK_EVENT_FLAG_NONE = $00000000;  


Adapter type ADAPTER_TYPE_*
ADAPTER_TYPE_UNKNOWN = 0;  
ADAPTER_TYPE_WIRED = 1;  
ADAPTER_TYPE_LOOPBACK = 2;  
ADAPTER_TYPE_WIRELESS = 3;  
ADAPTER_TYPE_SLIP = 4;  
ADAPTER_TYPE_PPP = 5;  


Adapter thread ADAPTER_THREAD_*
ADAPTER_THREAD_NAME = 'Network Adapter'; Thread name for Network adapter threads
ADAPTER_THREAD_PRIORITY = THREAD_PRIORITY_HIGHER; Thread priority for Network adapter threads


Adapter state ADAPTER_STATE_*
ADAPTER_STATE_DISABLED = 0;  
ADAPTER_STATE_ENABLED = 1;  


Adapter status ADAPTER_STATUS_*
ADAPTER_STATUS_DOWN = 0;  
ADAPTER_STATUS_UP = 1;  


Configuration type CONFIG_TYPE_*
CONFIG_TYPE_AUTO = 0;  
CONFIG_TYPE_STATIC = 1;  
CONFIG_TYPE_RARP = 2;  
CONFIG_TYPE_BOOTP = 3;  
CONFIG_TYPE_DHCP = 4;  
CONFIG_TYPE_PSEUDO = 5;  
CONFIG_TYPE_LOOPBACK = 6;  
CONFIG_TYPE_SLIP = 7;  
CONFIG_TYPE_PPP = 8;  
 
CONFIG_TYPE_UNKNOWN = Word(-1);  


Authentication type AUTH_TYPE_*
AUTH_TYPE_UNKNOWN = 0;  
AUTH_TYPE_EAP = 1;  
AUTH_TYPE_RSN = 2;  


Frame type FRAME_TYPE_*
FRAME_TYPE_UNKNOWN = 0;  
FRAME_TYPE_ETHERNET_II = 1; Blue Book
FRAME_TYPE_TOKEN_RING = 3; IEEE 802.5
FRAME_TYPE_APPLETALK = 5; LocalTalk
FRAME_TYPE_ETHERNET_8022 = 11; IEEE 802.2 LLC
FRAME_TYPE_ETHERNET_SNAP = 98; IEEE 802.2 LLC with SNAP Header
FRAME_TYPE_ETHERNET_8023 = 99; 802.3 RAW (Novell)
 
FRAME_START_ETHERNET_SNAP = $AAAA;  
FRAME_START_ETHERNET_8023 = $FFFF;  
 
ADAPTER_MODE_NONE = 1;  
ADAPTER_MODE_LOCAL = 2;  
ADAPTER_MODE_BROADCAST= 3; This is the default
ADAPTER_MODE_LOCAL_MULTI = 4; Mode 3 plus directed Multicast
ADAPTER_MODE_BROADCAST_MULTI = 5; Mode 3 plus all Multicast
ADAPTER_MODE_PROMISCUOUS = 6; Promiscuous mode


Configuration command CONFIG_*
CONFIG_ADAPTER_DISCOVER = 0; Discover an Address from the ConfigHandler
CONFIG_ADAPTER_REQUEST = 1; Request an Address from the ConfigHandler (Either configured or obtained from Discover)
CONFIG_ADAPTER_RELEASE = 2; Release the Address obtained from ConfigHandler
CONFIG_ADAPTER_RENEW = 3; Renew the Address obtained from ConfigHandler
CONFIG_ADAPTER_REBIND = 4; Rebind the Address obtained from ConfigHandler
CONFIG_ADAPTER_INFORM = 5; Obtain information only from the ConfigHandler
CONFIG_ADAPTER_REBOOT = 6; Request previous Address after a Reboot
 
CONFIG_RETRY_TIMEOUT = 300000; 5 min Config Retry Timeout
CONFIG_RENEW_TIMEOUT = 60000; 1 min Config Renew Timeout
CONFIG_REBIND_TIMEOUT = 60000; 1 min Config Rebind Timeout


Authentication command AUTH_COMMAND_*
AUTH_COMMAND_ASSOCIATE = 0;  
AUTH_COMMAND_DISASSOCIATE = 1;  
AUTH_COMMAND_AUTHENTICATE = 2;  
AUTH_COMMAND_UNAUTHENTICATE = 3;  


Multicast addressing MAX_MULTICAST_*
MAX_MULTICAST_ADDRESS = 8; Maximum number of addresses per adapter
 
MAX_PHYSICAL_PACKET = 2048; Large enough for all media types


Hardware addressing HARDWARE_ADDRESS_*
HARDWARE_ADDRESS_SIZE = 6; SizeOf(THardwareAddress)


Media type MEDIA_TYPE_*
MEDIA_TYPE_UNKNOWN = $0000;  
 
MEDIA_TYPE_ETHERNET = $0001; ARP type of Ethernet Hardware (This value must not change, it is the actual values used by ARP packets)
MEDIA_TYPE_TOKENRING = $0006; ARP type of Token-Ring Hardware (This value must not change, it is the actual values used by ARP packets)
MEDIA_TYPE_IEEE80211 = $1000;  
MEDIA_TYPE_LOOPBACK = $1001;  
MEDIA_TYPE_PPP = $1002;  
MEDIA_TYPE_SLIP = $1003;  


Packet type PACKET_TYPE_*
PACKET_MIN_TYPE = $0600; If the value Ethernet header TypeLength field is greater than this the frame is Ethernet II
 
PACKET_TYPE_IP = $0800;  
PACKET_TYPE_IP6 = $86DD;  
PACKET_TYPE_ARP = $0806;  
PACKET_TYPE_RARP = $8035;  
PACKET_TYPE_8021Q = $8100; 802.1Q with extended Ethernet header
PACKET_TYPE_IPX = $8137; IPX on EII
 
PACKET_TYPE_EAPOL = $888E; EAP-over-LAN (EAPOL)
PACKET_TYPE_RSN = $88C7; RSN pre-authentication
PACKET_TYPE_TDLS = $890D; Tunneled direct-link setup
 
PACKET_TYPE_RAW = $FFFF; IPX on 802.3
PACKET_TYPE_LLC = $0001; IPX on 802.2


Generic MII registers (Management Interface) MII_*
MII_BMCR = $00; Basic mode control register
MII_BMSR = $01; Basic mode status register
MII_PHYSID1 = $02; PHYS ID 1
MII_PHYSID2 = $03; PHYS ID 2
MII_ADVERTISE = $04; Advertisement control reg
MII_LPA = $05; Link partner ability reg
MII_EXPANSION = $06; Expansion register
MII_CTRL1000 = $09; 1000BASE-T control
MII_STAT1000 = $0a; 1000BASE-T status
MII_MMD_CTRL = $0d; MMD Access Control Register
MII_MMD_DATA = $0e; MMD Access Data Register
MII_ESTATUS = $0f; Extended Status
MII_DCOUNTER = $12; Disconnect counter
MII_FCSCOUNTER = $13; False carrier counter
MII_NWAYTEST = $14; N-way auto-neg test reg
MII_RERRCOUNTER = $15; Receive error counter
MII_SREVISION = $16; Silicon revision
MII_RESV1 = $17; Reserved...
MII_LBRERROR = $18; Lpback, rx, bypass error
MII_PHYADDR = $19; PHY address
MII_RESV2 = $1a; Reserved...
MII_TPISTATUS = $1b; TPI status for 10mbps
MII_NCONFIG = $1c; Network interface config


Basic mode control register BMCR_*
BMCR_RESV = $003f; Unused...
BMCR_SPEED1000 = $0040; MSB of Speed (1000)
BMCR_CTST = $0080; Collision test
BMCR_FULLDPLX = $0100; Full duplex
BMCR_ANRESTART = $0200; Auto negotiation restart
BMCR_ISOLATE = $0400; Isolate data paths from MII
BMCR_PDOWN = $0800; Enable low power state
BMCR_ANENABLE = $1000; Enable auto negotiation
BMCR_SPEED100 = $2000; Select 100Mbps
BMCR_LOOPBACK = $4000; TXD loopback bits
BMCR_RESET = $8000; Reset to default state


Basic mode status register BMSR_*
BMSR_ERCAP = $0001; Ext-reg capability
BMSR_JCD = $0002; Jabber detected
BMSR_LSTATUS = $0004; Link status
BMSR_ANEGCAPABLE = $0008; Able to do auto-negotiation
BMSR_RFAULT = $0010; Remote fault detected
BMSR_ANEGCOMPLETE = $0020; Auto-negotiation complete
BMSR_RESV = $00c0; Unused...
BMSR_ESTATEN = $0100; Extended Status in R15
BMSR_100HALF2 = $0200; Can do 100BASE-T2 HDX
BMSR_100FULL2 = $0400; Can do 100BASE-T2 FDX
BMSR_10HALF = $0800; Can do 10mbps, half-duplex
BMSR_10FULL = $1000; Can do 10mbps, full-duplex
BMSR_100HALF = $2000; Can do 100mbps, half-duplex
BMSR_100FULL = $4000; Can do 100mbps, full-duplex
BMSR_100BASE4 = $8000; Can do 100mbps, 4k packets


Advertisement control register ADVERTISE_*
ADVERTISE_SLCT = $001f; Selector bits
ADVERTISE_CSMA = $0001; Only selector supported
ADVERTISE_10HALF = $0020; Try for 10mbps half-duplex
ADVERTISE_1000XFULL = $0020; Try for 1000BASE-X full-duplex
ADVERTISE_10FULL = $0040; Try for 10mbps full-duplex
ADVERTISE_1000XHALF = $0040; Try for 1000BASE-X half-duplex
ADVERTISE_100HALF = $0080; Try for 100mbps half-duplex
ADVERTISE_1000XPAUSE = $0080; Try for 1000BASE-X pause
ADVERTISE_100FULL = $0100; Try for 100mbps full-duplex
ADVERTISE_1000XPSE_ASYM = $0100; Try for 1000BASE-X asym pause
ADVERTISE_100BASE4 = $0200; Try for 100mbps 4k packets
ADVERTISE_PAUSE_CAP = $0400; Try for pause
ADVERTISE_PAUSE_ASYM = $0800; Try for asymetric pause
ADVERTISE_RESV = $1000; Unused...
ADVERTISE_RFAULT = $2000; Say we can detect faults
ADVERTISE_LPACK = $4000; Ack link partners response
ADVERTISE_NPAGE = $8000; Next page bit
 
ADVERTISE_FULL = ADVERTISE_100FULL or ADVERTISE_10FULL or ADVERTISE_CSMA;  
ADVERTISE_ALL = ADVERTISE_10HALF or ADVERTISE_10FULL or ADVERTISE_100HALF or ADVERTISE_100FULL;  


Link partner ability register LPA_*
LPA_SLCT = $001f; Same as advertise selector
LPA_10HALF = $0020; Can do 10mbps half-duplex
LPA_1000XFULL = $0020; Can do 1000BASE-X full-duplex
LPA_10FULL = $0040; Can do 10mbps full-duplex
LPA_1000XHALF = $0040; Can do 1000BASE-X half-duplex
LPA_100HALF = $0080; Can do 100mbps half-duplex
LPA_1000XPAUSE = $0080; Can do 1000BASE-X pause
LPA_100FULL = $0100; Can do 100mbps full-duplex
LPA_1000XPAUSE_ASYM = $0100; Can do 1000BASE-X pause asym
LPA_100BASE4 = $0200; Can do 100mbps 4k packets
LPA_PAUSE_CAP = $0400; Can pause
LPA_PAUSE_ASYM = $0800; Can pause asymetrically
LPA_RESV = $1000; Unused...
LPA_RFAULT = $2000; Link partner faulted
LPA_LPACK = $4000; Link partner acked us
LPA_NPAGE = $8000; Next page bit
 
LPA_DUPLEX = LPA_10FULL or LPA_100FULL;  
LPA_100 = LPA_100FULL or LPA_100HALF or LPA_100BASE4;  


Expansion register for auto-negotiation EXPANSION_*
EXPANSION_NWAY = $0001; Can do N-way auto-nego
EXPANSION_LCWP = $0002; Got new RX page code word
EXPANSION_ENABLENPAGE = $0004; This enables npage words
EXPANSION_NPCAPABLE = $0008; Link partner supports npage
EXPANSION_MFAULTS = $0010; Multiple faults detected
EXPANSION_RESV = $ffe0; Unused...


Estatus register ESTATUS_*
ESTATUS_1000_TFULL = $2000; Can do 1000BT Full
ESTATUS_1000_THALF = $1000; Can do 1000BT Half


N-way test register NWAYTEST_*
NWAYTEST_RESV1 = $00ff; Unused...
NWAYTEST_LOOPBACK = $0100; Enable loopback for N-way
NWAYTEST_RESV2 = $fe00; Unused...


1000BASE-T control register *_1000*
ADVERTISE_1000FULL = $0200; Advertise 1000BASE-T full duplex
ADVERTISE_1000HALF = $0100; Advertise 1000BASE-T half duplex
CTL1000_AS_MASTER = $0800;  
CTL1000_ENABLE_MASTER = $1000;  


1000BASE-T Status register LPA_1000*
LPA_1000MSFAIL = $8000; Master/Slave resolution failure
LPA_1000LOCALRXOK = $2000; Link partner local receiver status
LPA_1000REMRXOK = $1000; Link partner remote receiver status
LPA_1000FULL = $0800; Link partner 1000BASE-T full duplex
LPA_1000HALF = $0400; Link partner 1000BASE-T half duplex


Flow control flags FLOW_CTRL_*
FLOW_CTRL_TX = $01;  
FLOW_CTRL_RX = $02;  


MMD access control register fields MII_MMD_CTRL_*
MII_MMD_CTRL_DEVAD_MASK = $1f; Mask MMD DEVAD
MII_MMD_CTRL_ADDR = $0000; Address
MII_MMD_CTRL_NOINCR = $4000; No post increment
MII_MMD_CTRL_INCR_RDWT = $8000; Post increment on reads & writes
MII_MMD_CTRL_INCR_ON_WT = $C000; Post increment on writes only


PHY link state PHY_LINK_*
PHY_LINK_DOWN = 0;  
PHY_LINK_UP = 1;  
 
PHY_LINK_UNKNOWN = -1;  


PHY interface mode PHY_INTERFACE_MODE_*
PHY_INTERFACE_MODE_NONE = 0;  
PHY_INTERFACE_MODE_INTERNAL = 1;  
PHY_INTERFACE_MODE_MII = 2;  
PHY_INTERFACE_MODE_GMII = 3;  
PHY_INTERFACE_MODE_SGMII = 4;  
PHY_INTERFACE_MODE_TBI = 5;  
PHY_INTERFACE_MODE_REVMII = 6;  
PHY_INTERFACE_MODE_RMII = 7;  
PHY_INTERFACE_MODE_RGMII = 8;  
PHY_INTERFACE_MODE_RGMII_ID = 9;  
PHY_INTERFACE_MODE_RGMII_RXID = 10;  
PHY_INTERFACE_MODE_RGMII_TXID = 11;  
PHY_INTERFACE_MODE_RTBI = 12;  
PHY_INTERFACE_MODE_SMII = 13;  
PHY_INTERFACE_MODE_XGMII = 14;  
PHY_INTERFACE_MODE_MOCA = 15;  
PHY_INTERFACE_MODE_QSGMII = 16;  
PHY_INTERFACE_MODE_TRGMII = 17;  
PHY_INTERFACE_MODE_1000BASEX = 18;  
PHY_INTERFACE_MODE_2500BASEX = 19;  
PHY_INTERFACE_MODE_RXAUI = 20;  
PHY_INTERFACE_MODE_XAUI = 21;  
PHY_INTERFACE_MODE_10GKR = 22; 10GBASE-KR, XFI, SFI - single lane 10G Serdes
PHY_INTERFACE_MODE_USXGMII = 23;  


PHY link speed PHY_SPEED_*
PHY_SPEED_10 = 10;  
PHY_SPEED_100 = 100;  
PHY_SPEED_1000 = 1000;  
 
PHY_SPEED_UNKNOWN = -1;  


PHY duplex mode PHY_DUPLEX_*
PHY_DUPLEX_HALF = 0;  
PHY_DUPLEX_FULL = 1;  
 
PHY_DUPLEX_UNKNOWN = -1;  


Service set SERVICE_SET_*
SERVICE_SET_UNKNOWN = 0;  
SERVICE_SET_BSS = 1; Basic Service Set
SERVICE_SET_ESS = 2; Extended Service Set
SERVICE_SET_IBSS = 3; Independent Basic Service Set
SERVICE_SET_MBSS = 4; Mesh Basic Service Set


Network logging NETWORK_LOG_*
NETWORK_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG; Network debugging messages
NETWORK_LOG_LEVEL_INFO = LOG_LEVEL_INFO; Network informational messages, such as a device being attached or detached
NETWORK_LOG_LEVEL_WARN = LOG_LEVEL_WARN; Network warning messages
NETWORK_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR; Network error messages
NETWORK_LOG_LEVEL_NONE = LOG_LEVEL_NONE; No Network messages


Ethernet specific constants ETHERNET_*
ETHERNET_ADDRESS_SIZE = 6; SizeOf(TEthernetAddress)
ETHERNET_HEADER_SIZE = 14; SizeOf(TEthernetHeader)
ETHERNET_VLAN_SIZE = 4; Length of Ethernet VLAN tag
ETHERNET_CRC_SIZE = 4; Length of Ethernet CRC (FCS)
 
ETHERNET_DEFAULT:THardwareAddress = ($00,$00,$00,$00,$00,$00);  
ETHERNET_LOOPBACK:THardwareAddress = ($00,$00,$00,$00,$00,$01);  
ETHERNET_BROADCAST:THardwareAddress = ($FF,$FF,$FF,$FF,$FF,$FF);  
ETHERNET_MULTICAST:THardwareAddress = ($01,$00,$5E,$00,$00,$00);  


Ethernet size ETHERNET_*_SIZE*
ETHERNET_MTU = 1500;  
ETHERNET_MIN_PAYLOAD = 46;  
ETHERNET_MIN_PACKET_SIZE = ETHERNET_HEADER_SIZE + ETHERNET_VLAN_SIZE + ETHERNET_MIN_PAYLOAD;  
ETHERNET_MAX_PACKET_SIZE = ETHERNET_HEADER_SIZE + ETHERNET_VLAN_SIZE + ETHERNET_MTU;  
 
ETHERNET_TRANSMIT_BUFFER_SIZE = ETHERNET_MAX_PACKET_SIZE;  


Ethernet 802.3 network LLC_HEADER_*
FRAME_TYPE_ETHERNET_8022
LLC_HEADER_SIZE = 3; SizeOf(TLLCHeader); Optionally can be 4 if Control is 2 octets


Ethernet SNAP network SNAP_HEADER_*
FRAME_TYPE_ETHERNET_SNAP
SNAP_HEADER_SIZE = 5; SizeOf(TSNAPHeader);


Type definitions



Hardware address

PHardwareAddress = ^THardwareAddress;

THardwareAddress = array[0..HARDWARE_ADDRESS_SIZE - 1] of Byte;

   

Hardware addresses

PHardwareAddresses = ^THardwareAddresses;

THardwareAddresses = array[0..0] of THardwareAddress;

   

Multicast address

PMulticastAddresses = ^TMulticastAddresses;

TMulticastAddresses = array[0..MAX_MULTICAST_ADDRESS - 1] of THardwareAddress;

   

Packet fragment

PPacketFragment = ^TPacketFragment;

TPacketFragment = packed record

Size:Integer;  
Data:Pointer;  
Next:PPacketFragment;  

Adapter statistics

PAdapterStatistics = ^TAdapterStatistics;

TAdapterStatistics = record

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

Network packet

PNetworkPacket = ^TNetworkPacket;

TNetworkPacket = record

Buffer:Pointer; Pointer to buffer (Set by driver that owns this packet)
Data:Pointer; Start of data within buffer (Set by driver that owns this packet)
Length:LongInt; Length of packet data (Set by driver on Receive/Set by caller on Transmit, contains maximum length on Allocate)
Flags:LongWord; Packet specific flags (eg Error, Broadcast etc) (Dependent on network type)

Network Buffer

PNetworkBuffer = ^TNetworkBuffer;

TNetworkBuffer = record

Wait:TSemaphoreHandle; Packet ready semaphore
Start:LongWord; Index of first packet ready
Count:LongWord; Number of packets ready in buffer
Packets:array[0..(NETWORK_BUFFER_SIZE - 1)] of PNetworkPacket;  

Network entry

PNetworkEntry = ^TNetworkEntry;

TNetworkEntry = record

Buffer:Pointer; Pointer to buffer (Allocated by driver that owns this entry)
Size:LongWord; Size of the buffer (Total size, usable size is Size minus Offset)
Offset:LongWord; Offset to start of data (Data for first packet will be at Buffer plus Offset, must be less than size)
Count:LongWord; Number of packets in the entry (Set by driver that owns this entry, must be at least one)
DriverData:Pointer; Driver private data (Managed by driver that owns this entry)
Packets:array of TNetworkPacket; {Array of 0 to Count - 1 packets in this entry Allocated by driver that owns this entry, must be at least one)

Network queue

PNetworkQueue = ^TNetworkQueue;

TNetworkQueue = record

Buffer:TBufferHandle; Handle for entry buffers
Wait:TSemaphoreHandle; Entry ready semaphore
Start:LongWord; Index of first entry ready
Count:LongWord; Number of entries ready in queue
Flags:LongWord; Queue specific flags (eg Paused, Halted etc) (Managed by driver)
Entries:array of PNetworkEntry; Array of 0 to Total - 1 entries in this queue (Allocated by driver that owns this queue)

Network statistics

PNetworkStatistics = ^TNetworkStatistics;

TNetworkStatistics = record

Note: Returned by NETWORK_CONTROL_GET_STATS)
ReceiveBytes:UInt64;  
ReceiveCount:UInt64;  
ReceiveErrors:UInt64;  
TransmitBytes:UInt64;  
TransmitCount:UInt64;  
TransmitErrors:UInt64;  
StatusCount:UInt64;  
StatusErrors:UInt64;  
BufferOverruns:UInt64;  
BufferUnavailable:UInt64;  

Network enumeration callback

TNetworkEnumerate = function(Network:PNetworkDevice; Data:Pointer):LongWord;

Network notification callback

TNetworkNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;

Network device open

TNetworkDeviceOpen = function(Network:PNetworkDevice):LongWord;

Network device close

TNetworkDeviceClose = function(Network:PNetworkDevice):LongWord;

Network device read

TNetworkDeviceRead = function(Network:PNetworkDevice; Buffer:Pointer; Size:LongWord; var Length:LongWord):LongWord;

Network device write

TNetworkDeviceWrite = function(Network:PNetworkDevice; Buffer:Pointer; Size:LongWord; var Length:LongWord):LongWord;

Network device control

TNetworkDeviceControl = function(Network:PNetworkDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;

Network buffer allocate

TNetworkBufferAllocate = function(Network:PNetworkDevice; var Entry:PNetworkEntry):LongWord;

Network buffer release

TNetworkBufferRelease = function(Network:PNetworkDevice; Entry:PNetworkEntry):LongWord;

Network buffer receive

TNetworkBufferReceive = function(Network:PNetworkDevice; var Entry:PNetworkEntry):LongWord;

Network buffer transmit

TNetworkBufferTransmit = function(Network:PNetworkDevice; Entry:PNetworkEntry):LongWord;

Network device

PNetworkDevice = ^TNetworkDevice;

TNetworkDevice = record

Device Properties
Device:TDevice; The Device entry for this Network
Network Properties
NetworkId:LongWord; Unique Id of this Network in the Network table
NetworkState:LongWord; Network state (eg NETWORK_STATE_OPEN)
NetworkStatus:LongWord; Network status (eg NETWORK_STATUS_UP)
DeviceOpen:TNetworkDeviceOpen; A Device specific DeviceOpen method implementing a standard Network device interface
DeviceClose:TNetworkDeviceClose; A Device specific DeviceClose method implementing a standard Network device interface
DeviceRead:TNetworkDeviceRead; A Device specific DeviceRead method implementing a standard Network device interface
DeviceWrite:TNetworkDeviceWrite; A Device specific DeviceWrite method implementing a standard Network device interface
DeviceControl:TNetworkDeviceControl; A Device specific DeviceControl method implementing a standard Network device interface
BufferAllocate:TNetworkBufferAllocate; A Device specific BufferAllocate method implementing a standard Network device interface
BufferRelease:TNetworkBufferRelease; A Device specific BufferRelease method implementing a standard Network device interface
BufferReceive:TNetworkBufferReceive; A Device specific BufferReceive method implementing a standard Network device interface
BufferTransmit:TNetworkBufferTransmit; A Device specific BufferTransmit method implementing a standard Network device interface
Driver Properties
Lock:TMutexHandle; Network lock
Buffer:TNetworkBuffer; Network receive buffer
TransmitWait:TSemaphoreHandle; Transmit complete semaphore
ReceiveBuffer:TBufferHandle; Buffer for receive packets
TransmitBuffer:TBufferHandle; Buffer for transmit packets
 
ReceiveQueue:TNetworkQueue; Queue for receive packets
TransmitQueue:TNetworkQueue; Queue for transmit packets (If applicable)
Statistics Properties
ReceiveBytes:UInt64;  
ReceiveCount:UInt64;  
ReceiveErrors:UInt64;  
TransmitBytes:UInt64;  
TransmitCount:UInt64;  
TransmitErrors:UInt64;  
StatusCount:UInt64;  
StatusErrors:UInt64;  
BufferOverruns:UInt64;  
BufferUnavailable:UInt64;  
Internal Properties
Prev:PNetworkDevice; Previous entry in Network table
Next:PNetworkDevice; Next entry in Network table

Network event callback

TNetworkEventCallback = function(Data:Pointer; Event:LongWord):LongWord;

Network Event

PNetworkEvent = ^TNetworkEvent;

TNetworkEvent = record

Event Properties
Signature:LongWord; Signature for entry validation
EventState:LongWord; Event state (eg Registered/Unregistered)
EventFlags:LongWord; Event flags (eg NETWORK_EVENT_FLAG_NONE)
Callback:TNetworkEventCallback; The callback for network events
Data:Pointer; A pointer to callback specific data to be passed with events (Optional)
Event:LongWord; The mask of events to notify on (eg NETWORK_EVENT_SYSTEM_START etc)
Internal Properties
Prev:PNetworkEvent; Previous entry in Event table
Next:PNetworkEvent; Next entry in Event table

Ethernet address

PEthernetAddress = ^TEthernetAddress;

TEthernetAddress = array[0..ETHERNET_ADDRESS_SIZE - 1] of Byte;

   

Ethernet header

PEthernetHeader = ^TEthernetHeader;

TEthernetHeader = packed record

DestAddress:THardwareAddress;  
SourceAddress:THardwareAddress;  
TypeLength:Word; Length or Type (IEEE 802.3 or BlueBook/DIX Ethernet)
Data:array[0..0] of Byte; Not part of header, included to provide a pointer to the start of data

Ethernet 802.3 network

PLLCHeader = ^TLLCHeader;

TLLCHeader = packed record

Note: FRAME_TYPE_ETHERNET_8022
DSAP:Byte;  
SSAP:Byte;  
Control:Byte;  
Information:array[0..0] of Byte; Optional (Control byte can be 1 or 2 octets)

Ethernet SNAP network

PSNAPHeader = ^TSNAPHeader;

TSNAPHeader = packed record

Note: FRAME_TYPE_ETHERNET_SNAP
OUI:array[0..2] of Byte;  
ProtocolID:Word;  
Data:array[0..0] of Byte; Not part of header, included to provide a pointer to the start of data

Adapter callback

TAdapterCallback = function(AAdapter:TNetworkAdapter):Boolean of object;

Adapter packet handler

TAdapterPacketHandler = function(AHandle:THandle; ASource,ADest,APacket:Pointer; ASize:Integer; ABroadcast:Boolean):Boolean of object;

Adapter monitor handler

TAdapterMonitorHandler = function(AHandle:THandle; APacket:Pointer; ASize:Integer; AStatus:Pointer):Boolean of object;

Adapter authenticator handler

TAdapterAuthenticatorHandler = function(AHandle:THandle; ACommand:Word):Boolean of object;


Class definitions



Network specific classes

TAdapterManager = class(TObject)
TAdapterTransport = class(TListObject)
TAdapterBinding = class(TListObject)
TAdapterMonitor = class(TListObject)
TAdapterAuthenticator = class(TListObject)
TNetworkList = class(TLinkedObjList)
TNetworkAdapter = class(TListObject)
TAdapterThread = class(TThread)
TAdapterBuffer = class(TObject)
TWiredAdapter = class(TNetworkAdapter)
TNetworkSetting = class(TListObject)
TNetworkSettings = class(TObject)
TServiceSet = class(TListObject)


Public variables



Network logging

NETWORK_DEFAULT_LOG_LEVEL:LongWord = NETWORK_LOG_LEVEL_DEBUG; Minimum level for Network messages. Only messages with level greater than or equal to this will be printed.
NETWORK_LOG_ENABLED:Boolean;

Network specific variables

AdapterManager:TAdapterManager;
NetworkSettings:TNetworkSettings;


Function declarations


Initialization functions

procedure NetworkInit;
Description: To be documented
Note To be documented


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


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


function NetworkStartCompleted:Boolean;
Description: To be documented
Return Returns True if the network sub system has been started


Network functions

function NetworkDeviceOpen(Network:PNetworkDevice):LongWord;
Description: To be documented
Note None documented


function NetworkDeviceClose(Network:PNetworkDevice):LongWord;
Description: To be documented
Note None documented


function NetworkDeviceRead(Network:PNetworkDevice; Buffer:Pointer; Size:LongWord; var Length:LongWord):LongWord;
Description: To be documented
Note None documented


function NetworkDeviceWrite(Network:PNetworkDevice; Buffer:Pointer; Size:LongWord; var Length:LongWord):LongWord;
Description: To be documented
Note None documented


function NetworkDeviceControl(Network:PNetworkDevice; Request:Integer; Argument1:PtrUInt; var Argument2:PtrUInt):LongWord;
Description: To be documented
Note None documented


function NetworkBufferAllocate(Network:PNetworkDevice; var Entry:PNetworkEntry):LongWord;
Description: Allocate a transmit buffer from the specified network device, the returned entry will include a buffer for writing data to as well as an offset value to allow the driver data to be written to the start of the buffer. When the data has been copied to the buffer, pass the entry to NetworkBufferTransmit.
Return ERROR_SUCCESS if completed or another error code on failure


function NetworkBufferRelease(Network:PNetworkDevice; Entry:PNetworkEntry):LongWord;
Description: Release a receive buffer to the specified network device, the entry must have been returned from NetworkBufferReceive
Return ERROR_SUCCESS if completed or another error code on failure


function NetworkBufferReceive(Network:PNetworkDevice; var Entry:PNetworkEntry):LongWord;
Description: Receive a completed receive buffer from the specified network device. The returned entry will contain a one or more packets of data to read from. When the data has been processed pass the returned buffer to NetworkBufferRelease.
Return ERROR_SUCCESS if completed or another error code on failure


function NetworkBufferTransmit(Network:PNetworkDevice; Entry:PNetworkEntry):LongWord;
Description: Transmit a completed transmit buffer to the specified network device. The entry must have been allocated using NetworkBufferAllocate.
Return ERROR_SUCCESS if completed or another error code on failure


function NetworkDeviceSetState(Network:PNetworkDevice; State:LongWord):LongWord;
Description: Set the state of the specified network and send a notification
Network The network to set the state for
State The new state to set and notify
Return ERROR_SUCCESS if completed or another error code on failure


function NetworkDeviceSetStatus(Network:PNetworkDevice; Status:LongWord):LongWord;
Description: Set the status of the specified network and send a notification
Network The network to set the status for
Status The new status to set and notify
Return ERROR_SUCCESS if completed or another error code on failure


function NetworkDeviceCreate:PNetworkDevice;
Description: Create a new Network entry
Return Pointer to new Network entry or nil if network could not be created


function NetworkDeviceCreateEx(Size:LongWord):PNetworkDevice;
Description: Create a new Network entry
Size Size in bytes to allocate for new network (Including the network entry)
Return Pointer to new Network entry or nil if network could not be created


function NetworkDeviceDestroy(Network:PNetworkDevice):LongWord;
Description: Destroy an existing Network entry
Note None documented


function NetworkDeviceRegister(Network:PNetworkDevice):LongWord;
Description: Register a new Network in the Network table
Note None documented


function NetworkDeviceDeregister(Network:PNetworkDevice):LongWord;
Description: Deregister a Network from the Network table
Note None documented


function NetworkDeviceFind(NetworkId:LongWord):PNetworkDevice;
Description: To be documented
Note None documented


function NetworkDeviceFindByName(const Name:String):PNetworkDevice; inline;
Description: To be documented
Note None documented


function NetworkDeviceFindByDescription(const Description:String):PNetworkDevice; inline;
Description: To be documented
Note None documented


function NetworkDeviceEnumerate(Callback:TNetworkEnumerate; Data:Pointer):LongWord;
Description: To be documented
Note None documented


function NetworkDeviceNotification(Network:PNetworkDevice; Callback:TNetworkNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented
Note None documented


function NetworkEventAllocate(Callback:TNetworkEventCallback; Data:Pointer; Event:LongWord):PNetworkEvent;
Description: Create and Register a new Event entry in the Event table
Note None documented


function NetworkEventRelease(Event:PNetworkEvent):LongWord;
Description: Deregister and Destroy an Event from the Event table
Note None documented


function NetworkEventRegister(Callback:TNetworkEventCallback; Data:Pointer; Event:LongWord):THandle;
Description: Register a callback for one or more network events
Note None documented


function NetworkEventDeregister(Handle:THandle):LongWord;
Description: Deregister a network event callback
Note None documented


function NetworkEventNotify(Event:LongWord):LongWord;
Description: To be documented
Note None documented


RTL network functions

function SysHostGetName:String;
Description: To be documented
Note None documented


function SysHostSetName(const AName:String):Boolean;
Description: To be documented
Note None documented


function SysHostGetDomain:String;
Description: To be documented
Note None documented


function SysHostSetDomain(const ADomain:String):Boolean;
Description: To be documented
Note None documented


Network helper functions

function NetworkGetLastError:LongInt;
Description: Get the last network error value for the current Thread
Return Last Network Error or ERROR_SUCCESS if no error


procedure NetworkSetLastError(Error:LongInt);
Description: Set the last network error value for the current Thread
Note None documented


function NetworkGetCount:LongWord;
Description: Get the current network count
Note None documented


function NetworkDeviceCheck(Network:PNetworkDevice):PNetworkDevice;
Description: Check if the supplied Network is in the network table
Note None documented


function NetworkDeviceTypeToString(NetworkType:LongWord):String;
Description: To be documented
Note None documented


function NetworkDeviceStateToString(NetworkState:LongWord):String;
Description: To be documented
Note None documented


function NetworkDeviceStatusToString(NetworkStatus:LongWord):String;
Description: To be documented
Note None documented


function NetworkDeviceStateToNotification(State:LongWord):LongWord;
Description: Convert a Network state value into the notification code for device notifications
Note None documented


function NetworkDeviceStatusToNotification(Status:LongWord):LongWord;
Description: Convert a Network status value into the notification code for device notifications
Note None documented


function NetworkEventCheck(Event:PNetworkEvent):PNetworkEvent;
Description: Check if the supplied Event is in the event table
Note None documented


procedure NetworkLog(Level:LongWord; Network:PNetworkDevice; const AText:String);
Description: To be documented
Note None documented


procedure NetworkLogInfo(Network:PNetworkDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure NetworkLogWarn(Network:PNetworkDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure NetworkLogError(Network:PNetworkDevice; const AText:String); inline;
Description: To be documented
Note None documented


procedure NetworkLogDebug(Network:PNetworkDevice; const AText:String); inline;
Description: To be documented
Note None documented


function HardwareAddressToString(const AAddress:THardwareAddress; const ASeparator: String = ''):String;
Description: To be documented
Note None documented


function StringToHardwareAddress(const AAddress:String):THardwareAddress;
Description: To be documented
Note None documented


function ValidHardwareAddress(const AAddress:THardwareAddress):Boolean;
Description: To be documented
Note None documented


function RandomHardwareAddress:THardwareAddress;
Description: To be documented
Note None documented


function CompareHardwareAddress(const AAddress1,AAddress2:THardwareAddress):Boolean;
Description: To be documented
Note None documented


function CompareHardwareDefault(const AAddress:THardwareAddress):Boolean;
Description: To be documented
Note None documented


function CompareHardwareBroadcast(const AAddress:THardwareAddress):Boolean;
Description: To be documented
Note None documented


function CompareHardwareMulticast(const AAddress:THardwareAddress):Boolean;
Description: To be documented
Note None documented


function AdapterTypeToString(AType:Word):String;
Description: To be documented
Note None documented


function AdapterModeToString(AMode:Word):String;
Description: To be documented
Note None documented


function AdapterConfigToString(AConfig:Word):String;
Description: To be documented
Note None documented


function AdapterStateToString(AState:Integer):String;
Description: To be documented
Note None documented


function AdapterStatusToString(AStatus:Integer):String;
Description: To be documented
Note None documented


function FrameTypeToString(AType:Word):String;
Description: To be documented
Note None documented


function MediaTypeToString(AType:Word):String;
Description: To be documented
Note None documented


function PacketTypeToString(AType:Word):String;
Description: To be documented
Note None documented


function ConfigTypeToString(AType:Word):String;
Description: To be documented
Note None documented


function ConfigCommandToString(ACommand:Word):String;
Description: To be documented
Note None documented


function AuthTypeToString(AType:Word):String;
Description: To be documented
Note None documented


function AuthCommandToString(ACommand:Word):String;
Description: To be documented
Note None documented


Return to Unit Reference