Difference between revisions of "Unit Services"

From Ultibo.org
Jump to: navigation, search
Line 1,449: Line 1,449:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,464: Line 1,464:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,479: Line 1,479:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,491: Line 1,491:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,503: Line 1,503:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,515: Line 1,515:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,527: Line 1,527:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,539: Line 1,539:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,554: Line 1,554:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,566: Line 1,566:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,578: Line 1,578:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,590: Line 1,590:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,602: Line 1,602:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,616: Line 1,616:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,628: Line 1,628:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,640: Line 1,640:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Expects Timestamp to be in Host order
 
| Expects Timestamp to be in Host order
 
|-
 
|-
Line 1,652: Line 1,652:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Expects Timestamp to be in Host order
 
| Expects Timestamp to be in Host order
 
|-
 
|-
Line 1,664: Line 1,664:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Returns Timestamp in Host order
 
| Returns Timestamp in Host order
 
|-
 
|-
Line 1,676: Line 1,676:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Expects Timestamp to be in Host order
 
| Expects Timestamp to be in Host order
 
|-
 
|-
Line 1,691: Line 1,691:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,703: Line 1,703:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,715: Line 1,715:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,730: Line 1,730:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,742: Line 1,742:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 1,754: Line 1,754:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-

Revision as of 01:43, 24 April 2018

Return to Unit Reference


Description


Ultibo Services interface unit

To be documented

Constants



NTP specific constants NTP_*
NTP_VERSION_1 = 1;  
NTP_VERSION_2 = 2;  
NTP_VERSION_3 = 3;  
NTP_VERSION_4 = 4;  
 
NTP_VERSION_MASK = $07; shl 3
 
NTP_VERSION = NTP_VERSION_4; Current NTP/SNTP version
NTP_MIN_VERSION = NTP_VERSION_2; Minimum acceptable NTP/SNTP version
NTP_MAX_VERSION = NTP_VERSION_4; Maximum acceptable NTP/SNTP version
 
NTP_PACKET_SIZE = 48; SizeOf(TNTPPacket)
 
NTP_TIMESTAMP_START = 94354848000000000; Offset between 1/1/1601 (Ultibo) and 1/1/1900 (NTP Timestamp)


NTP leap indicator NTP_LEAP_*
NTP_LEAP_NONE = 0;  
NTP_LEAP_LAST_61 = 1;  
NTP_LEAP_LAST_59 = 2;  
NTP_LEAP_ALARM = 3;  
 
NTP_LEAP_MASK = $03; shl 6


NTP mode NTP_MODE_*
NTP_MODE_RESERVED = 0; Reserved
NTP_MODE_SYMMETRIC_ACTIVE = 1; Symmetric active
NTP_MODE_SYMMETRIC_PASSIVE = 2; Symmetric passive
NTP_MODE_CLIENT = 3; Client
NTP_MODE_SERVER = 4; Server
NTP_MODE_BROADCAST = 5; Broadcast
NTP_MODE_CONTROL = 6; Reserved for NTP control message
NTP_MODE_PRIVATE = 7; Reserved for private use
 
NTP_MODE_MASK = $07; shl 0


NTP stratum NTP_STRATUM_*
NTP_STRATUM_INVALID = 0; unspecified or invalid
NTP_STRATUM_PRIMARY = 1; primary server (e.g., equipped with a GPS receiver)
NTP_STRATUM_SECONDARY2 = 2; secondary server (via NTP)
NTP_STRATUM_SECONDARY3 = 3; secondary server (via NTP)
NTP_STRATUM_SECONDARY4 = 4; secondary server (via NTP)
NTP_STRATUM_SECONDARY5 = 5; secondary server (via NTP)
NTP_STRATUM_SECONDARY6 = 6; secondary server (via NTP)
NTP_STRATUM_SECONDARY7 = 7; secondary server (via NTP)
NTP_STRATUM_SECONDARY8 = 8; secondary server (via NTP)
NTP_STRATUM_SECONDARY9 = 9; secondary server (via NTP)
NTP_STRATUM_SECONDARY10 = 10; secondary server (via NTP)
NTP_STRATUM_SECONDARY11 = 11; secondary server (via NTP)
NTP_STRATUM_SECONDARY12 = 12; secondary server (via NTP)
NTP_STRATUM_SECONDARY13 = 13; secondary server (via NTP)
NTP_STRATUM_SECONDARY14 = 14; secondary server (via NTP)
NTP_STRATUM_SECONDARY15 = 15; secondary server (via NTP)
NTP_STRATUM_UNSYNCRONIZED = 16; unsynchronized
NTP_STRATUM_RESERVED = 17; reserved


