FTP Constant Enumerations¶
FTP Command¶
Generated from pcapkit.vendor.ftp.command.Command, with the companion
FEATCode: the FEAT response keywords that
the same IANA registry’s FEAT code column names (RFC 5797 Section 3).
Changed in version 1.5.0: Neither Command._missing_ nor
Command.get() mints a member
(#860): only IANA-registered values are members, and
register() adds a new one.
Command.get() refuses a
non-str key with EnumValueError, with
or without default (#1824). get(42) and get(None) raised
AttributeError from key.upper(), and get(b'ABOR') returned an
unregistered member whose name and value were both the bytes object.
- class pcapkit.const.ftp.command.Command(*values)[source]¶
Bases:
EnumRegistry,aenum.StrEnum[Command] FTP Command
- feat: FEATCode | None¶
Feature code. Keyword returned in FEAT response line for this command/extension, c.f., RFC 5797 Section 2.2.
- type: CommandType¶
Type of “kind” of command, based on RFC 959 Section 4.
- conf: ConformanceRequirement¶
Expectation for support in modern FTP implementations.
- static __new__(cls, name, feat=None, desc=None, type=CommandType.undefined, conf=ConformanceRequirement.O)¶
Create a member from a registry row.
- Parameters:
name (
str) – Command word, which is also the member’s value.feat (
FEATCode|None) – Feature code of theFEATresponse line for the command.type (
CommandType) – Kind of command, based on RFC 959 Section 4.conf (
ConformanceRequirement) – Expectation for support in modern FTP implementations.
- Return type:
- __repr__()[source]¶
Show the member with its description, as
<Command.NAME: description>.- Return type:
- ALGS: Command = 'ALGS'¶
FTP64 ALG status [RFC 6384 Section 11]
- classmethod _unregistered_member(value, name)[source]¶
Build a member absent from this registry’s own lookup tables.
Leaves
feat,desc,typeandconfat the same defaults__new__()itself would, rather than missing entirely –_unregistered_member()bypasses__new__()(it callsstr’s directly), so those attributes would otherwise be absent and__repr__()(which readsdesc) would raise on the result. There is no more specific value to reconstruct them from – a bare wire command word carries none of them, which is exactly the owner’s reasoning for whyget()/_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 withFEATCodeandMethod, 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. Onlyname– the identifier, not the value – is canonicalised.name (
str) – Bare label for the unregistered member – here, the canonical upper-case form ofvalue, 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:
- classmethod register(value, name)[source]¶
Register a new command
valueundername, upper-cased.get()and_missing_()look a command up by its upper-case name, sonameis canonicalised to upper case here beforeregister()mints it.valueis kept as given, as a declared member’s value is.- Parameters:
- Return type:
- 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 atvalue.Canonicalised for the same reason as
register(), so thatget()finds the alias.- Parameters:
- Return type:
- Returns:
The existing member, now reachable under the upper-cased
nameas well.- Raises:
ValueError – As
register_alias().
- classmethod get(key, default=None)[source]¶
Resolve
keyto a member, matching the command code case-insensitively.A non-
strkeyis delegated toget(), asMethod.getdelegates every key, so_validate_value()refuses it there rather thankey.upper()being called on it (GitHub issue #1824). It is aclassmethod, as the base is, because a zero-argumentsuper()needs a first argument to bind.Command.get('X')binds the same as it would on astaticmethod.defaultis not forwarded on that path, asMethod.getdoes not forward its own: here it supplies the value of the unregistered member built on a name miss, while the base’sdefaultmust name a registered value. A refusedkeytherefore raises whateverdefaultis.- Parameters:
key (
str) – Key to get enum item. Looked up case-insensitively, as RFC 959 Section 5 treats FTP command codes, against member names canonicalised to upper case on registration.default (
str|None) – Value for the unregistered member built whenkeymatches no member name.None, the default, useskeyitself.
- Return type:
- Returns:
The member named
keyupper-cased. On a miss, an unregistered member with that name and the valuedefault(orkey), which is not added to the lookup tables, sogetnever registers a command (#860).- Raises:
EnumValueError – If
keyis not astr. This reaches the caller from the base’s non-strbranch, where_validate_value()refuses it beforecls(key)could reach_missing_(). AValueError, so anexcept ValueErrorcaller is unaffected.
- classmethod _validate_value(value)[source]¶
Reject
valueunless it is astr, as_missing_()does.Overrides
_validate_value()with the check_missing_()makes, and the message it raises, soregister()refuses a value the constructor refuses, in the same words (#1816).get()reaches it as well, through the base, for every non-strkey (#1824), so it refuses the same values. Anystrpasses, since_missing_()resolves every one.- Parameters:
value (
Any) – Value about to be looked up or minted.- Raises:
EnumValueError – If
valueis not astr. AValueError, so anexcept ValueErrorcaller is unaffected.
- static __new_member__(cls, name, feat=None, desc=None, type=CommandType.undefined, conf=ConformanceRequirement.O)¶
Create a member from a registry row.
- Parameters:
name (
str) – Command word, which is also the member’s value.feat (
FEATCode|None) – Feature code of theFEATresponse line for the command.type (
CommandType) – Kind of command, based on RFC 959 Section 4.conf (
ConformanceRequirement) – Expectation for support in modern FTP implementations.
- Return type:
- class pcapkit.const.ftp.command.FEATCode(*values)[source]¶
Bases:
EnumRegistry,aenum.StrEnumKeyword 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 codecolumn names – the group markers below plus the per-command keywords generated after them (data-driven, not hand-picked; seeprocess()) – rather than minting the per-command ones at import time as an incidental side effect of buildingCommand’s own rows. GitHub issue #860: that import-time mutation is the same defect shape #775 rules out onFilterType._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 this registry’s 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.- classmethod get(key, default=NO_DEFAULT)[source]¶
Resolve
keycase-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 Codecolumn 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
FEATresponse 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 aFEATresponse line is therefore holding upper case by recommendation, while some of this registry’s codes are registered in lower case – measured on the IANA CSV:base,feat,hist,nat6andsecu, against all-upper-case keywords for the rest, with none mixed. Without this overrideget('BASE')raisesKeyError, 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
keyis 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. Soget('BASE').nameis still'base'and still says placeholder. And the uniqueness rule quoted above is what makes that safe: a real keywordBASEcould not be registered alongside the placeholderbase, 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-mintingstrpath both survive: nothing here callscls(key), so a key matching no member, folded or not, still raises rather than growing the registry.get('ZZ-NOT-REAL')therefore raisesKeyErrorwhileFEATCode('ZZ-NOT-REAL')yields an unregistered member.- Parameters:
- Return type:
- Returns:
The canonical member for
key, or fordefault.- Raises:
KeyError – If no member matches
keyexactly or case-insensitively and there is no usabledefault.ValueError – As
get(), for a non-strkey.
- classmethod _validate_value(value)[source]¶
Reject
valueunless it is astr, as_missing_()does.Overrides
_validate_value()with the check_missing_()makes, and the message it raises, soregister()refuses exactly the valuesget()refuses, in the same words (#1816). Anystrpasses, since_missing_()resolves every one.- Parameters:
value (
Any) – Value about to be looked up or minted.- Raises:
EnumValueError – If
valueis not astr. AValueError, so anexcept ValueErrorcaller is unaffected.
- class pcapkit.const.ftp.command.CommandType(*values)[source]¶
Bases:
EnumLookup,aenum.IntFlagType of “kind” of command, based on RFC 959 Section 4.
Built on
EnumLookupper GitHub issue #930, which finished #877’s phase 2. This class defines nogetof its own, soget/get_allare the base’s, and its own_missing_()range guard below stands as written, sinceEnumLookupdoes not touch that hook.- undefined = 0¶
- A = 1¶
Access control.
- P = 2¶
Parameter setting.
- S = 4¶
Service execution.
- class pcapkit.const.ftp.command.ConformanceRequirement(*values)[source]¶
Bases:
EnumLookup,aenum.IntEnumExpectation for support in modern FTP implementations.
Built on
EnumLookupper GitHub issue #930, which finished #877’s phase 2. This class defines neithergetnor_missing_of its own.- M = 1¶
Mandatory to implement.
- O = 2¶
Optional.
- H = 3¶
Historic.
FTP Server Return Code¶
Generated from pcapkit.vendor.ftp.return_code.ReturnCode.
- class pcapkit.const.ftp.return_code.ReturnCode(*values)[source]¶
Bases:
EnumRegistry,aenum.IntEnum[ReturnCode] FTP Server Return Code
- kind: ResponseKind¶
Response kind.
- group: GroupingInformation¶
Grouping information.
- static __new__(cls, value, description=None)¶
Create a member, deriving its kind and group from the code’s first two digits.
- Parameters:
- Return type:
- 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,kindandgroupthe same way__new__()would, rather than leaving them unset –_unregistered_member()bypasses__new__()entirely (it callsint’s directly), so those attributes would otherwise be missing from the result and__str__()/__repr__()would raise on it.- Parameters:
- Return type:
- classmethod _validate_value(value)[source]¶
Reject
valueunless it is a three-digit reply code.Overrides
_validate_value()with the range check_missing_()makes, and the message it raises, soregister()refuses exactly the valuesget()refuses, in the same words (#1816). That range is0-999rather than the registry’s own, since_missing_()resolves a code outside the registry toUnknownrather than refusing it.- Parameters:
value (
Any) – Value about to be looked up or minted.- Raises:
EnumValueError – If
valueis not anintin0-999. AValueError, so anexcept ValueErrorcaller 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 toUnknown.- Parameters:
value (
int) – Value to get enum item.- Return type:
- class pcapkit.const.ftp.return_code.ResponseKind(*values)[source]¶
Bases:
EnumRegistry,aenum.IntEnumResponse kind; whether the response is good, bad or incomplete.
- PositivePreliminary = 1¶
- PositiveCompletion = 2¶
- PositiveIntermediate = 3¶
- TransientNegativeCompletion = 4¶
- PermanentNegativeCompletion = 5¶
- Protected = 6¶
- classmethod _validate_value(value)[source]¶
Reject
valueunless it is a digit, which_missing_()accepts.Overrides
_validate_value()with the range_missing_()resolves, and the message the constructor raises outside it, soregister()refuses exactly the valuesget()refuses, in the same words (#1816).- Parameters:
value (
Any) – Value about to be looked up or minted.- Raises:
EnumValueError – If
valueis not anintin0-9. AValueError, so anexcept ValueErrorcaller is unaffected.
- class pcapkit.const.ftp.return_code.GroupingInformation(*values)[source]¶
Bases:
EnumRegistry,aenum.IntEnumGrouping information.
- Syntax = 0¶
- Information = 1¶
- Connections = 2¶
- AuthenticationAccounting = 3¶
- Unspecified = 4¶
- FileSystem = 5¶
- classmethod _validate_value(value)[source]¶
Reject
valueunless it is a digit, which_missing_()accepts.Overrides
_validate_value()with the range_missing_()resolves, and the message the constructor raises outside it, soregister()refuses exactly the valuesget()refuses, in the same words (#1816).- Parameters:
value (
Any) – Value about to be looked up or minted.- Raises:
EnumValueError – If
valueis not anintin0-9. AValueError, so anexcept ValueErrorcaller is unaffected.
Footnotes