1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

nanocoap_sock: always use coap_opt_put_uri_pathquery()

This commit is contained in:
Benjamin Valentin 2024-01-11 16:16:44 +01:00
parent bb4c4ddf20
commit a470c1cb44
2 changed files with 13 additions and 12 deletions

View File

@ -318,7 +318,7 @@ static inline void nanocoap_sock_close(nanocoap_sock_t *sock)
* @brief Simple synchronous CoAP (confirmable) GET
*
* @param[in] sock socket to use for the request
* @param[in] path remote path
* @param[in] path remote path and query
* @param[out] buf buffer to write response to
* @param[in] len length of @p buffer
*
@ -332,7 +332,7 @@ ssize_t nanocoap_sock_get(nanocoap_sock_t *sock, const char *path, void *buf,
* @brief Simple synchronous CoAP (confirmable) PUT
*
* @param[in] sock socket to use for the request
* @param[in] path remote path
* @param[in] path remote path and query
* @param[in] request buffer containing the payload
* @param[in] len length of the payload to send
* @param[out] response buffer for the response, may be NULL
@ -349,7 +349,7 @@ ssize_t nanocoap_sock_put(nanocoap_sock_t *sock, const char *path,
* @brief Simple non-confirmable PUT
*
* @param[in] sock socket to use for the request
* @param[in] path remote path
* @param[in] path remote path and query
* @param[in] request buffer containing the payload
* @param[in] len length of the payload to send
* @param[out] response buffer for the response, may be NULL
@ -384,7 +384,7 @@ ssize_t nanocoap_sock_put_url(const char *url,
* @brief Simple synchronous CoAP (confirmable) POST
*
* @param[in] sock socket to use for the request
* @param[in] path remote path
* @param[in] path remote path and query
* @param[in] request buffer containing the payload
* @param[in] len length of the payload to send
* @param[out] response buffer for the response, may be NULL
@ -401,7 +401,7 @@ ssize_t nanocoap_sock_post(nanocoap_sock_t *sock, const char *path,
* @brief Simple non-confirmable POST
*
* @param[in] sock socket to use for the request
* @param[in] path remote path
* @param[in] path remote path and query
* @param[in] request buffer containing the payload
* @param[in] len length of the payload to send
* @param[out] response buffer for the response, may be NULL
@ -437,7 +437,7 @@ ssize_t nanocoap_sock_post_url(const char *url,
* ([RFC 8132](https://datatracker.ietf.org/doc/html/rfc8132))
*
* @param[in] sock socket to use for the request
* @param[in] path remote path
* @param[in] path remote path and query
* @param[in] request buffer containing the payload
* @param[in] len length of the payload to send
* @param[out] response buffer for the response, may be NULL
@ -455,7 +455,7 @@ ssize_t nanocoap_sock_fetch(nanocoap_sock_t *sock, const char *path,
* ([RFC 8132](https://datatracker.ietf.org/doc/html/rfc8132))
*
* @param[in] sock socket to use for the request
* @param[in] path remote path
* @param[in] path remote path and query
* @param[in] request buffer containing the payload
* @param[in] len length of the payload to send
* @param[out] response buffer for the response, may be NULL
@ -491,7 +491,7 @@ ssize_t nanocoap_sock_fetch_url(const char *url,
* @brief Simple synchronous CoAP (confirmable) DELETE
*
* @param[in] sock socket to use for the request
* @param[in] path remote path to delete
* @param[in] path remote path (with query) to delete
*
* @returns 0 on success
* @returns <0 on error

View File

@ -384,7 +384,7 @@ ssize_t nanocoap_sock_get(nanocoap_sock_t *sock, const char *path, void *buf, si
pktpos += coap_build_hdr(pkt.hdr, COAP_TYPE_CON, NULL, 0, COAP_METHOD_GET,
nanocoap_sock_next_msg_id(sock));
pktpos += coap_opt_put_uri_path(pktpos, 0, path);
pktpos += coap_opt_put_uri_pathquery(pktpos, NULL, path);
pkt.payload = pktpos;
pkt.payload_len = 0;
@ -415,12 +415,13 @@ ssize_t _sock_put_post(nanocoap_sock_t *sock, const char *path, unsigned code,
.iov_len = max_len,
};
uint16_t lastonum = 0;
pktpos += coap_build_hdr(pkt.hdr, type, NULL, 0, code, nanocoap_sock_next_msg_id(sock));
pktpos += coap_opt_put_uri_path(pktpos, 0, path);
pktpos += coap_opt_put_uri_pathquery(pktpos, &lastonum, path);
if (response == NULL && type == COAP_TYPE_NON) {
/* all responses (2.xx, 4.xx and 5.xx) are ignored */
pktpos += coap_opt_put_uint(pktpos, COAP_OPT_URI_PATH,
pktpos += coap_opt_put_uint(pktpos, lastonum,
COAP_OPT_NO_RESPONSE, 26);
}
@ -533,7 +534,7 @@ ssize_t nanocoap_sock_delete(nanocoap_sock_t *sock, const char *path)
pktpos += coap_build_hdr(pkt.hdr, COAP_TYPE_CON, NULL, 0, COAP_METHOD_DELETE,
nanocoap_sock_next_msg_id(sock));
pktpos += coap_opt_put_uri_path(pktpos, 0, path);
pktpos += coap_opt_put_uri_pathquery(pktpos, NULL, path);
pkt.payload = pktpos;