[ English | 简体中文 ]
FTP Server API
A simple FTP server interface providing user management and session handling capabilities.
Header file: #include <netutils/ftpd.h>
openvela Implementation Notes
- Use cases: IoT device debugging, firmware upload, file download, and other lightweight FTP applications
- Configuration dependency: Requires enabling
CONFIG_NETUTILS_FTPD - User management: Users and permissions are added via
ftpd_adduser - Session model:
ftpd_sessionprovides session handling for a single client connection, typically called in a dedicated thread
FTP Server
Header file: #include <netutils/ftpd.h>
ftpd_open
FTPD_SESSION ftpd_open(int port, sa_family_t family);
Creates an FTP server session.
Parameters:
portListening port (usually 21).familyAddress family (AF_INETorAF_INET6).
Returns:
Returns a session handle on success.
ftpd_adduser
int ftpd_adduser(FTPD_SESSION handle, uint8_t accountflags,
const char *user, const char *passwd, const char *home);
Adds an FTP user.
Parameters:
handleHandle returned byftpd_open().accountflagsUser attribute flags (seeFTPD_ACCOUNTFLAGS_*).userUsername (NULLmeans no login required).passwdPassword (NULLmeans no password required).homeUser home directory.
ftpd_session
int ftpd_session(FTPD_SESSION handle, int timeout);
Runs an FTP server session, waiting for and handling a single client connection.
Parameters:
handleSession handle.timeoutTimeout for waiting for a connection (milliseconds), 0 means wait indefinitely.
ftpd_close
void ftpd_close(FTPD_SESSION handle);
Closes the FTP server session.