slc

Special Line Character support for Telnet Linemode Option (RFC 1184).

class Forwardmask(value, ack=False)[source]

Forwardmask object using the bytemask value received by server.

Initialize Forwardmask with the given value.

Parameters:

value (Union[bytes, bytearray]) – Bytemask value received by server after IAC SB LINEMODE DO FORWARDMASK. It must be a bytearray of length 16 or 32.

description_table()[source]

Returns list of strings describing obj as a tabular ASCII map.

Return type:

List[str]

generate_forwardmask(binary_mode, tabset, ack=False)[source]

Generate a Forwardmask instance.

Generate a 32-byte (binary_mode is True) or 16-byte (False) Forwardmask instance appropriate for the specified slctab. A Forwardmask is formed by a bitmask of all 256 possible 8-bit keyboard ascii input, or, when not ‘outbinary’, a 16-byte 7-bit representation of each value, and whether they should be “forwarded” by the client on the transport stream

Return type:

Forwardmask

generate_slctab(tabset=None)[source]

Returns full ‘SLC Tab’ for definitions found using tabset.

Functions not listed in tabset are set as SLC_NOSUPPORT.

Return type:

Dict[bytes, SLC]

class Linemode(mask=b'\\x00')[source]

Represents the LINEMODE negotiation state.

A mask of LMODE_MODE_LOCAL means that all line editing is performed on the client side (default). A mask of theNULL (\x00) indicates that editing is performed on the remote side.

Initialize Linemode with the given mask.

Valid bit flags of mask are: LMODE_MODE_TRAPSIG, LMODE_MODE_ACK, LMODE_MODE_SOFT_TAB, and LMODE_MODE_LIT_ECHO.

property local: bool

True if linemode is local.

property edit: bool

True if EDIT bit set (client performs local line editing).

RFC 1184 name.

property remote: bool

True if linemode is remote.

property trapsig: bool

True if signals are trapped by client.

property ack: bool

Returns True if mode has been acknowledged.

property soft_tab: bool

Returns True if client will expand horizontal tab (\x09).

property lit_echo: bool

Returns True if non-printable characters are displayed as-is.

LMODE_MODE_EDIT = b'\x01'

RFC 1184’s name for LMODE_MODE_LOCAL (EDIT bit)

name_slc_command(byte)[source]

Given an SLC byte, return global mnemonic as string.

Return type:

str

class SLC(mask=b'\\x03', value=b'\\x00')[source]

Defines the willingness to support a Special Linemode Character.

Initialize SLC with the given mask and value.

Defined by its SLC support level, mask and default keyboard ASCII byte value (may be negotiated by client).

property level: bytes

Returns SLC level of support.

property nosupport: bool

Returns True if SLC level is SLC_NOSUPPORT.

property cantchange: bool

Returns True if SLC level is SLC_CANTCHANGE.

property variable: bool

Returns True if SLC level is SLC_VARIABLE.

property default: bool

Returns True if SLC level is SLC_DEFAULT.

property ack: int

Returns True if SLC_ACK bit is set.

property flushin: int

Returns True if SLC_FLUSHIN bit is set.

property flushout: int

Returns True if SLC_FLUSHOUT bit is set.

set_value(value)[source]

Set SLC keyboard ascii value to byte.

Return type:

None

set_mask(mask)[source]

Set SLC option mask, mask.

Return type:

None

set_flag(flag)[source]

Set SLC option flag, flag.

Return type:

None

class SLC_nosupport[source]

SLC definition inferring our unwillingness to support the option.

Initialize SLC_nosupport with NOSUPPORT level and disabled value.

snoop(byte, slctab, slc_callbacks)[source]

Scan slctab for matching byte values.

Returns (callback, func_byte, slc_definition) on match. Otherwise, (None, None, None). If no callback is assigned, the value of callback is always None.

Return type:

Tuple[Optional[Callable[..., Any]], Optional[bytes], Optional[SLC]]