mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
Merge pull request #20191 from benpicco/coap_get_method
nanocoap: introduce coap_get_method()
This commit is contained in:
commit
e3ce765a04
@ -499,6 +499,18 @@ static inline unsigned coap_get_code_raw(const coap_pkt_t *pkt)
|
||||
return (unsigned)pkt->hdr->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a request's method type
|
||||
*
|
||||
* @param[in] pkt CoAP request packet
|
||||
*
|
||||
* @returns request method type
|
||||
*/
|
||||
static inline coap_method_t coap_get_method(const coap_pkt_t *pkt)
|
||||
{
|
||||
return pkt->hdr->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the message ID of the given CoAP packet
|
||||
*
|
||||
|
@ -434,7 +434,7 @@ static ssize_t _delete_file(coap_pkt_t *pdu, uint8_t *buf, size_t len,
|
||||
static ssize_t nanocoap_fileserver_file_handler(coap_pkt_t *pdu, uint8_t *buf, size_t len,
|
||||
struct requestdata *request)
|
||||
{
|
||||
switch (coap_get_code_raw(pdu)) {
|
||||
switch (coap_get_method(pdu)) {
|
||||
case COAP_METHOD_GET:
|
||||
return _get_file(pdu, buf, len, request);
|
||||
#if IS_USED(MODULE_NANOCOAP_FILESERVER_PUT)
|
||||
@ -568,7 +568,7 @@ static ssize_t nanocoap_fileserver_directory_handler(coap_pkt_t *pdu, uint8_t *b
|
||||
struct requestdata *request,
|
||||
const char *root, const char* resource_dir)
|
||||
{
|
||||
switch (coap_get_code_raw(pdu)) {
|
||||
switch (coap_get_method(pdu)) {
|
||||
case COAP_METHOD_GET:
|
||||
return _get_directory(pdu, buf, len, request, root, resource_dir);
|
||||
#if IS_USED(MODULE_NANOCOAP_FILESERVER_PUT)
|
||||
|
Loading…
Reference in New Issue
Block a user