Telnet character TELNET_CHAR_*
TELNET_CHAR_NUL = #0;  
TELNET_CHAR_CR = #13;  
TELNET_CHAR_LF = #10;  
TELNET_CHAR_BELL = #7;  
TELNET_CHAR_TAB = #9;  
TELNET_CHAR_ESC = #27;  
TELNET_CHAR_BACKSPACE = #127;  
 
TELNET_BUFFER_SIZE = SIZE_2K;  


Telnet escape sequence TELNET_SEQUENCE_*
TELNET_SEQUENCE_UP_ARROW = #27#91#65; ESC[A
TELNET_SEQUENCE_DOWN_ARROW = #27#91#66; ESC[B
TELNET_SEQUENCE_RIGHT_ARROW = #27#91#67; ESC[C
TELNET_SEQUENCE_LEFT_ARROW = #27#91#68; ESC[D
 
TELNET_SEQUENCE_HOME = #27#91#49#126; ESC[1~
TELNET_SEQUENCE_INSERT = #27#91#50#126; ESC[2~
TELNET_SEQUENCE_DELETE = #27#91#51#126; ESC[3~
TELNET_SEQUENCE_END = #27#91#52#126; ESC[4~
TELNET_SEQUENCE_PGUP = #27#91#53#126; ESC[5~
TELNET_SEQUENCE_PGDN = #27#91#54#126; ESC[6~
 
TELNET_SEQUENCE_F1 = #27#91#49#49#126; ESC[11~
TELNET_SEQUENCE_F2 = #27#91#49#50#126; ESC[12~
TELNET_SEQUENCE_F3 = #27#91#49#51#126; ESC[13~
TELNET_SEQUENCE_F4 = #27#91#49#52#126; ESC[14~
TELNET_SEQUENCE_F5 = #27#91#49#53#126; ESC[15~
TELNET_SEQUENCE_F6 = #27#91#49#55#126; ESC[17~
TELNET_SEQUENCE_F7 = #27#91#49#56#126; ESC[18~
TELNET_SEQUENCE_F8 = #27#91#49#57#126; ESC[19~
TELNET_SEQUENCE_F9 = #27#91#50#48#126; ESC[20~
TELNET_SEQUENCE_F10 = #27#91#50#49#126; ESC[21~


Telnet buffer TELNET_BUFFER_*
TELNET_BUFFER_SIZE = SIZE_2K;  


Telnet state TELNET_STATE_*
TELNET_STATE_NONE = $00000000;  
TELNET_STATE_TRANSMIT_BINARY = $00000001;  
TELNET_STATE_ECHO = $00000002;  
TELNET_STATE_SUPPRESS_GA = $00000004;  
TELNET_STATE_TERMINAL_TYPE = $00000008;  
TELNET_STATE_WINDOW_SIZE = $00000010;  
TELNET_STATE_TERMINAL_SPEED = $00000020;  
TELNET_STATE_NEW_ENVIRONMENT = $00000040;  


Telnet command TELNET_COMMAND_*
TELNET_COMMAND_EOR = 239; 0xEF end of record command
TELNET_COMMAND_SE = 240; 0xF0 end of subnegotiations command
TELNET_COMMAND_NOP = 241; 0xF1 no operation command
TELNET_COMMAND_DM = 242; 0xF2 data mark command
TELNET_COMMAND_BRK = 243; 0xF3 break NVT charater
TELNET_COMMAND_IP = 244; 0xF4 interrupt process command
TELNET_COMMAND_AO = 245; 0xF5 abort output command
TELNET_COMMAND_AYT = 246; 0xF6 are you there command
TELNET_COMMAND_EC = 247; 0xF7 erase character command
TELNET_COMMAND_EL = 248; 0xF8 erase line command
TELNET_COMMAND_GA = 249; 0xF9 go ahead command
TELNET_COMMAND_SB = 250; 0xFA begin option subnegotiations command
TELNET_COMMAND_WILL = 251; 0xFB will enable option
TELNET_COMMAND_WONT = 252; 0xFC won't enable option
TELNET_COMMAND_DO = 253; 0xFD request other party enables option
TELNET_COMMAND_DONT = 254; 0xFE request other party doesn't enable option
TELNET_COMMAND_IAC = 255; 0xFF interpret as command


