Skip to content

Commit

Permalink
Revert "Added user-defined callback for finding oscore context"
Browse files Browse the repository at this point in the history
This reverts commit 8e9d700.
  • Loading branch information
Patryk Jarosz committed Mar 6, 2024
1 parent 8e9d700 commit 9a40fb1
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 54 deletions.
31 changes: 0 additions & 31 deletions include/coap3/coap_net_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@
* @{
*/

/**
* Optional user callback to be used, when oscore_find_context can't find any context.
* Could be used to check external storage (e.g. FLASH).
*
* @param c_context The CoAP COntext to search.
* @param rcpkey_id The Recipient kid.
* @param ctxkey_id The ID Context to match (or NULL if no check).
* @param oscore_r2 Partial id_context to match against or NULL.
* @param recipient_ctx The recipient context to update.
*
* return The OSCORE context and @p recipient_ctx updated, or NULL is error.
*/
typedef oscore_ctx_t * (*external_oscore_find_context_handler_t)(const coap_context_t *c_context,
const coap_bin_const_t rcpkey_id,
const coap_bin_const_t *ctxkey_id,
uint8_t *oscore_r2,
oscore_recipient_ctx_t **recipient_ctx);

/**
* Queue entry
*/
Expand Down Expand Up @@ -111,8 +93,6 @@ struct coap_context_t {
#endif /* WITH_LWIP */
#if COAP_OSCORE_SUPPORT
struct oscore_ctx_t *p_osc_ctx; /**< primary oscore context */
external_oscore_find_context_handler_t external_oscore_find_context_handler;
/**< Called when oscore_find_context didn't find any context*/
#endif /* COAP_OSCORE_SUPPORT */

#if COAP_CLIENT_SUPPORT
Expand Down Expand Up @@ -450,17 +430,6 @@ coap_mid_t coap_send_internal(coap_session_t *session, coap_pdu_t *pdu);
*/
int coap_client_delay_first(coap_session_t *session);

#if COAP_OSCORE_SUPPORT
/**
* Register optional user callback to be used, when oscore_find_context can't find any context.
* Callback could be used to check external storage (e.g. FLASH).
*
* @param ctx The current coap context to use.
* @param handler User callback.
*/
void coap_register_find_context_handler(coap_context_t *ctx, external_oscore_find_context_handler_t handler);
#endif

/** @} */

extern int coap_started;
Expand Down
13 changes: 1 addition & 12 deletions src/coap_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,6 @@ coap_new_context(const coap_address_t *listen_addr) {
#endif /* COAP_EPOLL_SUPPORT || COAP_SERVER_SUPPORT */
}

#if COAP_OSCORE_SUPPORT
void
coap_register_find_context_handler(coap_context_t *ctx, external_oscore_find_context_handler_t handler)
{
assert(ctx);
ctx->external_oscore_find_context_handler = handler;
}
#endif

void
coap_set_app_data(coap_context_t *ctx, void *app_data) {
assert(ctx);
Expand Down Expand Up @@ -726,9 +717,7 @@ coap_option_check_critical(coap_session_t *session,
case COAP_OPTION_OSCORE:
/* Valid critical if doing OSCORE */
#if COAP_OSCORE_SUPPORT
/* Only accept OSCORE option if any OSCORE context is available,
or the user provided an external handler for finding the context. */
if ((ctx->p_osc_ctx) || (ctx->external_oscore_find_context_handler))
if (ctx->p_osc_ctx)
break;
#endif /* COAP_OSCORE_SUPPORT */
/* Fall Through */
Expand Down
5 changes: 1 addition & 4 deletions src/coap_oscore.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,7 @@ coap_oscore_decrypt_pdu(coap_session_t *session,
if (opt == NULL)
return NULL;

/* OSCORE is enabled if any OSCORE context is available,
or the user provided an external handler for finding the context. */
if ((session->context->p_osc_ctx == NULL) &&
(session->context->external_oscore_find_context_handler == NULL)) {
if (session->context->p_osc_ctx == NULL) {
coap_log_warn("OSCORE: Not enabled\n");
if (!coap_request)
coap_handle_event(session->context,
Expand Down
7 changes: 0 additions & 7 deletions src/oscore/oscore_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,6 @@ oscore_find_context(const coap_context_t *c_context,
} /* while rpt */
pt = pt->next;
} /* end while */

/* no context was found in libcoap RAM - call user function to also check external storage (e.g. FLASH) */
if (c_context->external_oscore_find_context_handler)
{
return c_context->external_oscore_find_context_handler(c_context, rcpkey_id, ctxkey_id, oscore_r2, recipient_ctx);
}

return NULL;
}

Expand Down

0 comments on commit 9a40fb1

Please sign in to comment.