Skip to main content

Module ftp

Module ftp 

Source
Expand description

FTP (File Transfer Protocol) layer implementation.

Implements RFC 959 FTP packet parsing as a zero-copy view into a packet buffer.

FTP operates over two TCP connections:

  • Control connection (port 21): Commands and replies (text-based)
  • Data connection (port 20 or negotiated): Actual file data

This implementation focuses on the control connection protocol.

§Packet Format

Client Command:

COMMAND [arguments]\r\n

Server Reply:

NNN<SP>text\r\n               (single-line)
NNN-text\r\n ... NNN<SP>text\r\n  (multi-line)

Where NNN is a 3-digit reply code.

§Reply Code Categories

RangeMeaning
1xxPositive Preliminary
2xxPositive Completion
3xxPositive Intermediate
4xxTransient Negative
5xxPermanent Negative

Re-exports§

pub use builder::FtpBuilder;

Modules§

builder
FTP packet builder.

Structs§

FtpLayer
A zero-copy view into an FTP layer within a packet buffer.

Enums§

FtpMessageKind
Represents an FTP message type.

Constants§

CMD_ABOR
CMD_ACCT
CMD_ALLO
CMD_APPE
CMD_AUTH
CMD_CDUP
CMD_CWD
CMD_DELE
CMD_EPRT
CMD_EPSV
CMD_FEAT
CMD_HELP
CMD_LIST
CMD_MDTM
CMD_MKD
CMD_MLSD
CMD_MLST
CMD_MODE
CMD_NLST
CMD_NOOP
CMD_OPTS
CMD_PASS
CMD_PASV
CMD_PBSZ
CMD_PORT
CMD_PROT
CMD_PWD
CMD_QUIT
CMD_REIN
CMD_REST
CMD_RETR
CMD_RMD
CMD_RNFR
CMD_RNTO
CMD_SITE
CMD_SIZE
CMD_SMNT
CMD_STAT
CMD_STOR
CMD_STOU
CMD_STRU
CMD_SYST
CMD_TYPE
CMD_USER
FTP_CONTROL_PORT
FTP control port.
FTP_DATA_PORT
FTP data port.
FTP_MIN_HEADER_LEN
Minimum FTP payload: at least “OK\r\n” or short command.
REPLY_ARG_SYNTAX_ERROR
REPLY_AUTH_OK
REPLY_BAD_SEQUENCE
REPLY_CANT_OPEN_DATA
REPLY_CLOSING_CONTROL
REPLY_CLOSING_DATA
REPLY_CMD_NOT_IMPL
REPLY_CMD_NOT_IMPL_PARAM
REPLY_COMMAND_NOT_IMPLEMENTED
REPLY_CONN_CLOSED
REPLY_DATA_OPEN
REPLY_DATA_OPEN_XFER
REPLY_DIR_STATUS
REPLY_EXCEED_STORAGE
REPLY_EXTENDED_PASSIVE
REPLY_FILENAME_NOT_ALLOWED
REPLY_FILE_ACTION_OK
REPLY_FILE_STATUS
REPLY_FILE_STATUS_OK
REPLY_FILE_UNAVAIL
REPLY_FILE_UNAVAIL_BUSY
REPLY_HELP_MSG
REPLY_HOST_UNAVAIL
REPLY_INSUFF_STORAGE
REPLY_INVALID_CRED
REPLY_LOCAL_ERROR
REPLY_LONG_PASSIVE
REPLY_NAME_SYSTEM
REPLY_NEED_ACCOUNT
REPLY_NEED_ACCOUNT_FOR_STOR
REPLY_NOT_LOGGED_IN
REPLY_OK
REPLY_PAGE_TYPE_UNKNOWN
REPLY_PASSIVE
REPLY_PATHNAME_CREATED
REPLY_PENDING_INFO
REPLY_RESTART_MARKER
REPLY_SERVICE_NOT_AVAIL
REPLY_SERVICE_READY
REPLY_SERVICE_READY_IN
REPLY_SYNTAX_ERROR
REPLY_SYSTEM_STATUS
REPLY_USER_LOGGED_IN
REPLY_USER_OK_NEED_PASS

Statics§

FTP_COMMANDS
FTP command verbs for detection.
FTP_FIELD_NAMES
Field names for Python/generic access.

Functions§

ftp_show_fields
Display fields for FtpLayer in show() output.
is_ftp_payload
Returns true if buf looks like an FTP control-connection payload.
reply_code_description
Returns a human-readable description for an FTP reply code.