Telnet option TELNET_OPTION_*
TELNET_OPTION_TRANSMIT_BINARY = 0; 0x00 transmit binary option
TELNET_OPTION_ECHO = 1; 0x01 echo option
TELNET_OPTION_SUPPRESS_GA = 3; 0x03 suppress go ahead option
TELNET_OPTION_TERMINAL_TYPE = 24; 0x18 terminal type
TELNET_OPTION_WINDOW_SIZE = 31; 0x1F negotiate window size
TELNET_OPTION_TERMINAL_SPEED = 32; 0x20 terminal speed
TELNET_OPTION_NEW_ENVIRONMENT = 39; 0x27 new environment


SysLog logging SYSLOG_LOGGING_*
SYSLOG_LOGGING_DESCRIPTION = 'SysLog Logging';  


SysLog facility code SYSLOG_FACILITY_*
SYSLOG_FACILITY_KERNEL = 0; kernel messages
SYSLOG_FACILITY_USER = 1; user-level messages
SYSLOG_FACILITY_MAIL = 2; mail system
SYSLOG_FACILITY_SYSTEM = 3; system daemons
SYSLOG_FACILITY_SECURITY = 4; security/authorization messages (note 1)
SYSLOG_FACILITY_SYSLOG = 5; messages generated internally by syslogd
SYSLOG_FACILITY_PRINTER = 6; line printer subsystem
SYSLOG_FACILITY_NEWS = 7; network news subsystem
SYSLOG_FACILITY_UUCP = 8; UUCP subsystem
SYSLOG_FACILITY_CLOCK = 9; clock daemon (note 2)
SYSLOG_FACILITY_AUTH = 10; security/authorization messages (note 1)
SYSLOG_FACILITY_FTP = 11; FTP daemon
SYSLOG_FACILITY_NTP = 12; NTP subsystem
SYSLOG_FACILITY_AUDIT = 13; log audit (note 1)
SYSLOG_FACILITY_ALERT = 14; log alert (note 1)
SYSLOG_FACILITY_CLOCK2 = 15; clock daemon (note 2)
SYSLOG_FACILITY_LOCAL0 = 16; local use 0 (local0)
SYSLOG_FACILITY_LOCAL1 = 17; local use 1 (local1)
SYSLOG_FACILITY_LOCAL2 = 18; local use 2 (local2)
SYSLOG_FACILITY_LOCAL3 = 19; local use 3 (local3)
SYSLOG_FACILITY_LOCAL4 = 20; local use 4 (local4)
SYSLOG_FACILITY_LOCAL5 = 21; local use 5 (local5)
SYSLOG_FACILITY_LOCAL6 = 22; local use 6 (local6)
SYSLOG_FACILITY_LOCAL7 = 23; local use 7 (local7)


SysLog severity code SYSLOG_SEVERITY_*
SYSLOG_SEVERITY_EMERGENCY = 0; Emergency: system is unusable
SYSLOG_SEVERITY_ALERT = 1; Alert: action must be taken immediately
SYSLOG_SEVERITY_CRITICAL = 2; Critical: critical conditions
SYSLOG_SEVERITY_ERROR = 3; Error: error conditions
SYSLOG_SEVERITY_WARNING = 4; Warning: warning conditions
SYSLOG_SEVERITY_NOTICE = 5; Notice: normal but significant condition
SYSLOG_SEVERITY_INFORMATION = 6; Informational: informational messages
SYSLOG_SEVERITY_DEBUG = 7; Debug: debug-level messages


Service logging SERVICE_LOG_*
SERVICE_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG; Service debugging messages
SERVICE_LOG_LEVEL_INFO = LOG_LEVEL_INFO; Service informational messages, such as a service being created or destroyed
SERVICE_LOG_LEVEL_WARN = LOG_LEVEL_WARN; Service warning messages
SERVICE_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR; Service error messages
SERVICE_LOG_LEVEL_NONE = LOG_LEVEL_NONE; No Service messages


