Line data Source code
1 1 : /*
2 : * Copyright (c) 2018 Intel Corporation
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : *
10 : * @brief CoAP implementation for Zephyr.
11 : */
12 :
13 : #ifndef ZEPHYR_INCLUDE_NET_COAP_LINK_FORMAT_H_
14 : #define ZEPHYR_INCLUDE_NET_COAP_LINK_FORMAT_H_
15 :
16 : /**
17 : * @addtogroup coap COAP Library
18 : * @{
19 : */
20 :
21 : #ifdef __cplusplus
22 : extern "C" {
23 : #endif
24 :
25 : /**
26 : * This resource should be added before all other resources that should be
27 : * included in the responses of the .well-known/core resource if is to be used with
28 : * coap_well_known_core_get.
29 : */
30 1 : #define COAP_WELL_KNOWN_CORE_PATH \
31 : ((const char * const[]) { ".well-known", "core", NULL })
32 :
33 : /**
34 : * @brief Build a CoAP response for a .well-known/core CoAP request.
35 : *
36 : * @param resource Array of known resources, terminated with an empty resource
37 : * @param request A pointer to the .well-known/core CoAP request
38 : * @param response A pointer to a CoAP response, will be initialized
39 : * @param data A data pointer to be used to build the CoAP response
40 : * @param data_len The maximum length of the data buffer
41 : *
42 : * @return 0 in case of success or negative in case of error.
43 : */
44 1 : int coap_well_known_core_get(struct coap_resource *resource,
45 : const struct coap_packet *request,
46 : struct coap_packet *response,
47 : uint8_t *data, uint16_t data_len);
48 :
49 : /**
50 : * @brief Build a CoAP response for a .well-known/core CoAP request.
51 : *
52 : * @param resources Array of known resources
53 : * @param resources_len Number of resources in the array
54 : * @param request A pointer to the .well-known/core CoAP request
55 : * @param response A pointer to a CoAP response, will be initialized
56 : * @param data A data pointer to be used to build the CoAP response
57 : * @param data_len The maximum length of the data buffer
58 : *
59 : * @return 0 in case of success or negative in case of error.
60 : */
61 1 : int coap_well_known_core_get_len(struct coap_resource *resources,
62 : size_t resources_len,
63 : const struct coap_packet *request,
64 : struct coap_packet *response,
65 : uint8_t *data, uint16_t data_len);
66 :
67 : /**
68 : * In case you want to add attributes to the resources included in the
69 : * 'well-known/core' "virtual" resource, the 'user_data' field should point
70 : * to a valid coap_core_metadata structure.
71 : */
72 1 : struct coap_core_metadata {
73 : /** List of attributes to add */
74 1 : const char * const *attributes;
75 : /** User specific data */
76 1 : void *user_data;
77 : };
78 :
79 : #ifdef __cplusplus
80 : }
81 : #endif
82 :
83 : /**
84 : * @}
85 : */
86 :
87 : #endif /* ZEPHYR_INCLUDE_NET_COAP_LINK_FORMAT_H_ */
|