Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ftp.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright 2026 NXP
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
11
12#ifndef ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_FTP_H_
13#define ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_FTP_H_
14
23
24#include <zephyr/kernel.h>
25#include <errno.h>
26#include <stdbool.h>
27
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
42#define BT_FTP_UUID \
43 (const struct bt_uuid_128 *)BT_UUID_DECLARE_128( \
44 BT_UUID_128_ENCODE(0xf9ec7bc4, 0x953c, 0x11d2, 0x984e, 0x525400dc9e09))
45
47#define BT_FTP_FOLDER_LISTING_TYPE "x-obex/folder-listing"
48
63
90
91/* Forward declarations. */
92struct bt_ftp_client;
93struct bt_ftp_server;
94
100
115 void (*rfcomm_connected)(struct bt_conn *conn, struct bt_ftp_client *client);
116
130 void (*rfcomm_disconnected)(struct bt_ftp_client *client);
131
140 void (*l2cap_connected)(struct bt_conn *conn, struct bt_ftp_client *client);
141
155 void (*l2cap_disconnected)(struct bt_ftp_client *client);
156
168 void (*connect)(struct bt_ftp_client *client, uint8_t rsp_code, uint8_t version,
169 uint16_t mopl, struct net_buf *buf);
170
179 void (*disconnect)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
180
190 void (*abort)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
191
200 void (*set_folder)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
201
212 void (*pull_folder_listing)(struct bt_ftp_client *client, uint8_t rsp_code,
213 struct net_buf *buf);
214
225 void (*push_file)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
226
237 void (*pull_file)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
238
248 void (*remove)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
249
258 void (*rename)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
259
268 void (*copy)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
269
278 void (*set_permission)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
279};
280
291 const struct bt_ftp_client_cb *_cb;
292
294 struct bt_goep_transport _goep_transport;
295
297 struct bt_goep _goep;
298
300 uint32_t _conn_id;
301
303 struct bt_obex_client _client;
304
306 void (*_rsp_cb)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf);
307
309 atomic_t _optype;
310};
311
333int bt_ftp_client_rfcomm_connect(struct bt_conn *conn, struct bt_ftp_client *client,
334 const struct bt_ftp_client_cb *cb, uint8_t channel);
335
350
372int bt_ftp_client_l2cap_connect(struct bt_conn *conn, struct bt_ftp_client *client,
373 const struct bt_ftp_client_cb *cb, uint16_t psm);
374
389
414int bt_ftp_client_connect(struct bt_ftp_client *client, struct net_buf *buf);
415
437int bt_ftp_client_disconnect(struct bt_ftp_client *client, struct net_buf *buf);
438
460int bt_ftp_client_abort(struct bt_ftp_client *client, struct net_buf *buf);
461
499
526 struct net_buf *buf);
527
556int bt_ftp_client_push_file(struct bt_ftp_client *client, bool final, struct net_buf *buf);
557
583int bt_ftp_client_pull_file(struct bt_ftp_client *client, bool final, struct net_buf *buf);
584
607int bt_ftp_client_remove(struct bt_ftp_client *client, struct net_buf *buf);
608
635int bt_ftp_client_rename(struct bt_ftp_client *client, struct net_buf *buf);
636
662int bt_ftp_client_copy(struct bt_ftp_client *client, struct net_buf *buf);
663
689int bt_ftp_client_set_permission(struct bt_ftp_client *client, struct net_buf *buf);
690
704struct net_buf *bt_ftp_client_create_pdu(struct bt_ftp_client *client, struct net_buf_pool *pool);
705 /* bt_ftp_client */
707
713
737 void (*rfcomm_connected)(struct bt_conn *conn, struct bt_ftp_server *server);
738
746 void (*rfcomm_disconnected)(struct bt_ftp_server *server);
747
756 void (*l2cap_connected)(struct bt_conn *conn, struct bt_ftp_server *server);
757
765 void (*l2cap_disconnected)(struct bt_ftp_server *server);
766
777 void (*connect)(struct bt_ftp_server *server, uint8_t version, uint16_t mopl,
778 struct net_buf *buf);
779
788 void (*disconnect)(struct bt_ftp_server *server, struct net_buf *buf);
789
799 void (*abort)(struct bt_ftp_server *server, struct net_buf *buf);
800
824 void (*set_folder)(struct bt_ftp_server *server, uint8_t flags, struct net_buf *buf);
825
836 void (*pull_folder_listing)(struct bt_ftp_server *server, bool final, struct net_buf *buf);
837
849 void (*push_file)(struct bt_ftp_server *server, bool final, struct net_buf *buf);
850
861 void (*pull_file)(struct bt_ftp_server *server, bool final, struct net_buf *buf);
862
873 void (*remove)(struct bt_ftp_server *server, struct net_buf *buf);
874
886 void (*rename)(struct bt_ftp_server *server, struct net_buf *buf);
887
899 void (*copy)(struct bt_ftp_server *server, struct net_buf *buf);
900
912 void (*set_permission)(struct bt_ftp_server *server, struct net_buf *buf);
913};
914
922 const struct bt_ftp_server_cb *_cb;
923
925 struct bt_goep_transport _goep_transport;
926
928 struct bt_goep _goep;
929
931 uint32_t _conn_id;
932
934 struct bt_obex_server _server;
935
944 void (*_req_cb)(struct bt_ftp_server *server, bool final, struct net_buf *buf);
945
947 atomic_t _optype;
948};
949
954
972 int (*accept)(struct bt_conn *conn, struct bt_ftp_server_rfcomm *ftp_server_rfcomm,
973 struct bt_ftp_server **ftp_server);
974};
975
980
997 int (*accept)(struct bt_conn *conn, struct bt_ftp_server_l2cap *ftp_server_l2cap,
998 struct bt_ftp_server **ftp_server);
999};
1000
1024int bt_ftp_server_register(struct bt_ftp_server *server, const struct bt_ftp_server_cb *cb);
1025
1047
1069
1084
1099
1120int bt_ftp_server_connect(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1121
1137int bt_ftp_server_disconnect(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1138
1154int bt_ftp_server_abort(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1155
1171int bt_ftp_server_set_folder(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1172
1192 struct net_buf *buf);
1193
1212int bt_ftp_server_push_file(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1213
1232int bt_ftp_server_pull_file(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1233
1249int bt_ftp_server_remove(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1250
1266int bt_ftp_server_rename(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1267
1283int bt_ftp_server_copy(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf);
1284
1301 struct net_buf *buf);
1302
1316struct net_buf *bt_ftp_server_create_pdu(struct bt_ftp_server *server, struct net_buf_pool *pool);
1317 /* bt_ftp_server */
1319
1320#ifdef __cplusplus
1321}
1322#endif
1323
1327
1328#endif /* ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_FTP_H_ */
Bluetooth subsystem core APIs.
Bluetooth UUID handling.
Bluetooth connection handling.
System error numbers.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:34
int bt_ftp_client_abort(struct bt_ftp_client *client, struct net_buf *buf)
Send an OBEX ABORT request to the FTP server.
int bt_ftp_client_rename(struct bt_ftp_client *client, struct net_buf *buf)
Send a RENAME/MOVE action request to the FTP server.
int bt_ftp_client_disconnect(struct bt_ftp_client *client, struct net_buf *buf)
Send an OBEX DISCONNECT request to the FTP server.
int bt_ftp_client_rfcomm_connect(struct bt_conn *conn, struct bt_ftp_client *client, const struct bt_ftp_client_cb *cb, uint8_t channel)
Connect FTP client over RFCOMM (GOEP v1.1).
int bt_ftp_client_pull_file(struct bt_ftp_client *client, bool final, struct net_buf *buf)
Send a GET request to pull a file from the FTP server.
struct net_buf * bt_ftp_client_create_pdu(struct bt_ftp_client *client, struct net_buf_pool *pool)
Allocate a PDU buffer for an FTP client operation.
int bt_ftp_client_rfcomm_disconnect(struct bt_ftp_client *client)
Disconnect FTP client RFCOMM transport.
int bt_ftp_client_pull_folder_listing(struct bt_ftp_client *client, bool final, struct net_buf *buf)
Send a GET folder listing request to the FTP server.
int bt_ftp_client_l2cap_disconnect(struct bt_ftp_client *client)
Disconnect FTP client L2CAP transport.
int bt_ftp_client_connect(struct bt_ftp_client *client, struct net_buf *buf)
Send an OBEX CONNECT request to the FTP server.
int bt_ftp_client_copy(struct bt_ftp_client *client, struct net_buf *buf)
Send a COPY action request to the FTP server.
int bt_ftp_client_remove(struct bt_ftp_client *client, struct net_buf *buf)
Send a remove request to the FTP server.
int bt_ftp_client_push_file(struct bt_ftp_client *client, bool final, struct net_buf *buf)
Send a PUT request to push a file to the FTP server.
int bt_ftp_client_set_folder(struct bt_ftp_client *client, uint8_t flags, struct net_buf *buf)
Send a SetPath (set folder) request to the FTP server.
int bt_ftp_client_set_permission(struct bt_ftp_client *client, struct net_buf *buf)
Send a SET PERMISSIONS action request to the FTP server.
int bt_ftp_client_l2cap_connect(struct bt_conn *conn, struct bt_ftp_client *client, const struct bt_ftp_client_cb *cb, uint16_t psm)
Connect FTP client over L2CAP (GOEP v2).
int bt_ftp_server_l2cap_disconnect(struct bt_ftp_server *server)
Disconnect the FTP server L2CAP transport.
int bt_ftp_server_copy(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send a copy response from the FTP server.
struct net_buf * bt_ftp_server_create_pdu(struct bt_ftp_server *server, struct net_buf_pool *pool)
Allocate a PDU buffer for an FTP server response.
int bt_ftp_server_remove(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send a remove response from the FTP server.
int bt_ftp_server_set_folder(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send a set folder response from the FTP server.
int bt_ftp_server_disconnect(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send an OBEX DISCONNECT response from the FTP server.
int bt_ftp_server_abort(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send an OBEX ABORT response from the FTP server.
int bt_ftp_server_set_permission(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send a set permission response from the FTP server.
int bt_ftp_server_pull_folder_listing(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send a pull folder listing response from the FTP server.
int bt_ftp_server_pull_file(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send a pull file response from the FTP server.
int bt_ftp_server_register(struct bt_ftp_server *server, const struct bt_ftp_server_cb *cb)
Register an FTP server instance with the OBEX layer.
int bt_ftp_server_connect(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send an OBEX CONNECT response from the FTP server.
int bt_ftp_server_push_file(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send a push file response from the FTP server.
int bt_ftp_server_rfcomm_register(struct bt_ftp_server_rfcomm *server)
Register an FTP RFCOMM server.
int bt_ftp_server_rfcomm_disconnect(struct bt_ftp_server *server)
Disconnect the FTP server RFCOMM transport.
int bt_ftp_server_l2cap_register(struct bt_ftp_server_l2cap *server)
Register an FTP L2CAP server.
int bt_ftp_server_rename(struct bt_ftp_server *server, uint8_t rsp_code, struct net_buf *buf)
Send a rename/move response from the FTP server.
bt_ftp_rsp_code
FTP response codes.
Definition ftp.h:68
bt_ftp_set_folder_flags
FTP set folder operation flags.
Definition ftp.h:53
@ BT_FTP_RSP_CODE_PRECON_FAIL
Precondition failed.
Definition ftp.h:84
@ BT_FTP_RSP_CODE_NOT_IMPL
Not implemented.
Definition ftp.h:86
@ BT_FTP_RSP_CODE_NOT_ACCEPT
Not acceptable.
Definition ftp.h:82
@ BT_FTP_RSP_CODE_UNAVAIL
Service unavailable.
Definition ftp.h:88
@ BT_FTP_RSP_CODE_CONTINUE
Continue - more data to follow.
Definition ftp.h:70
@ BT_FTP_RSP_CODE_UNAUTH
Unauthorized.
Definition ftp.h:76
@ BT_FTP_RSP_CODE_FORBIDDEN
Forbidden - operation understood but refused.
Definition ftp.h:78
@ BT_FTP_RSP_CODE_BAD_REQ
Bad request.
Definition ftp.h:74
@ BT_FTP_RSP_CODE_SUCCESS
Success.
Definition ftp.h:72
@ BT_FTP_RSP_CODE_NOT_FOUND
Not found.
Definition ftp.h:80
@ BT_FTP_SET_FOLDER_FLAGS_ROOT
Navigate to root folder.
Definition ftp.h:55
@ BT_FTP_SET_FOLDER_FLAGS_UP
Navigate up to parent folder.
Definition ftp.h:59
@ BT_FTP_SET_FOLDER_FLAGS_DOWN
Navigate down to child folder.
Definition ftp.h:57
@ BT_FTP_SET_FOLDER_FLAGS_NEW
Create a new folder.
Definition ftp.h:61
@ BT_OBEX_RSP_CODE_NOT_FOUND
Not Found.
Definition obex.h:73
@ BT_OBEX_RSP_CODE_BAD_REQ
Bad Request - server couldn’t understand request.
Definition obex.h:65
@ BT_OBEX_RSP_CODE_NOT_ACCEPT
Not Acceptable.
Definition obex.h:77
@ BT_OBEX_RSP_CODE_FORBIDDEN
Forbidden - operation is understood but refused.
Definition obex.h:71
@ BT_OBEX_RSP_CODE_UNAVAIL
Service Unavailable.
Definition obex.h:103
@ BT_OBEX_RSP_CODE_CONTINUE
Continue.
Definition obex.h:35
@ BT_OBEX_RSP_CODE_PRECON_FAIL
Precondition Failed.
Definition obex.h:89
@ BT_OBEX_RSP_CODE_NOT_IMPL
Not Implemented.
Definition obex.h:99
@ BT_OBEX_RSP_CODE_UNAUTH
Unauthorized.
Definition obex.h:67
@ BT_OBEX_RSP_CODE_SUCCESS
Success.
Definition obex.h:39
@ BT_OBEX_SETPATH_FLAG_BACKUP
Backup a level before applying name (equivalent to ../ on many systems).
Definition obex.h:893
@ BT_OBEX_SETPATH_FLAG_NO_CREATE
Don't create folder if it does not exist, return an error instead.
Definition obex.h:895
Public kernel APIs.
Bluetooth L2CAP handling.
flags
Definition parser.h:86
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Opaque type representing a connection to a remote device.
FTP client callback structure.
Definition ftp.h:106
void(* l2cap_disconnected)(struct bt_ftp_client *client)
L2CAP transport disconnected callback.
Definition ftp.h:155
void(* push_file)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
Push file response callback.
Definition ftp.h:225
void(* rename)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
Rename/Move response callback.
Definition ftp.h:258
void(* pull_file)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
Pull file response callback.
Definition ftp.h:237
void(* disconnect)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
OBEX disconnect response callback.
Definition ftp.h:179
void(* set_permission)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
Set permission response callback.
Definition ftp.h:278
void(* copy)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
Copy response callback.
Definition ftp.h:268
void(* abort)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
OBEX ABORT response callback.
Definition ftp.h:190
void(* pull_folder_listing)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
Pull folder listing response callback.
Definition ftp.h:212
void(* l2cap_connected)(struct bt_conn *conn, struct bt_ftp_client *client)
L2CAP transport connected callback.
Definition ftp.h:140
void(* rfcomm_disconnected)(struct bt_ftp_client *client)
RFCOMM transport disconnected callback.
Definition ftp.h:130
void(* set_folder)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
Set folder response callback.
Definition ftp.h:200
void(* rfcomm_connected)(struct bt_conn *conn, struct bt_ftp_client *client)
RFCOMM transport connected callback.
Definition ftp.h:115
void(* connect)(struct bt_ftp_client *client, uint8_t rsp_code, uint8_t version, uint16_t mopl, struct net_buf *buf)
OBEX connect response callback.
Definition ftp.h:168
void(* remove)(struct bt_ftp_client *client, uint8_t rsp_code, struct net_buf *buf)
Remove response callback.
Definition ftp.h:248
FTP client structure.
Definition ftp.h:287
FTP server callback structure.
Definition ftp.h:728
void(* rfcomm_connected)(struct bt_conn *conn, struct bt_ftp_server *server)
RFCOMM transport connected callback.
Definition ftp.h:737
void(* disconnect)(struct bt_ftp_server *server, struct net_buf *buf)
OBEX DISCONNECT request callback.
Definition ftp.h:788
void(* pull_folder_listing)(struct bt_ftp_server *server, bool final, struct net_buf *buf)
Pull folder listing request callback.
Definition ftp.h:836
void(* l2cap_disconnected)(struct bt_ftp_server *server)
L2CAP transport disconnected callback.
Definition ftp.h:765
void(* rfcomm_disconnected)(struct bt_ftp_server *server)
RFCOMM transport disconnected callback.
Definition ftp.h:746
void(* remove)(struct bt_ftp_server *server, struct net_buf *buf)
Remove request callback.
Definition ftp.h:873
void(* rename)(struct bt_ftp_server *server, struct net_buf *buf)
Rename/Move action request callback.
Definition ftp.h:886
void(* set_folder)(struct bt_ftp_server *server, uint8_t flags, struct net_buf *buf)
Set folder request callback.
Definition ftp.h:824
void(* abort)(struct bt_ftp_server *server, struct net_buf *buf)
OBEX ABORT request callback.
Definition ftp.h:799
void(* pull_file)(struct bt_ftp_server *server, bool final, struct net_buf *buf)
Pull file request callback.
Definition ftp.h:861
void(* set_permission)(struct bt_ftp_server *server, struct net_buf *buf)
Set permission action request callback.
Definition ftp.h:912
void(* connect)(struct bt_ftp_server *server, uint8_t version, uint16_t mopl, struct net_buf *buf)
OBEX CONNECT request callback.
Definition ftp.h:777
void(* copy)(struct bt_ftp_server *server, struct net_buf *buf)
Copy action request callback.
Definition ftp.h:899
void(* push_file)(struct bt_ftp_server *server, bool final, struct net_buf *buf)
Push file request callback.
Definition ftp.h:849
void(* l2cap_connected)(struct bt_conn *conn, struct bt_ftp_server *server)
L2CAP transport connected callback.
Definition ftp.h:756
FTP server L2CAP registration structure.
Definition ftp.h:977
int(* accept)(struct bt_conn *conn, struct bt_ftp_server_l2cap *ftp_server_l2cap, struct bt_ftp_server **ftp_server)
Accept connection callback.
Definition ftp.h:997
struct bt_goep_transport_l2cap_server server
Underlying GOEP L2CAP server.
Definition ftp.h:979
FTP server RFCOMM registration structure.
Definition ftp.h:951
struct bt_goep_transport_rfcomm_server server
Underlying GOEP RFCOMM server.
Definition ftp.h:953
int(* accept)(struct bt_conn *conn, struct bt_ftp_server_rfcomm *ftp_server_rfcomm, struct bt_ftp_server **ftp_server)
Accept connection callback.
Definition ftp.h:972
FTP server structure.
Definition ftp.h:920
GOEP Server structure for GOEP v2.0 and later.
Definition goep.h:345
GOEP Server structure GOEP v1.1.
Definition goep.h:225
GOEP transport unified structure.
Definition goep.h:92
GOEP structure.
Definition goep.h:138
OBEX client structure.
Definition obex.h:538
OBEX server structure.
Definition obex.h:492
Network buffer pool representation.
Definition net_buf.h:1199
Network buffer representation.
Definition net_buf.h:1062