Type definitions



NTP short

PNTPShort = ^TNTPShort;

TNTPShort = packed record

Note: NTP Short Format
Seconds:Word; Seconds
Fraction:Word; Fraction

NTP timestamp

PNTPTimestamp = ^TNTPTimestamp;

TNTPTimestamp = packed record

Note: NTP Timestamp Format
Seconds:LongWord; Seconds
Fraction:LongWord; Seconds Fraction (0-padded)

NTP date format

PNTPDate = ^TNTPDate;

TNTPDate = packed record

EraNumber:LongWord; Era Number
EraOffset:LongWord; Era Offset
Fraction:Int64; Fraction

NTP packet

PNTPPacket = ^TNTPPacket;

TNTPPacket = packed record

LeapVersionMode:Byte; Leap Indicator (2 bits)/Version (3 bits)/Mode (3 bits)
Stratum:Byte; This is an eight-bit unsigned integer indicating the stratum
PollInterval:Byte; This is an eight-bit unsigned integer used as an exponent of two, where the resulting value is the maximum interval between successive messages in seconds.
Precision:ShortInt; This is an eight-bit signed integer used as an exponent of two, where the resulting value is the precision of the system clock in seconds.
RootDelay:LongInt; This is a 32-bit signed fixed-point number indicating the total roundtrip delay to the primary reference source, in seconds with the fraction point between bits 15 and 16.
RootDispersion:LongWord; This is a 32-bit unsigned fixed-point number indicating the maximum error due to the clock frequency tolerance, in seconds with the fraction point between bits 15 and 16.
ReferenceIdentifier:array[0..3] of Byte; This is a 32-bit bitstring identifying the particular reference source
ReferenceTimestamp:TNTPTimestamp; This field is the time the system clock was last set or corrected, in 64-bit timestamp format.
OriginateTimestamp:TNTPTimestamp; This is the time at which the request departed the client for the server, in 64-bit timestamp format.
ReceiveTimestamp:TNTPTimestamp; This is the time at which the request arrived at the server or the reply arrived at the client, in 64-bit timestamp format.
TransmitTimestamp:TNTPTimestamp; This is the time at which the request departed the client or the reply departed the server, in 64-bit timestamp format.
KeyIdentifier:LongWord; Optional for NTP authentication
MessageDigest:array[0..15] of Byte; Optional for NTP authentication

Syslog logging

PSyslogLogging = ^TSyslogLogging;

TSyslogLogging = record

Logging Properties
Logging:TLoggingDevice;  
Syslog Properties
Client:TSyslogClient;  

Telnet host event

TTelnetHostEvent = function(AConnection:TTelnetConnection):Boolean of Object;

Telnet count event

TTelnetCountEvent = function(AConnection:TTelnetConnection):Boolean of Object;

Telnet initialize event

TTelnetInitEvent = function(AConnection:TTelnetConnection):Boolean of Object;

Telnet character event

TTelnetCharEvent = function(AConnection:TTelnetConnection; AChar:Char):Boolean of Object;

Telnet command event

TTelnetCommandEvent = function(AConnection:TTelnetConnection; ACommand,AOption:Byte; AData:Pointer; ASize:LongWord):Boolean of Object;

Telnet connection event

TTelnetConnectionEvent = procedure(AConnection:TTelnetConnection) of Object;


Class definitions



Ping client

TPingClient = class(TWinsock2RAWClient)

private
 
public
 

NTP client

TNTPClient = class(TWinsock2UDPClient)

public
constructor Create;  
destructor Destroy; override;  
private
FLock:TMutexHandle;  
 
FPollInterval:LongWord; How often to poll the server (in seconds)
FPollTimeout:LongWord; How long before receive or send timeout occurs (in milliseconds)
FPollRetries:LongWord; How many times to retry a poll
 
FRetryTimeout:LongWord; How long to wait between poll retries (in milliseconds)
 
FInitialClockGet:Boolean; Has the time been obtained at least once
FInitialClockCount:LongWord; How many times have we tried to obtain the initial clock
 
FTimerHandle:TTimerHandle; Handle for the NTP update timer
 
