Skip to content

Commit

Permalink
gcoap: Rename gcoap_get_resource_list_tl to gcoap_get_resource_list
Browse files Browse the repository at this point in the history
This is an API change in the latter, which would typically now take an
extra argument GCOAP_SOCKET_TYPE_UNDEF.

Follow-Up-For: RIOT-OS#16688
  • Loading branch information
chrysn authored and Zhaolan Huang committed Dec 6, 2023
1 parent f256721 commit b51f45d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
28 changes: 1 addition & 27 deletions sys/include/net/gcoap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,6 @@ uint8_t gcoap_op_state(void);
* @brief Get the resource list, currently only `CoRE Link Format`
* (COAP_FORMAT_LINK) supported
*
* @deprecated Will be an alias for @ref gcoap_get_resource_list after the
* 2022.01 release. Will be removed after the 2022.04 release.
*
* If @p buf := NULL, nothing will be written but the size of the resulting
* resource list is computed and returned.
*
Expand All @@ -1109,32 +1106,9 @@ uint8_t gcoap_op_state(void);
* @return the number of bytes written to @p buf
* @return -1 on error
*/
int gcoap_get_resource_list_tl(void *buf, size_t maxlen, uint8_t cf,
int gcoap_get_resource_list(void *buf, size_t maxlen, uint8_t cf,
gcoap_socket_type_t tl_type);

/**
* @brief Get the resource list for all transports,
* currently only `CoRE Link Format` (COAP_FORMAT_LINK) supported
*
* If @p buf := NULL, nothing will be written but the size of the resulting
* resource list is computed and returned.
*
* @param[out] buf output buffer to write resource list into, my be NULL
* @param[in] maxlen length of @p buf, ignored if @p buf is NULL
* @param[in] cf content format to use for the resource list, currently
* only COAP_FORMAT_LINK supported
*
* @todo add support for `JSON CoRE Link Format`
* @todo add support for 'CBOR CoRE Link Format`
*
* @return the number of bytes written to @p buf
* @return -1 on error
*/
static inline int gcoap_get_resource_list(void *buf, size_t maxlen, uint8_t cf)
{
return gcoap_get_resource_list_tl(buf, maxlen, cf, GCOAP_SOCKET_TYPE_UNDEF);
}

/**
* @brief Writes a resource in CoRE Link Format to a provided buffer.
*
Expand Down
2 changes: 1 addition & 1 deletion sys/net/application_layer/cord/ep/cord_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ int cord_ep_register(const sock_udp_ep_t *remote, const char *regif)

/* add the resource description as payload */
res = gcoap_get_resource_list(pkt.payload, pkt.payload_len,
COAP_FORMAT_LINK);
COAP_FORMAT_LINK, GCOAP_SOCKET_TYPE_UNDEF);
if (res < 0) {
retval = CORD_EP_ERR;
goto end;
Expand Down
4 changes: 2 additions & 2 deletions sys/net/application_layer/gcoap/gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ static ssize_t _well_known_core_handler(coap_pkt_t* pdu, uint8_t *buf, size_t le
coap_opt_add_format(pdu, COAP_FORMAT_LINK);
ssize_t plen = coap_opt_finish(pdu, COAP_OPT_FINISH_PAYLOAD);

plen += gcoap_get_resource_list_tl(pdu->payload, (size_t)pdu->payload_len,
plen += gcoap_get_resource_list(pdu->payload, (size_t)pdu->payload_len,
COAP_FORMAT_LINK,
(gcoap_socket_type_t)coap_request_ctx_get_tl_type(ctx));
return plen;
Expand Down Expand Up @@ -1706,7 +1706,7 @@ uint8_t gcoap_op_state(void)
return count;
}

int gcoap_get_resource_list_tl(void *buf, size_t maxlen, uint8_t cf,
int gcoap_get_resource_list(void *buf, size_t maxlen, uint8_t cf,
gcoap_socket_type_t tl_type)
{
assert(cf == COAP_FORMAT_LINK);
Expand Down
6 changes: 3 additions & 3 deletions tests/unittests/tests-gcoap/tests-gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,15 @@ static void test_gcoap__server_get_resource_list(void)
gcoap_register_listener(&listener);
gcoap_register_listener(&listener_second);

size = gcoap_get_resource_list(NULL, 0, COAP_FORMAT_LINK);
size = gcoap_get_resource_list(NULL, 0, COAP_FORMAT_LINK, GCOAP_SOCKET_TYPE_UNDEF);
TEST_ASSERT_EQUAL_INT(strlen(resource_list_str), size);

res[0] = 'A';
size = gcoap_get_resource_list(res, 0, COAP_FORMAT_LINK);
size = gcoap_get_resource_list(res, 0, COAP_FORMAT_LINK, GCOAP_SOCKET_TYPE_UNDEF);
TEST_ASSERT_EQUAL_INT(0, size);
TEST_ASSERT_EQUAL_INT((int)'A', (int)res[0]);

size = gcoap_get_resource_list(res, 127, COAP_FORMAT_LINK);
size = gcoap_get_resource_list(res, 127, COAP_FORMAT_LINK, GCOAP_SOCKET_TYPE_UNDEF);
res[size] = '\0';
TEST_ASSERT_EQUAL_INT(strlen(resource_list_str), size);
TEST_ASSERT_EQUAL_STRING(resource_list_str, (char *)res);
Expand Down

0 comments on commit b51f45d

Please sign in to comment.