Contiki-NG
Loading...
Searching...
No Matches
edhoc-error.h File Reference

Error handling module header for EDHOC. More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  edhoc_error_context_t
 Error context structure for debugging. More...

Macros

#define EDHOC_SUCCESS_CHECK(result)
 Check if an operation was successful.
#define EDHOC_FAILED(result)
 Check if an operation failed.
#define EDHOC_ERROR(code, msg)
 Macro for setting error with context information.
#define EDHOC_CHECK(call)
 Macro for checking and propagating errors.

Enumerations

enum  edhoc_error_t {
}
 Unified error type for EDHOC operations. More...

Functions

const char * edhoc_error_string (edhoc_error_t error)
 Get a human-readable error message for an error code.
edhoc_error_t edhoc_set_error_context (edhoc_error_t code, const char *file, int line, const char *function, const char *message)
 Set error context for debugging (internal use).
const edhoc_error_context_tedhoc_get_last_error_context (void)
 Get the last error context (for debugging).

Detailed Description

Error handling module header for EDHOC.

This header defines a unified error handling system that provides consistent error reporting across all EDHOC operations.

Author
Niclas Finne nicla.nosp@m.s.fi.nosp@m.nne@r.nosp@m.i.se, Nicolas Tsiftes nicol.nosp@m.as.t.nosp@m.sifte.nosp@m.s@ri.nosp@m..se

Definition in file edhoc-error.h.

Macro Definition Documentation

◆ EDHOC_CHECK

#define EDHOC_CHECK ( call)
Value:
do { \
edhoc_error_t _result = (call); \
if(EDHOC_FAILED(_result)) { \
return _result; \
} \
} while(0)
edhoc_error_t
Unified error type for EDHOC operations.
Definition edhoc-error.h:60
#define EDHOC_FAILED(result)
Check if an operation failed.

Macro for checking and propagating errors.

Usage: EDHOC_CHECK(some_function(params));

Definition at line 193 of file edhoc-error.h.

◆ EDHOC_ERROR

#define EDHOC_ERROR ( code,
msg )
Value:
edhoc_set_error_context((code), __FILE__, __LINE__, __func__, (msg))
edhoc_error_t edhoc_set_error_context(edhoc_error_t code, const char *file, int line, const char *function, const char *message)
Set error context for debugging (internal use).

Macro for setting error with context information.

Usage: return EDHOC_ERROR(EDHOC_ERR_MEMORY_ALLOCATION, "Failed to allocate key storage");

Definition at line 185 of file edhoc-error.h.

◆ EDHOC_FAILED

#define EDHOC_FAILED ( result)
Value:
((result) < EDHOC_SUCCESS)

Check if an operation failed.

Parameters
resultThe result to check
Returns
true if failed, false otherwise

Definition at line 138 of file edhoc-error.h.

Referenced by edhoc_get_key_id_cred_x().

◆ EDHOC_SUCCESS_CHECK

#define EDHOC_SUCCESS_CHECK ( result)
Value:
((result) == EDHOC_SUCCESS)

Check if an operation was successful.

Parameters
resultThe result to check
Returns
true if successful, false otherwise

Definition at line 131 of file edhoc-error.h.

Enumeration Type Documentation

◆ edhoc_error_t

Unified error type for EDHOC operations.

This enum defines all possible error conditions that can occur in EDHOC operations. Error codes are categorized by type and use negative values to distinguish them from success (0) and positive return values (e.g., sizes, counts).

Convention:

  • EDHOC_SUCCESS (0): Operation completed successfully
  • Negative values: Specific error conditions
  • Positive values: Success with data (size, count, etc.)
Enumerator
EDHOC_ERR_MEMORY_ALLOCATION 

Memory allocation failed.

EDHOC_ERR_BUFFER_TOO_SMALL 

Provided buffer is too small.

EDHOC_ERR_BUFFER_OVERFLOW 

Buffer overflow detected.

EDHOC_ERR_NULL_POINTER 

Null pointer provided.

EDHOC_ERR_INVALID_LENGTH 

Invalid length parameter.

EDHOC_ERR_CRYPTO_KEYGEN 