function AcquireLock:Boolean;  
function ReleaseLock:Boolean;  
 
procedure SetPollInterval(APollInterval:LongWord);  
procedure SetPollTimeout(APollTimeout:LongWord);  
procedure SetPollRetries(APollRetries:LongWord);  
 
procedure SetRetryTimeout(ARetryTimeout:LongWord);  
 
procedure SetInitialClockGet(AInitialClockGet:Boolean);  
procedure SetInitialClockCount(AInitialClockCount:LongWord);  
 
procedure SetTimerHandle(ATimerHandle:TTimerHandle);  
public
property PollInterval:LongWord read FPollInterval write SetPollInterval;  
property PollTimeout:LongWord read FPollTimeout write SetPollTimeout;  
property PollRetries:LongWord read FPollRetries write SetPollRetries;  
 
property RetryTimeout:LongWord read FRetryTimeout write SetRetryTimeout;  
 
property InitialClockGet:Boolean read FInitialClockGet write SetInitialClockGet;  
property InitialClockCount:LongWord read FInitialClockCount write SetInitialClockCount;  
 
property TimerHandle:TTimerHandle read FTimerHandle write SetTimerHandle;  
 
function GetTime:Int64;  
 
procedure IncrementInitialClockCount;  

Telnet buffer

TTelnetBuffer = class(TObject)

public
constructor Create(ASize:LongWord);  
destructor Destroy; override;  
private
FLock:TCriticalSectionHandle;  
 
FData:Pointer;  
FSize:LongWord;  
FCount:LongWord;  
FStart:LongWord;  
 
function AcquireLock:Boolean;  
function ReleaseLock:Boolean;  
 
function GetCount:LongWord;  
public
property Count:LongWord read GetCount;  
 
function ReadData:Char;  
function WriteData(AChar:Char):Boolean;  
 
function WriteLock(var ASize:LongWord):Pointer;  
function WriteUnlock(ACount:LongWord):Boolean;  

Telnet connection

TTelnetConnection = class(TListObject)

public
constructor Create;  
destructor Destroy; override;  
private
FLock:TCriticalSectionHandle;  
 
FHandle:LongWord;  
FRxByteCount:Int64; Bytes Recv Count from Connection
FTxByteCount:Int64; Bytes Sent Count to Connection
FRequestCount:Int64; Requests Recv Count from Connection
FResponseCount:Int64; Responses Sent Count to Connection
FRequestTime:TDateTime; Last Request Time
FResponseTime:TDateTime; Last Response Time
FRemoteAddress:String; Address of Remote Client
FLocalState:LongWord; Local connection state (eg TELNET_STATE_ECHO)
FRemoteState:LongWord; Remote connection state (eg TELNET_STATE_ECHO)
 
FData:Pointer; Private data for application
FThread:TThread; TWinsock2TCPServerThread
FBuffer:TTelnetBuffer; Buffer for received data
FListener:TTelnetListener; Listener for Connection
 
function AcquireLock:Boolean;  
function ReleaseLock:Boolean;  
 
procedure SetHandle(AHandle:LongWord);  
function GetRxByteCount:Int64;  
procedure SetRxByteCount(const ARxByteCount:Int64);  
function GetTxByteCount:Int64;  
procedure SetTxByteCount(const ATxByteCount:Int64);  
function GetRequestCount:Int64;  
procedure SetRequestCount(const ARequestCount:Int64);  
function GetResponseCount:Int64;  
procedure SetResponseCount(const AResponseCount:Int64);  
function GetRequestTime:TDateTime;  
procedure SetRequestTime(const ARequestTime:TDateTime);  
function GetResponseTime:TDateTime;  
procedure SetResponseTime(const AResponseTime:TDateTime);  
function GetRemoteAddress:String;  
procedure SetRemoteAddress(const ARemoteAddress:String);  
procedure SetLocalState(ALocalState:LongWord);  
procedure SetRemoteState(ARemoteState:LongWord);  
 
