11#ifndef ZEPHYR_INCLUDE_NET_FTP_CLIENT_H_
12#define ZEPHYR_INCLUDE_NET_FTP_CLIENT_H_
33#if defined(CONFIG_FTP_CLIENT)
34#define FTP_BUFFER_SIZE CONFIG_FTP_CLIENT_BUF_SIZE
36#define FTP_BUFFER_SIZE 1
239#define FTP_PRELIMINARY_POS(code) ((code) >= 100 && (code) < 200)
240#define FTP_COMPLETION_POS(code) ((code) >= 200 && (code) < 300)
241#define FTP_INTERMEDIATE_POS(code) ((code) >= 300 && (code) < 400)
242#define FTP_TRANSIENT_NEG(code) ((code) >= 400 && (code) < 500)
243#define FTP_COMPLETION_NEG(code) ((code) >= 500 && (code) < 600)
244#define FTP_PROTECTED(code) ((code) >= 600 && (code) < 700)
245#define FTP_PROPRIETARY(code) ((code) >= 900 && (code) < 1000)
246#define FTP_WINSOCK_ERR(code) ((code) >= 10000)
332 const char *password);
430 const char *new_name);
int ftp_close(struct ftp_client *client)
Close FTP connection.
int ftp_delete(struct ftp_client *client, const char *file)
Delete a file.
int ftp_open(struct ftp_client *client, const char *hostname, uint16_t port, int sec_tag)
Open FTP connection.
ftp_reply_code
List of FTP server reply codes Reference RFC959 FTP Transfer Protocol.
Definition ftp_client.h:44
int ftp_list(struct ftp_client *client, const char *options, const char *target)
List information of folder or file.
int ftp_cwd(struct ftp_client *client, const char *folder)
Change working directory.
void(* ftp_client_callback_t)(const uint8_t *msg, uint16_t len)
FTP asynchronous callback function.
Definition ftp_client.h:268
int ftp_put(struct ftp_client *client, const char *file, const uint8_t *data, uint16_t length, int type)
Put data to a file If file does not exist, create the file.
int ftp_type(struct ftp_client *client, enum ftp_transfer_type type)
Set FTP transfer type.
int ftp_keepalive(struct ftp_client *client)
Exchange keep-alive commands with the server.
int ftp_status(struct ftp_client *client)
Get FTP server and connection status Also returns server system type.
int ftp_login(struct ftp_client *client, const char *username, const char *password)
FTP server login.
int ftp_pwd(struct ftp_client *client)
Print working directory.
int ftp_get(struct ftp_client *client, const char *file)
Get a file.
int ftp_uninit(struct ftp_client *client)
Uninitialize the FTP client context.
int ftp_mkd(struct ftp_client *client, const char *folder)
Make directory.
int ftp_rmd(struct ftp_client *client, const char *folder)
Remove directory.
ftp_transfer_type
FTP transfer mode.
Definition ftp_client.h:250
int ftp_rename(struct ftp_client *client, const char *old_name, const char *new_name)
Rename a file.
int ftp_init(struct ftp_client *client, ftp_client_callback_t ctrl_callback, ftp_client_callback_t data_callback)
Initialize the FTP client context.
ftp_put_type
FTP file write mode.
Definition ftp_client.h:256
@ FTP_CODE_451_ACTION_ABORTED
Requested action aborted.
Definition ftp_client.h:146
@ FTP_CODE_350_FILE_ACTION_PENDING
Requested file action pending further information.
Definition ftp_client.h:124
@ FTP_CODE_910_DATA_TRANSFER_TIMEOUT
Data transfer timeout.
Definition ftp_client.h:216
@ FTP_CODE_214_HELP_MSG
Help message.
Definition ftp_client.h:78
@ FTP_CODE_10054_CONNECTION_RESET_BY_PEER
Connection reset by peer.
Definition ftp_client.h:225
@ FTP_CODE_10066_DIRECTORY_NOT_EMPTY
Directory not empty.
Definition ftp_client.h:233
@ FTP_CODE_120_SERVICE_READY_IN_NNN_MINUTES
Service ready in nnn minutes.
Definition ftp_client.h:56
@ FTP_CODE_225_DATA_CONN_OPEN
Data connection open; no transfer in progress.
Definition ftp_client.h:88
@ FTP_CODE_331_USERNAME_OK_NEED_PASSWORD
User name okay, need password.
Definition ftp_client.h:120
@ FTP_CODE_234_SECURITY_ACCEPTED
Specifies that the server accepts the authentication mechanism specified by the client,...
Definition ftp_client.h:109
@ FTP_CODE_228_ENTERING_LONG_PASSIVE_MODE
Entering Long Passive Mode (long address, port).
Definition ftp_client.h:96
@ FTP_CODE_425_CANNOT_OPEN_DATA_CONN
Cannot open data connection.
Definition ftp_client.h:136
@ FTP_CODE_227_ENTERING_PASSIVE_MODE
Entering Passive Mode (h1,h2,h3,h4,p1,p2).
Definition ftp_client.h:94
@ FTP_CODE_633_CONFIDENTIALITY_PROTECTED_REPLY
Confidentiality protected reply.
Definition ftp_client.h:193
@ FTP_CODE_553_FILE_NAME_NOT_ALLOWED
Requested action not taken.
Definition ftp_client.h:184
@ FTP_CODE_500_GENERAL_ERROR
General error.
Definition ftp_client.h:158
@ FTP_CODE_504_COMMAND_NOT_IMPLEMENTED
Command not implemented for that parameter.
Definition ftp_client.h:166
@ FTP_CODE_230_USER_LOGGED_IN
User logged in, proceed.
Definition ftp_client.h:100
@ FTP_CODE_212_DIR_STATUS
Directory status.
Definition ftp_client.h:71
@ FTP_CODE_332_NEED_ACCOUNT
Need account for login.
Definition ftp_client.h:122
@ FTP_CODE_229_ENTERING_EXT_PASSIVE_MODE
Entering Extended Passive Mode (|||port|).
Definition ftp_client.h:98
@ FTP_CODE_233_LOGOUT_COMMAND_NOTED
Logout command noted, will complete when transfer done.
Definition ftp_client.h:104
@ FTP_CODE_900_UNKNOWN_ERROR
DUMMY.
Definition ftp_client.h:198
@ FTP_CODE_231_USER_LOGGED_OUT
User logged out; service terminated.
Definition ftp_client.h:102
@ FTP_CODE_426_CONN_CLOSED
Connection closed; transfer aborted.
Definition ftp_client.h:138
@ FTP_CODE_250_FILE_ACTION_COMPLETED
Requested file action okay, completed.
Definition ftp_client.h:111
@ FTP_CODE_220_SERVICE_READY
Service ready for new user.
Definition ftp_client.h:84
@ FTP_CODE_502_COMMAND_NOT_COMPLETED
Command not implemented.
Definition ftp_client.h:162
@ FTP_CODE_551_PAGE_TYPE_UNKNOWN
Requested action aborted.
Definition ftp_client.h:178
@ FTP_CODE_550_FILE_UNAVAILABLE
Requested action not taken.
Definition ftp_client.h:176
@ FTP_CODE_534_CANNOT_CONNECT_SSL_REQUIRED
Could Not Connect to Server - Policy Requires SSL.
Definition ftp_client.h:172
@ FTP_CODE_211_SYSTEM_STATUS
System status, or system help reply.
Definition ftp_client.h:69
@ FTP_CODE_905_NETWORK_DOWN
Network down.
Definition ftp_client.h:210
@ FTP_CODE_213_FILE_STATUS
File status.
Definition ftp_client.h:73
@ FTP_CODE_226_CLOSING_DATA_CONN_SUCCESS
Closing data connection.
Definition ftp_client.h:92
@ FTP_CODE_200_OK
Command OK.
Definition ftp_client.h:65
@ FTP_CODE_532_NEED_ACCOUNT
Need account for storing files.
Definition ftp_client.h:170
@ FTP_CODE_125_DATA_CONN_ALREADY_OPEN
Data connection already open; transfer starting.
Definition ftp_client.h:58
@ FTP_CODE_903_SOCKET_POLL_ERROR
Socket poll error.
Definition ftp_client.h:206
@ FTP_CODE_110_RESTART_MARKER_REPLAY
Restart marker replay.
Definition ftp_client.h:54
@ FTP_CODE_452_ACTION_NOT_TAKEN
Requested action not taken.
Definition ftp_client.h:150
@ FTP_CODE_503_BAD_SEQUENCE_OF_COMMANDS
Bad sequence of commands.
Definition ftp_client.h:164
@ FTP_CODE_202_NOT_IMPLEMENTED
Command not implemented, superfluous at this site.
Definition ftp_client.h:67
@ FTP_CODE_902_CONNECTION_ABORTED
Connection aborted.
Definition ftp_client.h:204
@ FTP_CODE_10060_CANNOT_CONNECT
Cannot connect to remote server.
Definition ftp_client.h:227
@ FTP_CODE_430_INVALID_USERNAME_OR_PASSWORD
Invalid username or password.
Definition ftp_client.h:140
@ FTP_CODE_150_FILE_STATUS_OK
File status okay; about to open data connection.
Definition ftp_client.h:60
@ FTP_CODE_501_SYNTAX_ERROR
Syntax error in parameters or arguments.
Definition ftp_client.h:160
@ FTP_CODE_215_NAME_SYSTEM_TYPE
NAME system type.
Definition ftp_client.h:82
@ FTP_CODE_10061_CONNECTION_REFUSED
Cannot connect to remote server.
Definition ftp_client.h:231
@ FTP_CODE_904_UNEXPECTED_POLL_EVENT
Unexpected poll event.
Definition ftp_client.h:208
@ FTP_CODE_552_FILE_EXCEEDED_STORAGE_LOCATION
Requested file action aborted.
Definition ftp_client.h:182
@ FTP_CODE_257_PATHNAME_CREATED
"PATHNAME" created
Definition ftp_client.h:113
@ FTP_CODE_901_DISCONNECTED_BY_REMOTE
Fatal errors.
Definition ftp_client.h:202
@ FTP_CODE_530_NOT_LOGGED_IN
Not logged in.
Definition ftp_client.h:168
@ FTP_CODE_434_HOST_UNAVAILABLE
Requested host unavailable.
Definition ftp_client.h:142
@ FTP_CODE_221_SERVICE_CLOSING_CONN
Service closing control connection.
Definition ftp_client.h:86
@ FTP_CODE_450_FILE_ACTION_NOT_TAKEN
Requested file action not taken.
Definition ftp_client.h:144
@ FTP_CODE_421_SERVICE_UNAVAILABLE
Service not available, closing control connection.
Definition ftp_client.h:134
@ FTP_CODE_10068_TOO_MANY_USERS
Too many users, server is full.
Definition ftp_client.h:235
@ FTP_CODE_631_INTEGRITY_PROTECTED_REPLY
Integrity protected reply.
Definition ftp_client.h:189
@ FTP_CODE_909_UNEXPECTED_ERROR
Unexpected error.
Definition ftp_client.h:212
@ FTP_CODE_632_INT_AND_CONF_PROTECTED_REPLY
Confidentiality and integrity protected reply.
Definition ftp_client.h:191
@ FTP_TYPE_BINARY
Binary transfer.
Definition ftp_client.h:252
@ FTP_TYPE_ASCII
ASCII transfer.
Definition ftp_client.h:251
@ FTP_PUT_NORMAL
Overwrite a file.
Definition ftp_client.h:257
@ FTP_PUT_APPEND
Append a file.
Definition ftp_client.h:259
@ FTP_PUT_UNIQUE
Write to a file with a unique file name.
Definition ftp_client.h:258
IPv6 and IPv4 definitions.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
FTP client context.
Definition ftp_client.h:271
int data_sock
Data socket.
Definition ftp_client.h:275
int sec_tag
Secure tag.
Definition ftp_client.h:276
ftp_client_callback_t ctrl_callback
Control callback.
Definition ftp_client.h:280
ftp_client_callback_t data_callback
Data callback.
Definition ftp_client.h:281
struct net_sockaddr remote
Server address.
Definition ftp_client.h:272
uint8_t data_buf[FTP_BUFFER_SIZE]
Data buffer.
Definition ftp_client.h:279
uint8_t ctrl_buf[FTP_BUFFER_SIZE]
Control buffer.
Definition ftp_client.h:277
bool connected
Server connected flag.
Definition ftp_client.h:273
int ctrl_sock
Control socket.
Definition ftp_client.h:274
size_t ctrl_len
Length of data in the control buffer.
Definition ftp_client.h:278
Mutex Structure.
Definition kernel.h:3402
A structure used to submit work after a delay.
Definition kernel.h:4531
Generic sockaddr struct.
Definition net_ip.h:408