Key generation failed.

EDHOC_ERR_CRYPTO_SIGN 

Digital signature failed.

EDHOC_ERR_CRYPTO_VERIFY 

Signature verification failed.

EDHOC_ERR_CRYPTO_ENCRYPT 

Encryption operation failed.

EDHOC_ERR_CRYPTO_DECRYPT 

Decryption operation failed.

EDHOC_ERR_CRYPTO_HASH 

Hash operation failed.

EDHOC_ERR_CRYPTO_KDF 

Key derivation failed.

EDHOC_ERR_CRYPTO_AUTHENTICATION 

Authentication failed.

EDHOC_ERR_CRYPTO_INVALID_KEY 

Invalid cryptographic key.

EDHOC_ERR_SUITE_NOT_SUPPORTED 

Cipher suite not supported.

EDHOC_ERR_MSG_MALFORMED 

Malformed message received.

EDHOC_ERR_METHOD_NOT_SUPPORTED 

EDHOC method not supported.

EDHOC_ERR_CID_INVALID 

Invalid connection identifier.

EDHOC_ERR_WRONG_CID 

Wrong connection identifier.

EDHOC_ERR_CREDENTIAL_INVALID 

Invalid credential.

EDHOC_ERR_ID_CRED_MALFORMED 

Malformed credential identifier.

EDHOC_ERR_SEQUENCE_ERROR 

Message sequence error.

EDHOC_ERR_CORRELATION 

Message correlation error.

EDHOC_ERR_CRITICAL_EAD_UNSUPPORTED 

Critical EAD item cannot be processed (RFC 9528 Section 6).

EDHOC_ERR_KEY_NOT_FOUND 

Key not found in storage.

EDHOC_ERR_KEY_STORAGE_FULL 

Key storage is full.

EDHOC_ERR_CREDENTIAL_NOT_FOUND 

Credential not found.

EDHOC_ERR_STORAGE_INIT_FAILED 

Storage initialization failed.

EDHOC_ERR_DUPLICATE_KEY 

Duplicate key in storage.

EDHOC_ERR_NETWORK_TIMEOUT 

Network operation timeout.

EDHOC_ERR_NETWORK_CONNECTION 

Network connection error.

EDHOC_ERR_COAP_ERROR 

CoAP protocol error.

EDHOC_ERR_MESSAGE_TOO_LARGE 

Message too large for transport.

EDHOC_ERR_CBOR_ENCODING 

CBOR encoding failed.

EDHOC_ERR_CBOR_DECODING 

CBOR decoding failed.

EDHOC_ERR_CBOR_INVALID_TYPE 

Invalid CBOR data type.

EDHOC_ERR_CBOR_MALFORMED 

Malformed CBOR data.

EDHOC_ERR_INVALID_STATE 

Invalid context state.

EDHOC_ERR_CONTEXT_NOT_INITIALIZED 

Context not initialized.

EDHOC_ERR_ALREADY_INITIALIZED 

Already initialized.

EDHOC_ERR_NOT_ALLOWED_IDENTITY 

Identity not allowed.

EDHOC_ERR_INVALID_PARAMETER 

Invalid parameter provided.

EDHOC_ERR_NOT_IMPLEMENTED 

Feature not implemented.

EDHOC_ERR_INTERNAL_ERROR 

Internal implementation error.

EDHOC_ERR_UNKNOWN 

Unknown error condition.

Definition at line 60 of file edhoc-error.h.

Function Documentation

◆ edhoc_error_string()

◆ edhoc_get_last_error_context()

const edhoc_error_context_t * edhoc_get_last_error_context ( void )

Get the last error context (for debugging).

Returns
Pointer to last error context, or NULL if none

Definition at line 176 of file edhoc-error.c.

◆ edhoc_set_error_context()

edhoc_error_t edhoc_set_error_context ( edhoc_error_t code,
const char * file,
int line,
const char * function,
const char * message )

Set error context for debugging (internal use).

Parameters
codeError code
fileSource file name
lineLine number
functionFunction name
messageAdditional message
Returns
The error code passed in

Definition at line 162 of file edhoc-error.c.