Skip to content

Commit

Permalink
make coap_print_wellknown a public function and add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
anyc committed May 29, 2024
1 parent 4acbc3d commit eb1685b
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 7 deletions.
29 changes: 29 additions & 0 deletions include/coap3/coap_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,35 @@ coap_print_status_t coap_print_link(const coap_resource_t *resource,
size_t *len,
size_t *offset);

/**
* Prints the names of all known resources to @p buf. This function
* sets @p buflen to the number of bytes actually written and returns
* @c 1 on succes. On error, the value in @p buflen is undefined and
* the return value will be @c 0.
*
* @param context The context with the resource map.
* @param session The CoAP session.
* @param buf The buffer to write the result.
* @param buflen Must be initialized to the maximum length of @p buf and will be
* set to the length of the well-known response on return.
* @param offset The offset in bytes where the output shall start and is
* shifted accordingly with the characters that have been
* processed. This parameter is used to support the block
* option.
* @param query_filter A filter query according to <a href="http://tools.ietf.org/html/draft-ietf-core-link-format-11#section-4.1">Link Format</a>
*
* @return COAP_PRINT_STATUS_ERROR on error. Otherwise, the lower 28 bits are
* set to the number of bytes that have actually been written to
* @p buf. COAP_PRINT_STATUS_TRUNC is set when the output has been
* truncated.
*/
coap_print_status_t coap_print_wellknown(coap_context_t *context,
coap_session_t *session,
unsigned char *buf,
size_t *buflen,
size_t offset,
const coap_string_t *query_filter);

/** @} */

/**
Expand Down
6 changes: 0 additions & 6 deletions include/coap3/coap_resource_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@ coap_resource_t *coap_get_resource_from_uri_path_lkd(coap_context_t *context,
*/
void coap_delete_attr(coap_attr_t *attr);

coap_print_status_t coap_print_wellknown(coap_context_t *,
coap_session_t *,
unsigned char *,
size_t *, size_t,
const coap_string_t *);

/** @} */

#endif /* COAP_SERVER_SUPPORT */
Expand Down
1 change: 1 addition & 0 deletions libcoap-3.map
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ global:
coap_print_addr;
coap_print_ip_addr;
coap_print_link;
coap_print_wellknown;
coap_prng;
coap_prng_init;
coap_q_block_is_supported;
Expand Down
1 change: 1 addition & 0 deletions libcoap-3.sym
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ coap_persist_track_funcs
coap_print_addr
coap_print_ip_addr
coap_print_link
coap_print_wellknown
coap_prng
coap_prng_init
coap_q_block_is_supported
Expand Down
1 change: 1 addition & 0 deletions man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ install-man: install-man3 install-man5 install-man7
@echo ".so man3/coap_resource.3" > coap_resource_release_userdata_handler.3
@echo ".so man3/coap_resource.3" > coap_resource_get_uri_path.3
@echo ".so man3/coap_resource.3" > coap_get_resource_from_uri_path.3
@echo ".so man3/coap_resource.3" > coap_print_wellknown.3
@echo ".so man3/coap_session.3" > coap_session_get_addr_remote.3
@echo ".so man3/coap_session.3" > coap_session_get_context.3
@echo ".so man3/coap_session.3" > coap_session_get_ifindex.3
Expand Down
15 changes: 14 additions & 1 deletion man/coap_resource.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ coap_resource_set_userdata,
coap_resource_get_userdata,
coap_resource_release_userdata_handler,
coap_resource_get_uri_path,
coap_get_resource_from_uri_path
coap_get_resource_from_uri_path,
coap_print_wellknown
- Work with CoAP resources

SYNOPSIS
Expand Down Expand Up @@ -66,6 +67,10 @@ coap_resource_release_userdata_handler_t _callback_);*
*coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *_context_,
coap_str_const_t *_uri_path_);*

*coap_print_status_t coap_print_wellknown(coap_context_t *context,
coap_session_t *session, unsigned char *buf, size_t *buflen, size_t offset,
const coap_string_t *query_filter);*

For specific (D)TLS library support, link with
*-lcoap-@LIBCOAP_API_VERSION@-notls*, *-lcoap-@LIBCOAP_API_VERSION@-gnutls*,
*-lcoap-@LIBCOAP_API_VERSION@-openssl*, *-lcoap-@LIBCOAP_API_VERSION@-mbedtls*,
Expand Down Expand Up @@ -292,6 +297,10 @@ the _resource_ definion.
The *coap_get_resource_from_uri_path*() function is used to return the resource
identified by the unique string _uri_path_ associated with _context_.

*Function: coap_print_wellknown()*

The *coap_print_wellknown*() function prints the names of all known resources
of the given _context_ into _buf_.

RETURN VALUES
-------------
Expand All @@ -312,6 +321,10 @@ there was a failure.
*coap_get_resource_from_uri_path*() returns the resource or NULL
if not found.

*coap_print_wellknown*() returns COAP_PRINT_STATUS_ERROR on error. Otherwise,
the lower 28 bits are set to the number of bytes that have actually been
written. COAP_PRINT_STATUS_TRUNC is set when the output has been truncated.

EXAMPLES
--------
*Fixed Resources Set Up*
Expand Down

0 comments on commit eb1685b

Please sign in to comment.