CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::TelnetLine Class Reference

One line of Telnet-style text traffic. More...

#include <NetworkProtocols.h>

Public Member Functions

 TelnetLine (uint64 source)
 Construct an empty line.
virtual ~TelnetLine ()
bool setLine (const char *buffer, bool addCR)
 Set the line text from a NUL-terminated string.
bool setLine (const char *buffer, uint32 len, bool addCR=false)
 Set the line text from a length-delimited buffer.
bool giveData (char *buffer, uint32 len)
 Take ownership of an existing buffer as the line text (no copy).
uint32 getSize ()
bool setCR (uint8 type)
 Select the line-ending convention.

Public Attributes

char * data
 Owned line text.
char cr [3]
 Active line-ending characters (\r\n or \n, NUL-terminated).
uint64 time
 Timestamp of creation/receipt (ms epoch).
uint64 source
 Packed uint64 endpoint of the sender.
uint32 size
 Line length in bytes.
uint32 user
 Optional user/session tag for multi-user telnet servers.

Detailed Description

One line of Telnet-style text traffic.

The unit of exchange for the PROTOCOL_TELNET protocol — a plain text line plus its line-ending convention, timestamp and source endpoint. Used for interactive console/diagnostic connections.

Definition at line 591 of file NetworkProtocols.h.

Constructor & Destructor Documentation

◆ TelnetLine()

cmlabs::TelnetLine::TelnetLine ( uint64 source)

Construct an empty line.

Parameters
sourcePacked uint64 endpoint of the sender.

Definition at line 1320 of file NetworkProtocols.cpp.

References cr, data, cmlabs::GetTimeNow(), size, source, time, and user.

◆ ~TelnetLine()

cmlabs::TelnetLine::~TelnetLine ( )
virtual

Definition at line 1332 of file NetworkProtocols.cpp.

References data.

Member Function Documentation

◆ getSize()

uint32 cmlabs::TelnetLine::getSize ( )
Returns
The line size in bytes (excluding terminator).

Definition at line 1354 of file NetworkProtocols.cpp.

References data, and size.

Referenced by cmlabs::TelnetProtocol::SendTelnetLine().

◆ giveData()

bool cmlabs::TelnetLine::giveData ( char * buffer,
uint32 len )

Take ownership of an existing buffer as the line text (no copy).

Parameters
bufferHeap buffer this object will delete[].
lenByte count.
Returns
true on success.

Definition at line 1384 of file NetworkProtocols.cpp.

References data, and size.

◆ setCR()

bool cmlabs::TelnetLine::setCR ( uint8 type)

Select the line-ending convention.

Parameters
typeTELNET_WINDOWS or TELNET_UNIX.
Returns
true on success.

Definition at line 1338 of file NetworkProtocols.cpp.

References cr, TELNET_UNIX, and TELNET_WINDOWS.

Referenced by cmlabs::TelnetProtocol::ReceiveTelnetLine().

◆ setLine() [1/2]

bool cmlabs::TelnetLine::setLine ( const char * buffer,
bool addCR )

Set the line text from a NUL-terminated string.

Parameters
bufferText (copied).
addCRAppend the line ending when true.
Returns
true on success.

Definition at line 1363 of file NetworkProtocols.cpp.

References setLine().

Referenced by cmlabs::TelnetProtocol::ReceiveTelnetLine(), and setLine().

◆ setLine() [2/2]

bool cmlabs::TelnetLine::setLine ( const char * buffer,
uint32 len,
bool addCR = false )

Set the line text from a length-delimited buffer.

Parameters
bufferText bytes (copied).
lenByte count.
addCRAppend the line ending when true.
Returns
true on success.

Definition at line 1367 of file NetworkProtocols.cpp.

References cr, and data.

Member Data Documentation

◆ cr

char cmlabs::TelnetLine::cr[3]

Active line-ending characters (\r\n or \n, NUL-terminated).

Definition at line 616 of file NetworkProtocols.h.

Referenced by setCR(), setLine(), and TelnetLine().

◆ data

char* cmlabs::TelnetLine::data

◆ size

uint32 cmlabs::TelnetLine::size

Line length in bytes.

Definition at line 619 of file NetworkProtocols.h.

Referenced by getSize(), giveData(), cmlabs::TelnetProtocol::ReceiveTelnetLine(), and TelnetLine().

◆ source

uint64 cmlabs::TelnetLine::source

Packed uint64 endpoint of the sender.

Definition at line 618 of file NetworkProtocols.h.

Referenced by TelnetLine().

◆ time

uint64 cmlabs::TelnetLine::time

Timestamp of creation/receipt (ms epoch).

Definition at line 617 of file NetworkProtocols.h.

Referenced by TelnetLine().

◆ user

uint32 cmlabs::TelnetLine::user

Optional user/session tag for multi-user telnet servers.

Definition at line 620 of file NetworkProtocols.h.

Referenced by TelnetLine().


The documentation for this class was generated from the following files: