tinydtls  0.8.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Fields
dtls_handler_t Struct Reference

#include <dtls.h>

Data Fields

int(* write )(struct dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len)
 
int(* read )(struct dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len)
 
int(* event )(struct dtls_context_t *ctx, session_t *session, dtls_alert_level_t level, unsigned short code)
 

Detailed Description

This structure contains callback functions used by tinydtls to communicate with the application. At least the write function must be provided. It is called by the DTLS state machine to send packets over the network. The read function is invoked to deliver decrypted and verfified application data. The third callback is an event handler function that is called when alert messages are encountered or events generated by the library have occured.

Definition at line 84 of file dtls.h.

Field Documentation

int(* dtls_handler_t::event)(struct dtls_context_t *ctx, session_t *session, dtls_alert_level_t level, unsigned short code)

The event handler is called when a message from the alert protocol is received or the state of the DTLS session changes.

Parameters
ctxThe current dtls context.
sessionThe session object that was affected.
levelThe alert level or 0 when an event ocurred that is not an alert.
codeValues less than 256 indicate alerts, while 256 or greater indicate internal DTLS session changes.
Returns
ignored

Definition at line 129 of file dtls.h.

int(* dtls_handler_t::read)(struct dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len)

Called from dtls_handle_message() deliver application data that was received on the given session. The data is delivered only after decryption and verification have succeeded.

Parameters
ctxThe current DTLS context.
sessionThe session object, including the address of the data's origin.
bufThe received data packet.
lenThe actual length of buf.
Returns
ignored

Definition at line 114 of file dtls.h.

int(* dtls_handler_t::write)(struct dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len)

Called from dtls_handle_message() to send DTLS packets over the network. The callback function must use the network interface denoted by session->ifindex to send the data.

Parameters
ctxThe current DTLS context.
sessionThe session object, including the address of the remote peer where the data shall be sent.
bufThe data to send.
lenThe actual length of buf.
Returns
The callback function must return the number of bytes that were sent, or a value less than zero to indicate an error.

Definition at line 99 of file dtls.h.


The documentation for this struct was generated from the following file: