From d746fc24e5a7b617d8477500782cb9a3c7ba8cd8 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Thu, 30 Sep 2021 21:27:07 +0100 Subject: [PATCH] coap_pdu_parse: Add to public API --- include/coap3/coap_pdu_internal.h | 19 ------------------- include/coap3/pdu.h | 19 +++++++++++++++++++ libcoap-3.map | 1 + libcoap-3.sym | 1 + 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/coap3/coap_pdu_internal.h b/include/coap3/coap_pdu_internal.h index d7c4b9ff..9959420c 100644 --- a/include/coap3/coap_pdu_internal.h +++ b/include/coap3/coap_pdu_internal.h @@ -201,25 +201,6 @@ int coap_pdu_parse_header(coap_pdu_t *pdu, coap_proto_t proto); */ int coap_pdu_parse_opt(coap_pdu_t *pdu); -/** -* Parses @p data into the CoAP PDU structure given in @p result. -* The target pdu must be large enough to -* This function returns @c 0 on error or a number greater than zero on success. -* -* @param proto Session's protocol -* @param data The raw data to parse as CoAP PDU. -* @param length The actual size of @p data. -* @param pdu The PDU structure to fill. Note that the structure must -* provide space to hold at least the token and options -* part of the message. -* -* @return 1 on success or @c 0 on error. -*/ -int coap_pdu_parse(coap_proto_t proto, - const uint8_t *data, - size_t length, - coap_pdu_t *pdu); - /** * Clears any contents from @p pdu and resets @c used_size, * and @c data pointers. @c max_size is set to @p size, any diff --git a/include/coap3/pdu.h b/include/coap3/pdu.h index 8031a1c2..eae21883 100644 --- a/include/coap3/pdu.h +++ b/include/coap3/pdu.h @@ -394,6 +394,25 @@ coap_pdu_duplicate(const coap_pdu_t *old_pdu, const uint8_t *token, coap_opt_filter_t *drop_options); +/** + * Parses @p data into the CoAP PDU structure given in @p result. + * The target pdu must be large enough to hold the token, options and data. + * This function returns @c 0 on error or a number greater than zero on success. + * + * @param proto Session's protocol + * @param data The raw data to parse as CoAP PDU. + * @param length The actual size of @p data. + * @param pdu The PDU structure to fill. Note that the structure must + * provide space to hold the token, optional options and + * optional data. + * + * @return 1 on success or @c 0 on error. + */ +int coap_pdu_parse(coap_proto_t proto, + const uint8_t *data, + size_t length, + coap_pdu_t *pdu); + /** * Adds token of length @p len to @p pdu. * Adding the token destroys any following contents of the pdu. Hence options diff --git a/libcoap-3.map b/libcoap-3.map index ac431930..92a37b5f 100644 --- a/libcoap-3.map +++ b/libcoap-3.map @@ -142,6 +142,7 @@ global: coap_pdu_get_token; coap_pdu_get_type; coap_pdu_init; + coap_pdu_parse; coap_pdu_set_code; coap_pdu_set_mid; coap_pdu_set_type; diff --git a/libcoap-3.sym b/libcoap-3.sym index 6390d290..43adfcb1 100644 --- a/libcoap-3.sym +++ b/libcoap-3.sym @@ -140,6 +140,7 @@ coap_pdu_get_mid coap_pdu_get_token coap_pdu_get_type coap_pdu_init +coap_pdu_parse coap_pdu_set_code coap_pdu_set_mid coap_pdu_set_type