diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f693f6c5..8a4af084 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: v0.9.0 hooks: - id: astyle_py - files: '^(man|include/oscore|src/oscore|src/coap_oscore|examples/riot|examples/lwip|examples/contiki|tests).*\.(c|cpp|cxx|h|h.in|h.riot|h.riot.in|h.windows|h.windows.in|h.contiki|hpp|inc)$' + files: '^(coap_config|man|include|src/oscore|src/coap_oscore|examples/riot|examples/lwip|examples/contiki|tests).*\.(c|cpp|cxx|h|h.in|h.riot|h.riot.in|h.windows|h.windows.in|h.contiki|hpp|inc)$' exclude: '^.*/(coap_uthash_internal.h|coap_utlist_internal.h)$' args: ['--style=google', '--align-pointer=name', diff --git a/include/coap3/block.h b/include/coap3/block.h index 652dc6b4..676b742f 100644 --- a/include/coap3/block.h +++ b/include/coap3/block.h @@ -82,7 +82,7 @@ int coap_q_block_is_supported(void); /** Returns the value of the last byte of @p opt. */ #define COAP_OPT_BLOCK_END_BYTE(opt) \ ((coap_opt_length(opt) && coap_opt_value(opt)) ? \ - *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) + *(coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) /** Returns the value of the More-bit of a Block option @p opt. */ #define COAP_OPT_BLOCK_MORE(opt) \ @@ -248,9 +248,8 @@ int coap_add_block_b_data(coap_pdu_t *pdu, size_t len, const uint8_t *data, * @return The current representation of the body or @c NULL if error. * If NULL, @p body_data will have been de-allocated. */ -coap_binary_t * -coap_block_build_body(coap_binary_t *body_data, size_t length, - const uint8_t *data, size_t offset, size_t total); +coap_binary_t *coap_block_build_body(coap_binary_t *body_data, size_t length, + const uint8_t *data, size_t offset, size_t total); /** * Adds the appropriate part of @p data to the @p response pdu. If blocks are @@ -271,13 +270,12 @@ coap_block_build_body(coap_binary_t *body_data, size_t length, * @param data The entire data block to transmit. * */ -void -coap_add_data_blocked_response(const coap_pdu_t *request, - coap_pdu_t *response, - uint16_t media_type, - int maxage, - size_t length, - const uint8_t* data); +void coap_add_data_blocked_response(const coap_pdu_t *request, + coap_pdu_t *response, + uint16_t media_type, + int maxage, + size_t length, + const uint8_t *data); /** * Callback handler for de-allocating the data based on @p app_ptr provided to @@ -390,19 +388,18 @@ int coap_add_data_large_request(coap_session_t *session, * * @return @c 1 if addition is successful, else @c 0. */ -int -coap_add_data_large_response(coap_resource_t *resource, - coap_session_t *session, - const coap_pdu_t *request, - coap_pdu_t *response, - const coap_string_t *query, - uint16_t media_type, - int maxage, - uint64_t etag, - size_t length, - const uint8_t *data, - coap_release_large_data_t release_func, - void *app_ptr); +int coap_add_data_large_response(coap_resource_t *resource, + coap_session_t *session, + const coap_pdu_t *request, + coap_pdu_t *response, + const coap_string_t *query, + uint16_t media_type, + int maxage, + uint64_t etag, + size_t length, + const uint8_t *data, + coap_release_large_data_t release_func, + void *app_ptr); /** * Set the context level CoAP block handling bits for handling RFC7959. @@ -423,7 +420,7 @@ coap_add_data_large_response(coap_resource_t *resource, * @param block_mode Zero or more COAP_BLOCK_ or'd options */ void coap_context_set_block_mode(coap_context_t *context, - uint8_t block_mode); + uint8_t block_mode); /** * Cancel an observe that is being tracked by the client large receive logic. @@ -439,7 +436,7 @@ void coap_context_set_block_mode(coap_context_t *context, * else @c 0. */ int coap_cancel_observe(coap_session_t *session, coap_binary_t *token, - coap_pdu_type_t message_type); + coap_pdu_type_t message_type); /**@}*/ diff --git a/include/coap3/coap_address.h b/include/coap3/coap_address.h index 2ab182e6..c687602c 100644 --- a/include/coap3/coap_address.h +++ b/include/coap3/coap_address.h @@ -51,8 +51,8 @@ coap_address_set_port(coap_address_t *addr, uint16_t port) { } #define _coap_address_equals_impl(A, B) \ - ((A)->port == (B)->port \ - && (!!ip_addr_cmp(&(A)->addr,&(B)->addr))) + ((A)->port == (B)->port && \ + (!!ip_addr_cmp(&(A)->addr,&(B)->addr))) #define _coap_address_isany_impl(A) ip_addr_isany(&(A)->addr) @@ -84,8 +84,8 @@ coap_address_set_port(coap_address_t *addr, uint16_t port) { } #define _coap_address_equals_impl(A,B) \ - ((A)->port == (B)->port \ - && uip_ipaddr_cmp(&((A)->addr),&((B)->addr))) + ((A)->port == (B)->port && \ + uip_ipaddr_cmp(&((A)->addr),&((B)->addr))) /** @todo implementation of _coap_address_isany_impl() for Contiki */ #define _coap_address_isany_impl(A) 0 @@ -101,8 +101,8 @@ coap_address_set_port(coap_address_t *addr, uint16_t port) { #define COAP_UNIX_PATH_MAX (sizeof(struct sockaddr_in6) - sizeof(sa_family_t)) struct coap_sockaddr_un { - sa_family_t sun_family; /* AF_UNIX */ - char sun_path[COAP_UNIX_PATH_MAX]; /* pathname max 26 with NUL byte */ + sa_family_t sun_family; /* AF_UNIX */ + char sun_path[COAP_UNIX_PATH_MAX]; /* pathname max 26 with NUL byte */ }; /** Multi-purpose address abstraction */ @@ -223,7 +223,7 @@ int coap_address_set_unix_domain(coap_address_t *addr, /* Convenience function to copy IPv6 addresses without garbage. */ #if defined(WITH_LWIP) || defined(WITH_CONTIKI) COAP_STATIC_INLINE void -coap_address_copy( coap_address_t *dst, const coap_address_t *src ) { +coap_address_copy(coap_address_t *dst, const coap_address_t *src) { memcpy(dst, src, sizeof(coap_address_t)); } #else /* ! WITH_LWIP && ! WITH_CONTIKI */ @@ -238,7 +238,8 @@ void coap_address_copy(coap_address_t *dst, const coap_address_t *src); */ COAP_STATIC_INLINE int coap_address_equals(const coap_address_t *a, const coap_address_t *b) { - assert(a); assert(b); + assert(a); + assert(b); return _coap_address_equals_impl(a, b); } #endif diff --git a/include/coap3/coap_async.h b/include/coap3/coap_async.h index f3af6c01..ca318069 100644 --- a/include/coap3/coap_async.h +++ b/include/coap3/coap_async.h @@ -53,10 +53,9 @@ int coap_async_is_supported(void); * @return A pointer to the registered coap_async_t object or @c * NULL in case of an error. */ -coap_async_t * -coap_register_async(coap_session_t *session, - const coap_pdu_t *request, - coap_tick_t delay); +coap_async_t *coap_register_async(coap_session_t *session, + const coap_pdu_t *request, + coap_tick_t delay); /** * Update the delay timeout, so changing when the registered @p async triggers. @@ -68,8 +67,7 @@ coap_register_async(coap_session_t *session, * @param delay The amount of time to delay before sending response, 0 means * wait forever. */ -void -coap_async_set_delay(coap_async_t *async, coap_tick_t delay); +void coap_async_set_delay(coap_async_t *async, coap_tick_t delay); /** * Trigger the registered @p async. @@ -79,8 +77,7 @@ coap_async_set_delay(coap_async_t *async, coap_tick_t delay); * * @param async The async object to trigger. */ -void -coap_async_trigger(coap_async_t *async); +void coap_async_trigger(coap_async_t *async); /** * Releases the memory that was allocated by coap_register_async() for the @@ -89,8 +86,7 @@ coap_async_trigger(coap_async_t *async); * @param session The session to use. * @param async The object to delete. */ -void -coap_free_async(coap_session_t *session, coap_async_t *async); +void coap_free_async(coap_session_t *session, coap_async_t *async); /** * Retrieves the object identified by @p token from the list of asynchronous diff --git a/include/coap3/coap_async_internal.h b/include/coap3/coap_async_internal.h index f3941426..ca6e7538 100644 --- a/include/coap3/coap_async_internal.h +++ b/include/coap3/coap_async_internal.h @@ -38,7 +38,7 @@ struct coap_async_t { 0 indicates never trigger */ coap_session_t *session; /**< transaction session */ coap_pdu_t *pdu; /**< copy of request pdu */ - void* appdata; /** User definable data pointer */ + void *appdata; /**< User definable data pointer */ }; /** @@ -59,8 +59,7 @@ coap_tick_t coap_check_async(coap_context_t *context, coap_tick_t now); * * @param context The context to remove all async entries from. */ -void -coap_delete_all_async(coap_context_t *context); +void coap_delete_all_async(coap_context_t *context); /** @} */ diff --git a/include/coap3/coap_block_internal.h b/include/coap3/coap_block_internal.h index 379de272..15fe6140 100644 --- a/include/coap3/coap_block_internal.h +++ b/include/coap3/coap_block_internal.h @@ -208,9 +208,9 @@ typedef enum { #endif /* COAP_Q_BLOCK_SUPPORT */ #if COAP_CLIENT_SUPPORT -coap_lg_crcv_t * coap_block_new_lg_crcv(coap_session_t *session, - coap_pdu_t *pdu, - coap_lg_xmit_t *lg_xmit); +coap_lg_crcv_t *coap_block_new_lg_crcv(coap_session_t *session, + coap_pdu_t *pdu, + coap_lg_xmit_t *lg_xmit); void coap_block_delete_lg_crcv(coap_session_t *session, coap_lg_crcv_t *lg_crcv); @@ -278,10 +278,10 @@ int coap_handle_request_put_block(coap_context_t *context, int *added_block, coap_lg_srcv_t **free_lg_srcv); -coap_lg_xmit_t * coap_find_lg_xmit_response(const coap_session_t *session, - const coap_pdu_t *request, - const coap_resource_t *resource, - const coap_string_t *query); +coap_lg_xmit_t *coap_find_lg_xmit_response(const coap_session_t *session, + const coap_pdu_t *request, + const coap_resource_t *resource, + const coap_string_t *query); #endif /* COAP_SERVER_SUPPORT */ #if COAP_CLIENT_SUPPORT @@ -293,10 +293,9 @@ int coap_handle_response_get_block(coap_context_t *context, coap_pdu_t *sent, coap_pdu_t *rcvd, coap_recurse_t recursive); -coap_mid_t -coap_retransmit_oscore_pdu(coap_session_t *session, - coap_pdu_t *pdu, - coap_opt_t *echo); +coap_mid_t coap_retransmit_oscore_pdu(coap_session_t *session, + coap_pdu_t *pdu, + coap_opt_t *echo); #endif /* COAP_CLIENT_SUPPORT */ void coap_block_delete_lg_xmit(coap_session_t *session, diff --git a/include/coap3/coap_cache.h b/include/coap3/coap_cache.h index 92ff562a..0d6e1025 100644 --- a/include/coap3/coap_cache.h +++ b/include/coap3/coap_cache.h @@ -70,7 +70,7 @@ typedef enum coap_cache_record_pdu_t { */ coap_cache_key_t *coap_cache_derive_key(const coap_session_t *session, const coap_pdu_t *pdu, - coap_cache_session_based_t session_based); + coap_cache_session_based_t session_based); /** * Calculates a cache-key for the given CoAP PDU. See @@ -99,10 +99,10 @@ coap_cache_key_t *coap_cache_derive_key(const coap_session_t *session, * @return The returned cache-key or @c NULL if failure. */ coap_cache_key_t *coap_cache_derive_key_w_ignore(const coap_session_t *session, - const coap_pdu_t *pdu, - coap_cache_session_based_t session_based, - const uint16_t *ignore_options, - size_t ignore_count); + const coap_pdu_t *pdu, + coap_cache_session_based_t session_based, + const uint16_t *ignore_options, + size_t ignore_count); /** * Delete the cache-key. @@ -150,10 +150,10 @@ int coap_cache_ignore_options(coap_context_t *context, * @return The returned cache-key or @c NULL if failure. */ coap_cache_entry_t *coap_new_cache_entry(coap_session_t *session, - const coap_pdu_t *pdu, - coap_cache_record_pdu_t record_pdu, - coap_cache_session_based_t session_based, - unsigned int idle_time); + const coap_pdu_t *pdu, + coap_cache_record_pdu_t record_pdu, + coap_cache_session_based_t session_based, + unsigned int idle_time); /** * Remove a cache-entry from the hash list and free off all the appropriate @@ -192,7 +192,7 @@ coap_cache_entry_t *coap_cache_get_by_key(coap_context_t *context, */ coap_cache_entry_t *coap_cache_get_by_pdu(coap_session_t *session, const coap_pdu_t *pdu, - coap_cache_session_based_t session_based); + coap_cache_session_based_t session_based); /** * Returns the PDU information stored in the @p coap_cache entry. diff --git a/include/coap3/coap_cache_internal.h b/include/coap3/coap_cache_internal.h index 77c8ee83..789e5b50 100644 --- a/include/coap3/coap_cache_internal.h +++ b/include/coap3/coap_cache_internal.h @@ -43,7 +43,7 @@ struct coap_cache_entry_t { coap_cache_key_t *cache_key; coap_session_t *session; coap_pdu_t *pdu; - void* app_data; + void *app_data; coap_tick_t expire_ticks; unsigned int idle_timeout; coap_cache_app_data_free_callback_t callback; @@ -91,8 +91,8 @@ void coap_digest_free(coap_digest_ctx_t *digest_ctx); * @return @c 1 success, @c 0 failure. */ int coap_digest_update(coap_digest_ctx_t *digest_ctx, - const uint8_t *data, - size_t data_len + const uint8_t *data, + size_t data_len ); /** diff --git a/include/coap3/coap_debug.h b/include/coap3/coap_debug.h index b479d226..8a745d1f 100644 --- a/include/coap3/coap_debug.h +++ b/include/coap3/coap_debug.h @@ -75,7 +75,8 @@ typedef enum { #define _COAP_LOG_DEBUG 7 #define _COAP_LOG_OSCORE 8 -COAP_STATIC_INLINE void coap_no_log(void) { } +COAP_STATIC_INLINE void +coap_no_log(void) { } #define coap_log_emerg(...) coap_log(COAP_LOG_EMERG, __VA_ARGS__) @@ -198,7 +199,7 @@ coap_log_t coap_dtls_get_log_level(void); * COAP_LOG_DTLS_BASE + one of the COAP_LOG_* values. * @param message Zero-terminated string message to log. */ -typedef void (*coap_log_handler_t) (coap_log_t level, const char *message); +typedef void (*coap_log_handler_t)(coap_log_t level, const char *message); /** * Add a custom log callback handler. @@ -242,7 +243,7 @@ const char *coap_package_build(void); */ #if (defined(__GNUC__)) void coap_log_impl(coap_log_t level, - const char *format, ...) __attribute__ ((format(printf, 2, 3))); + const char *format, ...) __attribute__((format(printf, 2, 3))); #else void coap_log_impl(coap_log_t level, const char *format, ...); #endif @@ -258,12 +259,12 @@ void coap_log_impl(coap_log_t level, const char *format, ...); void coap_print_contiki_prefix(coap_log_t level); #define coap_log(level, ...) do { \ - if (LOG_CONF_LEVEL_COAP \ - && ((int)((level)) <= (int)coap_get_log_level())) { \ - coap_print_contiki_prefix(level); \ - printf(__VA_ARGS__); \ - } \ -} while(0) + if (LOG_CONF_LEVEL_COAP && \ + ((int)((level)) <= (int)coap_get_log_level())) { \ + coap_print_contiki_prefix(level); \ + printf(__VA_ARGS__); \ + } \ + } while(0) #else /* !WITH_CONTIKI */ /** * Logging function. @@ -274,9 +275,9 @@ void coap_print_contiki_prefix(coap_log_t level); * @param level One of the COAP_LOG_* values. */ #define coap_log(level, ...) do { \ - if ((int)((level))<=(int)coap_get_log_level()) \ - coap_log_impl((level), __VA_ARGS__); \ -} while(0) + if ((int)((level))<=(int)coap_get_log_level()) \ + coap_log_impl((level), __VA_ARGS__); \ + } while(0) #endif /* !WITH_CONTIKI */ #endif @@ -290,9 +291,9 @@ void coap_print_contiki_prefix(coap_log_t level); * @param level One of the COAP_LOG_* values. */ #define coap_dtls_log(level, ...) do { \ - if ((int)((level))<=(int)coap_dtls_get_log_level()) \ - coap_log_impl((level)+COAP_LOG_DTLS_BASE, __VA_ARGS__); \ -} while(0) + if ((int)((level))<=(int)coap_dtls_get_log_level()) \ + coap_log_impl((level)+COAP_LOG_DTLS_BASE, __VA_ARGS__); \ + } while(0) #endif #include "pdu.h" @@ -369,8 +370,8 @@ size_t coap_print_addr(const coap_address_t *address, * @return The pointer to provided buffer with as much of the IP address added * as possible. */ -const char* coap_print_ip_addr(const coap_address_t *address, - char *buffer, size_t size); +const char *coap_print_ip_addr(const coap_address_t *address, + char *buffer, size_t size); /** @} */ diff --git a/include/coap3/coap_dtls.h b/include/coap3/coap_dtls.h index a6a22fe7..4cff26b3 100644 --- a/include/coap3/coap_dtls.h +++ b/include/coap3/coap_dtls.h @@ -129,7 +129,7 @@ coap_tls_version_t *coap_get_tls_library_version(void); * * @return @c 1 if successful, else @c 0. */ -typedef int (*coap_dtls_security_setup_t)(void* tls_session, +typedef int (*coap_dtls_security_setup_t)(void *tls_session, coap_dtls_pki_t *setup_data); /** @@ -153,12 +153,12 @@ typedef int (*coap_dtls_security_setup_t)(void* tls_session, * @return @c 1 if accepted, else @c 0 if to be rejected. */ typedef int (*coap_dtls_cn_callback_t)(const char *cn, - const uint8_t *asn1_public_cert, - size_t asn1_length, - coap_session_t *coap_session, - unsigned int depth, - int validated, - void *arg); + const uint8_t *asn1_public_cert, + size_t asn1_length, + coap_session_t *coap_session, + unsigned int depth, + int validated, + void *arg); /** * The enum used for determining the provided PKI ASN.1 (DER) Private Key @@ -273,7 +273,7 @@ typedef struct coap_dtls_key_t { * @return New set of certificates to use, or @c NULL if SNI is to be rejected. */ typedef coap_dtls_key_t *(*coap_dtls_pki_sni_callback_t)(const char *sni, - void* arg); + void *arg); #define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */ @@ -304,13 +304,13 @@ struct coap_dtls_pki_t { * COAP_PKI_KEY_PEM */ uint8_t reserved[3]; /**< Reserved - must be set to 0 for future compatibility */ - /* Size of 3 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserved slots so - * no need to change - * COAP_DTLS_PKI_SETUP_VERSION and just - * decrement the reserved[] count. - */ + /* Size of 3 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserved slots so + * no need to change + * COAP_DTLS_PKI_SETUP_VERSION and just + * decrement the reserved[] count. + */ /** CN check callback function. * If not NULL, is called when the TLS connection has passed the configured @@ -334,7 +334,7 @@ struct coap_dtls_pki_t { */ coap_dtls_security_setup_t additional_tls_setup_call_back; - char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + char *client_sni; /**< If not NULL, SNI to use in client TLS setup. Owned by the client app and must remain valid during the call to coap_new_client_session_pki() */ @@ -366,9 +366,9 @@ typedef struct coap_dtls_cpsk_info_t { * @return New coap_dtls_cpsk_info_t object or @c NULL on error. */ typedef const coap_dtls_cpsk_info_t *(*coap_dtls_ih_callback_t)( - coap_str_const_t *hint, - coap_session_t *coap_session, - void *arg); + coap_str_const_t *hint, + coap_session_t *coap_session, + void *arg); #define COAP_DTLS_CPSK_SETUP_VERSION 1 /**< Latest CPSK setup version */ @@ -382,13 +382,13 @@ typedef struct coap_dtls_cpsk_t { /* Options to enable different TLS functionality in libcoap */ uint8_t reserved[7]; /**< Reserved - must be set to 0 for future compatibility */ - /* Size of 7 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserverd slot so - * no need to change - * COAP_DTLS_CPSK_SETUP_VERSION and just - * decrement the reserved[] count. - */ + /* Size of 7 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_CPSK_SETUP_VERSION and just + * decrement the reserved[] count. + */ /** Identity Hint check callback function. * If not NULL, is called when the Identity Hint (TLS1.2 or earlier) is @@ -399,7 +399,7 @@ typedef struct coap_dtls_cpsk_t { void *ih_call_back_arg; /**< Passed in to the Identity Hint callback function */ - char* client_sni; /**< If not NULL, SNI to use in client TLS setup. + char *client_sni; /**< If not NULL, SNI to use in client TLS setup. Owned by the client app and must remain valid during the call to coap_new_client_session_psk2() Note: Not supported by TinyDTLS. */ @@ -435,9 +435,9 @@ typedef struct coap_dtls_spsk_info_t { * structure. */ typedef const coap_bin_const_t *(*coap_dtls_id_callback_t)( - coap_bin_const_t *identity, - coap_session_t *coap_session, - void *arg); + coap_bin_const_t *identity, + coap_session_t *coap_session, + void *arg); /** * PSK SNI callback that can be set up by coap_context_set_psk2(). * Invoked when libcoap has done the validation checks at the TLS level @@ -453,9 +453,9 @@ typedef const coap_bin_const_t *(*coap_dtls_id_callback_t)( * @return New coap_dtls_spsk_info_t object or @c NULL on error. */ typedef const coap_dtls_spsk_info_t *(*coap_dtls_psk_sni_callback_t)( - const char *sni, - coap_session_t *coap_session, - void *arg); + const char *sni, + coap_session_t *coap_session, + void *arg); #define COAP_DTLS_SPSK_SETUP_VERSION 1 /**< Latest SPSK setup version */ @@ -469,13 +469,13 @@ typedef struct coap_dtls_spsk_t { /* Options to enable different TLS functionality in libcoap */ uint8_t reserved[7]; /**< Reserved - must be set to 0 for future compatibility */ - /* Size of 7 chosen to align to next - * parameter, so if newly defined option - * it can use one of the reserverd slot so - * no need to change - * COAP_DTLS_SPSK_SETUP_VERSION and just - * decrement the reserved[] count. - */ + /* Size of 7 chosen to align to next + * parameter, so if newly defined option + * it can use one of the reserverd slot so + * no need to change + * COAP_DTLS_SPSK_SETUP_VERSION and just + * decrement the reserved[] count. + */ /** Identity check callback function. * If not @p NULL, is called when the Identity is provided by the client. diff --git a/include/coap3/coap_dtls_internal.h b/include/coap3/coap_dtls_internal.h index 9a54a602..e85c0af0 100644 --- a/include/coap3/coap_dtls_internal.h +++ b/include/coap3/coap_dtls_internal.h @@ -50,8 +50,7 @@ * * @return A DTLS context object or @c NULL on error. */ -void * -coap_dtls_new_context(coap_context_t *coap_context); +void *coap_dtls_new_context(coap_context_t *coap_context); #if COAP_SERVER_SUPPORT /** @@ -65,9 +64,8 @@ coap_dtls_new_context(coap_context_t *coap_context); * @return @c 1 if successful, else @c 0. */ -int -coap_dtls_context_set_spsk(coap_context_t *coap_context, - coap_dtls_spsk_t *setup_data); +int coap_dtls_context_set_spsk(coap_context_t *coap_context, + coap_dtls_spsk_t *setup_data); #endif /* COAP_SERVER_SUPPORT */ #if COAP_CLIENT_SUPPORT @@ -82,9 +80,8 @@ coap_dtls_context_set_spsk(coap_context_t *coap_context, * @return @c 1 if successful, else @c 0. */ -int -coap_dtls_context_set_cpsk(coap_context_t *coap_context, - coap_dtls_cpsk_t *setup_data); +int coap_dtls_context_set_cpsk(coap_context_t *coap_context, + coap_dtls_cpsk_t *setup_data); #endif /* COAP_CLIENT_SUPPORT */ /** @@ -104,10 +101,9 @@ coap_dtls_context_set_cpsk(coap_context_t *coap_context, * @return @c 1 if successful, else @c 0. */ -int -coap_dtls_context_set_pki(coap_context_t *coap_context, - const coap_dtls_pki_t *setup_data, - const coap_dtls_role_t role); +int coap_dtls_context_set_pki(coap_context_t *coap_context, + const coap_dtls_pki_t *setup_data, + const coap_dtls_role_t role); /** * Set the dtls context's default Root CA information for a client or server. @@ -121,10 +117,9 @@ coap_dtls_context_set_pki(coap_context_t *coap_context, * @return @c 1 if successful, else @c 0. */ -int -coap_dtls_context_set_pki_root_cas(coap_context_t *coap_context, - const char *ca_file, - const char *ca_dir); +int coap_dtls_context_set_pki_root_cas(coap_context_t *coap_context, + const char *ca_file, + const char *ca_dir); /** * Check whether one of the coap_dtls_context_set_{psk|pki}() functions have @@ -330,7 +325,7 @@ void *coap_tls_new_server_session(coap_session_t *coap_session); * * @param coap_session The CoAP session. */ -void coap_tls_free_session( coap_session_t *coap_session ); +void coap_tls_free_session(coap_session_t *coap_session); /** * Send data to a TLS peer, with implicit flush. @@ -345,7 +340,7 @@ void coap_tls_free_session( coap_session_t *coap_session ); ssize_t coap_tls_write(coap_session_t *coap_session, const uint8_t *data, size_t data_len - ); + ); /** * Read some data from a TLS peer. @@ -360,7 +355,7 @@ ssize_t coap_tls_write(coap_session_t *coap_session, ssize_t coap_tls_read(coap_session_t *coap_session, uint8_t *data, size_t data_len - ); + ); /** * Layer function interface for layer below TLS accept/connect being @@ -391,7 +386,7 @@ void coap_tls_close(coap_session_t *session); * @return @c NULL if no key, else a pointer the current key. */ const coap_bin_const_t *coap_get_session_client_psk_key( - const coap_session_t *coap_session); + const coap_session_t *coap_session); /** * Get the current client's PSK identity. @@ -401,7 +396,7 @@ const coap_bin_const_t *coap_get_session_client_psk_key( * @return @c NULL if no identity, else a pointer the current identity. */ const coap_bin_const_t *coap_get_session_client_psk_identity( - const coap_session_t *coap_session); + const coap_session_t *coap_session); /** * Get the current server's PSK key. @@ -411,7 +406,7 @@ const coap_bin_const_t *coap_get_session_client_psk_identity( * @return @c NULL if no key, else a pointer the current key. */ const coap_bin_const_t *coap_get_session_server_psk_key( - const coap_session_t *coap_session); + const coap_session_t *coap_session); /** * Get the current server's PSK identity hint. @@ -421,7 +416,7 @@ const coap_bin_const_t *coap_get_session_server_psk_key( * @return @c NULL if no hint, else a pointer the current hint. */ const coap_bin_const_t *coap_get_session_server_psk_hint( - const coap_session_t *coap_session); + const coap_session_t *coap_session); /** * Initialize the underlying (D)TLS Library layer. diff --git a/include/coap3/coap_encode.h b/include/coap3/coap_encode.h index 34ab2e4f..fe10b2cc 100644 --- a/include/coap3/coap_encode.h +++ b/include/coap3/coap_encode.h @@ -33,7 +33,7 @@ extern int coap_fls(unsigned int i); #endif #ifndef HAVE_FLSLL - /* include this only if flsll() is not available */ +/* include this only if flsll() is not available */ extern int coap_flsll(long long i); #else #define coap_flsll(i) flsll(i) @@ -99,8 +99,8 @@ unsigned int coap_encode_var_safe(uint8_t *buf, * when encoding value of 0) or @c 0 on error. */ unsigned int coap_encode_var_safe8(uint8_t *buf, - size_t length, - uint64_t value); + size_t length, + uint64_t value); /** @} */ @@ -120,8 +120,7 @@ unsigned int coap_encode_var_safe8(uint8_t *buf, * would catch this error at run-time and should be used instead. */ COAP_STATIC_INLINE COAP_DEPRECATED int -coap_encode_var_bytes(uint8_t *buf, unsigned int value -) { +coap_encode_var_bytes(uint8_t *buf, unsigned int value) { return (int)coap_encode_var_safe(buf, sizeof(value), value); } diff --git a/include/coap3/coap_event.h b/include/coap3/coap_event.h index 66c1a364..8710509e 100644 --- a/include/coap3/coap_event.h +++ b/include/coap3/coap_event.h @@ -32,9 +32,9 @@ * retransmission timeouts. */ typedef enum { -/* - * (D)TLS events for COAP_PROTO_DTLS and COAP_PROTO_TLS - */ + /* + * (D)TLS events for COAP_PROTO_DTLS and COAP_PROTO_TLS + */ /** Triggerred when (D)TLS session closed */ COAP_EVENT_DTLS_CLOSED = 0x0000, /** Triggered when (D)TLS session connected */ @@ -44,9 +44,9 @@ typedef enum { /** Triggered when (D)TLS error occurs */ COAP_EVENT_DTLS_ERROR = 0x0200, -/* - * TCP events for COAP_PROTO_TCP and COAP_PROTO_TLS - */ + /* + * TCP events for COAP_PROTO_TCP and COAP_PROTO_TLS + */ /** Triggered when TCP layer connects */ COAP_EVENT_TCP_CONNECTED = 0x1001, /** Triggered when TCP layer is closed */ @@ -54,9 +54,9 @@ typedef enum { /** Triggered when TCP layer fails for some reason */ COAP_EVENT_TCP_FAILED = 0x1003, -/* - * CSM exchange events for reliable protocols only - */ + /* + * CSM exchange events for reliable protocols only + */ /** Triggered when TCP layer completes exchange of CSM information */ COAP_EVENT_SESSION_CONNECTED = 0x2001, /** Triggered when TCP layer closes following exchange of CSM information */ @@ -64,46 +64,46 @@ typedef enum { /** Triggered when TCP layer fails following exchange of CSM information */ COAP_EVENT_SESSION_FAILED = 0x2003, -/* - * (Q-)Block errors - */ + /* + * (Q-)Block errors + */ /** Triggered when not all of a large body has been received */ COAP_EVENT_PARTIAL_BLOCK = 0x3001, /** Triggered when not all of a large body has been transmitted */ COAP_EVENT_XMIT_BLOCK_FAIL = 0x3002, -/* - * Server session events - */ -/** - * Called in the CoAP IO loop if a new *server-side* session is created due - * to an incoming connection. - * - * Note that the session might not be a fully established connection yet, - * it might also refer to, e.g., a DTLS session in a handshake stage. - */ + /* + * Server session events + */ + /** + * Called in the CoAP IO loop if a new *server-side* session is created due + * to an incoming connection. + * + * Note that the session might not be a fully established connection yet, + * it might also refer to, e.g., a DTLS session in a handshake stage. + */ COAP_EVENT_SERVER_SESSION_NEW = 0x4001, -/** - * Called in the CoAP IO loop if a server session is deleted (e.g., due to - * inactivity or because the maximum number of idle sessions was exceeded). - * - * The session will still contain valid data when the event handler is - * called. - */ + /** + * Called in the CoAP IO loop if a server session is deleted (e.g., due to + * inactivity or because the maximum number of idle sessions was exceeded). + * + * The session will still contain valid data when the event handler is + * called. + */ COAP_EVENT_SERVER_SESSION_DEL = 0x4002, -/* - * Message receive and transmit events - */ + /* + * Message receive and transmit events + */ /** Triggered when badly formatted packet received */ COAP_EVENT_BAD_PACKET = 0x5001, /** Triggered when a message is retransmitted */ COAP_EVENT_MSG_RETRANSMITTED = 0x5002, -/* - * OSCORE events - */ + /* + * OSCORE events + */ /** Triggered when there is an OSCORE decryption failure */ COAP_EVENT_OSCORE_DECRYPTION_FAILURE = 0x6001, /** Triggered when trying to use OSCORE to decrypt, but it is not enabled */ @@ -116,18 +116,18 @@ typedef enum { COAP_EVENT_OSCORE_INTERNAL_ERROR, /** Triggered when there is an OSCORE decode of OSCORE option failure */ COAP_EVENT_OSCORE_DECODE_ERROR, -/* - * WebSocket events - */ + /* + * WebSocket events + */ /** Triggered when there is an oversize WebSockets packet */ COAP_EVENT_WS_PACKET_SIZE = 0x7001, /** Triggered when the WebSockets layer is up */ COAP_EVENT_WS_CONNECTED, /** Triggered when the WebSockets layer is closed */ COAP_EVENT_WS_CLOSED, -/* - * Keepalive events - */ + /* + * Keepalive events + */ /** Triggered when no response to a keep alive (ping) packet */ COAP_EVENT_KEEPALIVE_FAILURE = 0x8001, } coap_event_t; @@ -152,7 +152,7 @@ typedef int (*coap_event_handler_t)(coap_session_t *session, * de-registered. */ void coap_register_event_handler(coap_context_t *context, - coap_event_handler_t hnd); + coap_event_handler_t hnd); /** @} */ diff --git a/include/coap3/coap_io.h b/include/coap3/coap_io.h index cf9cf35d..7b6ee788 100644 --- a/include/coap3/coap_io.h +++ b/include/coap3/coap_io.h @@ -57,7 +57,7 @@ typedef struct coap_addr_tuple_t { coap_address_t local; /**< local address and port */ } coap_addr_tuple_t; -const char *coap_socket_strerror( void ); +const char *coap_socket_strerror(void); /** * Check whether TCP is available. diff --git a/include/coap3/coap_io_internal.h b/include/coap3/coap_io_internal.h index 51de4788..9719fa14 100644 --- a/include/coap3/coap_io_internal.h +++ b/include/coap3/coap_io_internal.h @@ -73,26 +73,24 @@ struct coap_socket_t { #define COAP_SOCKET_MULTICAST 0x1000 /**< socket is used for multicast communication */ #if COAP_SERVER_SUPPORT -coap_endpoint_t *coap_malloc_endpoint( void ); -void coap_mfree_endpoint( coap_endpoint_t *ep ); +coap_endpoint_t *coap_malloc_endpoint(void); +void coap_mfree_endpoint(coap_endpoint_t *ep); #endif /* COAP_SERVER_SUPPORT */ const char *coap_socket_format_errno(int error); #if COAP_CLIENT_SUPPORT -int -coap_socket_connect_udp(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr); +int coap_socket_connect_udp(coap_socket_t *sock, + const coap_address_t *local_if, + const coap_address_t *server, + int default_port, + coap_address_t *local_addr, + coap_address_t *remote_addr); #endif /* COAP_CLIENT_SUPPORT */ -int -coap_socket_bind_udp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr ); +int coap_socket_bind_udp(coap_socket_t *sock, + const coap_address_t *listen_addr, + coap_address_t *bound_addr); /** * Function interface to close off a socket. @@ -157,9 +155,8 @@ void coap_epoll_ctl_mod(coap_socket_t *sock, uint32_t events, const char *func); void coap_update_epoll_timer(coap_context_t *context, coap_tick_t delay); #ifdef WITH_LWIP -ssize_t -coap_socket_send_pdu( coap_socket_t *sock, coap_session_t *session, - coap_pdu_t *pdu ); +ssize_t coap_socket_send_pdu(coap_socket_t *sock, coap_session_t *session, + coap_pdu_t *pdu); #endif /** diff --git a/include/coap3/coap_layers_internal.h b/include/coap3/coap_layers_internal.h index 5fc52fc8..a2e6ba14 100644 --- a/include/coap3/coap_layers_internal.h +++ b/include/coap3/coap_layers_internal.h @@ -50,7 +50,7 @@ typedef enum { * -2 Recieved ICMP unreachable. */ typedef ssize_t (*coap_layer_read_t)(coap_session_t *session, - uint8_t *data, size_t datalen); + uint8_t *data, size_t datalen); /** * Function write interface for layer data sending. diff --git a/include/coap3/coap_mem.h b/include/coap3/coap_mem.h index 908abd02..f875c366 100644 --- a/include/coap3/coap_mem.h +++ b/include/coap3/coap_mem.h @@ -109,14 +109,16 @@ void coap_free_type(coap_memory_tag_t type, void *p); /** * Wrapper function to coap_malloc_type() for backwards compatibility. */ -COAP_STATIC_INLINE void *coap_malloc(size_t size) { +COAP_STATIC_INLINE void * +coap_malloc(size_t size) { return coap_malloc_type(COAP_STRING, size); } /** * Wrapper function to coap_free_type() for backwards compatibility. */ -COAP_STATIC_INLINE void coap_free(void *object) { +COAP_STATIC_INLINE void +coap_free(void *object) { coap_free_type(COAP_STRING, object); } @@ -128,15 +130,16 @@ COAP_STATIC_INLINE void coap_free(void *object) { /* no initialization needed with lwip (or, more precisely: lwip must be * completely initialized anyway by the time coap gets active) */ -COAP_STATIC_INLINE void coap_memory_init(void) {} +COAP_STATIC_INLINE void +coap_memory_init(void) {} /* It would be nice to check that size equals the size given at the memp * declaration, but i currently don't see a standard way to check that without * sourcing the custom memp pools and becoming dependent of its syntax */ #define coap_malloc_type(type, asize) \ - (((asize) <= memp_pools[MEMP_ ## type]->size) ? \ - memp_malloc(MEMP_ ## type) : NULL) + (((asize) <= memp_pools[MEMP_ ## type]->size) ? \ + memp_malloc(MEMP_ ## type) : NULL) #define coap_free_type(type, p) memp_free(MEMP_ ## type, p) /* As these are fixed size, return value if already defined */ @@ -146,12 +149,14 @@ COAP_STATIC_INLINE void coap_memory_init(void) {} /* Those are just here to make uri.c happy where string allocation has not been * made conditional. */ -COAP_STATIC_INLINE void *coap_malloc(size_t size) { +COAP_STATIC_INLINE void * +coap_malloc(size_t size) { (void)size; LWIP_ASSERT("coap_malloc must not be used in lwIP", 0); } -COAP_STATIC_INLINE void coap_free(void *pointer) { +COAP_STATIC_INLINE void +coap_free(void *pointer) { (void)pointer; LWIP_ASSERT("coap_free must not be used in lwIP", 0); } diff --git a/include/coap3/coap_mutex_internal.h b/include/coap3/coap_mutex_internal.h index d6249a17..54caa036 100644 --- a/include/coap3/coap_mutex_internal.h +++ b/include/coap3/coap_mutex_internal.h @@ -30,7 +30,7 @@ typedef pthread_mutex_t coap_mutex_t; #define COAP_MUTEX_DEFINE(_name) \ - static coap_mutex_t _name = PTHREAD_MUTEX_INITIALIZER + static coap_mutex_t _name = PTHREAD_MUTEX_INITIALIZER #define coap_mutex_lock(a) pthread_mutex_lock(a) #define coap_mutex_trylock(a) pthread_mutex_trylock(a) #define coap_mutex_unlock(a) pthread_mutex_unlock(a) @@ -41,7 +41,7 @@ typedef pthread_mutex_t coap_mutex_t; typedef mutex_t coap_mutex_t; #define COAP_MUTEX_DEFINE(_name) \ - static coap_mutex_t _name = MUTEX_INIT + static coap_mutex_t _name = MUTEX_INIT #define coap_mutex_lock(a) mutex_lock(a) #define coap_mutex_trylock(a) mutex_trylock(a) #define coap_mutex_unlock(a) mutex_unlock(a) @@ -53,7 +53,7 @@ typedef mutex_t coap_mutex_t; /* Single threaded, no-op'd in lwip/sys.h */ typedef int coap_mutex_t; #define COAP_MUTEX_DEFINE(_name) \ - static coap_mutex_t _name + static coap_mutex_t _name #define coap_mutex_lock(a) *(a) = 1 #define coap_mutex_trylock(a) *(a) = 1 #define coap_mutex_unlock(a) *(a) = 0 @@ -71,7 +71,7 @@ typedef sys_mutex_t *coap_mutex_t; /* Contiki does not have a mutex API, used as single thread */ typedef int coap_mutex_t; #define COAP_MUTEX_DEFINE(_name) \ - static coap_mutex_t _name + static coap_mutex_t _name #define coap_mutex_lock(a) *(a) = 1 #define coap_mutex_trylock(a) *(a) = 1 #define coap_mutex_unlock(a) *(a) = 0 @@ -81,7 +81,7 @@ typedef int coap_mutex_t; typedef struct k_mutex coap_mutex_t; #define COAP_MUTEX_DEFINE(_name) \ - static SYS_MUTEX_DEFINE(_name) + static SYS_MUTEX_DEFINE(_name) #define coap_mutex_lock(a) sys_mutex_lock(a, K_FOREVER) #define coap_mutex_trylock(a) sys_mutex_lock(a, K_NO_WAIT) #define coap_mutex_unlock(a) sys_mutex_unlock(a) @@ -91,7 +91,7 @@ typedef struct k_mutex coap_mutex_t; #warning "stub mutex functions" typedef int coap_mutex_t; #define COAP_MUTEX_DEFINE(_name) \ - static coap_mutex_t _name + static coap_mutex_t _name #define coap_mutex_lock(a) *(a) = 1 #define coap_mutex_trylock(a) *(a) = 1 #define coap_mutex_unlock(a) *(a) = 0 diff --git a/include/coap3/coap_net.h b/include/coap3/coap_net.h index b8b02fce..46f2f51e 100644 --- a/include/coap3/coap_net.h +++ b/include/coap3/coap_net.h @@ -106,9 +106,8 @@ typedef void (*coap_pong_handler_t)(coap_session_t *session, * @param context The context to register the handler for. * @param handler The response handler to register. */ -void -coap_register_response_handler(coap_context_t *context, - coap_response_handler_t handler); +void coap_register_response_handler(coap_context_t *context, + coap_response_handler_t handler); /** * Registers a new message handler that is called whenever a confirmable @@ -119,9 +118,8 @@ coap_register_response_handler(coap_context_t *context, * @param context The context to register the handler for. * @param handler The nack handler to register. */ -void -coap_register_nack_handler(coap_context_t *context, - coap_nack_handler_t handler); +void coap_register_nack_handler(coap_context_t *context, + coap_nack_handler_t handler); /** * Registers a new message handler that is called whenever a CoAP Ping @@ -130,9 +128,8 @@ coap_register_nack_handler(coap_context_t *context, * @param context The context to register the handler for. * @param handler The ping handler to register. */ -void -coap_register_ping_handler(coap_context_t *context, - coap_ping_handler_t handler); +void coap_register_ping_handler(coap_context_t *context, + coap_ping_handler_t handler); /** * Registers a new message handler that is called whenever a CoAP Pong @@ -141,9 +138,8 @@ coap_register_ping_handler(coap_context_t *context, * @param context The context to register the handler for. * @param handler The pong handler to register. */ -void -coap_register_pong_handler(coap_context_t *context, - coap_pong_handler_t handler); +void coap_register_pong_handler(coap_context_t *context, + coap_pong_handler_t handler); /** * Registers the option type @p type with the given context object @p ctx. @@ -151,8 +147,7 @@ coap_register_pong_handler(coap_context_t *context, * @param ctx The context to use. * @param type The option type to register. */ -void -coap_register_option(coap_context_t *ctx, uint16_t type); +void coap_register_option(coap_context_t *ctx, uint16_t type); /** * Creates a new coap_context_t object that will hold the CoAP stack status. @@ -173,8 +168,8 @@ coap_context_t *coap_new_context(const coap_address_t *listen_addr); * * @return @c 1 if successful, else @c 0. */ -int coap_context_set_psk( coap_context_t *context, const char *hint, - const uint8_t *key, size_t key_len ); +int coap_context_set_psk(coap_context_t *context, const char *hint, + const uint8_t *key, size_t key_len); /** * Set the context's default PSK hint and/or key for a server. @@ -197,9 +192,8 @@ int coap_context_set_psk2(coap_context_t *context, * * @return @c 1 if successful, else @c 0. */ -int -coap_context_set_pki(coap_context_t *context, - const coap_dtls_pki_t *setup_data); +int coap_context_set_pki(coap_context_t *context, + const coap_dtls_pki_t *setup_data); /** * Set the context's default Root CA information for a client or server. @@ -212,10 +206,9 @@ coap_context_set_pki(coap_context_t *context, * * @return @c 1 if successful, else @c 0. */ -int -coap_context_set_pki_root_cas(coap_context_t *context, - const char *ca_file, - const char *ca_dir); +int coap_context_set_pki_root_cas(coap_context_t *context, + const char *ca_file, + const char *ca_dir); /** * Set the context keepalive timer for sessions. @@ -264,9 +257,8 @@ int coap_context_get_coap_fd(const coap_context_t *context); * @param context The coap_context_t object. * @param max_idle_sessions The maximum idle session count. */ -void -coap_context_set_max_idle_sessions(coap_context_t *context, - unsigned int max_idle_sessions); +void coap_context_set_max_idle_sessions(coap_context_t *context, + unsigned int max_idle_sessions); /** * Get the maximum idle sessions count. @@ -275,8 +267,7 @@ coap_context_set_max_idle_sessions(coap_context_t *context, * * @return The count of max idle sessions. */ -unsigned int -coap_context_get_max_idle_sessions(const coap_context_t *context); +unsigned int coap_context_get_max_idle_sessions(const coap_context_t *context); /** * Set the session timeout value. The number of seconds of inactivity after @@ -286,9 +277,8 @@ coap_context_get_max_idle_sessions(const coap_context_t *context); * @param context The coap_context_t object. * @param session_timeout The session timeout value. */ -void -coap_context_set_session_timeout(coap_context_t *context, - unsigned int session_timeout); +void coap_context_set_session_timeout(coap_context_t *context, + unsigned int session_timeout); /** * Get the session timeout value @@ -297,8 +287,7 @@ coap_context_set_session_timeout(coap_context_t *context, * * @return The session timeout value. */ -unsigned int -coap_context_get_session_timeout(const coap_context_t *context); +unsigned int coap_context_get_session_timeout(const coap_context_t *context); /** * Set the CSM timeout value. The number of seconds to wait for a (TCP) CSM @@ -308,9 +297,8 @@ coap_context_get_session_timeout(const coap_context_t *context); * @param context The coap_context_t object. * @param csm_tmeout The CSM timeout value. */ -void -coap_context_set_csm_timeout(coap_context_t *context, - unsigned int csm_tmeout); +void coap_context_set_csm_timeout(coap_context_t *context, + unsigned int csm_tmeout); /** * Get the CSM timeout value @@ -319,8 +307,7 @@ coap_context_set_csm_timeout(coap_context_t *context, * * @return The CSM timeout value. */ -unsigned int -coap_context_get_csm_timeout(const coap_context_t *context); +unsigned int coap_context_get_csm_timeout(const coap_context_t *context); /** * Set the CSM max session size value. The largest PDU that can be received. @@ -328,9 +315,8 @@ coap_context_get_csm_timeout(const coap_context_t *context); * @param context The coap_context_t object. * @param csm_max_message_size The CSM max message size value. */ -void -coap_context_set_csm_max_message_size(coap_context_t *context, - uint32_t csm_max_message_size); +void coap_context_set_csm_max_message_size(coap_context_t *context, + uint32_t csm_max_message_size); /** * Get the CSM max session size value @@ -339,8 +325,7 @@ coap_context_set_csm_max_message_size(coap_context_t *context, * * @return The CSM max session size value. */ -uint32_t -coap_context_get_csm_max_message_size(const coap_context_t *context); +uint32_t coap_context_get_csm_max_message_size(const coap_context_t *context); /** * Set the maximum number of sessions in (D)TLS handshake value. If this number @@ -351,9 +336,8 @@ coap_context_get_csm_max_message_size(const coap_context_t *context); * @param context The coap_context_t object. * @param max_handshake_sessions The maximum number of sessions in handshake. */ -void -coap_context_set_max_handshake_sessions(coap_context_t *context, - unsigned int max_handshake_sessions); +void coap_context_set_max_handshake_sessions(coap_context_t *context, + unsigned int max_handshake_sessions); /** * Get the session timeout value @@ -362,8 +346,7 @@ coap_context_set_max_handshake_sessions(coap_context_t *context, * * @return The maximim number of sessions in (D)TLS handshake value. */ -unsigned int -coap_context_get_max_handshake_sessions(const coap_context_t *context); +unsigned int coap_context_get_max_handshake_sessions(const coap_context_t *context); /** * Returns a new message id and updates @p session->tx_mid accordingly. The @@ -460,9 +443,8 @@ coap_mid_t coap_send_error(coap_session_t *session, * @return message id on success or @c COAP_INVALID_MID * otherwise. */ -coap_mid_t -coap_send_message_type(coap_session_t *session, const coap_pdu_t *request, - coap_pdu_type_t type); +coap_mid_t coap_send_message_type(coap_session_t *session, const coap_pdu_t *request, + coap_pdu_type_t type); /** * Sends an ACK message with code @c 0 for the specified @p request to @p dst. @@ -504,7 +486,7 @@ coap_send_rst(coap_session_t *session, const coap_pdu_t *request) { * @return The message id of the sent message or @c * COAP_INVALID_MID on error. */ -coap_mid_t coap_send( coap_session_t *session, coap_pdu_t *pdu ); +coap_mid_t coap_send(coap_session_t *session, coap_pdu_t *pdu); #define coap_send_large(session, pdu) coap_send(session, pdu) @@ -550,12 +532,11 @@ void coap_ticks(coap_tick_t *); * * @return 0 on success, -1 on error */ -int -coap_join_mcast_group_intf(coap_context_t *ctx, const char *groupname, - const char *ifname); +int coap_join_mcast_group_intf(coap_context_t *ctx, const char *groupname, + const char *ifname); #define coap_join_mcast_group(ctx, groupname) \ - (coap_join_mcast_group_intf(ctx, groupname, NULL)) + (coap_join_mcast_group_intf(ctx, groupname, NULL)) /** * Function interface for defining the hop count (ttl) for sending @@ -567,8 +548,7 @@ coap_join_mcast_group_intf(coap_context_t *ctx, const char *groupname, * * @return 1 on success, 0 on error */ -int -coap_mcast_set_hops(coap_session_t *session, size_t hops); +int coap_mcast_set_hops(coap_session_t *session, size_t hops); /** * Function interface to enable processing mcast requests on a per resource @@ -577,8 +557,7 @@ coap_mcast_set_hops(coap_session_t *session, size_t hops); * * @param context The current context. */ -void -coap_mcast_per_resource(coap_context_t *context); +void coap_mcast_per_resource(coap_context_t *context); /**@}*/ @@ -709,13 +688,12 @@ int coap_io_pending(coap_context_t *context); * select() to wait for network events or 0 if wait should be * forever. */ -unsigned int -coap_io_prepare_io(coap_context_t *ctx, - coap_socket_t *sockets[], - unsigned int max_sockets, - unsigned int *num_sockets, - coap_tick_t now -); +unsigned int coap_io_prepare_io(coap_context_t *ctx, + coap_socket_t *sockets[], + unsigned int max_sockets, + unsigned int *num_sockets, + coap_tick_t now + ); /** * Processes any outstanding read, write, accept or connect I/O as indicated @@ -751,8 +729,7 @@ void coap_io_do_io(coap_context_t *ctx, coap_tick_t now); * epoll_wait() to wait for network events or 0 if wait should be * forever. */ -unsigned int -coap_io_prepare_epoll(coap_context_t *ctx, coap_tick_t now); +unsigned int coap_io_prepare_epoll(coap_context_t *ctx, coap_tick_t now); struct epoll_event; @@ -769,7 +746,7 @@ struct epoll_event; * @param nevents The number of events. * */ -void coap_io_do_epoll(coap_context_t *ctx, struct epoll_event* events, +void coap_io_do_epoll(coap_context_t *ctx, struct epoll_event *events, size_t nevents); /**@}*/ @@ -803,7 +780,7 @@ void coap_lwip_dump_memory_pools(coap_log_t log_level); * * @return @c 1 if packet received, @c 0 for timeout, else @c -1 on error. */ -typedef int (*coap_lwip_input_wait_handler_t)(void* arg, uint32_t milli_secs); +typedef int (*coap_lwip_input_wait_handler_t)(void *arg, uint32_t milli_secs); /** * Set up a wait / timeout callback handler for use when @@ -840,8 +817,7 @@ void coap_lwip_set_input_wait_handler(coap_context_t *context, * an error */ COAP_STATIC_INLINE COAP_DEPRECATED int -coap_run_once(coap_context_t *ctx, uint32_t timeout_ms) -{ +coap_run_once(coap_context_t *ctx, uint32_t timeout_ms) { return coap_io_process(ctx, timeout_ms); } @@ -865,11 +841,11 @@ coap_run_once(coap_context_t *ctx, uint32_t timeout_ms) */ COAP_STATIC_INLINE COAP_DEPRECATED unsigned int coap_write(coap_context_t *ctx, - coap_socket_t *sockets[], - unsigned int max_sockets, - unsigned int *num_sockets, - coap_tick_t now -) { + coap_socket_t *sockets[], + unsigned int max_sockets, + unsigned int *num_sockets, + coap_tick_t now + ) { return coap_io_prepare_io(ctx, sockets, max_sockets, num_sockets, now); } @@ -885,7 +861,7 @@ coap_write(coap_context_t *ctx, */ COAP_STATIC_INLINE COAP_DEPRECATED void coap_read(coap_context_t *ctx, coap_tick_t now -) { + ) { coap_io_do_io(ctx, now); } diff --git a/include/coap3/coap_net_internal.h b/include/coap3/coap_net_internal.h index 73488d5e..8f3f0758 100644 --- a/include/coap3/coap_net_internal.h +++ b/include/coap3/coap_net_internal.h @@ -56,8 +56,8 @@ struct coap_context_t { coap_resource_t *proxy_uri_resource; /**< can be used for handling proxy URI resources */ coap_resource_release_userdata_handler_t release_userdata; - /**< function to release user_data - when resource is deleted */ + /**< function to release user_data + when resource is deleted */ #endif /* COAP_SERVER_SUPPORT */ #if COAP_ASYNC_SUPPORT @@ -236,12 +236,12 @@ unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now); /** * Returns the next pdu to send without removing from sendqeue. */ -coap_queue_t *coap_peek_next( coap_context_t *context ); +coap_queue_t *coap_peek_next(coap_context_t *context); /** * Returns the next pdu to send and removes it from the sendqeue. */ -coap_queue_t *coap_pop_next( coap_context_t *context ); +coap_queue_t *coap_pop_next(coap_context_t *context); /** * Handles retransmissions of confirmable messages @@ -290,9 +290,8 @@ int coap_remove_from_queue(coap_queue_t **queue, coap_mid_t id, coap_queue_t **node); -coap_mid_t -coap_wait_ack( coap_context_t *context, coap_session_t *session, - coap_queue_t *node); +coap_mid_t coap_wait_ack(coap_context_t *context, coap_session_t *session, + coap_queue_t *node); /** * Cancels all outstanding messages for session @p session that have the specified @@ -313,10 +312,9 @@ void coap_cancel_all_messages(coap_context_t *context, * @param session Session of the messages to remove. * @param reason The reasion for the session cancellation */ -void -coap_cancel_session_messages(coap_context_t *context, - coap_session_t *session, - coap_nack_reason_t reason); +void coap_cancel_session_messages(coap_context_t *context, + coap_session_t *session, + coap_nack_reason_t reason); /** * Dispatches the PDUs from the receive queue in given context. diff --git a/include/coap3/coap_netif_internal.h b/include/coap3/coap_netif_internal.h index f115118e..1196e73e 100644 --- a/include/coap3/coap_netif_internal.h +++ b/include/coap3/coap_netif_internal.h @@ -54,7 +54,7 @@ int coap_netif_available_ep(coap_endpoint_t *endpoint); * @return @c 1 OK, 0 on failure. */ int coap_netif_dgrm_listen(coap_endpoint_t *endpoint, - const coap_address_t *listen_addr); + const coap_address_t *listen_addr); /** * Layer function interface for Netif datagram connect (udp). @@ -121,7 +121,7 @@ ssize_t coap_netif_dgrm_write(coap_session_t *session, const uint8_t *data, * @return @c 1 OK, 0 on failure. */ int coap_netif_strm_listen(coap_endpoint_t *endpoint, - const coap_address_t *listen_addr); + const coap_address_t *listen_addr); /** * Layer function interface for Netif stream accept. diff --git a/include/coap3/coap_option.h b/include/coap3/coap_option.h index 553c5006..38c76291 100644 --- a/include/coap3/coap_option.h +++ b/include/coap3/coap_option.h @@ -112,8 +112,7 @@ typedef struct coap_opt_filter_t { * * @param filter The filter to clear. */ -void -coap_option_filter_clear(coap_opt_filter_t *filter); +void coap_option_filter_clear(coap_opt_filter_t *filter); /** * Sets the corresponding entry for @p number in @p filter. This @@ -358,7 +357,7 @@ coap_optlist_t *coap_new_optlist(uint16_t number, * * @return @c 1 if succesful or @c 0 if failure; */ -int coap_add_optlist_pdu(coap_pdu_t *pdu, coap_optlist_t** optlist_chain); +int coap_add_optlist_pdu(coap_pdu_t *pdu, coap_optlist_t **optlist_chain); /** * Adds @p optlist to the given @p optlist_chain. The optlist_chain variable diff --git a/include/coap3/coap_oscore.h b/include/coap3/coap_oscore.h index 6fe191f1..573de5da 100644 --- a/include/coap3/coap_oscore.h +++ b/include/coap3/coap_oscore.h @@ -79,13 +79,12 @@ coap_session_t *coap_new_client_session_oscore(coap_context_t *ctx, * @return A new CoAP session or NULL if failed. Call coap_session_release() * to free. */ -coap_session_t * -coap_new_client_session_oscore_psk(coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - coap_dtls_cpsk_t *psk_data, - coap_oscore_conf_t *oscore_conf); +coap_session_t *coap_new_client_session_oscore_psk(coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_cpsk_t *psk_data, + coap_oscore_conf_t *oscore_conf); /** * Creates a new client session to the designated server with PKI credentials @@ -106,13 +105,12 @@ coap_new_client_session_oscore_psk(coap_context_t *ctx, * @return A new CoAP session or NULL if failed. Call coap_session_release() * to free. */ -coap_session_t * -coap_new_client_session_oscore_pki(coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - coap_dtls_pki_t *pki_data, - coap_oscore_conf_t *oscore_conf); +coap_session_t *coap_new_client_session_oscore_pki(coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_pki_t *pki_data, + coap_oscore_conf_t *oscore_conf); /** * Set the context's default OSCORE configuration for a server. @@ -154,11 +152,10 @@ typedef int (*coap_oscore_save_seq_num_t)(uint64_t sender_seq_num, void *param); * off with coap_delete_oscore_conf() when no longer required, * otherwise it is freed off when coap_free_context() is called. */ -coap_oscore_conf_t * -coap_new_oscore_conf(coap_str_const_t conf_mem, - coap_oscore_save_seq_num_t save_seq_num_func, - void *save_seq_num_func_param, - uint64_t start_seq_num); +coap_oscore_conf_t *coap_new_oscore_conf(coap_str_const_t conf_mem, + coap_oscore_save_seq_num_t save_seq_num_func, + void *save_seq_num_func_param, + uint64_t start_seq_num); /** * Release all the information associated with the OSCORE configuration. diff --git a/include/coap3/coap_pdu_internal.h b/include/coap3/coap_pdu_internal.h index e87331c1..b8b6b08f 100644 --- a/include/coap3/coap_pdu_internal.h +++ b/include/coap3/coap_pdu_internal.h @@ -190,7 +190,7 @@ int coap_pdu_check_resize(coap_pdu_t *pdu, size_t new_size); * @return A value greater than zero on success or @c 0 on error. */ size_t coap_pdu_parse_header_size(coap_proto_t proto, - const uint8_t *data); + const uint8_t *data); /** * Parses @p data to extract the message size. diff --git a/include/coap3/coap_resource_internal.h b/include/coap3/coap_resource_internal.h index df4ce59a..43a6fd1f 100644 --- a/include/coap3/coap_resource_internal.h +++ b/include/coap3/coap_resource_internal.h @@ -101,7 +101,7 @@ struct coap_resource_t { /** * Array valid names this host is known by (proxy support) */ - coap_str_const_t ** proxy_name_list; + coap_str_const_t **proxy_name_list; /** * This pointer is under user control. It can be used to store context for diff --git a/include/coap3/coap_session.h b/include/coap3/coap_session.h index 426e58c6..5b61a443 100644 --- a/include/coap3/coap_session.h +++ b/include/coap3/coap_session.h @@ -118,7 +118,7 @@ void *coap_session_get_app_data(const coap_session_t *session); * @return The session's remote address or @c NULL on failure. */ const coap_address_t *coap_session_get_addr_remote( - const coap_session_t *session); + const coap_session_t *session); /** * Get the remote multicast IP address and port from the session if the @@ -132,7 +132,7 @@ const coap_address_t *coap_session_get_addr_remote( * this is not a multicast session. */ const coap_address_t *coap_session_get_addr_mcast( - const coap_session_t *session); + const coap_session_t *session); /** * Get the local IP address and port from the session. @@ -142,7 +142,7 @@ const coap_address_t *coap_session_get_addr_mcast( * @return The session's local address or @c NULL on failure. */ const coap_address_t *coap_session_get_addr_local( - const coap_session_t *session); + const coap_session_t *session); /** * Get the session protocol type @@ -245,10 +245,10 @@ size_t coap_session_max_pdu_size(const coap_session_t *session); * @return A new CoAP session or NULL if failed. Call coap_session_release to free. */ coap_session_t *coap_new_client_session( - coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto ); /** @@ -267,13 +267,13 @@ coap_session_t *coap_new_client_session( * @return A new CoAP session or NULL if failed. Call coap_session_release to free. */ coap_session_t *coap_new_client_session_psk( - coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - const char *identity, - const uint8_t *key, - unsigned key_len + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + const char *identity, + const uint8_t *key, + unsigned key_len ); /** @@ -292,11 +292,11 @@ coap_session_t *coap_new_client_session_psk( * to free. */ coap_session_t *coap_new_client_session_psk2( - coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - coap_dtls_cpsk_t *setup_data + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_cpsk_t *setup_data ); /** @@ -306,8 +306,8 @@ coap_session_t *coap_new_client_session_psk2( * * @return @c hint if successful, else @c NULL. */ -const coap_bin_const_t * coap_session_get_psk_hint( - const coap_session_t *session); +const coap_bin_const_t *coap_session_get_psk_hint( + const coap_session_t *session); /** * Get the server session's current PSK identity (PSK). @@ -317,7 +317,7 @@ const coap_bin_const_t * coap_session_get_psk_hint( * @return PSK identity if successful, else @c NULL. */ const coap_bin_const_t *coap_session_get_psk_identity( - const coap_session_t *session); + const coap_session_t *session); /** * Get the session's current pre-shared key (PSK). * @@ -325,8 +325,8 @@ const coap_bin_const_t *coap_session_get_psk_identity( * * @return @c psk_key if successful, else @c NULL. */ -const coap_bin_const_t * coap_session_get_psk_key( - const coap_session_t *session); +const coap_bin_const_t *coap_session_get_psk_key( + const coap_session_t *session); /** * Creates a new client session to the designated server with PKI credentials @@ -344,11 +344,11 @@ const coap_bin_const_t * coap_session_get_psk_key( * to free. */ coap_session_t *coap_new_client_session_pki( - coap_context_t *ctx, - const coap_address_t *local_if, - const coap_address_t *server, - coap_proto_t proto, - coap_dtls_pki_t *setup_data + coap_context_t *ctx, + const coap_address_t *local_if, + const coap_address_t *server, + coap_proto_t proto, + coap_dtls_pki_t *setup_data ); /** @@ -371,7 +371,7 @@ void coap_session_init_token(coap_session_t *session, size_t length, * */ void coap_session_new_token(coap_session_t *session, size_t *length, - uint8_t *token); + uint8_t *token); /** * @ingroup logging @@ -394,7 +394,8 @@ const char *coap_session_str(const coap_session_t *session); * * @return The new endpoint or @c NULL on failure. */ -coap_endpoint_t *coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto); +coap_endpoint_t *coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, + coap_proto_t proto); /** * Set the endpoint's default MTU. This is the maximum message size that can be @@ -436,108 +437,108 @@ coap_session_t *coap_session_get_by_peer(const coap_context_t *context, */ const char *coap_endpoint_str(const coap_endpoint_t *endpoint); - /** - * @ingroup application_api - * @defgroup cc Rate Control - * API for updating transmission parameters for CoAP rate control. - * The transmission parameters for CoAP rate control ("Congestion - * Control" in stream-oriented protocols) are defined in - * https://rfc-editor.org/rfc/rfc7252#section-4.8 and - * https://rfc-editor.org/rfc/rfc9177#section-6.2 - * @{ - */ +/** + * @ingroup application_api + * @defgroup cc Rate Control + * API for updating transmission parameters for CoAP rate control. + * The transmission parameters for CoAP rate control ("Congestion + * Control" in stream-oriented protocols) are defined in + * https://rfc-editor.org/rfc/rfc7252#section-4.8 and + * https://rfc-editor.org/rfc/rfc9177#section-6.2 + * @{ + */ - /** - * Number of seconds when to expect an ACK or a response to an - * outstanding CON message. - * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 - * - * Configurable using coap_session_set_ack_timeout() - */ +/** + * Number of seconds when to expect an ACK or a response to an + * outstanding CON message. + * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 + * + * Configurable using coap_session_set_ack_timeout() + */ #define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0}) - /** - * A factor that is used to randomize the wait time before a message - * is retransmitted to prevent synchronization effects. - * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 - * - * Configurable using coap_session_set_ack_random_factor() - */ +/** + * A factor that is used to randomize the wait time before a message + * is retransmitted to prevent synchronization effects. + * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 + * + * Configurable using coap_session_set_ack_random_factor() + */ #define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500}) - /** - * Number of message retransmissions before message sending is stopped. - * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 - * - * Configurable using coap_session_set_max_retransmit() - */ +/** + * Number of message retransmissions before message sending is stopped. + * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 + * + * Configurable using coap_session_set_max_retransmit() + */ #define COAP_DEFAULT_MAX_RETRANSMIT (4U) - /** - * The number of simultaneous outstanding interactions that a client - * maintains to a given server. - * RFC 7252, Section 4.8 Default value of NSTART is 1 - * - * Configurable using coap_session_set_nstart() - */ +/** + * The number of simultaneous outstanding interactions that a client + * maintains to a given server. + * RFC 7252, Section 4.8 Default value of NSTART is 1 + * + * Configurable using coap_session_set_nstart() + */ #define COAP_DEFAULT_NSTART (1U) - /** - * The number of seconds to use as bounds for multicast traffic - * RFC 7252, Section 4.8 Default value of DEFAULT_LEISURE is 5.0 - * - * Configurable using coap_session_set_default_leisure() - */ +/** + * The number of seconds to use as bounds for multicast traffic + * RFC 7252, Section 4.8 Default value of DEFAULT_LEISURE is 5.0 + * + * Configurable using coap_session_set_default_leisure() + */ #define COAP_DEFAULT_DEFAULT_LEISURE ((coap_fixed_point_t){5,0}) - /** - * The number of bytes/second allowed when there is no response - * RFC 7252, Section 4.8 Default value of PROBING_RATE is 1 - * - * Configurable using coap_session_set_probing_rate() - */ +/** + * The number of bytes/second allowed when there is no response + * RFC 7252, Section 4.8 Default value of PROBING_RATE is 1 + * + * Configurable using coap_session_set_probing_rate() + */ #define COAP_DEFAULT_PROBING_RATE (1U) - /** - * Number of Q-Block1 or Q-Block2 payloads that can be sent in a burst - * before a delay has to kick in. - * RFC9177 Section 6.2 Default value of MAX_PAYLOAD is 10 - * - * Configurable using coap_session_set_max_payloads() - */ +/** + * Number of Q-Block1 or Q-Block2 payloads that can be sent in a burst + * before a delay has to kick in. + * RFC9177 Section 6.2 Default value of MAX_PAYLOAD is 10 + * + * Configurable using coap_session_set_max_payloads() + */ #define COAP_DEFAULT_MAX_PAYLOADS (10U) - /** - * The number of times for requests for re-transmission of missing Q-Block1 - * when no response has been received. - * RFC9177 Section 6.2 Default value of NON_MAX_RETRANSMIT is 4 - * - * Configurable using coap_session_set_non_max_retransmit() - */ +/** + * The number of times for requests for re-transmission of missing Q-Block1 + * when no response has been received. + * RFC9177 Section 6.2 Default value of NON_MAX_RETRANSMIT is 4 + * + * Configurable using coap_session_set_non_max_retransmit() + */ #define COAP_DEFAULT_NON_MAX_RETRANSMIT (4U) - /** - * The delay (+ ACK_RANDOM_FACTOR) to introduce once NON MAX_PAYLOADS - * Q-Block1 or Q-Block2 have been sent to reduce congestion control. - * RFC9177 Section 6.2 Default value of NON_TIMEOUT is 2. - * - * Configurable using coap_session_set_non_timeout() - */ +/** + * The delay (+ ACK_RANDOM_FACTOR) to introduce once NON MAX_PAYLOADS + * Q-Block1 or Q-Block2 have been sent to reduce congestion control. + * RFC9177 Section 6.2 Default value of NON_TIMEOUT is 2. + * + * Configurable using coap_session_set_non_timeout() + */ #define COAP_DEFAULT_NON_TIMEOUT ((coap_fixed_point_t){2,0}) - /** - * The time to wait for any missing Q-Block1 or Q-Block2 packets before - * requesting re-transmission of missing packets. - * RFC9177 Section 6.2 Default value of NON_RECEIVE_TIMEOUT is 4. - * - * Configurable using coap_session_set_non_receive_timeout() - */ +/** + * The time to wait for any missing Q-Block1 or Q-Block2 packets before + * requesting re-transmission of missing packets. + * RFC9177 Section 6.2 Default value of NON_RECEIVE_TIMEOUT is 4. + * + * Configurable using coap_session_set_non_receive_timeout() + */ #define COAP_DEFAULT_NON_RECEIVE_TIMEOUT ((coap_fixed_point_t){4,0}) - /** - * The MAX_LATENCY definition. - * RFC 7252, Section 4.8.2 MAX_LATENCY is 100. - */ +/** + * The MAX_LATENCY definition. + * RFC 7252, Section 4.8.2 MAX_LATENCY is 100. + */ #define COAP_DEFAULT_MAX_LATENCY (100U) /** @@ -593,7 +594,7 @@ void coap_session_set_ack_random_factor(coap_session_t *session, * @return Current ack randomize value */ coap_fixed_point_t coap_session_get_ack_random_factor( - const coap_session_t *session); + const coap_session_t *session); /** * Set the CoAP maximum retransmit count before failure @@ -661,7 +662,7 @@ void coap_session_set_default_leisure(coap_session_t *session, * @return Current default_leisure value */ coap_fixed_point_t coap_session_get_default_leisure( - const coap_session_t *session); + const coap_session_t *session); /** * Set the CoAP probing rate when there is no response @@ -693,7 +694,7 @@ uint32_t coap_session_get_probing_rate(const coap_session_t *session); * get changed. */ void coap_session_set_max_payloads(coap_session_t *session, - uint16_t value); + uint16_t value); /** * Get the CoAP maximum payloads count of Q-Block1 or Q-Block2 before delay @@ -716,7 +717,7 @@ uint16_t coap_session_get_max_payloads(const coap_session_t *session); * get changed. */ void coap_session_set_non_max_retransmit(coap_session_t *session, - uint16_t value); + uint16_t value); /** * Get the CoAP NON maximum retransmit count of missing Q-Block1 or Q-Block2 @@ -780,9 +781,9 @@ void coap_session_set_non_receive_timeout(coap_session_t *session, * @return NON_RECEIVE_TIMEOUT delay */ coap_fixed_point_t coap_session_get_non_receive_timeout( - const coap_session_t *session); + const coap_session_t *session); - /** @} */ +/** @} */ /** * Send a ping message for the session. * @param session The CoAP session. diff --git a/include/coap3/coap_session_internal.h b/include/coap3/coap_session_internal.h index 12faad45..967c7e8b 100644 --- a/include/coap3/coap_session_internal.h +++ b/include/coap3/coap_session_internal.h @@ -235,7 +235,7 @@ coap_fixed_point_t coap_multi_fixed_uint(coap_fixed_point_t fp1, uint32_t u2); coap_fixed_point_t coap_add_fixed_fixed(coap_fixed_point_t fp1, - coap_fixed_point_t fp2); + coap_fixed_point_t fp2); coap_fixed_point_t coap_add_fixed_uint(coap_fixed_point_t fp1, uint32_t u2); @@ -301,7 +301,7 @@ int coap_session_refresh_psk_key(coap_session_t *session, * @return @c 1 if successful, else @c 0. */ int coap_session_refresh_psk_identity(coap_session_t *session, - const coap_bin_const_t *psk_identity); + const coap_bin_const_t *psk_identity); #if COAP_SERVER_SUPPORT /** @@ -313,8 +313,8 @@ int coap_session_refresh_psk_identity(coap_session_t *session, * add to unused queue. */ coap_session_t *coap_new_server_session( - coap_context_t *ctx, - coap_endpoint_t *ep + coap_context_t *ctx, + coap_endpoint_t *ep ); #endif /* COAP_SERVER_SUPPORT */ @@ -341,9 +341,8 @@ void coap_session_establish(coap_session_t *session); */ ssize_t coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu); -ssize_t -coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, - coap_queue_t *node); +ssize_t coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, + coap_queue_t *node); #if COAP_SERVER_SUPPORT /** @@ -356,7 +355,7 @@ coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, * @return The CoAP session or @c NULL if error. */ coap_session_t *coap_endpoint_get_session(coap_endpoint_t *endpoint, - const coap_packet_t *packet, coap_tick_t now); + const coap_packet_t *packet, coap_tick_t now); #endif /* COAP_SERVER_SUPPORT */ /** @@ -379,7 +378,7 @@ size_t coap_session_max_pdu_rcv_size(const coap_session_t *session); * @return CoAP session or @c NULL if error. */ coap_session_t *coap_session_new_dtls_session(coap_session_t *session, - coap_tick_t now); + coap_tick_t now); void coap_session_free(coap_session_t *session); void coap_session_mfree(coap_session_t *session); @@ -398,132 +397,132 @@ void coap_session_mfree(coap_session_t *session); #define COAP_NON_MAX_RETRANSMIT(s) ((s)->non_max_retransmit) #define COAP_NON_TIMEOUT(s) ((s)->non_timeout) #define COAP_NON_TIMEOUT_TICKS(s) \ - (COAP_NON_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \ - COAP_NON_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) + (COAP_NON_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \ + COAP_NON_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) #define COAP_NON_RECEIVE_TIMEOUT(s) ((s)->non_receive_timeout) #define COAP_NON_PROBING_WAIT_BASE(s) ((s)->non_probing_wait_base) #define COAP_NON_PARTIAL_TIMEOUT(s) ((s)->non_partial_timeout) - /** - * The DEFAULT_LEISURE definition for the session (s). - * - * RFC 7252, Section 4.8 - * Initial value 5.0 seconds - */ +/** + * The DEFAULT_LEISURE definition for the session (s). + * + * RFC 7252, Section 4.8 + * Initial value 5.0 seconds + */ #define COAP_DEFAULT_LEISURE_TICKS(s) \ - (COAP_DEFAULT_LEISURE(s).integer_part * COAP_TICKS_PER_SECOND + \ - COAP_DEFAULT_LEISURE(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) - /** - * The MAX_TRANSMIT_SPAN definition for the session (s). - * - * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_SPAN - * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT)) - 1) * ACK_RANDOM_FACTOR - */ + (COAP_DEFAULT_LEISURE(s).integer_part * COAP_TICKS_PER_SECOND + \ + COAP_DEFAULT_LEISURE(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) +/** + * The MAX_TRANSMIT_SPAN definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_SPAN + * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT)) - 1) * ACK_RANDOM_FACTOR + */ #define COAP_MAX_TRANSMIT_SPAN(s) \ - (((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part) * \ - ((1 << ((s)->max_retransmit)) -1) * \ - ((s)->ack_random_factor.integer_part * 1000 + \ - (s)->ack_random_factor.fractional_part) \ - / 1000000) + (((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part) * \ + ((1 << ((s)->max_retransmit)) -1) * \ + ((s)->ack_random_factor.integer_part * 1000 + \ + (s)->ack_random_factor.fractional_part) \ + / 1000000) - /** - * The MAX_TRANSMIT_WAIT definition for the session (s). - * - * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_WAIT - * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT + 1)) - 1) * ACK_RANDOM_FACTOR - */ +/** + * The MAX_TRANSMIT_WAIT definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_WAIT + * ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT + 1)) - 1) * ACK_RANDOM_FACTOR + */ #define COAP_MAX_TRANSMIT_WAIT(s) \ - (((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part) * \ - ((1 << ((s)->max_retransmit + 1)) -1) * \ - ((s)->ack_random_factor.integer_part * 1000 + \ - (s)->ack_random_factor.fractional_part) \ - / 1000000) + (((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part) * \ + ((1 << ((s)->max_retransmit + 1)) -1) * \ + ((s)->ack_random_factor.integer_part * 1000 + \ + (s)->ack_random_factor.fractional_part) \ + / 1000000) #define COAP_MAX_TRANSMIT_WAIT_TICKS(s) \ - (COAP_MAX_TRANSMIT_WAIT(s) * COAP_TICKS_PER_SECOND) + (COAP_MAX_TRANSMIT_WAIT(s) * COAP_TICKS_PER_SECOND) - /** - * The PROCESSING_DELAY definition for the session (s). - * - * RFC 7252, Section 4.8.2 Calculation of PROCESSING_DELAY - * PROCESSING_DELAY set to ACK_TIMEOUT - */ +/** + * The PROCESSING_DELAY definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of PROCESSING_DELAY + * PROCESSING_DELAY set to ACK_TIMEOUT + */ #define COAP_PROCESSING_DELAY(s) \ - (((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part + \ - 500) / 1000) + (((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part + \ + 500) / 1000) - /** - * The MAX_RTT definition for the session (s). - * - * RFC 7252, Section 4.8.2 Calculation of MAX_RTT - * (2 * MAX_LATENCY) + PROCESSING_DELAY - */ +/** + * The MAX_RTT definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of MAX_RTT + * (2 * MAX_LATENCY) + PROCESSING_DELAY + */ #define COAP_MAX_RTT(s) \ - ((2 * COAP_DEFAULT_MAX_LATENCY) + COAP_PROCESSING_DELAY(s)) + ((2 * COAP_DEFAULT_MAX_LATENCY) + COAP_PROCESSING_DELAY(s)) - /** - * The EXCHANGE_LIFETIME definition for the session (s). - * - * RFC 7252, Section 4.8.2 Calculation of EXCHANGE_LIFETIME - * MAX_TRANSMIT_SPAN + (2 * MAX_LATENCY) + PROCESSING_DELAY - */ +/** + * The EXCHANGE_LIFETIME definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of EXCHANGE_LIFETIME + * MAX_TRANSMIT_SPAN + (2 * MAX_LATENCY) + PROCESSING_DELAY + */ #define COAP_EXCHANGE_LIFETIME(s) \ - (COAP_MAX_TRANSMIT_SPAN(s) + (2 * COAP_DEFAULT_MAX_LATENCY) + \ - COAP_PROCESSING_DELAY(s)) + (COAP_MAX_TRANSMIT_SPAN(s) + (2 * COAP_DEFAULT_MAX_LATENCY) + \ + COAP_PROCESSING_DELAY(s)) - /** - * The NON_LIFETIME definition for the session (s). - * - * RFC 7252, Section 4.8.2 Calculation of NON_LIFETIME - * MAX_TRANSMIT_SPAN + MAX_LATENCY - */ +/** + * The NON_LIFETIME definition for the session (s). + * + * RFC 7252, Section 4.8.2 Calculation of NON_LIFETIME + * MAX_TRANSMIT_SPAN + MAX_LATENCY + */ #define COAP_NON_LIFETIME(s) \ - (COAP_MAX_TRANSMIT_SPAN(s) + COAP_DEFAULT_MAX_LATENCY) + (COAP_MAX_TRANSMIT_SPAN(s) + COAP_DEFAULT_MAX_LATENCY) - /** - * The NON_RECEIVE_TIMEOUT definition for the session (s). - * - * RFC9177 Section 6.2 - * 2 * NON_TIMEOUT - */ +/** + * The NON_RECEIVE_TIMEOUT definition for the session (s). + * + * RFC9177 Section 6.2 + * 2 * NON_TIMEOUT + */ #define COAP_NON_RECEIVE_TIMEOUT_TICKS(s) ( \ - COAP_NON_RECEIVE_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \ - COAP_NON_RECEIVE_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) + COAP_NON_RECEIVE_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \ + COAP_NON_RECEIVE_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) - /** - * The NON_PROBING_WAIT definition for the session (s). - * - * RFC9177 Section 6.2 - * NON_PROBING_WAIT = NON_TIMEOUT * ((2 ** NON_MAX_RETRANSMIT) - 1) * - * ACK_RANDOM_FACTOR + (2 * MAX_LATENCY) + NON_TIMEOUT_RANDOM - * Default is 247-248 seconds - */ +/** + * The NON_PROBING_WAIT definition for the session (s). + * + * RFC9177 Section 6.2 + * NON_PROBING_WAIT = NON_TIMEOUT * ((2 ** NON_MAX_RETRANSMIT) - 1) * + * ACK_RANDOM_FACTOR + (2 * MAX_LATENCY) + NON_TIMEOUT_RANDOM + * Default is 247-248 seconds + */ #define COAP_NON_PROBING_WAIT(s) \ - coap_add_fixed_fixed(COAP_NON_PROBING_WAIT_BASE(s), \ - COAP_NON_TIMEOUT_RANDOM(s)) + coap_add_fixed_fixed(COAP_NON_PROBING_WAIT_BASE(s), \ + COAP_NON_TIMEOUT_RANDOM(s)) #define COAP_NON_PROBING_WAIT_TICKS(s) \ - (COAP_NON_PROBING_WAIT(s).integer_part * COAP_TICKS_PER_SECOND + \ - COAP_NON_PROBING_WAIT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) + (COAP_NON_PROBING_WAIT(s).integer_part * COAP_TICKS_PER_SECOND + \ + COAP_NON_PROBING_WAIT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) - /** - * The NON_PARTIAL_TIMEOUT definition for the session (s). - * - * RFC9177 Section 6.2 - * Initial value EXCHANGE_LIFETIME (247 seconds) - */ +/** + * The NON_PARTIAL_TIMEOUT definition for the session (s). + * + * RFC9177 Section 6.2 + * Initial value EXCHANGE_LIFETIME (247 seconds) + */ #define COAP_NON_PARTIAL_TIMEOUT_TICKS(s) \ - (COAP_NON_PARTIAL_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \ + (COAP_NON_PARTIAL_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \ COAP_NON_PARTIAL_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000) - /** - * The NON_TIMEOUT_RANDOM definition for the session (s). - * - * RFC9177 Section 6.2 - * Default is 2-3 seconds - */ +/** + * The NON_TIMEOUT_RANDOM definition for the session (s). + * + * RFC9177 Section 6.2 + * Default is 2-3 seconds + */ #define COAP_NON_TIMEOUT_RANDOM(s) \ - coap_get_non_timeout_random(s) + coap_get_non_timeout_random(s) /** @} */ @@ -537,7 +536,7 @@ void coap_session_mfree(coap_session_t *session); HASH_ITER(hh, (e), el, rtmp) #define SESSIONS_ITER_SAFE(e, el, rtmp) \ -for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp)) + for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp)) #define SESSIONS_FIND(e, k, res) { \ HASH_FIND(hh, (e), &(k), sizeof(k), (res)); \ diff --git a/include/coap3/coap_str.h b/include/coap3/coap_str.h index d9744426..03918ae4 100644 --- a/include/coap3/coap_str.h +++ b/include/coap3/coap_str.h @@ -187,9 +187,9 @@ coap_str_const_t *coap_make_str_const(const char *string); * @c 0 otherwise. */ #define coap_string_equal(string1,string2) \ - ((string1)->length == (string2)->length && ((string1)->length == 0 || \ - ((string1)->s && (string2)->s && \ - memcmp((string1)->s, (string2)->s, (string1)->length) == 0))) + ((string1)->length == (string2)->length && ((string1)->length == 0 || \ + ((string1)->s && (string2)->s && \ + memcmp((string1)->s, (string2)->s, (string1)->length) == 0))) /** * Compares the two binary data for equality @@ -201,9 +201,9 @@ coap_str_const_t *coap_make_str_const(const char *string); * @c 0 otherwise. */ #define coap_binary_equal(binary1,binary2) \ - ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \ - ((binary1)->s && (binary2)->s && \ - memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0))) + ((binary1)->length == (binary2)->length && ((binary1)->length == 0 || \ + ((binary1)->s && (binary2)->s && \ + memcmp((binary1)->s, (binary2)->s, (binary1)->length) == 0))) /** @} */ diff --git a/include/coap3/coap_subscribe.h b/include/coap3/coap_subscribe.h index 32583a7f..087bba41 100644 --- a/include/coap3/coap_subscribe.h +++ b/include/coap3/coap_subscribe.h @@ -207,10 +207,10 @@ void coap_persist_track_funcs(coap_context_t *context, */ coap_subscription_t *coap_persist_observe_add(coap_context_t *context, coap_proto_t e_proto, - const coap_address_t *e_listen_addr, - const coap_addr_tuple_t *s_addr_info, - const coap_bin_const_t *raw_packet, - const coap_bin_const_t *oscore_info); + const coap_address_t *e_listen_addr, + const coap_addr_tuple_t *s_addr_info, + const coap_bin_const_t *raw_packet, + const coap_bin_const_t *oscore_info); /** * Start up persist tracking using the libcoap module. If the files already diff --git a/include/coap3/coap_subscribe_internal.h b/include/coap3/coap_subscribe_internal.h index fcd1fc93..aab0d621 100644 --- a/include/coap3/coap_subscribe_internal.h +++ b/include/coap3/coap_subscribe_internal.h @@ -76,10 +76,9 @@ void coap_subscription_init(coap_subscription_t *); * @param session The session that the observe notify failed on. * @param token The token used when the observe notify failed. */ -void -coap_handle_failed_notify(coap_context_t *context, - coap_session_t *session, - const coap_bin_const_t *token); +void coap_handle_failed_notify(coap_context_t *context, + coap_session_t *session, + const coap_bin_const_t *token); /** * Checks all known resources to see if they are dirty and then notifies diff --git a/include/coap3/coap_tcp_internal.h b/include/coap3/coap_tcp_internal.h index 30ebc61a..87558da1 100644 --- a/include/coap3/coap_tcp_internal.h +++ b/include/coap3/coap_tcp_internal.h @@ -45,13 +45,12 @@ * * @return @c 1 if succesful, @c 0 if failure of some sort */ -int -coap_socket_connect_tcp1(coap_socket_t *sock, - const coap_address_t *local_if, - const coap_address_t *server, - int default_port, - coap_address_t *local_addr, - coap_address_t *remote_addr); +int coap_socket_connect_tcp1(coap_socket_t *sock, + const coap_address_t *local_if, + const coap_address_t *server, + int default_port, + coap_address_t *local_addr, + coap_address_t *remote_addr); /** * Complete the TCP Connection @@ -64,10 +63,9 @@ coap_socket_connect_tcp1(coap_socket_t *sock, * * @return @c 1 if succesful, @c 0 if failure of some sort */ -int -coap_socket_connect_tcp2(coap_socket_t *sock, - coap_address_t *local_addr, - coap_address_t *remote_addr); +int coap_socket_connect_tcp2(coap_socket_t *sock, + coap_address_t *local_addr, + coap_address_t *remote_addr); /** * Create a new TCP socket and then listen for new incoming TCP sessions @@ -81,10 +79,9 @@ coap_socket_connect_tcp2(coap_socket_t *sock, * * @return @c 1 if succesful, @c 0 if failure of some sort */ -int -coap_socket_bind_tcp(coap_socket_t *sock, - const coap_address_t *listen_addr, - coap_address_t *bound_addr); +int coap_socket_bind_tcp(coap_socket_t *sock, + const coap_address_t *listen_addr, + coap_address_t *bound_addr); /** * Accept a new incoming TCP session @@ -99,11 +96,10 @@ coap_socket_bind_tcp(coap_socket_t *sock, * * @return @c 1 if succesful, @c 0 if failure of some sort */ -int -coap_socket_accept_tcp(coap_socket_t *server, - coap_socket_t *new_client, - coap_address_t *local_addr, - coap_address_t *remote_addr); +int coap_socket_accept_tcp(coap_socket_t *server, + coap_socket_t *new_client, + coap_address_t *local_addr, + coap_address_t *remote_addr); #endif /* !COAP_DISABLE_TCP */ diff --git a/include/coap3/coap_time.h b/include/coap3/coap_time.h index 591c6d7c..fe808c0d 100644 --- a/include/coap3/coap_time.h +++ b/include/coap3/coap_time.h @@ -36,21 +36,25 @@ typedef uint32_t coap_tick_t; typedef uint32_t coap_time_t; typedef int32_t coap_tick_diff_t; -COAP_STATIC_INLINE void coap_ticks_impl(coap_tick_t *t) { +COAP_STATIC_INLINE void +coap_ticks_impl(coap_tick_t *t) { *t = sys_now(); } -COAP_STATIC_INLINE void coap_clock_init_impl(void) { +COAP_STATIC_INLINE void +coap_clock_init_impl(void) { } #define coap_clock_init coap_clock_init_impl #define coap_ticks coap_ticks_impl -COAP_STATIC_INLINE coap_time_t coap_ticks_to_rt(coap_tick_t t) { +COAP_STATIC_INLINE coap_time_t +coap_ticks_to_rt(coap_tick_t t) { return t / COAP_TICKS_PER_SECOND; } -COAP_STATIC_INLINE uint64_t coap_ticks_to_rt_us(coap_tick_t t) { +COAP_STATIC_INLINE uint64_t +coap_ticks_to_rt_us(coap_tick_t t) { return (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND; } @@ -70,19 +74,23 @@ typedef int coap_tick_diff_t; #define COAP_TICKS_PER_SECOND CLOCK_SECOND -COAP_STATIC_INLINE void coap_clock_init(void) { +COAP_STATIC_INLINE void +coap_clock_init(void) { clock_init(); } -COAP_STATIC_INLINE void coap_ticks(coap_tick_t *t) { +COAP_STATIC_INLINE void +coap_ticks(coap_tick_t *t) { *t = clock_time(); } -COAP_STATIC_INLINE coap_time_t coap_ticks_to_rt(coap_tick_t t) { +COAP_STATIC_INLINE coap_time_t +coap_ticks_to_rt(coap_tick_t t) { return t / COAP_TICKS_PER_SECOND; } -COAP_STATIC_INLINE uint64_t coap_ticks_to_rt_us(coap_tick_t t) { +COAP_STATIC_INLINE uint64_t +coap_ticks_to_rt_us(coap_tick_t t) { return (uint64_t)t * 1000000 / COAP_TICKS_PER_SECOND; } @@ -99,9 +107,11 @@ typedef uint64_t coap_tick_t; typedef int64_t coap_tick_diff_t; typedef uint32_t coap_time_t; -static inline void coap_clock_init(void) {} +static inline void +coap_clock_init(void) {} -static inline void coap_ticks(coap_tick_t *t) { +static inline void +coap_ticks(coap_tick_t *t) { #ifdef MODULE_ZTIMER64_XTIMER_COMPAT *t = xtimer_now_usec64(); #else /* MODULE_ZTIMER64_XTIMER_COMPAT */ @@ -109,15 +119,18 @@ static inline void coap_ticks(coap_tick_t *t) { #endif /* MODULE_ZTIMER64_XTIMER_COMPAT */ } -static inline coap_time_t coap_ticks_to_rt(coap_tick_t t) { +static inline coap_time_t +coap_ticks_to_rt(coap_tick_t t) { return t / 1000000UL; } -static inline uint64_t coap_ticks_to_rt_us(coap_tick_t t) { +static inline uint64_t +coap_ticks_to_rt_us(coap_tick_t t) { return t; } -static inline coap_tick_t coap_ticks_from_rt_us(uint64_t t) { +static inline coap_tick_t +coap_ticks_from_rt_us(uint64_t t) { return t / 1000000UL; } #else /* !WITH_LWIP && !WITH_CONTIKI && !RIOT_VERSION */ @@ -191,7 +204,8 @@ coap_tick_t coap_ticks_from_rt_us(uint64_t t); * Returns @c 1 if and only if @p a is less than @p b where less is defined on a * signed data type. */ -COAP_STATIC_INLINE int coap_time_lt(coap_tick_t a, coap_tick_t b) { +COAP_STATIC_INLINE int +coap_time_lt(coap_tick_t a, coap_tick_t b) { return ((coap_tick_diff_t)(a - b)) < 0; } @@ -199,7 +213,8 @@ COAP_STATIC_INLINE int coap_time_lt(coap_tick_t a, coap_tick_t b) { * Returns @c 1 if and only if @p a is less than or equal @p b where less is * defined on a signed data type. */ -COAP_STATIC_INLINE int coap_time_le(coap_tick_t a, coap_tick_t b) { +COAP_STATIC_INLINE int +coap_time_le(coap_tick_t a, coap_tick_t b) { return a == b || coap_time_lt(a,b); } diff --git a/include/coap3/pdu.h b/include/coap3/pdu.h index 98ff9ee3..c7845756 100644 --- a/include/coap3/pdu.h +++ b/include/coap3/pdu.h @@ -295,7 +295,7 @@ COAP_DEPRECATED typedef struct { * * @return A pointer to the new PDU object or @c NULL on error. */ -coap_pdu_t * coap_pdu_from_pbuf(struct pbuf *pbuf); +coap_pdu_t *coap_pdu_from_pbuf(struct pbuf *pbuf); #endif /** @@ -414,12 +414,11 @@ void coap_delete_pdu(coap_pdu_t *pdu); * * @return The duplicated PDU or @c NULL if failure. */ -coap_pdu_t * -coap_pdu_duplicate(const coap_pdu_t *old_pdu, - coap_session_t *session, - size_t token_length, - const uint8_t *token, - coap_opt_filter_t *drop_options); +coap_pdu_t *coap_pdu_duplicate(const coap_pdu_t *old_pdu, + coap_session_t *session, + size_t token_length, + const uint8_t *token, + coap_opt_filter_t *drop_options); /** * Parses @p data into the CoAP PDU structure given in @p result. @@ -455,8 +454,8 @@ int coap_pdu_parse(coap_proto_t proto, * @return A value greater than zero on success, or @c 0 on error. */ int coap_add_token(coap_pdu_t *pdu, - size_t len, - const uint8_t *data); + size_t len, + const uint8_t *data); /** * Adds option of given @p number to @p pdu that is passed as first diff --git a/include/coap3/resource.h b/include/coap3/resource.h index 62450d31..a094d484 100644 --- a/include/coap3/resource.h +++ b/include/coap3/resource.h @@ -33,11 +33,11 @@ * Definition of message handler function */ typedef void (*coap_method_handler_t) - (coap_resource_t *, - coap_session_t *, - const coap_pdu_t * /* request */, - const coap_string_t * /* query string */, - coap_pdu_t * /* response */); +(coap_resource_t *, + coap_session_t *, + const coap_pdu_t * /* request */, + const coap_string_t * /* query string */, + coap_pdu_t * /* response */); #define COAP_ATTR_FLAGS_RELEASE_NAME 0x1 #define COAP_ATTR_FLAGS_RELEASE_VALUE 0x2 @@ -249,7 +249,7 @@ coap_resource_t *coap_resource_unknown_init2(coap_method_handler_t put_handler, * @return A pointer to the new object or @c NULL on error. */ coap_resource_t *coap_resource_proxy_uri_init(coap_method_handler_t handler, - size_t host_name_count, const char *host_name_list[]); + size_t host_name_count, const char *host_name_list[]); /** * Creates a new resource object for handling proxy URIs with configurable @@ -270,9 +270,9 @@ coap_resource_t *coap_resource_proxy_uri_init(coap_method_handler_t handler, * @return A pointer to the new object or @c NULL on error. */ coap_resource_t *coap_resource_proxy_uri_init2(coap_method_handler_t handler, - size_t host_name_count, - const char *host_name_list[], - int flags); + size_t host_name_count, + const char *host_name_list[], + int flags); /** * Returns the resource identified by the unique string @p uri_path. If no @@ -284,7 +284,7 @@ coap_resource_t *coap_resource_proxy_uri_init2(coap_method_handler_t handler, * @return A pointer to the resource or @c NULL if not found. */ coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, - coap_str_const_t *uri_path); + coap_str_const_t *uri_path); /** * Get the uri_path from a @p resource. @@ -293,7 +293,7 @@ coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, * * @return The uri_path if it exists or @c NULL otherwise. */ -coap_str_const_t* coap_resource_get_uri_path(coap_resource_t *resource); +coap_str_const_t *coap_resource_get_uri_path(coap_resource_t *resource); /** * Sets the notification message type of resource @p resource to given @@ -339,7 +339,7 @@ typedef void (*coap_resource_release_userdata_handler_t)(void *user_data); * */ void coap_resource_release_userdata_handler(coap_context_t *context, - coap_resource_release_userdata_handler_t callback); + coap_resource_release_userdata_handler_t callback); /** * Registers the given @p resource for @p context. The resource must have been @@ -387,8 +387,8 @@ void coap_register_handler(coap_resource_t *resource, * @param handler The handler to register with @p resource. */ void coap_register_request_handler(coap_resource_t *resource, - coap_request_t method, - coap_method_handler_t handler); + coap_request_t method, + coap_method_handler_t handler); /** * Registers a new attribute with the given @p resource. As the @@ -500,13 +500,12 @@ coap_print_status_t coap_print_link(const coap_resource_t *resource, * @return A pointer to the resource or @c NULL if not found. */ coap_resource_t *coap_get_resource_from_uri_path(coap_context_t *context, - coap_str_const_t *uri_path); + coap_str_const_t *uri_path); /** * @deprecated use coap_resource_notify_observers() instead. */ -COAP_DEPRECATED int -coap_resource_set_dirty(coap_resource_t *r, - const coap_string_t *query); +COAP_DEPRECATED int coap_resource_set_dirty(coap_resource_t *r, + const coap_string_t *query); #endif /* COAP_RESOURCE_H_ */