procedure SetData(AData:Pointer);  
procedure SetThread(AThread:TThread);  
procedure SetListener(AListener:TTelnetListener);  
public
property Handle:LongWord read FHandle write SetHandle;  
property RxByteCount:Int64 read GetRxByteCount write SetRxByteCount;  
property TxByteCount:Int64 read GetTxByteCount write SetTxByteCount;  
property RequestCount:Int64 read GetRequestCount write SetRequestCount;  
property ResponseCount:Int64 read GetResponseCount write SetResponseCount;  
property RequestTime:TDateTime read GetRequestTime write SetRequestTime;  
property ResponseTime:TDateTime read GetResponseTime write SetResponseTime;  
property RemoteAddress:String read GetRemoteAddress write SetRemoteAddress;  
property LocalState:LongWord read FLocalState write SetLocalState;  
property RemoteState:LongWord read FRemoteState write SetRemoteState;  
 
property Data:Pointer read FData write SetData;  
property Thread:TThread read FThread write SetThread;  
property Buffer:TTelnetBuffer read FBuffer;  
property Listener:TTelnetListener read FListener write SetListener;  
 
procedure IncrementRxByteCount(const ARxByteCount:Int64);  
procedure IncrementTxByteCount(const ATxByteCount:Int64);  
procedure IncrementRequestCount;  
procedure IncrementResponseCount;  

Telnet listener

TTelnetListener = class(TWinsock2TCPListener)

public
constructor Create;  
private
FOnConnected:TTelnetConnectionEvent;  
FOnDisconnected:TTelnetConnectionEvent;  
 
FOnCheckHost:TTelnetHostEvent;  
FOnCheckCount:TTelnetCountEvent;  
 
FOnInit:TTelnetInitEvent;  
FOnChar:TTelnetCharEvent;  
FOnCommand:TTelnetCommandEvent;  
protected
procedure DoConnect(AThread:TWinsock2TCPServerThread); override;  
procedure DoDisconnect(AThread:TWinsock2TCPServerThread); override;  
 
function DoCheckHost(AThread:TWinsock2TCPServerThread):Boolean; virtual;  
function DoCheckCount(AThread:TWinsock2TCPServerThread):Boolean; virtual;  
 
function DoExecute(AThread:TWinsock2TCPServerThread):Boolean; override;  
 
procedure DoInit(AThread:TWinsock2TCPServerThread);  
procedure DoChar(AThread:TWinsock2TCPServerThread; AChar:Char);  
procedure DoCommand(AThread:TWinsock2TCPServerThread; ACommand,AOption:Byte; AData:Pointer; ASize:LongWord);  
 
function SendEcho(AThread:TWinsock2TCPServerThread; AChar:Char):Boolean;  
public
property OnConnected:TTelnetConnectionEvent read FOnConnected write FOnConnected;  
property OnDisconnected:TTelnetConnectionEvent read FOnDisconnected write FOnDisconnected;  
 
property OnCheckHost:TTelnetHostEvent read FOnCheckHost write FOnCheckHost;  
property OnCheckCount:TTelnetCountEvent read FOnCheckCount write FOnCheckCount;  
 
property OnInit:TTelnetInitEvent read FOnInit write FOnInit;  
property OnChar:TTelnetCharEvent read FOnChar write FOnChar;  
property OnCommand:TTelnetCommandEvent read FOnCommand write FOnCommand;  
 
function GetChar(AThread:TWinsock2TCPServerThread; var AChar:Char):Boolean;  
 
function SendChar(AThread:TWinsock2TCPServerThread; AChar:Char):Boolean;  
function SendText(AThread:TWinsock2TCPServerThread; const AText:String):Boolean;  
function SendCommand(AThread:TWinsock2TCPServerThread; ACommand,AOption:Byte; AData:Pointer; ASize:LongWord):Boolean;  

SysLog client

TSyslogClient = class(TObject)

public
constructor Create;  
destructor Destroy; override;  
private
FLock:TMutexHandle;  
 
FProtocol:LongWord;  
FBoundPort:Word;  
FRemoteHost:String;  
FRemotePort:Word;  
FOctetCounting:Boolean;  
 
FUDPClient:TWinsock2UDPClient;  
FTCPClient:TWinsock2TCPClient;  
 
function AcquireLock:Boolean;  
function ReleaseLock:Boolean;  
 
