nRF Connect SDK API 2.8.99
Loading...
Searching...
No Matches
ftp_client.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
16#ifndef FTP_CLIENT_
17#define FTP_CLIENT_
18
19#include <zephyr/kernel.h>
20#include <zephyr/types.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
31 /* 100 Series The requested action is being initiated, expect another
32 * reply before proceeding with a new command
33 */
34
47
48 /* 200 Series The requested action has been successfully completed */
49
100
101 /* 300 Series The command has been accepted, but the requested action
102 *is on hold, pending receipt of further information
103 */
104
111
112 /* 400 Series The command was not accepted and the requested action
113 * did not take place, but the error condition is temporary and the
114 * action may be requested again
115 */
116
137
138 /* 500 Series Syntax error, command unrecognized and the requested
139 * action did not take place. This may include errors such as command
140 * line too long
141 */
142
171
172 /* Replies regarding confidentiality and integrity */
173
180
181 /* Nordic proprietary reply codes */
182
185
199
200 /* Non-fatal errors */
203
204 /* 10000 Series Common Winsock Error Codes[2] (These are not FTP
205 * return codes)
206 */
207
221 FTP_CODE_10068 = 10068
223
224#define FTP_PRELIMINARY_POS(code) (code > 100 && code < 200)
225#define FTP_COMPLETION_POS(code) (code > 200 && code < 300)
226#define FTP_INTERMEDIATE_POS(code) (code > 300 && code < 400)
227#define FTP_TRANSIENT_NEG(code) (code > 400 && code < 500)
228#define FTP_COMPLETION_NEG(code) (code > 500 && code < 600)
229#define FTP_PROTECTED(code) (code > 600 && code < 700)
230#define FTP_PROPRIETARY(code) (code > 900 && code < 1000)
231#define FTP_WINSOCK_ERR(code) (code > 10000)
232
237
243
250typedef void (*ftp_client_callback_t)(const uint8_t *msg, uint16_t len);
251
260int ftp_init(ftp_client_callback_t ctrl_callback, ftp_client_callback_t data_callback);
261
267int ftp_uninit(void);
268
277int ftp_open(const char *hostname, uint16_t port, int sec_tag);
278
286int ftp_login(const char *username, const char *password);
287
292int ftp_close(void);
293
299int ftp_status(void);
300
308
313int ftp_pwd(void);
314
322int ftp_list(const char *options, const char *target);
323
330int ftp_cwd(const char *folder);
331
338int ftp_mkd(const char *folder);
339
346int ftp_rmd(const char *folder);
347
355int ftp_rename(const char *old_name, const char *new_name);
356
363int ftp_delete(const char *file);
364
371int ftp_get(const char *file);
372
383int ftp_put(const char *file, const uint8_t *data, uint16_t length, int type);
384
385#ifdef __cplusplus
386}
387#endif
388
389#endif /* FTP_CLIENT_ */
390
ftp_reply_code
List of FTP server reply codes Reference RFC959 FTP Transfer Protocol.
Definition ftp_client.h:30
@ FTP_CODE_532
Definition ftp_client.h:156
@ FTP_CODE_332
Definition ftp_client.h:108
@ FTP_CODE_211
Definition ftp_client.h:55
@ FTP_CODE_909
Definition ftp_client.h:198
@ FTP_CODE_150
Definition ftp_client.h:46
@ FTP_CODE_910
Definition ftp_client.h:202
@ FTP_CODE_552
Definition ftp_client.h:168
@ FTP_CODE_331
Definition ftp_client.h:106
@ FTP_CODE_120
Definition ftp_client.h:42
@ FTP_CODE_226
Definition ftp_client.h:78
@ FTP_CODE_214
Definition ftp_client.h:64
@ FTP_CODE_900
Definition ftp_client.h:184
@ FTP_CODE_632
Definition ftp_client.h:177
@ FTP_CODE_550
Definition ftp_client.h:162
@ FTP_CODE_227
Definition ftp_client.h:80
@ FTP_CODE_220
Definition ftp_client.h:70
@ FTP_CODE_426
Definition ftp_client.h:124
@ FTP_CODE_10060
Definition ftp_client.h:213
@ FTP_CODE_503
Definition ftp_client.h:150
@ FTP_CODE_233
Definition ftp_client.h:90
@ FTP_CODE_110
Definition ftp_client.h:40
@ FTP_CODE_452
Definition ftp_client.h:136
@ FTP_CODE_633
Definition ftp_client.h:179
@ FTP_CODE_212
Definition ftp_client.h:57
@ FTP_CODE_430
Definition ftp_client.h:126
@ FTP_CODE_631
Definition ftp_client.h:175
@ FTP_CODE_504
Definition ftp_client.h:152
@ FTP_CODE_200
Definition ftp_client.h:51
@ FTP_CODE_350
Definition ftp_client.h:110
@ FTP_CODE_500
Definition ftp_client.h:144
@ FTP_CODE_229
Definition ftp_client.h:84
@ FTP_CODE_904
Definition ftp_client.h:194
@ FTP_CODE_10066
Definition ftp_client.h:219
@ FTP_CODE_902
Definition ftp_client.h:190
@ FTP_CODE_425
Definition ftp_client.h:122
@ FTP_CODE_551
Definition ftp_client.h:164
@ FTP_CODE_501
Definition ftp_client.h:146
@ FTP_CODE_502
Definition ftp_client.h:148
@ FTP_CODE_250
Definition ftp_client.h:97
@ FTP_CODE_553
Definition ftp_client.h:170
@ FTP_CODE_10054
Definition ftp_client.h:211
@ FTP_CODE_421
Definition ftp_client.h:120
@ FTP_CODE_225
Definition ftp_client.h:74
@ FTP_CODE_451
Definition ftp_client.h:132
@ FTP_CODE_231
Definition ftp_client.h:88
@ FTP_CODE_905
Definition ftp_client.h:196
@ FTP_CODE_221
Definition ftp_client.h:72
@ FTP_CODE_228
Definition ftp_client.h:82
@ FTP_CODE_202
Definition ftp_client.h:53
@ FTP_CODE_901
Definition ftp_client.h:188
@ FTP_CODE_10061
Definition ftp_client.h:217
@ FTP_CODE_213
Definition ftp_client.h:59
@ FTP_CODE_534
Definition ftp_client.h:158
@ FTP_CODE_903
Definition ftp_client.h:192
@ FTP_CODE_215
Definition ftp_client.h:68
@ FTP_CODE_257
Definition ftp_client.h:99
@ FTP_CODE_434
Definition ftp_client.h:128
@ FTP_CODE_230
Definition ftp_client.h:86
@ FTP_CODE_530
Definition ftp_client.h:154
@ FTP_CODE_10068
Definition ftp_client.h:221
@ FTP_CODE_234
Definition ftp_client.h:95
@ FTP_CODE_450
Definition ftp_client.h:130
@ FTP_CODE_125
Definition ftp_client.h:44
int ftp_status(void)
Get FTP server and connection status Also returns server system type.
ftp_trasfer_type
Definition ftp_client.h:233
@ FTP_TYPE_BINARY
Definition ftp_client.h:235
@ FTP_TYPE_ASCII
Definition ftp_client.h:234
int ftp_put(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_close(void)
Close FTP connection.
void(* ftp_client_callback_t)(const uint8_t *msg, uint16_t len)
FTP asynchronous callback function.
Definition ftp_client.h:250
int ftp_rmd(const char *folder)
Remove directory.
int ftp_list(const char *options, const char *target)
List information of folder or file.
int ftp_mkd(const char *folder)
Make directory.
int ftp_rename(const char *old_name, const char *new_name)
Rename a file.
int ftp_pwd(void)
Print working directory.
int ftp_login(const char *username, const char *password)
FTP server login.
int ftp_get(const char *file)
Get a file.
int ftp_delete(const char *file)
Delete a file.
int ftp_type(enum ftp_trasfer_type type)
Set FTP transfer type.
int ftp_init(ftp_client_callback_t ctrl_callback, ftp_client_callback_t data_callback)
Initialize the FTP client library.
int ftp_cwd(const char *folder)
Change working directory.
int ftp_uninit(void)
Uninitialize the FTP client library.
ftp_put_type
Definition ftp_client.h:238
@ FTP_PUT_NORMAL
Definition ftp_client.h:239
@ FTP_PUT_APPEND
Definition ftp_client.h:241
@ FTP_PUT_UNIQUE
Definition ftp_client.h:240
int ftp_open(const char *hostname, uint16_t port, int sec_tag)
Open FTP connection.