FTP - File Transfer Protocol¶
Removed in version 1.6.0: pcapkit.protocols.application.ftp.FTP_REQUEST,
pcapkit.protocols.application.ftp.FTP_RESPONSE and
pcapkit.protocols.application.ftp.Type, with no alias: they are in this module,
and pcapkit.protocols.application.ftp exports the protocol class alone
(#2534).
pcapkit.protocols.application.ftp.protocol contains
FTP,
which implements an extractor for File Transfer Protocol
(FTP) [*], the control channel; the data channel is
FTP_DATA, in
pcapkit.protocols.application.ftp_data.protocol.
Changed in version 1.5.0: A command or reply rebuilds byte for byte, its CRLF included, and keeps the command’s case and any octets that are not UTF-8 as captured. A line with no argument and a multi-line reply, whole in one segment or not, parse and rebuild as captured (#1238, #1239, #1240, #1241, #1303, #1333).
Removed in version 1.5.0: pcapkit.protocols.application.ftp.FTP_DATA, with no alias. The class
moved to pcapkit.protocols.application.ftp_data.protocol, since TCP port 20
dispatches it and port 21 the control channel – two protocols, so two
modules (#2285).
- class pcapkit.protocols.application.ftp.protocol.FTP(file=None, length=None, **kwargs)[source]¶
Bases:
Application[FTP,FTP]This class implements File Transfer Protocol.
- property length: NoReturn¶
Header length of current protocol.
- Raises:
UnsupportedCall – This protocol doesn’t support
length.
- read(length=None, **kwargs)[source]¶
Read File Transfer Protocol (FTP).
- Parameters:
- Return type:
- Returns:
Parsed packet data.
- Raises:
ProtocolError – If the packet is malformed.
- make(cmmd=None, code=None, args=None, more=False, charset=None, raw_cmmd=None, lines=(), **kwargs)[source]¶
Make (construct) packet data.
The line is terminated with CRLF. Arguments of
Nonewrite no argument and no separator; otherwise a single SP separates them from the command or code, except after the hyphen of a multi-line reply, which the text follows immediately (RFC 959 Section 4).Commands are case-insensitive (RFC 959 Section 5), so
raw_cmmdis written in place ofcmmdwhenever the two differ only in case, which keeps the case the command was read in.- Parameters:
cmmd (
Command|str|bytes|bytearray|None) – FTP command, astr(anCommandmember is one),bytesorbytearray.code (
ReturnCode|int|str|bytes|bytearray|None) – FTP status code, anintin0–999(anReturnCodemember is one) or a numericstr,bytesorbytearrayholding one.args (
str|bytes|bytearray|None) – Optional FTP command arguments and/or status messages, astr,bytesorbytearray.more (
bool) – More status messages to follow for response packets.charset (
str|None) – Encoding forstrarguments, UTF-8 if not given.raw_cmmd (
bytes|None) – FTP command as received, in its original case.lines (
Iterable[bytes]) – Lines of a multi-line reply after the first, each written verbatim and terminated with CRLF; the last, and only the last, is the closing line,<code> SP <text>.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- Raises:
ProtocolError – If neither or both of
cmmdandcodeare given, ifcmmdorargsis not astr,bytesorbytearray(aboolincluded), ifcodeis not anintin0–999(aboolincluded) nor a numericstr,bytesorbytearrayholding one, or iflinesare given other than as the rest of a multi-line reply.
- classmethod __index__()[source]¶
Numeral registry index of the protocol.
- Return type:
- Returns:
Numeral registry index of the protocol in IANA service names and port numbers: TCP port 21, the port of
TCP.ftpas anint, whichTCP.__proto__dispatches here (The Registry Index).
Auxiliary Data¶
- class pcapkit.protocols.application.ftp.protocol.Type(*values)[source]¶
Bases:
EnumLookup,StrEnumFTP packet type.
Built on
EnumLookup, the lookup contract shared by every non-registry enumeration (#877). The class defines neithergetnor_missing_of its own.- REQUEST = 'request'¶
Request packet.
- RESPONSE = 'response'¶
Response packet.
Header Schemas¶
Removed in version 1.6.0: pcapkit.protocols.schema.application.ftp, with no alias: the module moved here
(#2534).
Data Models¶
Removed in version 1.6.0: pcapkit.protocols.data.application.ftp, with no alias: the module moved here
(#2534).
- class pcapkit.protocols.application.ftp.data.FTP(*args, **kwargs)[source]¶
Bases:
ProtocolData model for FTP protocol.
- class pcapkit.protocols.application.ftp.data.Request(type, cmmd, args, charset, raw_cmmd)[source]¶
Bases:
FTPData model for FTP request.
- class pcapkit.protocols.application.ftp.data.Response(type, code, args, more, charset, lines)[source]¶
Bases:
FTPData model for FTP response.
- code: ReturnCode¶
Return code.
Footnotes