[riot-notifications] [RIOT-OS/RIOT] net/nanocoap: get option bytes (#12075)

chrysn notifications at github.com
Wed Sep 11 16:11:32 CEST 2019


chrysn commented on this pull request.



> @@ -573,6 +573,23 @@ static inline ssize_t coap_get_uri_query(const coap_pkt_t *pkt, uint8_t *target)
  */
 ssize_t coap_opt_get_next(const coap_pkt_t *pkt, coap_optpos_t *opt,
                           uint8_t **value, bool init_opt);
+
+/**
+ * @brief   Retrieve the value for an option as an opaque array of bytes
+ *
+ * Retrieves the location and length of the option value of any type. Useful for
+ * an opaque option, which essentially is an array of bytes. If more than one
+ * option for a given option number, retrieves the first option. To retrieve
+ * subsequent options, see coap_opt_get_next().

I don't think that the library user should be trusted to do the `{0, value + optlen - (uint8_t *)pkt.hdr}` calculation from a coap_opt_get_opaque invocation. I suggest this method be only advertised for single-valued option.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/12075#pullrequestreview-286819687
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190911/aa9ab62d/attachment.htm>


More information about the notifications mailing list