From 769978904a19ec6c6f1c14184fb87a427443fd9f Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 21 Jan 2021 15:40:40 +0100 Subject: [PATCH] suit/transport/coap: use coap_opt_put_uri() The URI is passed as a string to `suit_coap_get_blockwise()`. It may contain query parameters, those will not be translated properly to CoAP options if `coap_opt_put_uri_path()` is used. Instead use `coap_opt_put_uri()` to handle both path and query parameters. --- sys/suit/transport/coap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/suit/transport/coap.c b/sys/suit/transport/coap.c index 77e3702012..fefa6aecc1 100644 --- a/sys/suit/transport/coap.c +++ b/sys/suit/transport/coap.c @@ -198,14 +198,15 @@ static int _fetch_block(coap_pkt_t *pkt, uint8_t *buf, sock_udp_t *sock, const char *path, coap_blksize_t blksize, size_t num) { uint8_t *pktpos = buf; + uint16_t lastonum = 0; pkt->hdr = (coap_hdr_t *)buf; pktpos += coap_build_hdr(pkt->hdr, COAP_TYPE_CON, NULL, 0, COAP_METHOD_GET, num); - pktpos += coap_opt_put_uri_path(pktpos, 0, path); + pktpos += coap_opt_put_uri_pathquery(pktpos, &lastonum, path); pktpos += - coap_opt_put_uint(pktpos, COAP_OPT_URI_PATH, COAP_OPT_BLOCK2, + coap_opt_put_uint(pktpos, lastonum, COAP_OPT_BLOCK2, (num << 4) | blksize); pkt->payload = pktpos;