FTP Constant Enumerations

This module contains all constant enumerations of FTP implementations. Available enumerations include:

FTP_Command

FTP Commands [*]

FTP_ReturnCode

FTP Return Codes [†]

FTP Command

This module contains the constant enumeration for FTP Command, which is automatically generated from pcapkit.vendor.ftp.command.Command, plus the companion FEATCode enumeration it also declares – the FEAT response keywords the FEAT code column of the same IANA registry names, c.f., RFC 5797 Section 3.

class pcapkit.const.ftp.command.Command(*values)[source]

Bases: EnumRegistry, StrEnum

[Command] FTP Command

Changed in version 1.5.0: Neither _missing_ nor get() mints a member. The owner ruled on GitHub issue #860 that get should not mint: only IANA-registered values are legitimate members, a new one is properly created through register(), and get is not given enough information to create one. Concretely true here – a bare wire command word carries no feat/desc/type/conf, so a minted member had all four hollowed out to their defaults; register() is the path that can actually supply them.

feat: FEATCode | None

Feature code. Keyword returned in FEAT response line for this command/extension, c.f., RFC 5797 Section 2.2.

desc: str | None

Brief description of command / extension.

type: CommandType

Type of “kind” of command, based on RFC 959 Section 4.

conf: ConformanceRequirement

Expectation for support in modern FTP implementations.

ABOR: Command = 'ABOR'

Abort [RFC 959]

ACCT: Command = 'ACCT'

Account [RFC 959]

ADAT: Command = 'ADAT'

Authentication/Security Data [RFC 2228][RFC 2773][RFC 4217]

ALGS: Command = 'ALGS'

FTP64 ALG status [RFC 6384 Section 11]

ALLO: Command = 'ALLO'

Allocate [RFC 959]

APPE: Command = 'APPE'

Append (with create) [RFC 959]

AUTH: Command = 'AUTH'

Authentication/Security Mechanism [2][RFC 2773][RFC 4217]

CCC: Command = 'CCC'

Clear Command Channel [RFC 2228]

CDUP: Command = 'CDUP'

Change to Parent Directory [RFC 959]

CONF: Command = 'CONF'

Confidentiality Protected Command [RFC 2228]

CWD: Command = 'CWD'

Change Working Directory [RFC 959]

DELE: Command = 'DELE'

Delete File [RFC 959]

ENC: Command = 'ENC'

Privacy Protected Command [RFC 2228][RFC 2773][RFC 4217]

EPRT: Command = 'EPRT'

Extended Port [RFC 2428]

EPSV: Command = 'EPSV'

Extended Passive Mode [RFC 2428]

FEAT: Command = 'FEAT'

Feature Negotiation [RFC 2389]

HELP: Command = 'HELP'

Help [RFC 959]

HOST: Command = 'HOST'

Hostname [RFC 7151]

LANG: Command = 'LANG'

Language (for Server Messages) [RFC 2640]

LIST: Command = 'LIST'

List [RFC 959][RFC 1123]

LPRT: Command = 'LPRT'

Data Port [RFC 1545][RFC 1639]

LPSV: Command = 'LPSV'

Passive Mode [RFC 1545][RFC 1639]

MDTM: Command = 'MDTM'

File Modification Time [RFC 3659]

MIC: Command = 'MIC'

Integrity Protected Command [RFC 2228][RFC 2773][RFC 4217]

MKD: Command = 'MKD'

Make Directory [RFC 959]

MLSD: Command = 'MLSD'

List Directory (for machine) [RFC 3659]

MLST: Command = 'MLST'

List Single Object [RFC 3659]

MODE: Command = 'MODE'

Transfer Mode [RFC 959]

NLST: Command = 'NLST'

Name List [RFC 959][RFC 1123]

NOOP: Command = 'NOOP'

No-Op [RFC 959]

OPTS: Command = 'OPTS'

Options [RFC 2389]

PASS: Command = 'PASS'

Password [RFC 959]

PASV: Command = 'PASV'

Passive Mode [RFC 959][RFC 1123]

PBSZ: Command = 'PBSZ'

Protection Buffer Size [RFC 4217]

