Loading...
Searching...
No Matches
coap_event.h
Go to the documentation of this file.
/*
* coap_event.h -- libcoap Event API
*
* Copyright (C) 2016 Olaf Bergmann <bergmann@tzi.org>
* Copyright (C) 2021-2024 Jon Shallow <supjps-libcoap@jpshallow.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef COAP_EVENT_H_
#define COAP_EVENT_H_
#include "libcoap.h"
typedef enum {
/*
* (D)TLS events for COAP_PROTO_DTLS and COAP_PROTO_TLS
*/
COAP_EVENT_DTLS_CLOSED = 0x0000,
COAP_EVENT_DTLS_CONNECTED = 0x01DE,
COAP_EVENT_DTLS_RENEGOTIATE = 0x01DF,
COAP_EVENT_DTLS_ERROR = 0x0200,
/*
* TCP events for COAP_PROTO_TCP and COAP_PROTO_TLS
*/
COAP_EVENT_TCP_CONNECTED = 0x1001,
COAP_EVENT_TCP_CLOSED = 0x1002,
COAP_EVENT_TCP_FAILED = 0x1003,
/*
* CSM exchange events for reliable protocols only
*/
COAP_EVENT_SESSION_CONNECTED = 0x2001,
COAP_EVENT_SESSION_CLOSED = 0x2002,
COAP_EVENT_SESSION_FAILED = 0x2003,
/*
* (Q-)Block errors
*/
COAP_EVENT_PARTIAL_BLOCK = 0x3001,
COAP_EVENT_XMIT_BLOCK_FAIL = 0x3002,
/*
* Server session events
*/
COAP_EVENT_SERVER_SESSION_NEW = 0x4001,
COAP_EVENT_SERVER_SESSION_DEL = 0x4002,
/*
* Message receive and transmit events
*/
COAP_EVENT_BAD_PACKET = 0x5001,
COAP_EVENT_MSG_RETRANSMITTED = 0x5002,
/*
* OSCORE events
*/
COAP_EVENT_OSCORE_DECRYPTION_FAILURE = 0x6001,
COAP_EVENT_OSCORE_NOT_ENABLED,
COAP_EVENT_OSCORE_NO_PROTECTED_PAYLOAD,
COAP_EVENT_OSCORE_NO_SECURITY,
COAP_EVENT_OSCORE_INTERNAL_ERROR,
COAP_EVENT_OSCORE_DECODE_ERROR,
/*
* WebSocket events
*/
COAP_EVENT_WS_PACKET_SIZE = 0x7001,
COAP_EVENT_WS_CONNECTED,
COAP_EVENT_WS_CLOSED,
/*
* Keepalive events
*/
COAP_EVENT_KEEPALIVE_FAILURE = 0x8001,
} coap_event_t;
typedef int (*coap_event_handler_t)(coap_session_t *session,
const coap_event_t event);
void coap_register_event_handler(coap_context_t *context,
coap_event_handler_t hnd);
COAP_DEPRECATED
void coap_set_event_handler(coap_context_t *context,
coap_event_handler_t hnd);
COAP_DEPRECATED
void coap_clear_event_handler(coap_context_t *context);
#endif /* COAP_EVENT_H */
coap_set_event_handler
COAP_DEPRECATED void coap_set_event_handler(coap_context_t *context, coap_event_handler_t hnd)
Registers the function hnd as callback for events from the given CoAP context context.
Definition coap_event.c:30
coap_clear_event_handler
COAP_DEPRECATED void coap_clear_event_handler(coap_context_t *context)
Clears the event handler registered with context.
Definition coap_event.c:36
coap_event_t
coap_event_t
Scalar type to represent different events, e.g.
Definition coap_event.h:34
coap_event_handler_t
int(* coap_event_handler_t)(coap_session_t *session, const coap_event_t event)
Type for event handler functions that can be registered with a CoAP context using the function coap_s...
Definition coap_event.h:146
coap_register_event_handler
void coap_register_event_handler(coap_context_t *context, coap_event_handler_t hnd)
Registers the function hnd as callback for events from the given CoAP context context.
Definition coap_event.c:24
COAP_EVENT_OSCORE_DECODE_ERROR
@ COAP_EVENT_OSCORE_DECODE_ERROR
Triggered when there is an OSCORE decode of OSCORE option failure.
Definition coap_event.h:118
COAP_EVENT_SESSION_CONNECTED
@ COAP_EVENT_SESSION_CONNECTED
Triggered when TCP layer completes exchange of CSM information.
Definition coap_event.h:61
COAP_EVENT_OSCORE_INTERNAL_ERROR
@ COAP_EVENT_OSCORE_INTERNAL_ERROR
Triggered when there is an OSCORE internal error i.e malloc failed.
Definition coap_event.h:116
COAP_EVENT_DTLS_CLOSED
@ COAP_EVENT_DTLS_CLOSED
Triggered when (D)TLS session closed.
Definition coap_event.h:39
COAP_EVENT_TCP_FAILED
@ COAP_EVENT_TCP_FAILED
Triggered when TCP layer fails for some reason.
Definition coap_event.h:55
COAP_EVENT_WS_CONNECTED
@ COAP_EVENT_WS_CONNECTED
Triggered when the WebSockets layer is up.
Definition coap_event.h:125
COAP_EVENT_DTLS_CONNECTED
@ COAP_EVENT_DTLS_CONNECTED
Triggered when (D)TLS session connected.
Definition coap_event.h:41
COAP_EVENT_SESSION_FAILED
@ COAP_EVENT_SESSION_FAILED
Triggered when TCP layer fails following exchange of CSM information.
Definition coap_event.h:65
COAP_EVENT_PARTIAL_BLOCK
@ COAP_EVENT_PARTIAL_BLOCK
Triggered when not all of a large body has been received.
Definition coap_event.h:71
COAP_EVENT_XMIT_BLOCK_FAIL
@ COAP_EVENT_XMIT_BLOCK_FAIL
Triggered when not all of a large body has been transmitted.
Definition coap_event.h:73
COAP_EVENT_SERVER_SESSION_NEW
@ COAP_EVENT_SERVER_SESSION_NEW
Called in the CoAP IO loop if a new server-side session is created due to an incoming connection.
Definition coap_event.h:85
COAP_EVENT_OSCORE_NOT_ENABLED
@ COAP_EVENT_OSCORE_NOT_ENABLED
Triggered when trying to use OSCORE to decrypt, but it is not enabled.
Definition coap_event.h:110
COAP_EVENT_WS_CLOSED
@ COAP_EVENT_WS_CLOSED
Triggered when the WebSockets layer is closed.
Definition coap_event.h:127
COAP_EVENT_SESSION_CLOSED
@ COAP_EVENT_SESSION_CLOSED
Triggered when TCP layer closes following exchange of CSM information.
Definition coap_event.h:63
COAP_EVENT_SERVER_SESSION_DEL
@ COAP_EVENT_SERVER_SESSION_DEL
Called in the CoAP IO loop if a server session is deleted (e.g., due to inactivity or because the max...
Definition coap_event.h:94
COAP_EVENT_OSCORE_NO_SECURITY
@ COAP_EVENT_OSCORE_NO_SECURITY
Triggered when there is no OSCORE security definition found.
Definition coap_event.h:114
COAP_EVENT_DTLS_RENEGOTIATE
@ COAP_EVENT_DTLS_RENEGOTIATE
Triggered when (D)TLS session renegotiated.
Definition coap_event.h:43
COAP_EVENT_BAD_PACKET
@ COAP_EVENT_BAD_PACKET
Triggered when badly formatted packet received.
Definition coap_event.h:100
COAP_EVENT_MSG_RETRANSMITTED
@ COAP_EVENT_MSG_RETRANSMITTED
Triggered when a message is retransmitted.
Definition coap_event.h:102
COAP_EVENT_OSCORE_NO_PROTECTED_PAYLOAD
@ COAP_EVENT_OSCORE_NO_PROTECTED_PAYLOAD
Triggered when there is no OSCORE encrypted payload provided.
Definition coap_event.h:112
COAP_EVENT_TCP_CLOSED
@ COAP_EVENT_TCP_CLOSED
Triggered when TCP layer is closed.
Definition coap_event.h:53
COAP_EVENT_WS_PACKET_SIZE
@ COAP_EVENT_WS_PACKET_SIZE
Triggered when there is an oversize WebSockets packet.
Definition coap_event.h:123
COAP_EVENT_TCP_CONNECTED
@ COAP_EVENT_TCP_CONNECTED
Triggered when TCP layer connects.
Definition coap_event.h:51
COAP_EVENT_OSCORE_DECRYPTION_FAILURE
@ COAP_EVENT_OSCORE_DECRYPTION_FAILURE
Triggered when there is an OSCORE decryption failure.
Definition coap_event.h:108
COAP_EVENT_KEEPALIVE_FAILURE
@ COAP_EVENT_KEEPALIVE_FAILURE
Triggered when no response to a keep alive (ping) packet.
Definition coap_event.h:132
COAP_EVENT_DTLS_ERROR
@ COAP_EVENT_DTLS_ERROR
Triggered when (D)TLS error occurs.
Definition coap_event.h:45
libcoap.h
Platform specific header file for CoAP stack.
COAP_DEPRECATED
#define COAP_DEPRECATED
Definition libcoap.h:62
coap_context_t
The CoAP stack's global state is stored in a coap_context_t object.
Definition coap_net_internal.h:50
coap_session_t
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
Definition coap_session_internal.h:68