FTP - File Transfer Protocol¶
pcapkit.protocols.application.ftp contains
FTP,
which implements extractor for File Transfer Protocol
(FTP) [*], and FTP_DATA
for its data channel.
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).
- class pcapkit.protocols.application.ftp.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:
code (
ReturnCode|int|str|bytes|None) – FTP status code.args (
str|bytes|None) – Optional FTP command arguments and/or status messages.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, or iflinesare given other than as the rest of a multi-line reply.
- class pcapkit.protocols.application.ftp.FTP_DATA(file=None, length=None, **kwargs)[source]¶
Bases:
RawThis class implements FTP data channel transmission.
Auxiliary Data¶
- class pcapkit.protocols.application.ftp.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.
- static _generate_next_value_(name, start, count, last_values)¶
Return the lower-cased version of the member name.
Header Schemas¶
Data Models¶
- class pcapkit.protocols.data.application.ftp.FTP(dict_=None, **kwargs)[source]¶
Bases:
ProtocolData model for FTP protocol.
- class pcapkit.protocols.data.application.ftp.Request(*args: VT, **kwargs: VT)[source]¶
Bases:
FTPData model for FTP request.
- class pcapkit.protocols.data.application.ftp.Response(*args: VT, **kwargs: VT)[source]¶
Bases:
FTPData model for FTP response.
- code: ReturnCode¶
Return code.
Footnotes