Line data Source code
1 0 : /* obex.h - IrDA Oject Exchange Protocol handling */
2 :
3 : /*
4 : * Copyright 2024-2025 NXP
5 : *
6 : * SPDX-License-Identifier: Apache-2.0
7 : */
8 :
9 : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_OBEX_H_
10 : #define ZEPHYR_INCLUDE_BLUETOOTH_OBEX_H_
11 :
12 : /**
13 : * @brief IrDA Oject Exchange Protocol (OBEX)
14 : * @defgroup bt_obex IrDA Oject Exchange Protocol (OBEX)
15 : * @ingroup bluetooth
16 : * @{
17 : */
18 :
19 : #include <zephyr/kernel.h>
20 : #include <string.h>
21 : #include <errno.h>
22 : #include <stdbool.h>
23 :
24 : #ifdef __cplusplus
25 : extern "C" {
26 : #endif
27 :
28 : /** @brief OBEX Response Code. */
29 1 : enum __packed bt_obex_rsp_code {
30 : /** Continue */
31 : BT_OBEX_RSP_CODE_CONTINUE = 0x90,
32 : /** OK */
33 : BT_OBEX_RSP_CODE_OK = 0xa0,
34 : /** Success */
35 : BT_OBEX_RSP_CODE_SUCCESS = 0xa0,
36 : /** Created */
37 : BT_OBEX_RSP_CODE_CREATED = 0xa1,
38 : /** Accepted */
39 : BT_OBEX_RSP_CODE_ACCEPTED = 0xa2,
40 : /** Non-Authoritative Information */
41 : BT_OBEX_RSP_CODE_NON_AUTH_INFO = 0xa3,
42 : /** No Content */
43 : BT_OBEX_RSP_CODE_NO_CONTENT = 0xa4,
44 : /** Reset Content */
45 : BT_OBEX_RSP_CODE_RESET_CONTENT = 0xa5,
46 : /** Partial Content */
47 : BT_OBEX_RSP_CODE_PARTIAL_CONTENT = 0xa6,
48 : /** Multiple Choices */
49 : BT_OBEX_RSP_CODE_MULTI_CHOICES = 0xb0,
50 : /** Moved Permanently */
51 : BT_OBEX_RSP_CODE_MOVED_PERM = 0xb1,
52 : /** Moved temporarily */
53 : BT_OBEX_RSP_CODE_MOVED_TEMP = 0xb2,
54 : /** See Other */
55 : BT_OBEX_RSP_CODE_SEE_OTHER = 0xb3,
56 : /** Not modified */
57 : BT_OBEX_RSP_CODE_NOT_MODIFIED = 0xb4,
58 : /** Use Proxy */
59 : BT_OBEX_RSP_CODE_USE_PROXY = 0xb5,
60 : /** Bad Request - server couldn’t understand request */
61 : BT_OBEX_RSP_CODE_BAD_REQ = 0xc0,
62 : /** Unauthorized */
63 : BT_OBEX_RSP_CODE_UNAUTH = 0xc1,
64 : /** Payment Required */
65 : BT_OBEX_RSP_CODE_PAY_REQ = 0xc2,
66 : /** Forbidden - operation is understood but refused */
67 : BT_OBEX_RSP_CODE_FORBIDDEN = 0xc3,
68 : /** Not Found */
69 : BT_OBEX_RSP_CODE_NOT_FOUND = 0xc4,
70 : /** Method Not Allowed */
71 : BT_OBEX_RSP_CODE_NOT_ALLOW = 0xc5,
72 : /** Not Acceptable */
73 : BT_OBEX_RSP_CODE_NOT_ACCEPT = 0xc6,
74 : /** Proxy Authentication Required */
75 : BT_OBEX_RSP_CODE_PROXY_AUTH_REQ = 0xc7,
76 : /** Request Time Out */
77 : BT_OBEX_RSP_CODE_REQ_TIMEOUT = 0xc8,
78 : /** Conflict */
79 : BT_OBEX_RSP_CODE_CONFLICT = 0xc9,
80 : /** Gone */
81 : BT_OBEX_RSP_CODE_GONE = 0xca,
82 : /** Length Required */
83 : BT_OBEX_RSP_CODE_LEN_REQ = 0xcb,
84 : /** Precondition Failed */
85 : BT_OBEX_RSP_CODE_PRECON_FAIL = 0xcc,
86 : /** Requested Entity Too Large */
87 : BT_OBEX_RSP_CODE_ENTITY_TOO_LARGE = 0xcd,
88 : /** Requested URL Too Large */
89 : BT_OBEX_RSP_CODE_URL_TOO_LARGE = 0xce,
90 : /** Unsupported media type */
91 : BT_OBEX_RSP_CODE_UNSUPP_MEDIA_TYPE = 0xcf,
92 : /** Internal serve Error */
93 : BT_OBEX_RSP_CODE_INTER_ERROR = 0xd0,
94 : /** Not Implemented */
95 : BT_OBEX_RSP_CODE_NOT_IMPL = 0xd1,
96 : /** Bad Gateway */
97 : BT_OBEX_RSP_CODE_BAD_GATEWAY = 0xd2,
98 : /** Service Unavailable */
99 : BT_OBEX_RSP_CODE_UNAVAIL = 0xd3,
100 : /** Gateway Timeout */
101 : BT_OBEX_RSP_CODE_GATEWAY_TIMEOUT = 0xd4,
102 : /** HTTP Version not supported */
103 : BT_OBEX_RSP_CODE_VER_UNSUPP = 0xd5,
104 : /** Database Full */
105 : BT_OBEX_RSP_CODE_DB_FULL = 0xe0,
106 : /** Database Locked */
107 : BT_OBEX_RSP_CODE_DB_LOCK = 0xe1,
108 : };
109 :
110 : /** Converts a OBEX response code to string.
111 : *
112 : * @param rsp_code Response code.
113 : *
114 : * @return The string representation of the response code.
115 : * If @kconfig{CONFIG_BT_OEBX_RSP_CODE_TO_STR} is not enabled,
116 : * this just returns the empty string.
117 : */
118 : #if defined(CONFIG_BT_OEBX_RSP_CODE_TO_STR)
119 : const char *bt_obex_rsp_code_to_str(enum bt_obex_rsp_code rsp_code);
120 : #else
121 1 : static inline const char *bt_obex_rsp_code_to_str(enum bt_obex_rsp_code rsp_code)
122 : {
123 : ARG_UNUSED(rsp_code);
124 :
125 : return "";
126 : }
127 : #endif /* CONFIG_BT_OEBX_RSP_CODE_TO_STR */
128 :
129 : /** @brief OBEX Header ID */
130 1 : enum __packed bt_obex_header_id {
131 : /** Number of objects (used by Connect) */
132 : BT_OBEX_HEADER_ID_COUNT = 0xC0,
133 :
134 : /** Name of the object (often a file name) */
135 : BT_OBEX_HEADER_ID_NAME = 0x01,
136 :
137 : /** Type of object - e.g. text, html, binary, manufacturer specific */
138 : BT_OBEX_HEADER_ID_TYPE = 0x42,
139 :
140 : /** The length of the object in bytes */
141 : BT_OBEX_HEADER_ID_LEN = 0xC3,
142 :
143 : /** Date/time stamp – ISO 8601 version - preferred */
144 : BT_OBEX_HEADER_ID_TIME_ISO_8601 = 0x44,
145 :
146 : /** Date/time stamp – 4 byte version (for compatibility only) */
147 : BT_OBEX_HEADER_ID_TIME = 0xC4,
148 :
149 : /** Text description of the object */
150 : BT_OBEX_HEADER_ID_DES = 0x05,
151 :
152 : /** Name of service that operation is targeted to */
153 : BT_OBEX_HEADER_ID_TARGET = 0x46,
154 :
155 : /** An HTTP 1.x header */
156 : BT_OBEX_HEADER_ID_HTTP = 0x47,
157 :
158 : /** A chunk of the object body. */
159 : BT_OBEX_HEADER_ID_BODY = 0x48,
160 :
161 : /** The final chunk of the object body. */
162 : BT_OBEX_HEADER_ID_END_BODY = 0x49,
163 :
164 : /** Identifies the OBEX application, used to tell if talking to a peer. */
165 : BT_OBEX_HEADER_ID_WHO = 0x4A,
166 :
167 : /** An identifier used for OBEX connection multiplexing. */
168 : BT_OBEX_HEADER_ID_CONN_ID = 0xCB,
169 :
170 : /** Extended application request & response information. */
171 : BT_OBEX_HEADER_ID_APP_PARAM = 0x4C,
172 :
173 : /** Authentication digest-challenge. */
174 : BT_OBEX_HEADER_ID_AUTH_CHALLENGE = 0x4D,
175 :
176 : /** Authentication digest-response. */
177 : BT_OBEX_HEADER_ID_AUTH_RSP = 0x4E,
178 :
179 : /** Indicates the creator of an object. */
180 : BT_OBEX_HEADER_ID_CREATE_ID = 0xCF,
181 :
182 : /** Uniquely identifies the network client (OBEX server). */
183 : BT_OBEX_HEADER_ID_WAN_UUID = 0x50,
184 :
185 : /** OBEX Object class of object. */
186 : BT_OBEX_HEADER_ID_OBJECT_CLASS = 0x51,
187 :
188 : /** Parameters used in session commands/responses. */
189 : BT_OBEX_HEADER_ID_SESSION_PARAM = 0x52,
190 :
191 : /** Sequence number used in each OBEX packet for reliability. */
192 : BT_OBEX_HEADER_ID_SESSION_SEQ_NUM = 0x93,
193 :
194 : /** Specifies the action to be performed (used in ACTION operation). */
195 : BT_OBEX_HEADER_ID_ACTION_ID = 0x94,
196 :
197 : /** The destination object name (used in certain ACTION operations). */
198 : BT_OBEX_HEADER_ID_DEST_NAME = 0x15,
199 :
200 : /** 4-byte bit mask for setting permissions. */
201 : BT_OBEX_HEADER_ID_PERM = 0xD6,
202 :
203 : /** 1-byte value to setup Single Response Mode (SRM). */
204 : BT_OBEX_HEADER_ID_SRM = 0x97,
205 :
206 : /** 1-byte value for setting parameters used during Single Response Mode (SRM). */
207 : BT_OBEX_HEADER_ID_SRM_PARAM = 0x98,
208 : };
209 :
210 : /** The OBEX packet header length for PUT and GET request and response. */
211 1 : #define BT_OBEX_HDR_LEN 3
212 :
213 : /** The max PDU data length of OBEX pachet. */
214 1 : #define BT_OBEX_PDU_LEN(mopl) ((mopl) - BT_OBEX_HDR_LEN)
215 :
216 : /** The header length of the OBEX header body/end body. */
217 1 : #define BT_OBEX_HDR_LEN_OF_HEADER_BODY 3
218 :
219 : /** The max remaining length of the buffer if the adding header is body/end body.
220 : *
221 : * It is used to calculate the max sending length when adding the header body data.
222 : * @code{.c}
223 : * uint16_t len = BT_OBEX_PDU_LEN(mopl);
224 : *
225 : * len = MIN(len - buf->len, net_buf_tailroom(buf));
226 : * if (len > BT_OBEX_HDR_LEN_OF_HEADER_BODY) {
227 : * len = BT_OBEX_DATA_LEN_OF_HEADER_BODY(len);
228 : * Calling bt_obex_add_header_body() or bt_obex_add_header_end_body()
229 : * ...
230 : * }
231 : * @endcode
232 : *
233 : * @param len The max remaining length.
234 : */
235 1 : #define BT_OBEX_DATA_LEN_OF_HEADER_BODY(len) ((len) - BT_OBEX_HDR_LEN_OF_HEADER_BODY)
236 :
237 0 : #define BT_OBEX_SEND_BUF_RESERVE 7
238 :
239 : struct bt_obex;
240 : struct bt_obex_server;
241 : struct bt_obex_client;
242 :
243 : /** @brief OBEX server operations structure.
244 : *
245 : * The object has to stay valid and constant for the lifetime of the OBEX server.
246 : */
247 1 : struct bt_obex_server_ops {
248 : /** @brief OBEX connect request callback
249 : *
250 : * If this callback is provided it will be called whenever the OBEX connect request
251 : * is received.
252 : *
253 : * @param server The OBEX server object.
254 : * @param version OBEX version number.
255 : * @param mopl Maximum OBEX packet length.
256 : * @param buf Sequence of headers.
257 : */
258 1 : void (*connect)(struct bt_obex_server *server, uint8_t version, uint16_t mopl,
259 : struct net_buf *buf);
260 :
261 : /** @brief OBEX disconnect request callback
262 : *
263 : * If this callback is provided it will be called whenever the OBEX disconnect request
264 : * is received.
265 : *
266 : * @param server The OBEX server object.
267 : * @param buf Sequence of headers.
268 : */
269 1 : void (*disconnect)(struct bt_obex_server *server, struct net_buf *buf);
270 :
271 : /** @brief OBEX put request callback
272 : *
273 : * If this callback is provided it will be called whenever the OBEX put request is
274 : * received.
275 : *
276 : * @param server The OBEX server object.
277 : * @param final If the final bit is set.
278 : * @param buf Sequence of headers.
279 : */
280 1 : void (*put)(struct bt_obex_server *server, bool final, struct net_buf *buf);
281 :
282 : /** @brief OBEX get request callback
283 : *
284 : * If this callback is provided it will be called whenever the OBEX get request is
285 : * received.
286 : *
287 : * @param server The OBEX server object.
288 : * @param final If the final bit is set.
289 : * @param buf Sequence of headers.
290 : */
291 1 : void (*get)(struct bt_obex_server *server, bool final, struct net_buf *buf);
292 :
293 : /** @brief OBEX abort request callback
294 : *
295 : * If this callback is provided it will be called whenever the OBEX abort request is
296 : * received.
297 : *
298 : * @param server The OBEX server object.
299 : * @param buf Optional headers.
300 : */
301 1 : void (*abort)(struct bt_obex_server *server, struct net_buf *buf);
302 :
303 : /** @brief OBEX SetPath request callback
304 : *
305 : * If this callback is provided it will be called whenever the OBEX SetPath request is
306 : * received.
307 : *
308 : * @param server The OBEX server object.
309 : * @param flags The flags.
310 : * @param buf Optional headers.
311 : */
312 1 : void (*setpath)(struct bt_obex_server *server, uint8_t flags, struct net_buf *buf);
313 :
314 : /** @brief OBEX action request callback
315 : *
316 : * If this callback is provided it will be called whenever the OBEX action request is
317 : * received.
318 : *
319 : * @param server The OBEX server object.
320 : * @param final If the final bit is set.
321 : * @param buf Sequence of headers (Including action identifier header if it exists).
322 : */
323 1 : void (*action)(struct bt_obex_server *server, bool final, struct net_buf *buf);
324 : };
325 :
326 : /** @brief OBEX client operations structure.
327 : *
328 : * The object has to stay valid and constant for the lifetime of the OBEX client.
329 : */
330 1 : struct bt_obex_client_ops {
331 : /** @brief OBEX connect response callback
332 : *
333 : * If this callback is provided it will be called whenever the OBEX connect response
334 : * is received.
335 : *
336 : * @param client The OBEX client object.
337 : * @param rsp_code Response code.
338 : * @param version OBEX version number.
339 : * @param mopl Maximum OBEX packet length.
340 : * @param buf Sequence of headers.
341 : */
342 1 : void (*connect)(struct bt_obex_client *client, uint8_t rsp_code, uint8_t version,
343 : uint16_t mopl, struct net_buf *buf);
344 :
345 : /** @brief OBEX disconnect response callback
346 : *
347 : * If this callback is provided it will be called whenever the OBEX disconnect response
348 : * is received.
349 : *
350 : * @param client The OBEX client object.
351 : * @param rsp_code Response code.
352 : * @param buf Sequence of headers.
353 : */
354 1 : void (*disconnect)(struct bt_obex_client *client, uint8_t rsp_code, struct net_buf *buf);
355 :
356 : /** @brief OBEX put response callback
357 : *
358 : * If this callback is provided it will be called whenever the OBEX put response is
359 : * received.
360 : *
361 : * @param client The OBEX client object.
362 : * @param rsp_code Response code.
363 : * @param buf Optional response headers.
364 : */
365 1 : void (*put)(struct bt_obex_client *client, uint8_t rsp_code, struct net_buf *buf);
366 :
367 : /** @brief OBEX get response callback
368 : *
369 : * If this callback is provided it will be called whenever the OBEX get response is
370 : * received.
371 : *
372 : * @param client The OBEX client object.
373 : * @param rsp_code Response code.
374 : * @param buf Optional response headers.
375 : */
376 1 : void (*get)(struct bt_obex_client *client, uint8_t rsp_code, struct net_buf *buf);
377 :
378 : /** @brief OBEX abort response callback
379 : *
380 : * If this callback is provided it will be called whenever the OBEX abort response is
381 : * received.
382 : *
383 : * @param client The OBEX client object.
384 : * @param rsp_code Response code.
385 : * @param buf Optional response headers.
386 : */
387 1 : void (*abort)(struct bt_obex_client *client, uint8_t rsp_code, struct net_buf *buf);
388 :
389 : /** @brief OBEX SetPath response callback
390 : *
391 : * If this callback is provided it will be called whenever the OBEX SetPath response is
392 : * received.
393 : *
394 : * @param client The OBEX client object.
395 : * @param rsp_code Response code.
396 : * @param buf Optional response headers.
397 : */
398 1 : void (*setpath)(struct bt_obex_client *client, uint8_t rsp_code, struct net_buf *buf);
399 :
400 : /** @brief OBEX action response callback
401 : *
402 : * If this callback is provided it will be called whenever the OBEX action response is
403 : * received.
404 : *
405 : * @param client The OBEX client object.
406 : * @param rsp_code Response code.
407 : * @param buf Optional response headers.
408 : */
409 1 : void (*action)(struct bt_obex_client *client, uint8_t rsp_code, struct net_buf *buf);
410 : };
411 :
412 : /** @brief OBEX transport operations structure.
413 : *
414 : * The object has to stay valid and constant for the lifetime of the OBEX client/server.
415 : */
416 1 : struct bt_obex_transport_ops {
417 : /** @brief allocate buf callback
418 : *
419 : * If this callback is provided it will be called to allocate a net buffer to store
420 : * the outgoing data.
421 : *
422 : * @param obex The OBEX object.
423 : * @param pool Which pool to take the buffer from.
424 : *
425 : * @return Allocated buffer.
426 : */
427 : struct net_buf *(*alloc_buf)(struct bt_obex *obex, struct net_buf_pool *pool);
428 :
429 : /** @brief Send OBEX data via transport
430 : *
431 : * If this callback is provided it will be called to send data via OBEX transport.
432 : *
433 : * @param obex The OBEX object.
434 : * @param buf OBEX packet.
435 : *
436 : * @return 0 in case of success or negative value in case of error.
437 : * @return -EMSGSIZE if `buf` is larger than `obex`'s MOPL.
438 : */
439 1 : int (*send)(struct bt_obex *obex, struct net_buf *buf);
440 :
441 : /** @brief Disconnect from transport
442 : *
443 : * If this callback is provided it will be called to disconnect transport.
444 : *
445 : * @param obex The OBEX object.
446 : *
447 : * @return 0 in case of success or negative value in case of error.
448 : */
449 1 : int (*disconnect)(struct bt_obex *obex);
450 : };
451 :
452 : /** @brief Life-span states of OBEX.
453 : *
454 : * Used only by internal APIs dealing with setting OBEX to proper state depending on operational
455 : * context.
456 : *
457 : * OBEX enters the @ref BT_OBEX_CONNECTING state upon @ref bt_obex_connect, or upon returning
458 : * from @ref bt_obex_server_ops::connect.
459 : *
460 : * When OBEX leaves the @ref BT_OBEX_CONNECTING state and enters the @ref BT_OBEX_CONNECTED,
461 : * @ref bt_obex_connect_rsp or @ref bt_obex_client_ops::connect is called with the response code
462 : * @ref BT_OBEX_RSP_CODE_SUCCESS.
463 : *
464 : * When OBEX enters the @ref BT_OBEX_DISCONNECTED from other states,
465 : * @ref bt_obex_client_ops::disconnect or @ref bt_obex_connect_rsp is called with the response code
466 : * @ref BT_OBEX_RSP_CODE_SUCCESS. Or OBEX transport enters the disconnected state from other OBEX
467 : * transport states.
468 : */
469 1 : enum __packed bt_obex_state {
470 : /** OBEX disconnected */
471 : BT_OBEX_DISCONNECTED,
472 : /** OBEX in connecting state */
473 : BT_OBEX_CONNECTING,
474 : /** OBEX ready for upper layer traffic on it */
475 : BT_OBEX_CONNECTED,
476 : /** OBEX in disconnecting state */
477 : BT_OBEX_DISCONNECTING,
478 : };
479 :
480 : /* bt_obex flags */
481 0 : enum {
482 : BT_OBEX_HAS_TARGET, /* Has target_header */
483 : };
484 :
485 0 : union bt_obex_uuid {
486 0 : struct bt_uuid uuid;
487 0 : struct bt_uuid_16 u16;
488 0 : struct bt_uuid_32 u32;
489 0 : struct bt_uuid_128 u128;
490 : };
491 :
492 : /** @brief OBEX server structure. */
493 1 : struct bt_obex_server {
494 : /** @brief OBEX Object */
495 1 : struct bt_obex *obex;
496 :
497 : /** @brief UUID of the service */
498 1 : const struct bt_uuid_128 *uuid;
499 :
500 : /** @brief OBEX Server operations
501 : *
502 : * If it is a obex sever, the upper layer should pass the operations of server to
503 : * `server_ops` when providing the OBEX server structure.
504 : */
505 1 : const struct bt_obex_server_ops *ops;
506 :
507 : struct {
508 : /** @brief The Maximum OBEX Packet Length (MOPL) */
509 1 : uint16_t mopl;
510 0 : } rx;
511 :
512 : struct {
513 : /** @brief The Maximum OBEX Packet Length (MOPL) */
514 : uint16_t mopl;
515 0 : } tx;
516 :
517 : /** @internal Saves the current state, @ref bt_obex_state */
518 : atomic_t _state;
519 :
520 : /** @internal OBEX opcode */
521 : atomic_t _opcode;
522 :
523 : /** @internal OBEX flags */
524 : atomic_t _flags;
525 :
526 : /** @internal Target of service */
527 : union bt_obex_uuid _target;
528 :
529 : /** @internal OBEX connection identifier */
530 : uint32_t _conn_id;
531 :
532 : /** @internal sys snode */
533 : sys_snode_t _node;
534 : };
535 :
536 : /** @brief OBEX client structure. */
537 1 : struct bt_obex_client {
538 : /** @brief OBEX Object */
539 1 : struct bt_obex *obex;
540 :
541 : /** @brief OBEX Client operations
542 : *
543 : * If it is a obex client, the upper layer should pass the operations of client to
544 : * `client_ops` when providing the OBEX client structure.
545 : */
546 1 : const struct bt_obex_client_ops *ops;
547 :
548 : struct {
549 : /** @brief The Maximum OBEX Packet Length (MOPL) */
550 1 : uint16_t mopl;
551 0 : } rx;
552 :
553 : struct {
554 : /** @brief The Maximum OBEX Packet Length (MOPL) */
555 : uint16_t mopl;
556 0 : } tx;
557 :
558 : /** @internal Saves the current state, @ref bt_obex_state */
559 : atomic_t _state;
560 :
561 : /** @internal OBEX opcode */
562 : atomic_t _opcode;
563 :
564 : /** @internal OBEX previous opcode */
565 : atomic_t _pre_opcode;
566 :
567 : /** @internal OBEX flags */
568 : atomic_t _flags;
569 :
570 : /** @internal target of the conn req */
571 : union bt_obex_uuid _target;
572 :
573 : /** @internal OBEX connection identifier */
574 : uint32_t _conn_id;
575 :
576 : /** @internal sys snode */
577 : sys_snode_t _node;
578 : };
579 :
580 : /** @brief OBEX structure. */
581 1 : struct bt_obex {
582 : struct {
583 : /** @brief MTU of OBEX transport */
584 1 : uint16_t mtu;
585 0 : } rx;
586 :
587 : struct {
588 : /** @brief MTU of OBEX transport */
589 : uint16_t mtu;
590 0 : } tx;
591 :
592 : /** @internal OBEX transport operations */
593 : const struct bt_obex_transport_ops *_transport_ops;
594 :
595 : /** @internal OBEX executing client */
596 : atomic_ptr_t _active_client;
597 :
598 : /** @internal OBEX executing client */
599 : atomic_ptr_t _active_server;
600 :
601 : /** @internal OBEX clients */
602 : sys_slist_t _clients;
603 :
604 : /** @internal OBEX servers */
605 : sys_slist_t _servers;
606 : };
607 :
608 : /** @brief OBEX server register
609 : *
610 : * Register a OBEX server with the specific UUID.
611 : *
612 : * The OBEX object of the server should be set before calling the function.
613 : * If the UUID is NULL, any connection request will be accepted. Or, the space of the UUID should
614 : * be retained.
615 : * Before calling the API, @ref bt_obex_server::ops should be initialized with valid
616 : * address of type @ref bt_obex_server_ops object. And the @ref bt_obex_server::obex should be
617 : * initialized with the valid OBEX object of type @ref bt_obex.
618 : *
619 : * @param server The OBEX server object.
620 : * @param uuid The UUID of the service.
621 : *
622 : * @return 0 in case of success or negative value in case of error.
623 : */
624 1 : int bt_obex_server_register(struct bt_obex_server *server, const struct bt_uuid_128 *uuid);
625 :
626 : /** @brief OBEX server unregister
627 : *
628 : * Unregister a registered OBEX server.
629 : *
630 : * The server should be disconnected when calling the function.
631 : *
632 : * @param server The OBEX server object.
633 : *
634 : * @return 0 in case of success or negative value in case of error.
635 : */
636 1 : int bt_obex_server_unregister(struct bt_obex_server *server);
637 :
638 : /** @brief OBEX connect request
639 : *
640 : * The connect operation initiates the connection and sets up the basic expectations of each side
641 : * of the link. The connect request must fit in a single packet.
642 : * The third parameter `buf` saves the packet data (sequence of headers) of the connect request is
643 : * stored in thrid parameter `buf`. All headers are packed by calling function
644 : * bt_obex_add_header_*. Such as header `Authenticate Challenge` is packed by calling
645 : * @ref bt_obex_add_header_auth_challenge.
646 : * The OBEX object of the client should be set before calling the function.
647 : * Before calling the API, @ref bt_obex_client::ops should be initialized with valid
648 : * address of type @ref bt_obex_client_ops object. And the @ref bt_obex_client::obex should be
649 : * initialized with the valid OBEX object of type @ref bt_obex.
650 : *
651 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
652 : * the caller retains the ownership of the buffer.
653 : *
654 : * @param client OBEX client object.
655 : * @param mopl Maximum OBEX packet length.
656 : * @param buf Sequence of headers to be sent out.
657 : *
658 : * @return 0 in case of success or negative value in case of error.
659 : */
660 1 : int bt_obex_connect(struct bt_obex_client *client, uint16_t mopl, struct net_buf *buf);
661 :
662 : /** @brief OBEX connect response
663 : *
664 : * The connect response is used to acknowledged connect request packet.
665 : * The connect response must fit in a single packet.
666 : *
667 : * The second parameter `rsp_code` is used to pass the response code @ref bt_obex_rsp_code. The
668 : * typical values @ref BT_OBEX_RSP_CODE_SUCCESS for `success`.
669 : * The 4th parameter `buf` saves the packet data (sequence of headers) of the connect response is
670 : * stored in thrid parameter `buf`. All headers are packed by calling function
671 : * bt_obex_add_header_*. Such as header `Authenticate Response` is packed by calling
672 : * @ref bt_obex_add_header_auth_rsp.
673 : *
674 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
675 : * the caller retains the ownership of the buffer.
676 : *
677 : * @param server OBEX server object.
678 : * @param rsp_code Response code.
679 : * @param mopl Maximum OBEX packet length.
680 : * @param buf Sequence of headers to be sent out.
681 : *
682 : * @return 0 in case of success or negative value in case of error.
683 : */
684 1 : int bt_obex_connect_rsp(struct bt_obex_server *server, uint8_t rsp_code, uint16_t mopl,
685 : struct net_buf *buf);
686 :
687 : /** @brief OBEX disconnect request
688 : *
689 : * The disconnect operation signals the end of the OBEX connection from client side.
690 : * The disconnect request must fit in a single packet.
691 : *
692 : * The second parameter `buf` saves the packet data (sequence of headers) of the disconnect
693 : * request is stored in second parameter `buf`. All headers are packed by calling function
694 : * bt_obex_add_header_*. Such as header `Connection Id` is packed by calling
695 : * @ref bt_obex_add_header_conn_id.
696 : *
697 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
698 : * the caller retains the ownership of the buffer.
699 : *
700 : * @param client OBEX client object.
701 : * @param buf Sequence of headers to be sent out.
702 : *
703 : * @return 0 in case of success or negative value in case of error.
704 : */
705 1 : int bt_obex_disconnect(struct bt_obex_client *client, struct net_buf *buf);
706 :
707 : /** @brief OBEX disconnect response
708 : *
709 : * The disconnect response is used to acknowledged disconnect request packet.
710 : * The disconnect response must fit in a single packet.
711 : *
712 : * The second parameter `rsp_code` is used to pass the response code @ref bt_obex_rsp_code. The
713 : * typical values, @ref BT_OBEX_RSP_CODE_SUCCESS for `success`, @ref BT_OBEX_RSP_CODE_UNAVAIL for
714 : * `service unavailable` if the header `Connection Id` is invalid.
715 : * The third parameter `buf` saves the packet data (sequence of headers) of the connect response
716 : * is stored in third parameter `buf`. All headers are packed by calling function
717 : * bt_obex_add_header_*.
718 : *
719 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
720 : * the caller retains the ownership of the buffer.
721 : *
722 : * @param server OBEX server object.
723 : * @param rsp_code Response code.
724 : * @param buf Sequence of headers to be sent out.
725 : *
726 : * @return 0 in case of success or negative value in case of error.
727 : */
728 1 : int bt_obex_disconnect_rsp(struct bt_obex_server *server, uint8_t rsp_code, struct net_buf *buf);
729 :
730 : /** @brief OBEX put request
731 : *
732 : * The put operation sends one object from the client to the server.
733 : * The put operation consists of one or more request packets, the last of which should have the
734 : * second parameter `final` set.
735 : * The third parameter `buf` saves the packet data (sequence of headers) of the put request is
736 : * stored in thrid parameter `buf`. All headers are packed by calling function
737 : * bt_obex_add_header_*. Such as header `Name` is packed by calling @ref bt_obex_add_header_name.
738 : *
739 : * @note A put operation with NO Body or End-of-Body headers whatsoever should be treated as a
740 : * delete request. Similarly, a put operation with an empty End-of-Body header requests the
741 : * recipient to create an empty object. This definition may not make sense or apply to every
742 : * implementation (in other words devices are not required to support delete operations or
743 : * empty objects).
744 : *
745 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
746 : * the caller retains the ownership of the buffer.
747 : *
748 : * @param client OBEX client object.
749 : * @param final The final bit of opcode.
750 : * @param buf Sequence of headers to be sent out.
751 : *
752 : * @return 0 in case of success or negative value in case of error.
753 : */
754 1 : int bt_obex_put(struct bt_obex_client *client, bool final, struct net_buf *buf);
755 :
756 : /** @brief OBEX put response
757 : *
758 : * The put response is used to acknowledged each put request packet. It is sent from the server
759 : * to client.
760 : * The second parameter `rsp_code` is used to pass the response code @ref bt_obex_rsp_code. The
761 : * typical values, @ref BT_OBEX_RSP_CODE_CONTINUE for `continue`, @ref BT_OBEX_RSP_CODE_SUCCESS
762 : * for `success`.
763 : * The third parameter `buf` saves the packet data (sequence of headers) of the put response is
764 : * stored in thrid parameter `buf`. All headers are packed by calling function
765 : * bt_obex_add_header_*. Such as header `srm` is packed by calling @ref bt_obex_add_header_srm.
766 : * Or, the `buf` could be NULL if there is not any data needs to be sent.
767 : *
768 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
769 : * the caller retains the ownership of the buffer.
770 : *
771 : * @param server OBEX server object.
772 : * @param rsp_code Response code.
773 : * @param buf Sequence of headers to be sent out.
774 : *
775 : * @return 0 in case of success or negative value in case of error.
776 : */
777 1 : int bt_obex_put_rsp(struct bt_obex_server *server, uint8_t rsp_code, struct net_buf *buf);
778 :
779 : /** @brief OBEX get request
780 : *
781 : * The get operation requests that the server return an object to the client.
782 : * The get operation consists of one or more request packets, the last of which should have the
783 : * second parameter `final` set, and the request phase of the get is complete. Once a get request
784 : * is sent with the final bit, all subsequent get request packets must set the final bit until
785 : * the operation is complete.
786 : * The third parameter `buf` saves the packet data (sequence of headers) of the get request is
787 : * stored in thrid parameter `buf`. All headers are packed by calling function
788 : * bt_obex_add_header_*. Such as header `Name` is packed by calling @ref bt_obex_add_header_name.
789 : * Or, the `buf` could be NULL if there is not any data needs to be sent.
790 : *
791 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
792 : * the caller retains the ownership of the buffer.
793 : *
794 : * @param client OBEX client object.
795 : * @param final The final bit of opcode.
796 : * @param buf Sequence of headers to be sent out.
797 : *
798 : * @return 0 in case of success or negative value in case of error.
799 : */
800 1 : int bt_obex_get(struct bt_obex_client *client, bool final, struct net_buf *buf);
801 :
802 : /** @brief OBEX get response
803 : *
804 : * The get response is used to acknowledged get request packets. It is sent from the server
805 : * to client.
806 : * If the server has more than one object that fits the request, the behavior is system
807 : * dependent. But the server device must not begin sending the object body chunks until the
808 : * request phase is complete.
809 : *
810 : * The second parameter `rsp_code` is used to pass the response code @ref bt_obex_rsp_code. The
811 : * typical values, @ref BT_OBEX_RSP_CODE_CONTINUE for `continue`, @ref BT_OBEX_RSP_CODE_SUCCESS
812 : * for `success`.
813 : * A successful response for an object that fits entirely in one response packet is
814 : * @ref BT_OBEX_RSP_CODE_SUCCESS (Success, with Final bit set) in the response code, followed
815 : * by the object body. If the response is large enough to require multiple GET responses, only
816 : * the last response is @ref BT_OBEX_RSP_CODE_SUCCESS, and the others are all
817 : * @ref BT_OBEX_RSP_CODE_CONTINUE (Continue). The object is returned as a sequence of headers
818 : * just as with put operation. Any other response code @ref bt_obex_rsp_code indicates failure.
819 : * The typical failure response codes, @ref BT_OBEX_RSP_CODE_BAD_REQ for `Bad request - server
820 : * couldn’t understand request`, @ref BT_OBEX_RSP_CODE_FORBIDDEN for `Forbidden - operation is
821 : * understood but refused`.
822 : * The third parameter `buf` saves the packet data (sequence of headers) of the get response is
823 : * stored in thrid parameter `buf`. All headers are packed by calling function
824 : * bt_obex_add_header_*. Such as header `srm` is packed by calling @ref bt_obex_add_header_srm.
825 : * Or, the `buf` could be NULL if there is not any data needs to be sent.
826 : *
827 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
828 : * the caller retains the ownership of the buffer.
829 : *
830 : * @param server OBEX server object.
831 : * @param rsp_code Response code.
832 : * @param buf Sequence of headers to be sent out.
833 : *
834 : * @return 0 in case of success or negative value in case of error.
835 : */
836 1 : int bt_obex_get_rsp(struct bt_obex_server *server, uint8_t rsp_code, struct net_buf *buf);
837 :
838 : /** @brief OBEX abort request
839 : *
840 : * The abort request is used when the client decides to terminate a multi-packet operation (such
841 : * as put) before it would be normally end. The abort request always fits in one OBEX packet and
842 : * have the Final bit set.
843 : * The second parameter `buf` saves the packet data (sequence of headers) of the abort request is
844 : * stored in thrid parameter `buf`. All headers are packed by calling function
845 : * bt_obex_add_header_*. Such as header `description` is packed by calling
846 : * @ref bt_obex_add_header_description. Or, the `buf` could be NULL if there is not any data
847 : * needs to be sent.
848 : *
849 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
850 : * the caller retains the ownership of the buffer.
851 : *
852 : * @param client OBEX client object.
853 : * @param buf Sequence of headers to be sent out.
854 : *
855 : * @return 0 in case of success or negative value in case of error.
856 : */
857 1 : int bt_obex_abort(struct bt_obex_client *client, struct net_buf *buf);
858 :
859 : /** @brief OBEX abort response
860 : *
861 : * The abort response is used to acknowledged abort request packet. It is sent from the server
862 : * to client.
863 : * The abort response always fits in one OBEX packet and have the Final bit set.
864 : *
865 : * The second parameter `rsp_code` is used to pass the response code @ref bt_obex_rsp_code. The
866 : * typical value @ref BT_OBEX_RSP_CODE_SUCCESS for `success`.
867 : * The third parameter `buf` saves the packet data (sequence of headers) of the abort response is
868 : * stored in thrid parameter `buf`. All headers are packed by calling function
869 : * bt_obex_add_header_*. Or, the `buf` could be NULL if there is not any data needs to be sent.
870 : *
871 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
872 : * the caller retains the ownership of the buffer.
873 : *
874 : * @param server OBEX server object.
875 : * @param rsp_code Response code.
876 : * @param buf Sequence of headers to be sent out.
877 : *
878 : * @return 0 in case of success or negative value in case of error.
879 : */
880 1 : int bt_obex_abort_rsp(struct bt_obex_server *server, uint8_t rsp_code, struct net_buf *buf);
881 :
882 : /** @brief OBEX setpath request
883 : *
884 : * The setpath request is used to set the "current folder" on the receiving side in order to
885 : * enable transfers that need additional path information. The Path name is contained in a Name
886 : * header.
887 : * The setpath request always fits in one OBEX packet and have the Final bit set.
888 : *
889 : * The second parameter `flags` is the setpath operation flag bit maps. Bit 0 means `backup a
890 : * level before applying name (equivalent to ../ on many systems)`. Bit 1 means `Don’t create
891 : * folder if it does not exist, return an error instead.` Other bits must be set to zero by
892 : * sender and ignored by receiver.
893 : * The third parameter `buf` saves the packet data (sequence of headers) of the setpath request is
894 : * stored in thrid parameter `buf`. All headers are packed by calling function
895 : * bt_obex_add_header_*. Such as header `Name` is packed by calling @ref bt_obex_add_header_name.
896 : * If the header `Name` is added, it means the client wants to go one level down relative to the
897 : * current folder into the folder `name`. Or, the client wants to go back to the default folder
898 : * when no bit of flags set.
899 : *
900 : * @note The Name header may be omitted when flags or constants indicate the entire operation
901 : * being requested. For example, back up one level (bit 0 of `flags` is set), equivalent to
902 : * "cd .." on some systems.
903 : *
904 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
905 : * the caller retains the ownership of the buffer.
906 : *
907 : * @param client OBEX client object.
908 : * @param flags Flags for setpath request.
909 : * @param buf Sequence of headers to be sent out.
910 : *
911 : * @return 0 in case of success or negative value in case of error.
912 : */
913 1 : int bt_obex_setpath(struct bt_obex_client *client, uint8_t flags, struct net_buf *buf);
914 :
915 : /** @brief OBEX setpath response
916 : *
917 : * The setpath response is used to acknowledged setpath request packet. It is sent from the
918 : * server to client.
919 : * The setpath response always fits in one OBEX packet and have the Final bit set.
920 : *
921 : * The second parameter `rsp_code` is used to pass the response code @ref bt_obex_rsp_code. The
922 : * typical value @ref BT_OBEX_RSP_CODE_SUCCESS for `success`. Any other response code
923 : * @ref bt_obex_rsp_code indicates failure. The typical failure response codes,
924 : * @ref BT_OBEX_RSP_CODE_BAD_REQ for `Bad request - server couldn’t understand request`,
925 : * @ref BT_OBEX_RSP_CODE_FORBIDDEN for `Forbidden - operation is understood but refused`.
926 : * The third parameter `buf` saves the packet data (sequence of headers) of the setpath response
927 : * is stored in thrid parameter `buf`. All headers are packed by calling function
928 : * bt_obex_add_header_*. Or, the `buf` could be NULL if there is not any data needs to be sent.
929 : *
930 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
931 : * the caller retains the ownership of the buffer.
932 : *
933 : * @param server OBEX server object.
934 : * @param rsp_code Response code.
935 : * @param buf Sequence of headers to be sent out.
936 : *
937 : * @return 0 in case of success or negative value in case of error.
938 : */
939 1 : int bt_obex_setpath_rsp(struct bt_obex_server *server, uint8_t rsp_code, struct net_buf *buf);
940 :
941 : /** @brief OBEX Actions. */
942 1 : enum __packed bt_obex_action_id {
943 : /** Copy Object Action */
944 : BT_OBEX_ACTION_COPY = 0x00,
945 : /** Move/Rename Object Action */
946 : BT_OBEX_ACTION_MOVE_RENAME = 0x01,
947 : /** Set Object Permissions Action */
948 : BT_OBEX_ACTION_SET_PERM = 0x02,
949 : };
950 :
951 : /** @brief OBEX action request
952 : *
953 : * The action operation is defined to cover the needs of common actions. The `Action Id` header
954 : * @ref BT_OBEX_HEADER_ID_ACTION_ID is used in the action operation and contains an action
955 : * identifier which defines what action is to be performed. All actions are optional and depends
956 : * on the implementation of server.
957 : *
958 : * There are three actions defined @ref bt_obex_action_id,
959 : *
960 : * @ref BT_OBEX_ACTION_COPY is used to copy an object from one location to another. The header
961 : * `Name` @ref BT_OBEX_HEADER_ID_NAME specifies the source file name and the header `Dest Name`
962 : * @ref BT_OBEX_HEADER_ID_DEST_NAME specifies the destination file name. These two headers are
963 : * mandatory for this action.
964 : *
965 : * @ref BT_OBEX_ACTION_MOVE_RENAME is used to move an object from one location to another. It
966 : * can also be used to rename an object. The header `Name` @ref BT_OBEX_HEADER_ID_NAME specifies
967 : * the source file name and the header `Dest Name` @ref BT_OBEX_HEADER_ID_DEST_NAME specifies the
968 : * destination file name. These two headers are mandatory for this action.
969 : *
970 : * @ref BT_OBEX_ACTION_SET_PERM is used to set the access permissions of an object or folder.
971 : * The header `Name` @ref BT_OBEX_HEADER_ID_NAME specifies the source file name and the header
972 : * `Permissions` @ref BT_OBEX_HEADER_ID_PERM specifies the new permissions for this object. These
973 : * two headers are mandatory for this action.
974 : *
975 : * The action operation consists of one or more request packets, the last of which should have
976 : * the second parameter `final` set.
977 : * The third parameter `buf` saves the packet data (sequence of headers) of the action request is
978 : * stored in thrid parameter `buf`. All headers are packed by calling function
979 : * bt_obex_add_header_*. Such as header `Name` is packed by calling @ref bt_obex_add_header_name.
980 : *
981 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
982 : * the caller retains the ownership of the buffer.
983 : *
984 : * @param client OBEX client object.
985 : * @param final The final bit of opcode.
986 : * @param buf Sequence of headers to be sent out.
987 : *
988 : * @return 0 in case of success or negative value in case of error.
989 : */
990 1 : int bt_obex_action(struct bt_obex_client *client, bool final, struct net_buf *buf);
991 :
992 : /** @brief OBEX action response
993 : *
994 : * The action response is used to acknowledged action request packets. It is sent from the server
995 : * to client.
996 : * The second parameter `rsp_code` is used to pass the response code @ref bt_obex_rsp_code. The
997 : * typical value @ref BT_OBEX_RSP_CODE_SUCCESS for `success`.
998 : *
999 : * There are three actions defined @ref bt_obex_action_id. For each action request, there are
1000 : * failure response codes corresponding to it.
1001 : *
1002 : * For action @ref BT_OBEX_ACTION_COPY,
1003 : * @ref BT_OBEX_RSP_CODE_NOT_FOUND - `Source object or destination folder does not exist`.
1004 : * @ref BT_OBEX_RSP_CODE_FORBIDDEN - `Cannot modify the permissions of the destination
1005 : * object/folder, permission denied`.
1006 : * @ref BT_OBEX_RSP_CODE_DB_FULL - `Cannot create object in destination folder, out of memory`
1007 : * @ref BT_OBEX_RSP_CODE_CONFLICT - `Cannot modify the permissions, sharing violation, object or
1008 : * Set Object Permissions Action busy`.
1009 : * @ref BT_OBEX_RSP_CODE_NOT_IMPL - `Set Object Permissions Action not supported`.
1010 : * @ref BT_OBEX_RSP_CODE_NOT_MODIFIED - `Cannot create folder/file, destination folder/file
1011 : * already exits`.
1012 : *
1013 : * For action @ref BT_OBEX_ACTION_MOVE_RENAME,
1014 : * @ref BT_OBEX_RSP_CODE_NOT_FOUND - `Source object or destination folder does not exist`.
1015 : * @ref BT_OBEX_RSP_CODE_FORBIDDEN - `Cannot modify the permissions of the destination
1016 : * object/folder, permission denied`.
1017 : * @ref BT_OBEX_RSP_CODE_DB_FULL - `Cannot create object in destination folder, out of memory`
1018 : * @ref BT_OBEX_RSP_CODE_CONFLICT - `Cannot modify the permissions, sharing violation, object or
1019 : * Set Object Permissions Action busy`.
1020 : * @ref BT_OBEX_RSP_CODE_NOT_IMPL - `Set Object Permissions Action not supported`.
1021 : * @ref BT_OBEX_RSP_CODE_NOT_MODIFIED - `Cannot create folder/file, destination folder/file
1022 : * already exits`.
1023 : *
1024 : * For action @ref BT_OBEX_ACTION_SET_PERM,
1025 : * @ref BT_OBEX_RSP_CODE_NOT_FOUND - `Source object or destination folder does not exist`.
1026 : * @ref BT_OBEX_RSP_CODE_FORBIDDEN - `Cannot modify the permissions of the destination
1027 : * object/folder, permission denied`.
1028 : * @ref BT_OBEX_RSP_CODE_NOT_IMPL - `Set Object Permissions Action not supported`.
1029 : * @ref BT_OBEX_RSP_CODE_CONFLICT - `Cannot modify the permissions, sharing violation, object or
1030 : * Set Object Permissions Action busy`.
1031 : *
1032 : * The third parameter `buf` saves the packet data (sequence of headers) of the action response
1033 : * is stored in thrid parameter `buf`. All headers are packed by calling function
1034 : * bt_obex_add_header_*. Or, the `buf` could be NULL if there is not any data needs to be sent.
1035 : *
1036 : * @note Buffer ownership is transferred to the stack in case of success, in case of an error
1037 : * the caller retains the ownership of the buffer.
1038 : *
1039 : * @param server OBEX server object.
1040 : * @param rsp_code Response code.
1041 : * @param buf Sequence of headers to be sent out.
1042 : *
1043 : * @return 0 in case of success or negative value in case of error.
1044 : */
1045 1 : int bt_obex_action_rsp(struct bt_obex_server *server, uint8_t rsp_code, struct net_buf *buf);
1046 :
1047 : /** @brief Add Header: number of objects (used by Connect)
1048 : *
1049 : * @param buf Buffer needs to be sent.
1050 : * @param count Number of objects.
1051 : *
1052 : * @return 0 in case of success or negative value in case of error.
1053 : */
1054 1 : int bt_obex_add_header_count(struct net_buf *buf, uint32_t count);
1055 :
1056 : /** @brief Add Header: name of the object (often a file name)
1057 : *
1058 : * @param buf Buffer needs to be sent.
1059 : * @param len Length of name.
1060 : * @param name Name of the object.
1061 : *
1062 : * @return 0 in case of success or negative value in case of error.
1063 : */
1064 1 : int bt_obex_add_header_name(struct net_buf *buf, uint16_t len, const uint8_t *name);
1065 :
1066 : /** @brief Add Header: type of object - e.g. text, html, binary, manufacturer specific
1067 : *
1068 : * @param buf Buffer needs to be sent.
1069 : * @param len Length of type.
1070 : * @param type Type of the object.
1071 : *
1072 : * @return 0 in case of success or negative value in case of error.
1073 : */
1074 1 : int bt_obex_add_header_type(struct net_buf *buf, uint16_t len, const uint8_t *type);
1075 :
1076 : /** @brief Add Header: the length of the object in bytes
1077 : *
1078 : * @param buf Buffer needs to be sent.
1079 : * @param len The length of the object in bytes.
1080 : *
1081 : * @return 0 in case of success or negative value in case of error.
1082 : */
1083 1 : int bt_obex_add_header_len(struct net_buf *buf, uint32_t len);
1084 :
1085 : /** @brief Add Header: date/time stamp – ISO 8601 version - preferred
1086 : *
1087 : * @param buf Buffer needs to be sent.
1088 : * @param len Length of data/time stamp.
1089 : * @param t Data/time stamp.
1090 : *
1091 : * @return 0 in case of success or negative value in case of error.
1092 : */
1093 1 : int bt_obex_add_header_time_iso_8601(struct net_buf *buf, uint16_t len, const uint8_t *t);
1094 :
1095 : /** @brief Add Header: date/time stamp – 4 byte version (for compatibility only)
1096 : *
1097 : * @param buf Buffer needs to be sent.
1098 : * @param t Data/time stamp.
1099 : *
1100 : * @return 0 in case of success or negative value in case of error.
1101 : */
1102 1 : int bt_obex_add_header_time(struct net_buf *buf, uint32_t t);
1103 :
1104 : /** @brief Add Header: text description of the object
1105 : *
1106 : * @param buf Buffer needs to be sent.
1107 : * @param len Length of description.
1108 : * @param dec Description of the object.
1109 : *
1110 : * @return 0 in case of success or negative value in case of error.
1111 : */
1112 1 : int bt_obex_add_header_description(struct net_buf *buf, uint16_t len, const uint8_t *dec);
1113 :
1114 : /** @brief Add Header: name of service that operation is targeted to
1115 : *
1116 : * @param buf Buffer needs to be sent.
1117 : * @param len Length of target name.
1118 : * @param target Target name.
1119 : *
1120 : * @return 0 in case of success or negative value in case of error.
1121 : */
1122 1 : int bt_obex_add_header_target(struct net_buf *buf, uint16_t len, const uint8_t *target);
1123 :
1124 : /** @brief Add Header: an HTTP 1.x header
1125 : *
1126 : * @param buf Buffer needs to be sent.
1127 : * @param len Length of http 1.x header.
1128 : * @param http Http 1.x header.
1129 : *
1130 : * @return 0 in case of success or negative value in case of error.
1131 : */
1132 1 : int bt_obex_add_header_http(struct net_buf *buf, uint16_t len, const uint8_t *http);
1133 :
1134 : /** @brief Add Header: a chunk of the object body
1135 : *
1136 : * @param buf Buffer needs to be sent.
1137 : * @param len Length of body.
1138 : * @param body Object Body.
1139 : *
1140 : * @return 0 in case of success or negative value in case of error.
1141 : */
1142 1 : int bt_obex_add_header_body(struct net_buf *buf, uint16_t len, const uint8_t *body);
1143 :
1144 : /** @brief Add Header: the final chunk of the object body.
1145 : *
1146 : * @param buf Buffer needs to be sent.
1147 : * @param len Length of body.
1148 : * @param body Object Body.
1149 : *
1150 : * @return 0 in case of success or negative value in case of error.
1151 : */
1152 1 : int bt_obex_add_header_end_body(struct net_buf *buf, uint16_t len, const uint8_t *body);
1153 :
1154 : /** @brief Add Header: identifies the OBEX application, used to tell if talking to a peer.
1155 : *
1156 : * @param buf Buffer needs to be sent.
1157 : * @param len Length of who.
1158 : * @param who Who.
1159 : *
1160 : * @return 0 in case of success or negative value in case of error.
1161 : */
1162 1 : int bt_obex_add_header_who(struct net_buf *buf, uint16_t len, const uint8_t *who);
1163 :
1164 : /** @brief Add Header: an identifier used for OBEX connection multiplexing.
1165 : *
1166 : * @param buf Buffer needs to be sent.
1167 : * @param conn_id Connection Id.
1168 : *
1169 : * @return 0 in case of success or negative value in case of error.
1170 : */
1171 1 : int bt_obex_add_header_conn_id(struct net_buf *buf, uint32_t conn_id);
1172 :
1173 : /**
1174 : * @brief Bluetooth OBEX TLV triplet.
1175 : *
1176 : * Description of different data types that can be encoded into
1177 : * TLV triplet. Used to form arrays that are passed to the
1178 : * bt_obex_add_header_app_param(), bt_obex_add_header_auth_challenge(),
1179 : * and bt_obex_add_header_auth_rsp() function.
1180 : */
1181 1 : struct bt_obex_tlv {
1182 0 : uint8_t type;
1183 0 : uint8_t data_len;
1184 0 : const uint8_t *data;
1185 : };
1186 :
1187 : /** @brief Add Header: extended application request & response information.
1188 : *
1189 : * @param buf Buffer needs to be sent.
1190 : * @param count Number of @ref bt_obex_tlv structures in @p data.
1191 : * @param data Array of @ref bt_obex_tlv structures.
1192 : *
1193 : * @return 0 in case of success or negative value in case of error.
1194 : */
1195 1 : int bt_obex_add_header_app_param(struct net_buf *buf, size_t count,
1196 : const struct bt_obex_tlv data[]);
1197 :
1198 : /**
1199 : * OBEX digest-challenge tag: Nonce
1200 : * String of bytes representing the nonce.
1201 : */
1202 1 : #define BT_OBEX_CHALLENGE_TAG_NONCE 0x00
1203 :
1204 : /**
1205 : * OBEX digest-challenge tag: Options
1206 : * Optional Challenge Information.
1207 : */
1208 1 : #define BT_OBEX_CHALLENGE_TAG_OPTIONS 0x01
1209 :
1210 : /** Option BIT0: When set, the User Id must be sent in the authenticate response. */
1211 1 : #define BT_OBEX_CHALLENGE_TAG_OPTION_REQ_USER_ID BIT(0)
1212 : /** Option BIT1: Access mode: Read Only when set, otherwise Full access is permitted. */
1213 1 : #define BT_OBEX_CHALLENGE_TAG_OPTION_ACCESS_MODE BIT(1)
1214 :
1215 : /**
1216 : * OBEX digest-challenge tag: Realm
1217 : * A displayable string indicating which userid and/or password to use. The first byte of the
1218 : * string is the character set to use. The character set uses the same values as those defined
1219 : * in IrLMP for the nickname.
1220 : */
1221 1 : #define BT_OBEX_CHALLENGE_TAG_REALM 0x02
1222 :
1223 : /** @brief Add Header: authentication digest-challenge.
1224 : *
1225 : * @param buf Buffer needs to be sent.
1226 : * @param count Number of @ref bt_obex_tlv structures in @p data.
1227 : * @param data Array of @ref bt_obex_tlv structures.
1228 : *
1229 : * @return 0 in case of success or negative value in case of error.
1230 : */
1231 1 : int bt_obex_add_header_auth_challenge(struct net_buf *buf, size_t count,
1232 : const struct bt_obex_tlv data[]);
1233 :
1234 : /**
1235 : * OBEX digest-Response tag: Request-digest
1236 : * String of bytes representing the request digest.
1237 : */
1238 1 : #define BT_OBEX_RESPONSE_TAG_REQ_DIGEST 0x00
1239 :
1240 : /**
1241 : * OBEX digest-Response tag: User Id
1242 : * User ID string of length n. Max size is 20 bytes.
1243 : */
1244 1 : #define BT_OBEX_RESPONSE_TAG_USER_ID 0x01
1245 :
1246 : /**
1247 : * OBEX digest-Response tag: Nonce
1248 : * The nonce sent in the digest challenge string.
1249 : */
1250 1 : #define BT_OBEX_RESPONSE_TAG_NONCE 0x02
1251 :
1252 : /** @brief Add Header: authentication digest-response.
1253 : *
1254 : * @param buf Buffer needs to be sent.
1255 : * @param count Number of @ref bt_obex_tlv structures in @p data.
1256 : * @param data Array of @ref bt_obex_tlv structures.
1257 : *
1258 : * @return 0 in case of success or negative value in case of error.
1259 : */
1260 1 : int bt_obex_add_header_auth_rsp(struct net_buf *buf, size_t count, const struct bt_obex_tlv data[]);
1261 :
1262 : /** @brief Add Header: indicates the creator of an object.
1263 : *
1264 : * @param buf Buffer needs to be sent.
1265 : * @param creator_id Creator Id.
1266 : *
1267 : * @return 0 in case of success or negative value in case of error.
1268 : */
1269 1 : int bt_obex_add_header_creator_id(struct net_buf *buf, uint32_t creator_id);
1270 :
1271 : /** @brief Add Header: uniquely identifies the network client (OBEX server).
1272 : *
1273 : * @param buf Buffer needs to be sent.
1274 : * @param len Length of UUID.
1275 : * @param uuid UUID.
1276 : *
1277 : * @return 0 in case of success or negative value in case of error.
1278 : */
1279 1 : int bt_obex_add_header_wan_uuid(struct net_buf *buf, uint16_t len, const uint8_t *uuid);
1280 :
1281 : /** @brief Add Header: OBEX Object class of object.
1282 : *
1283 : * @param buf Buffer needs to be sent.
1284 : * @param len Length of object class.
1285 : * @param obj_class Class of object.
1286 : *
1287 : * @return 0 in case of success or negative value in case of error.
1288 : */
1289 1 : int bt_obex_add_header_obj_class(struct net_buf *buf, uint16_t len, const uint8_t *obj_class);
1290 :
1291 : /** @brief Add Header: parameters used in session commands/responses.
1292 : *
1293 : * @param buf Buffer needs to be sent.
1294 : * @param len Length of session parameter.
1295 : * @param session_param Session parameter.
1296 : *
1297 : * @return 0 in case of success or negative value in case of error.
1298 : */
1299 1 : int bt_obex_add_header_session_param(struct net_buf *buf, uint16_t len,
1300 : const uint8_t *session_param);
1301 :
1302 : /** @brief Add Header: sequence number used in each OBEX packet for reliability.
1303 : *
1304 : * @param buf Buffer needs to be sent.
1305 : * @param session_seq_number Session sequence parameter.
1306 : *
1307 : * @return 0 in case of success or negative value in case of error.
1308 : */
1309 1 : int bt_obex_add_header_session_seq_number(struct net_buf *buf, uint32_t session_seq_number);
1310 :
1311 : /** @brief Add Header: specifies the action to be performed (used in ACTION operation).
1312 : *
1313 : * @param buf Buffer needs to be sent.
1314 : * @param action_id Action Id @ref bt_obex_action_id.
1315 : *
1316 : * @return 0 in case of success or negative value in case of error.
1317 : */
1318 1 : int bt_obex_add_header_action_id(struct net_buf *buf, uint32_t action_id);
1319 :
1320 : /** @brief Add Header: the destination object name (used in certain ACTION operations).
1321 : *
1322 : * @param buf Buffer needs to be sent.
1323 : * @param len Length of destination name.
1324 : * @param dest_name Destination name.
1325 : *
1326 : * @return 0 in case of success or negative value in case of error.
1327 : */
1328 1 : int bt_obex_add_header_dest_name(struct net_buf *buf, uint16_t len, const uint8_t *dest_name);
1329 :
1330 : /** @brief Add Header: 4-byte bit mask for setting permissions.
1331 : *
1332 : * @param buf Buffer needs to be sent.
1333 : * @param perm Permissions.
1334 : *
1335 : * @return 0 in case of success or negative value in case of error.
1336 : */
1337 1 : int bt_obex_add_header_perm(struct net_buf *buf, uint32_t perm);
1338 :
1339 : /** @brief Add Header: 1-byte value to setup Single Response Mode (SRM).
1340 : *
1341 : * @param buf Buffer needs to be sent.
1342 : * @param srm SRM.
1343 : *
1344 : * @return 0 in case of success or negative value in case of error.
1345 : */
1346 1 : int bt_obex_add_header_srm(struct net_buf *buf, uint8_t srm);
1347 :
1348 : /** @brief Add Header: Single Response Mode (SRM) Parameter.
1349 : *
1350 : * @param buf Buffer needs to be sent.
1351 : * @param srm_param SRM parameter.
1352 : *
1353 : * @return 0 in case of success or negative value in case of error.
1354 : */
1355 1 : int bt_obex_add_header_srm_param(struct net_buf *buf, uint8_t srm_param);
1356 :
1357 : /** @brief OBEX Header structure */
1358 1 : struct bt_obex_hdr {
1359 : /** Header ID @ref bt_obex_header_id */
1360 1 : uint8_t id;
1361 : /** The length of header value */
1362 1 : uint16_t len;
1363 : /** Header value */
1364 1 : const uint8_t *data;
1365 : };
1366 :
1367 : /** @brief Helper for parsing OBEX header.
1368 : *
1369 : * A helper for parsing the header structure for OBEX packets. The most common scenario is to
1370 : * call this helper on the in the callback of OBEX server and client.
1371 : *
1372 : * @warning This helper function will consume `buf` when parsing. The user should make a copy
1373 : * if the original data is to be used afterwards.
1374 : *
1375 : * @param buf OBEX packet as given to the callback of OBEX server and client.
1376 : * @param func Callback function which will be called for each element that's found in the data
1377 : * The callback should return true to continue parsing, or false to stop parsing.
1378 : * @param user_data User data to be passed to the callback.
1379 : *
1380 : * @return 0 in case of success or negative value in case of error.
1381 : */
1382 1 : int bt_obex_header_parse(struct net_buf *buf,
1383 : bool (*func)(struct bt_obex_hdr *hdr, void *user_data), void *user_data);
1384 :
1385 : /** @brief Get header value: number of objects (used by Connect)
1386 : *
1387 : * @param buf Buffer needs to be sent.
1388 : * @param count Number of objects.
1389 : *
1390 : * @return 0 in case of success or negative value in case of error.
1391 : */
1392 1 : int bt_obex_get_header_count(struct net_buf *buf, uint32_t *count);
1393 :
1394 : /** @brief Get header value: name of the object (often a file name)
1395 : *
1396 : * @param buf Buffer needs to be sent.
1397 : * @param len Length of name.
1398 : * @param name Name of the object.
1399 : *
1400 : * @return 0 in case of success or negative value in case of error.
1401 : */
1402 1 : int bt_obex_get_header_name(struct net_buf *buf, uint16_t *len, const uint8_t **name);
1403 :
1404 : /** @brief Get header value: type of object - e.g. text, html, binary, manufacturer specific
1405 : *
1406 : * @param buf Buffer needs to be sent.
1407 : * @param len Length of type.
1408 : * @param type Type of the object.
1409 : *
1410 : * @return 0 in case of success or negative value in case of error.
1411 : */
1412 1 : int bt_obex_get_header_type(struct net_buf *buf, uint16_t *len, const uint8_t **type);
1413 :
1414 : /** @brief Get header value: the length of the object in bytes
1415 : *
1416 : * @param buf Buffer needs to be sent.
1417 : * @param len The length of the object in bytes.
1418 : *
1419 : * @return 0 in case of success or negative value in case of error.
1420 : */
1421 1 : int bt_obex_get_header_len(struct net_buf *buf, uint32_t *len);
1422 :
1423 : /** @brief Get header value: date/time stamp – ISO 8601 version - preferred
1424 : *
1425 : * @param buf Buffer needs to be sent.
1426 : * @param len Length of data/time stamp.
1427 : * @param t Data/time stamp.
1428 : *
1429 : * @return 0 in case of success or negative value in case of error.
1430 : */
1431 1 : int bt_obex_get_header_time_iso_8601(struct net_buf *buf, uint16_t *len, const uint8_t **t);
1432 :
1433 : /** @brief Get header value: date/time stamp – 4 byte version (for compatibility only)
1434 : *
1435 : * @param buf Buffer needs to be sent.
1436 : * @param t Data/time stamp.
1437 : *
1438 : * @return 0 in case of success or negative value in case of error.
1439 : */
1440 1 : int bt_obex_get_header_time(struct net_buf *buf, uint32_t *t);
1441 :
1442 : /** @brief Get header value: text description of the object
1443 : *
1444 : * @param buf Buffer needs to be sent.
1445 : * @param len Length of description.
1446 : * @param dec Description of the object.
1447 : *
1448 : * @return 0 in case of success or negative value in case of error.
1449 : */
1450 1 : int bt_obex_get_header_description(struct net_buf *buf, uint16_t *len, const uint8_t **dec);
1451 :
1452 : /** @brief Get header value: name of service that operation is targeted to
1453 : *
1454 : * @param buf Buffer needs to be sent.
1455 : * @param len Length of target name.
1456 : * @param target Target name.
1457 : *
1458 : * @return 0 in case of success or negative value in case of error.
1459 : */
1460 1 : int bt_obex_get_header_target(struct net_buf *buf, uint16_t *len, const uint8_t **target);
1461 :
1462 : /** @brief Get header value: an HTTP 1.x header
1463 : *
1464 : * @param buf Buffer needs to be sent.
1465 : * @param len Length of http 1.x header.
1466 : * @param http Http 1.x header.
1467 : *
1468 : * @return 0 in case of success or negative value in case of error.
1469 : */
1470 1 : int bt_obex_get_header_http(struct net_buf *buf, uint16_t *len, const uint8_t **http);
1471 :
1472 : /** @brief Get header value: a chunk of the object body.
1473 : *
1474 : * @param buf Buffer needs to be sent.
1475 : * @param len Length of body.
1476 : * @param body Object Body.
1477 : *
1478 : * @return 0 in case of success or negative value in case of error.
1479 : */
1480 1 : int bt_obex_get_header_body(struct net_buf *buf, uint16_t *len, const uint8_t **body);
1481 :
1482 : /** @brief Get header value: the final chunk of the object body.
1483 : *
1484 : * @param buf Buffer needs to be sent.
1485 : * @param len Length of body.
1486 : * @param body Object Body.
1487 : *
1488 : * @return 0 in case of success or negative value in case of error.
1489 : */
1490 1 : int bt_obex_get_header_end_body(struct net_buf *buf, uint16_t *len, const uint8_t **body);
1491 :
1492 : /** @brief Get header value: identifies the OBEX application, used to tell if talking to a peer.
1493 : *
1494 : * @param buf Buffer needs to be sent.
1495 : * @param len Length of who.
1496 : * @param who Who.
1497 : *
1498 : * @return 0 in case of success or negative value in case of error.
1499 : */
1500 1 : int bt_obex_get_header_who(struct net_buf *buf, uint16_t *len, const uint8_t **who);
1501 :
1502 : /** @brief Get header value: an identifier used for OBEX connection multiplexing.
1503 : *
1504 : * @param buf Buffer needs to be sent.
1505 : * @param conn_id Connection Id.
1506 : *
1507 : * @return 0 in case of success or negative value in case of error.
1508 : */
1509 1 : int bt_obex_get_header_conn_id(struct net_buf *buf, uint32_t *conn_id);
1510 :
1511 : /** @brief Helper for parsing OBEX TLV triplet.
1512 : *
1513 : * A helper for parsing the TLV triplet structure for OBEX packets. The most common scenario is to
1514 : * call this helper on the in the callback of OBEX server and client.
1515 : * The @p data is encoded by using A Tag-Length-Value encoding scheme. Usually, it is the header
1516 : * value of the header `Application Request-Response Parameters`, `Authenticate Challenge`, and
1517 : * `Authenticate Response`. It means the @p data is the output of the
1518 : * @ref bt_obex_get_header_app_param, @ref bt_obex_get_header_auth_challenge, or
1519 : * @ref bt_obex_get_header_auth_rsp.
1520 : *
1521 : * @param len The length of the @p data.
1522 : * @param data The data as given to the callback of OBEX server and client.
1523 : * @param func Callback function which will be called for each TLV triplet that's found from the
1524 : * @p data. The callback should return true to continue parsing, or false to stop
1525 : * parsing.
1526 : * @param user_data User data to be passed to the callback.
1527 : *
1528 : * @return 0 in case of success or negative value in case of error.
1529 : */
1530 1 : int bt_obex_tlv_parse(uint16_t len, const uint8_t *data,
1531 : bool (*func)(struct bt_obex_tlv *tlv, void *user_data), void *user_data);
1532 :
1533 : /** @brief Get header value: extended application request & response information.
1534 : *
1535 : * The parameter can be parsed by calling @ref bt_obex_tlv_parse.
1536 : *
1537 : * @param buf Buffer needs to be sent.
1538 : * @param len Length of app_param.
1539 : * @param app_param Application parameter.
1540 : *
1541 : * @return 0 in case of success or negative value in case of error.
1542 : */
1543 1 : int bt_obex_get_header_app_param(struct net_buf *buf, uint16_t *len, const uint8_t **app_param);
1544 :
1545 : /** @brief Get header value: authentication digest-challenge.
1546 : *
1547 : * The options can be parsed by calling @ref bt_obex_tlv_parse.
1548 : *
1549 : * @param buf Buffer needs to be sent.
1550 : * @param len Length of auth_challenge.
1551 : * @param auth Authentication challenge.
1552 : *
1553 : * @return 0 in case of success or negative value in case of error.
1554 : */
1555 1 : int bt_obex_get_header_auth_challenge(struct net_buf *buf, uint16_t *len, const uint8_t **auth);
1556 :
1557 : /** @brief Get header value: authentication digest-response.
1558 : *
1559 : * The options can be parsed by calling @ref bt_obex_tlv_parse.
1560 : *
1561 : * @param buf Buffer needs to be sent.
1562 : * @param len Length of authentication response.
1563 : * @param auth Authentication response.
1564 : *
1565 : * @return 0 in case of success or negative value in case of error.
1566 : */
1567 1 : int bt_obex_get_header_auth_rsp(struct net_buf *buf, uint16_t *len, const uint8_t **auth);
1568 :
1569 : /** @brief Get header value: indicates the creator of an object.
1570 : *
1571 : * @param buf Buffer needs to be sent.
1572 : * @param creator_id Creator Id.
1573 : *
1574 : * @return 0 in case of success or negative value in case of error.
1575 : */
1576 1 : int bt_obex_get_header_creator_id(struct net_buf *buf, uint32_t *creator_id);
1577 :
1578 : /** @brief Get header value: uniquely identifies the network client (OBEX server).
1579 : *
1580 : * @param buf Buffer needs to be sent.
1581 : * @param len Length of UUID.
1582 : * @param uuid UUID.
1583 : *
1584 : * @return 0 in case of success or negative value in case of error.
1585 : */
1586 1 : int bt_obex_get_header_wan_uuid(struct net_buf *buf, uint16_t *len, const uint8_t **uuid);
1587 :
1588 : /** @brief Get header value: oBEX Object class of object.
1589 : *
1590 : * @param buf Buffer needs to be sent.
1591 : * @param len Length of oject class.
1592 : * @param obj_class Class of object.
1593 : *
1594 : * @return 0 in case of success or negative value in case of error.
1595 : */
1596 1 : int bt_obex_get_header_obj_class(struct net_buf *buf, uint16_t *len, const uint8_t **obj_class);
1597 :
1598 : /** @brief Get header value: parameters used in session commands/responses.
1599 : *
1600 : * @param buf Buffer needs to be sent.
1601 : * @param len Length of session parameter.
1602 : * @param session_param Session parameter.
1603 : *
1604 : * @return 0 in case of success or negative value in case of error.
1605 : */
1606 1 : int bt_obex_get_header_session_param(struct net_buf *buf, uint16_t *len,
1607 : const uint8_t **session_param);
1608 :
1609 : /** @brief Get header value: sequence number used in each OBEX packet for reliability.
1610 : *
1611 : * @param buf Buffer needs to be sent.
1612 : * @param session_seq_number Session sequence parameter.
1613 : *
1614 : * @return 0 in case of success or negative value in case of error.
1615 : */
1616 1 : int bt_obex_get_header_session_seq_number(struct net_buf *buf, uint32_t *session_seq_number);
1617 :
1618 : /** @brief Get header value: specifies the action to be performed (used in ACTION operation).
1619 : *
1620 : * @param buf Buffer needs to be sent.
1621 : * @param action_id Action Id @ref bt_obex_action_id.
1622 : *
1623 : * @return 0 in case of success or negative value in case of error.
1624 : */
1625 1 : int bt_obex_get_header_action_id(struct net_buf *buf, uint32_t *action_id);
1626 :
1627 : /** @brief Get header value: the destination object name (used in certain ACTION operations).
1628 : *
1629 : * @param buf Buffer needs to be sent.
1630 : * @param len Length of destination name.
1631 : * @param dest_name Destination name.
1632 : *
1633 : * @return 0 in case of success or negative value in case of error.
1634 : */
1635 1 : int bt_obex_get_header_dest_name(struct net_buf *buf, uint16_t *len, const uint8_t **dest_name);
1636 :
1637 : /** @brief Get header value: 4-byte bit mask for setting permissions.
1638 : *
1639 : * @param buf Buffer needs to be sent.
1640 : * @param perm Permissions.
1641 : *
1642 : * @return 0 in case of success or negative value in case of error.
1643 : */
1644 1 : int bt_obex_get_header_perm(struct net_buf *buf, uint32_t *perm);
1645 :
1646 : /** @brief Get header value: 1-byte value to setup Single Response Mode (SRM).
1647 : *
1648 : * @param buf Buffer needs to be sent.
1649 : * @param srm SRM.
1650 : *
1651 : * @return 0 in case of success or negative value in case of error.
1652 : */
1653 1 : int bt_obex_get_header_srm(struct net_buf *buf, uint8_t *srm);
1654 :
1655 : /** @brief Get header value: Single Response Mode (SRM) Parameter.
1656 : *
1657 : * @param buf Buffer needs to be sent.
1658 : * @param srm_param SRM parameter.
1659 : *
1660 : * @return 0 in case of success or negative value in case of error.
1661 : */
1662 1 : int bt_obex_get_header_srm_param(struct net_buf *buf, uint8_t *srm_param);
1663 :
1664 : /** @brief Make the UUID with specific data and len
1665 : *
1666 : * @param uuid OBEX uuid.
1667 : * @param data UUID data.
1668 : * @param len UUID data length.
1669 : *
1670 : * @return 0 in case of success or negative value in case of error.
1671 : */
1672 1 : int bt_obex_make_uuid(union bt_obex_uuid *uuid, const uint8_t *data, uint16_t len);
1673 :
1674 : #ifdef __cplusplus
1675 : }
1676 : #endif
1677 :
1678 : /**
1679 : * @}
1680 : */
1681 :
1682 : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_OBEX_H_ */
|