PORT: Command = 'PORT'

Data Port [RFC 959]

PROT: Command = 'PROT'

Data Channel Protection Level [RFC 4217]

PWD: Command = 'PWD'

Print Directory [RFC 959]

QUIT: Command = 'QUIT'

Logout [RFC 959]

REIN: Command = 'REIN'

Reinitialize [RFC 959]

REST: Command = 'REST'

Restart (for STREAM mode) [3][RFC 3659]

RETR: Command = 'RETR'

Retrieve [RFC 959]

RMD: Command = 'RMD'

Remove Directory [RFC 959]

RNFR: Command = 'RNFR'

Rename From [RFC 959]

RNTO: Command = 'RNTO'

Rename To [RFC 959][RFC Errata 5748]

SITE: Command = 'SITE'

Site Parameters [RFC 959][RFC 1123]

SIZE: Command = 'SIZE'

File Size [RFC 3659]

SMNT: Command = 'SMNT'

Structure Mount [RFC 959]

STAT: Command = 'STAT'

Status [RFC 959]

STOR: Command = 'STOR'

Store [RFC 959]

STOU: Command = 'STOU'

Store Unique [RFC 959][RFC 1123]

STRU: Command = 'STRU'

File Structure [RFC 959]

SYST: Command = 'SYST'

System [RFC 959]

TYPE: Command = 'TYPE'

Representation Type [4][RFC 959]

USER: Command = 'USER'

User Name [RFC 959]

XCUP: Command = 'XCUP'

None [RFC 775][RFC 1123]

XCWD: Command = 'XCWD'

None [RFC 775][RFC 1123]

XMKD: Command = 'XMKD'

None [RFC 775][RFC 1123]

XPWD: Command = 'XPWD'

None [RFC 775][RFC 1123]

XRMD: Command = 'XRMD'

None [RFC 775][RFC 1123]

TVFS: Command = 'TVFS'

Trivial Virtual File Store [RFC 3659]

classmethod _unregistered_member(value, name)[source]

Build a member absent from this registry’s own lookup tables.

Leaves feat, desc, type and conf at the same defaults __new__() itself would, rather than missing entirely – _unregistered_member() bypasses __new__() (it calls str’s directly), so those four attributes would otherwise be absent and __repr__() (which reads desc) would raise on the result. There is no more specific value to reconstruct them from – a bare wire command word carries none of the four, which is exactly the owner’s reasoning for why get()/ _missing_ must not mint one: register() is the path that can actually supply them.

Parameters:
  • value (str) – Value to get enum item – the convention here, shared with FEATCode and Method, is the caller’s own casing, unchanged: an unregistered member’s value is exactly what was observed on the wire, matching how a registered member’s own value is exactly what was declared, never reformatted. Only name – the identifier, not the value – is canonicalised.

  • name (str) – Bare label for the unregistered member – here, the canonical upper-case form of value, matching the name every registered member of this class is looked up by, since #860’s open-vocabulary registries have no manufactured placeholder label to fall back to.

Return type:

Command

classmethod register(value, name)[source]

Register a new command value under name, upper-cased.

get() and _missing_() look a command up by its upper-case name, so name is canonicalised to upper case here before register() mints it. value is kept as given, as a declared member’s value is.

Parameters:
  • value (str) – Value of the new member.

  • name (str) – Name of the new member, in any case.

Return type:

Command

Returns:

The newly registered member.

Raises:

ValueError – As register().

classmethod register_alias(value, name)[source]

Add name, upper-cased, as a further name for the member at value.

Canonicalised for the same reason as register(), so that get() finds the alias.

Parameters:
  • value (str) – Value of the existing member to alias.

  • name (str) – Alias to add for it, in any case.

Return type:

Command

Returns:

The existing member, now reachable under the upper-cased name as well.

Raises:

ValueError – As register_alias().

classmethod _validate_value(value)[source]

Reject value unless it is a str, as _missing_() does.