procedure SetProtocol(AProtocol:LongWord);  
procedure SetBoundPort(ABoundPort:Word);  
function GetRemoteHost:String;  
procedure SetRemoteHost(const ARemoteHost:String);  
procedure SetRemotePort(ARemotePort:Word);  
procedure SetOctetCounting(AOctetCounting:Boolean);  
protected
function GetPriority(AFacility,ASeverity:LongWord):String;  
function GetMessage(const APriority,AAddress,ATag,AContent:String):String;  
public
property Protocol:LongWord read FProtocol write SetProtocol;  
property BoundPort:Word read FBoundPort write SetBoundPort;  
property RemoteHost:String read GetRemoteHost write SetRemoteHost;  
property RemotePort:Word read FRemotePort write SetRemotePort;  
property OctetCounting:Boolean read FOctetCounting write SetOctetCounting;  
 
function SendMessage(AFacility,ASeverity:LongWord; const ATag,AContent:String):LongWord;  


Public variables



Service logging

SERVICE_DEFAULT_LOG_LEVEL:LongWord = SERVICE_LOG_LEVEL_DEBUG; Minimum level for Service messages. Only messages with level greater than or equal to this will be printed.
SERVICE_LOG_ENABLED:Boolean;


Function declarations



Initialization functions

procedure ServicesInit;
Description: To be documented
Note None documented


NTP functions

procedure NTPUpdateTime(Client:TNTPClient);
Description: To be documented
Note None documented


SysLog functions

function SysLogLoggingStart(Logging:PLoggingDevice):LongWord;
Description: To be documented
Note None documented


function SysLogLoggingStop(Logging:PLoggingDevice):LongWord;
Description: To be documented
Note None documented


function SysLogLoggingOutput(Logging:PLoggingDevice; const Data:String):LongWord;
Description: To be documented
Note None documented


function SysLogLoggingOutputEx(Logging:PLoggingDevice; Facility,Severity:LongWord; const Tag,Content:String):LongWord;
Description: To be documented
Note None documented


function SysLogLoggingGetTarget(Logging:PLoggingDevice):String;
Description: To be documented
Note None documented


function SysLogLoggingSetTarget(Logging:PLoggingDevice; const Target:String):LongWord;
Description: To be documented
Note None documented


Service helper functions

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


procedure ServiceLogInfo(const AText:String); inline;
Description: To be documented
Note None documented


procedure ServiceLogWarn(const AText:String); inline;
Description: To be documented
Note None documented


procedure ServiceLogError(const AText:String); inline;
Description: To be documented
Note None documented


procedure ServiceLogDebug(const AText:String); inline;
Description: To be documented
Note None documented


NTP helper functions

function NTPTimestampToHost(const Timestamp:TNTPTimestamp):TNTPTimestamp;
Description: Convert an NTP Timestamp to Host order
Note None documented


function NTPTimestampToNetwork(const Timestamp:TNTPTimestamp):TNTPTimestamp;
Description: Convert an NTP Timestamp to Network order
Note None documented


function NTPTimestampAdd(const Timestamp1,Timestamp2:TNTPTimestamp):TNTPTimestamp;
Description: To be documented
Note Expects Timestamp to be in Host order


function NTPTimestampSubtract(const Timestamp1,Timestamp2:TNTPTimestamp):TNTPTimestamp;
Description: To be documented
Note Expects Timestamp to be in Host order


function ClockTimeToNTPTimestamp(const Time:Int64):TNTPTimestamp;
Description: To be documented
Note Returns Timestamp in Host order


function NTPTimestampToClockTime(const Timestamp:TNTPTimestamp):Int64;
Description: To be documented
Note Expects Timestamp to be in Host order


Telnet helper functions

function TelnetCommandToString(Command:Byte):String;
Description: To be documented
Note None documented


function TelnetCommandHasOption(Command:Byte):Boolean;
Description: To be documented
Note None documented


function TelnetOptionToString(Option:Byte):String;
Description: To be documented
Note None documented


SysLog helper functions

function FileTimeToSysLogDateTime(const AFileTime:TFileTime):String;
Description: To be documented
Note None documented


function LoggingFacilityToSysLogFacility(Facility:LongWord):LongWord;
Description: To be documented
Note None documented


function LoggingSeverityToSysLogSeverity(Severity:LongWord):LongWord;
Description: To be documented
Note None documented


Return to Unit Reference