libcoap 4.3.4
coap_layers_internal.h File Reference

Internal layer I/O functions. More...

#include "coap_internal.h"
+ Include dependency graph for coap_layers_internal.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  coap_layer_func_t
 

Typedefs

typedef ssize_t(* coap_layer_read_t) (coap_session_t *session, uint8_t *data, size_t datalen)
 Function read interface for layer data receiving. More...
 
typedef ssize_t(* coap_layer_write_t) (coap_session_t *session, const uint8_t *data, size_t datalen)
 Function write interface for layer data sending. More...
 
typedef void(* coap_layer_establish_t) (coap_session_t *session)
 Function establish interface for layer establish handling. More...
 
typedef void(* coap_layer_close_t) (coap_session_t *session)
 Function close interface for layer closing. More...
 

Enumerations

enum  coap_layer_t { COAP_LAYER_SESSION , COAP_LAYER_WS , COAP_LAYER_TLS , COAP_LAYER_LAST }
 

Variables

coap_layer_func_t coap_layers_coap [COAP_PROTO_LAST][COAP_LAYER_LAST]
 

Detailed Description

Internal layer I/O functions.

Definition in file coap_layers_internal.h.

Typedef Documentation

◆ coap_layer_close_t

typedef void(* coap_layer_close_t) (coap_session_t *session)

Function close interface for layer closing.

When this layer is properly closed, then the next layer must get called by calling session->lfunc[this_layer].l_close(session) (or done at any point when layer is closed).

Parameters
sessionSession being closed.

Definition at line 104 of file coap_layers_internal.h.

◆ coap_layer_establish_t

typedef void(* coap_layer_establish_t) (coap_session_t *session)

Function establish interface for layer establish handling.

If this layer is properly established on invocation, then the next layer must get called by calling session->lfunc[this_layer].l_establish(session) (or done at any point when layer is established). If the establishment of a layer fails, then coap_session_disconnected(session, COAP_NACK_xxx_LAYER_FAILED) must be called.

Parameters
sessionSession being established

Definition at line 92 of file coap_layers_internal.h.

◆ coap_layer_read_t

typedef ssize_t(* coap_layer_read_t) (coap_session_t *session, uint8_t *data, size_t datalen)

Function read interface for layer data receiving.

If a called lower layer returned value is 0 or less, this must get passed back to the caller.

If the layer function consumes all the data (i.e. to handle the protocol layer requirements), then the function must return 0 to indicate no data.

Otherwise data must get updated (limited by datalen) and the number of bytes available returned.

Note: If the number of returned bytes is less that read in, then COAP_SOCKET_CAN_READ must be dropped from session->sock.flags.

Parameters
sessionSession to receive data on.
dataThe data to receive.
datalenThe maximum length of data.
Returns
>=0 Number of bytes read. -1 Error error in errno). -2 Recieved ICMP unreachable.

Definition at line 52 of file coap_layers_internal.h.

◆ coap_layer_write_t

typedef ssize_t(* coap_layer_write_t) (coap_session_t *session, const uint8_t *data, size_t datalen)

Function write interface for layer data sending.

If a called lower layer returned value is 0 or less, this must get passed back to the caller.

If the layer function cannot transmit any data (congestion control etc.), then the function must return 0 to indicate no data sent.

It is possible that not all the data is sent (congestion control etc.), and bytes written is less that datalen.

Note: If the number of returned bytes is less that to be written, COAP_SOCKET_WANT_WRITE must be added to session->sock.flags.

Parameters
sessionSession to receive data on.
dataThe data to write out.
datalenThe maximum length of data.
Returns
>=0 Number of bytes written. -1 Error error in errno).

Definition at line 77 of file coap_layers_internal.h.

Enumeration Type Documentation

◆ coap_layer_t

Enumerator
COAP_LAYER_SESSION 
COAP_LAYER_WS 
COAP_LAYER_TLS 
COAP_LAYER_LAST 

Definition at line 22 of file coap_layers_internal.h.

Variable Documentation

◆ coap_layers_coap

Definition at line 39 of file coap_layers.c.