mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-19 14:09:05 +03:00
coap_net.c: Add Reserved options RFC7252 Table 7 to option check list
The checking can be overriden by using coap_register_option(). Updated the diagnostic payload for 4.02 responses to be inline with RFC 7252, and not include the actual errant options in the response.
This commit is contained in:
1 parent
daa4e05e18
commit
c816bf7fcf
5 files changed
+102
-107
No files matched your search
@@ -144,12 +144,18 @@ 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.
|
||||
* Registers the option number @p number with the given context object @p context.
|
||||
*
|
||||
* @param ctx The context to use.
|
||||
* @param type The option type to register.
|
||||
* A registered option should only be for options that libcoap library does not
|
||||
* know about (not defined in the CoAP RFCs). On receipt or sending of a PDU,
|
||||
* this registered option will get ignored when checking for unknown critical
|
||||
* options, duplicate options or the options defined as Reserved in RFC 7252 Table 7.
|
||||
*
|
||||
* @param context The context to use.
|
||||
* @param number The option number to register.
|
||||
*/
|
||||
COAP_API void coap_register_option(coap_context_t *ctx, uint16_t type);
|
||||
COAP_API void coap_register_option(coap_context_t *context,
|
||||
coap_option_num_t number);
|
||||
|
||||
/**
|
||||
* Creates a new coap_context_t object that will hold the CoAP stack status.
|
||||
|
||||
@@ -374,33 +374,19 @@ void coap_dispatch(coap_context_t *context, coap_session_t *session,
|
||||
coap_pdu_t *pdu);
|
||||
|
||||
/**
|
||||
* Verifies that @p pdu contains no unknown critical options. Options must be
|
||||
* registered at @p ctx, using the function coap_register_option(). A basic set
|
||||
* of options is registered automatically by coap_new_context(). This function
|
||||
* returns @c 1 if @p pdu is ok, @c 0 otherwise. The given filter object @p
|
||||
* unknown will be updated with the unknown options. As only @c COAP_MAX_OPT
|
||||
* options can be signalled this way, remaining options must be examined
|
||||
* manually.
|
||||
* Verifies that @p pdu contains no unknown critical options, duplicate options
|
||||
* or the options defined as Reserved in RFC 7252 Table 7.
|
||||
*
|
||||
* @code
|
||||
coap_opt_filter_t f = COAP_OPT_NONE;
|
||||
coap_opt_iterator_t opt_iter;
|
||||
|
||||
if (coap_option_check_critical(session, pdu, f) == 0) {
|
||||
coap_option_iterator_init(pdu, &opt_iter, f);
|
||||
|
||||
while (coap_option_next(&opt_iter)) {
|
||||
if (opt_iter.type & 0x01) {
|
||||
... handle unknown critical option in opt_iter ...
|
||||
}
|
||||
}
|
||||
}
|
||||
@endcode
|
||||
* Options registered using coap_register_option() are not tested.
|
||||
*
|
||||
* The given filter object @p unknown will be updated with the unknown options.
|
||||
* The maximum number of unknown options is limited by what can be put into a
|
||||
* coap_opt_filter_t.
|
||||
*
|
||||
* @param session The current session.
|
||||
* @param pdu The PDU to check.
|
||||
* @param unknown The output filter that will be updated to indicate the
|
||||
* unknown critical options found in @p pdu.
|
||||
* unknown critical/duplicated/reserved options found in @p pdu.
|
||||
*
|
||||
* @return @c 1 if everything was ok, @c 0 otherwise.
|
||||
*/
|
||||
@@ -558,14 +544,19 @@ int coap_join_mcast_group_intf_lkd(coap_context_t *ctx, const char *groupname,
|
||||
const char *ifname);
|
||||
|
||||
/**
|
||||
* Registers the option type @p type with the given context object @p ctx.
|
||||
* Registers the option number @p number with the given context object @p context.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* @param ctx The context to use.
|
||||
* @param type The option type to register.
|
||||
* A registered option should only be for options that libcoap library does not
|
||||
* know about (not defined in the CoAP RFCs). On receipt or sending of a PDU,
|
||||
* this registered option will get ignored when checking for unknown critical
|
||||
* options, duplicate options or the options defined as Reserved in RFC 7252 Table 7.
|
||||
*
|
||||
* @param context The context to use.
|
||||
* @param number The option number to register.
|
||||
*/
|
||||
void coap_register_option_lkd(coap_context_t *ctx, uint16_t type);
|
||||
void coap_register_option_lkd(coap_context_t *context, coap_option_num_t number);
|
||||
|
||||
/**
|
||||
* Set the context's default PKI information for a server.
|
||||
|
||||
Reference in new issue
Block a user