Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coap: create typedef for CoAP methods #20003

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions sys/include/net/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
* Used in a CoAP request to signal that the request payload conveys both an
* EDHOC message_3 and OSCORE protected data, combined together.
*
* @see [draft-ietf-core-oscore-edhoc-02](https://datatracker.ietf.org/doc/draft-ietf-core-oscore-edhoc/02/)

Check warning on line 88 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
*/
#define COAP_OPT_EDHOC (21)
#define COAP_OPT_BLOCK2 (23)
Expand Down Expand Up @@ -163,14 +163,20 @@
* @name CoAP method codes used in header
* @{
*/
#define COAP_CLASS_REQ (0)
#define COAP_METHOD_GET (1)
#define COAP_METHOD_POST (2)
#define COAP_METHOD_PUT (3)
#define COAP_METHOD_DELETE (4)
#define COAP_METHOD_FETCH (5)
#define COAP_METHOD_PATCH (6)
#define COAP_METHOD_IPATCH (7)
#define COAP_CLASS_REQ (0) /**< Code Class for Request */

/**
* @brief CoAP method codes used in request
*/
typedef enum {
COAP_METHOD_GET = 1, /**< GET request (no paylod) */
COAP_METHOD_POST = 2, /**< POST request (resource processes payload) */
COAP_METHOD_PUT = 3, /**< PUT request (update resource with payload) */
COAP_METHOD_DELETE = 4, /**< DELETE request (no payload, remove resource)*/
COAP_METHOD_FETCH = 5, /**< FETCH request (RFC 8132) */
COAP_METHOD_PATCH = 6, /**< PATCH request (RFC 8132) */
COAP_METHOD_IPATCH = 7, /**< iPATCH request (RFC 8132) */
} coap_method_t;
/** @} */

/**
Expand Down Expand Up @@ -348,7 +354,7 @@
#define COAP_FORMAT_SWID_CBOR (258)
/**
* @brief Content-Type `application/pkixcmp`
* @see [draft-ietf-ace-cmpv2-coap-transport](https://datatracker.ietf.org/doc/draft-ietf-ace-cmpv2-coap-transport/)

Check warning on line 357 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* @see [RFC 4210](https://datatracker.ietf.org/doc/html/rfc4210)
*/
#define COAP_FORMAT_PKIXCMP (259)
Expand Down Expand Up @@ -435,22 +441,22 @@
#define COAP_FORMAT_YAML_DATA_CBOR_ID_NAME (341)
/**
* @brief Content-Type `application/td+json`
* @see [Web of Things (WoT) Thing Description 1.1](https://www.w3.org/TR/wot-thing-description11/)

Check warning on line 444 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
*/
#define COAP_FORMAT_TD_JSON (432)
/**
* @brief Content-Type `application/tm+json`
* @see [Web of Things (WoT) Thing Description 1.1](https://www.w3.org/TR/wot-thing-description11/)

Check warning on line 449 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
*/
#define COAP_FORMAT_TM_JSON (433)
/**
* @brief Content-Type `application/voucher-cose+cbor`
* @see [draft-ietf-anima-constrained-voucher](https://datatracker.ietf.org/doc/draft-ietf-anima-constrained-voucher/)

Check warning on line 454 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
* @note Temporary registration until April 12, 2024.
*/
#define COAP_FORMAT_VOUCER_COSE_CBOR (836)
/**
* @brief Content-Type `application/vnd.ocf+cbor`

Check warning on line 459 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
*/
#define COAP_FORMAT_VND_OCF_CBOR (10000)
/**
Expand Down Expand Up @@ -482,17 +488,17 @@
#define COAP_FORMAT_VND_OMA_LWM2M_TLV (11542)
/**
* @brief Content-Type `application/vnd.oma.lwm2m+json`
* @see [OMA-TS-LightweightM2M-V1_0](https://www.openmobilealliance.org/release/LightweightM2M/V1_0-20170208-A/OMA-TS-LightweightM2M-V1_0-20170208-A.pdf)

Check warning on line 491 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
*/
#define COAP_FORMAT_VND_OMA_LWM2M_JSON (11543)
/**
* @brief Content-Type `application/vnd.oma.lwm2m+cbor`
* @see [OMA-TS-LightweightM2M-V1_2](https://www.openmobilealliance.org/release/LightweightM2M/V1_2-20201110-A/HTML-Version/OMA-TS-LightweightM2M_Core-V1_2-20201110-A.html)

Check warning on line 496 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
*/
#define COAP_FORMAT_VND_OMA_LWM2M_CBOR (11544)
/**
* @brief Content-Type `text/css`
* @see https://datatracker.ietf.org/doc/html/rfc2318

Check warning on line 501 in sys/include/net/coap.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
*/
#define COAP_FORMAT_TEXT_CSS (20000)
/**
Expand Down
4 changes: 2 additions & 2 deletions sys/include/net/nanocoap_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ typedef struct {
nanocoap_sock_t *sock; /**< socket used for the request */
const char *path; /**< path on the server */
uint32_t blknum; /**< current block number */
uint8_t method; /**< request method (GET, POST, PUT) */
coap_method_t method; /**< request method (GET, POST, PUT) */
uint8_t blksize; /**< CoAP blocksize exponent */
} coap_block_request_t;

Expand Down Expand Up @@ -580,7 +580,7 @@ ssize_t nanocoap_request(coap_pkt_t *pkt, const sock_udp_ep_t *local,
static inline int nanocoap_block_request_connect_url(coap_block_request_t *ctx,
nanocoap_sock_t *sock,
const char *url,
uint8_t method,
coap_method_t method,
coap_blksize_t blksize)
{
ctx->sock = sock;
Expand Down
Loading