Overrides _validate_value() with the check _missing_() makes, and the message it raises, so register() refuses a value the constructor refuses, in the same words (#1816). get() reaches it as well, through the base, for every non-str key (#1824), so it refuses the same values. Any str passes, since _missing_() resolves every one.

Parameters:

value (Any) – Value about to be looked up or minted.

Raises:

EnumValueError – If value is not a str. A ValueError, so an except ValueError caller is unaffected.

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters:

value (str) – Value to get enum item. Matched case-insensitively against the canonical upper-case member names.

Return type:

Command

static _generate_next_value_(name, start, count, last_values)

Return the lower-cased version of the member name.

class pcapkit.const.ftp.command.FEATCode(*values)[source]

Bases: EnumRegistry, StrEnum

Keyword returned in FEAT response line for this command/extension, c.f., RFC 5797 Section 3.

Note

Declares every FEAT keyword the IANA registry’s own FEAT code column names – the 5 group markers below plus the per-command keywords generated after them (data-driven, not hand-picked; see process()) – rather than minting the per-command ones at import time as an incidental side effect of building Command’s own rows. GitHub issue #860: that import-time mutation was the same defect shape #775 removed from FilterType. _missing_ still unmints for a keyword that turns up on the wire but names none of these – the extendability the owner conditionally asked to keep on GitHub issue #860: unsure what a FEAT value absent from the RFC’s list means in the CSV table, the owner said that if the expected handling is our current approach, as industry convention has it, the registry stays extendable as is, and then approved declaring the registry’s keywords as real members with _missing_ still covering the rest. No custom __new__ here, so the base’s generic _unregistered_member() needs no override.

base = '<base>'

FTP standard commands [RFC 0959].

hist = '<hist>'

Historic experimental commands [RFC 0775][RFC 1639].

secu = '<secu>'

FTP Security Extensions [RFC 2228].

feat = '<feat>'

FTP Feature Negotiation [RFC 2389].

nat6 = '<nat6>'

FTP Extensions for NAT/IPv6 [RFC 2428].

AUTH = 'AUTH'

Authentication/Security Mechanism [2][RFC 2773][RFC 4217]

HOST = 'HOST'

Hostname [RFC 7151]

UTF8 = 'UTF8'

Language (for Server Messages) [RFC 2640]

MDTM = 'MDTM'

File Modification Time [RFC 3659]

MLST = 'MLST'

List Directory (for machine) [RFC 3659]

PBSZ = 'PBSZ'

Protection Buffer Size [RFC 4217]

PROT = 'PROT'

Data Channel Protection Level [RFC 4217]

REST = 'REST'

Restart (for STREAM mode) [3][RFC 3659]

SIZE = 'SIZE'

File Size [RFC 3659]

TVFS = 'TVFS'

Trivial Virtual File Store [RFC 3659]

classmethod get(key, default=<NO_DEFAULT>)[source]

Resolve key case-insensitively, per RFC 5797 Section 2.

One of the few case-insensitive overrides the ruling on GitHub issue #877 allows, and the registry’s own defining document states the comparison rule outright rather than leaving it to be inferred – RFC 5797 Section 2, on the FEAT Code column this class is generated from: “IANA maintains uniqueness of feature names (FEAT codes) based on case-insensitive comparison.” Two FEAT codes therefore cannot differ only by case, so folding the caller’s key cannot resolve ambiguously.

RFC 2389 Section 3.2, which defines the FEAT response the codes appear in, points the same way from the wire side: “The feature-label and feature-parms are nominally case sensitive, however … it is to be expected that those definitions will usually specify the label and parameters in a case independent manner. Where this is done, implementations are recommended to use upper case letters when transmitting the feature response.” A caller feeding a FEAT response line is therefore holding upper case by recommendation, while 5 of this registry’s 15 codes are registered in lower case – measured on the IANA CSV: 10 distinct all-upper-case keywords against base, feat, hist, nat6 and secu, with none mixed. Without this override get('BASE') raised KeyError, which is the defect GitHub issue #903’s audit found.

The obvious objection, answered: RFC 5797 uses case presentationally to tell a real keyword from a placeholder – “defined FEAT keywords codes are listed in all uppercase, whereas placeholder keywords … are listed in lowercase” – so folding might look like it discards that distinction. It does not. Only the inbound key is folded; every member keeps the registrar’s own casing, and the fold itself is backed by the RFC: the final ruling on GitHub issue #877 is that an enum treats its values as case-insensitive where the RFC states they are, and as case-sensitive otherwise. So get('BASE').name is still 'base' and still says placeholder. And the uniqueness rule quoted above is what makes that safe: a real keyword BASE could not be registered alongside the placeholder base, so there is no second member for the fold to hide.

Folds only as a fallback. An exact name or value hit is delegated to get() untouched, so the base’s own precedence – name before value – and its non-minting str path both survive: nothing here calls cls(key), so a key matching no member, folded or not, still raises rather than growing the registry. get('ZZ-NOT-REAL') therefore still raises KeyError while FEATCode('ZZ-NOT-REAL') still yields an unregistered member, exactly as before.

Parameters:
  • key (Any) – Name or value to look up. A non-str key is passed straight through, since case cannot apply to it.

  • default (Any) – As get(). Not folded – it names an already-registered value rather than arriving from the wire, so the caller spells it from this module.

Return type:

FEATCode

Returns:

The canonical member for key, or for default.

Raises:
  • KeyError – If no member matches key exactly or case-insensitively and there is no usable default.

  • ValueError – As get(), for a non-str key.

classmethod _validate_value(value)[source]

Reject value unless it is a str, as _missing_() does.

Overrides _validate_value() with the check _missing_() makes, and the message it raises, so register() refuses exactly the values get() refuses, in the same words (#1816). Any str passes, since _missing_() resolves every one.

Parameters:

value (Any) – Value about to be looked up or minted.

Raises:

EnumValueError – If value is not a str. A ValueError, so an except ValueError caller is unaffected.

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters:

value (str) – Value to get enum item.

Return type:

FEATCode

static _generate_next_value_(name, start, count, last_values)

Return the lower-cased version of the member name.

FTP Server Return Code

This module contains the constant enumeration for FTP Server Return Code, which is automatically generated from pcapkit.vendor.ftp.return_code.ReturnCode.

class pcapkit.const.ftp.return_code.ReturnCode(*values)[source]

Bases: EnumRegistry, IntEnum

[ReturnCode] FTP Server Return Code

description: str | None

Description of the return code.

kind: ResponseKind

Response kind.

group: GroupingInformation

Grouping information.

CODE_110: ReturnCode = 110

Restart marker replay. In this case, the text is exact and not left to the particular implementation; it must read: MARK yyyy = mmmm where yyyy is User-process data stream marker, and mmmm server’s equivalent marker (note the spaces between markers and “=”).

CODE_120: ReturnCode = 120

Service ready in nnn minutes.

CODE_125: ReturnCode = 125

Data connection already open; transfer starting.

CODE_150: ReturnCode = 150

File status okay; about to open data connection.

CODE_202: ReturnCode = 202

Command not implemented, superfluous at this site.

CODE_211: ReturnCode = 211

System status, or system help reply.

CODE_212: ReturnCode = 212

Directory status.

CODE_213: ReturnCode = 213

File status.

CODE_214: ReturnCode = 214

Help message. Explains how to use the server or the meaning of a particular non-standard command. This reply is useful only to the human user.

CODE_215: ReturnCode = 215

NAME system type. Where NAME is an official system name from the registry kept by IANA.

CODE_220: ReturnCode = 220

Service ready for new user.

CODE_221: ReturnCode = 221

Service closing control connection. Logged out if appropriate.

CODE_225: ReturnCode = 225

Data connection open; no transfer in progress.

CODE_226: ReturnCode = 226

Closing data connection. Requested file action successful (for example, file transfer or file abort).

CODE_227: ReturnCode = 227

Entering Passive Mode (h1,h2,h3,h4,p1,p2).

CODE_228: ReturnCode = 228

Entering Long Passive Mode (long address, port).

CODE_229: ReturnCode = 229

Entering Extended Passive Mode ( |||port| ).

CODE_230: ReturnCode = 230

User logged in, proceed.

CODE_232: ReturnCode = 232

User logged in, authorized by security data exchange.

CODE_234: ReturnCode = 234

Server accepts the security mechanism specified by the client; no security data needs to be exchanged.

CODE_235: ReturnCode = 235

Server accepts the security data given by the client; no further security data needs to be exchanged.

CODE_250: ReturnCode = 250

Requested file action was okay, completed.

CODE_331: ReturnCode = 331

User name okay, password needed.

CODE_332: ReturnCode = 332

No need account for login.

CODE_334: ReturnCode = 334

Server accepts the security mechanism specified by the client; some security data needs to be exchanged.

CODE_335: ReturnCode = 335

Server accepts the security data given by the client; more security data needs to be exchanged.

CODE_336: ReturnCode = 336

Username okay, password okay. Challenge is “… . “.

CODE_421: ReturnCode = 421

Service NOT available, closing control connection. This may be a reply to any command if the service knows it must shut down.

CODE_425: ReturnCode = 425

Can’t open data connection.

CODE_426: ReturnCode = 426

Connection closed; transfer aborted.

CODE_430: ReturnCode = 430

Invalid username or password

CODE_431: ReturnCode = 431

Need some unavailable resource to process security.

CODE_434: ReturnCode = 434

Requested host unavailable.

CODE_450: ReturnCode = 450

Requested file action not taken. File unavailable (e.g., file busy).

CODE_451: ReturnCode = 451

Requested action aborted. Local error in processing.

CODE_452: ReturnCode = 452

Requested action not taken. Insufficient storage space in system.

CODE_501: ReturnCode = 501

Syntax error in parameters or arguments.

CODE_502: ReturnCode = 502

Command not implemented.

CODE_503: ReturnCode = 503

Bad sequence of commands.

CODE_504: ReturnCode = 504

Command not implemented for that parameter.

CODE_530: ReturnCode = 530

Not logged in.

CODE_532: ReturnCode = 532

Need account for storing files.

CODE_533: ReturnCode = 533

Command protection level denied for policy reasons.

CODE_534: ReturnCode = 534

Request denied for policy reasons.

CODE_535: ReturnCode = 535

Failed security check.

CODE_536: ReturnCode = 536

Data protection level not supported by security mechanism.

CODE_537: ReturnCode = 537

Command protection level not supported by security mechanism.

CODE_550: ReturnCode = 550

Requested action not taken. File unavailable (e.g., file not found, no access).

CODE_551: ReturnCode = 551

Requested action aborted. Page type unknown.

CODE_552: ReturnCode = 552

Requested file action aborted. Exceeded storage allocation (for current directory or dataset).

CODE_553: ReturnCode = 553

Requested action not taken. File name not allowed.

CODE_631: ReturnCode = 631

Integrity protected reply.

CODE_632: ReturnCode = 632

Confidentiality and integrity protected reply.

CODE_633: ReturnCode = 633

Confidentiality protected reply.

classmethod _unregistered_member(value, name)[source]

Build a member absent from this registry’s own lookup tables.

Reconstructs description, kind and group the same way __new__() would, rather than leaving them unset – _unregistered_member() bypasses __new__() entirely (it calls int’s directly), so those three attributes would otherwise be missing from the result and __str__()/__repr__() would raise on it.

Parameters:
  • value (int) – Value to get enum item.

  • name (str) – Bare label for the unregistered member, per the ranged mint/unmint criterion.

Return type:

ReturnCode

classmethod _validate_value(value)[source]

Reject value unless it is a three-digit reply code.

Overrides _validate_value() with the range check _missing_() makes, and the message it raises, so register() refuses exactly the values get() refuses, in the same words (#1816). That range is 0-999 rather than the registry’s own, since _missing_() resolves a code outside the registry to Unknown rather than refusing it.

Parameters:

value (Any) – Value about to be looked up or minted.

Raises:

EnumValueError – If value is not an int in 0-999. A ValueError, so an except ValueError caller is unaffected.

classmethod _missing_(value)[source]

Lookup function used when value is not found.

A reply code is three digits (RFC 959 Section 4.2), so every value from 0 to 999 can arrive on the wire: one within the registry’s range resolves to Unassigned, any other to Unknown.

Parameters:

value (int) – Value to get enum item.

Return type:

ReturnCode

Footnotes