libcoap  4.3.0
coap_session.h File Reference

Defines the application visible session information. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  coap_fixed_point_t
 Abstraction of a fixed point number that can be used where necessary instead of a float. More...
 

Macros

#define COAP_PROTO_NOT_RELIABLE(p)   ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS)
 
#define COAP_PROTO_RELIABLE(p)   ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS)
 
#define COAP_DEFAULT_ACK_TIMEOUT   ((coap_fixed_point_t){2,0})
 Number of seconds when to expect an ACK or a response to an outstanding CON message. More...
 
#define COAP_DEFAULT_ACK_RANDOM_FACTOR   ((coap_fixed_point_t){1,500})
 A factor that is used to randomize the wait time before a message is retransmitted to prevent synchronization effects. More...
 
#define COAP_DEFAULT_MAX_RETRANSMIT   4
 Number of message retransmissions before message sending is stopped RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4. More...
 
#define COAP_DEFAULT_NSTART   1
 The number of simultaneous outstanding interactions that a client maintains to a given server. More...
 
#define COAP_DEFAULT_LEISURE   (5U)
 The maximum number of seconds before sending back a response to a multicast request. More...
 
#define COAP_MAX_TRANSMIT_SPAN(s)
 The MAX_TRANSMIT_SPAN definition for the session (s). More...
 
#define COAP_MAX_TRANSMIT_WAIT(s)
 The MAX_TRANSMIT_WAIT definition for the session (s). More...
 
#define COAP_MAX_LATENCY   100
 The MAX_LATENCY definition. More...
 
#define COAP_PROCESSING_DELAY(s)
 The PROCESSING_DELAY definition for the session (s). More...
 
#define COAP_MAX_RTT(s)    ((2 * COAP_MAX_LATENCY) + COAP_PROCESSING_DELAY(s))
 The MAX_RTT definition for the session (s). More...
 
#define COAP_EXCHANGE_LIFETIME(s)    (COAP_MAX_TRANSMIT_SPAN(s) + (2 * COAP_MAX_LATENCY) + COAP_PROCESSING_DELAY(s))
 The EXCHANGE_LIFETIME definition for the session (s). More...
 
#define COAP_NON_LIFETIME(s)    (COAP_MAX_TRANSMIT_SPAN(s) + COAP_MAX_LATENCY)
 The NON_LIFETIME definition for the session (s). More...
 

Typedefs

typedef struct coap_fixed_point_t coap_fixed_point_t
 Abstraction of a fixed point number that can be used where necessary instead of a float. More...
 
typedef enum coap_session_type_t coap_session_type_t
 coap_session_type_t values More...
 
typedef enum coap_session_state_t coap_session_state_t
 coap_session_state_t values More...
 

Enumerations

enum  coap_session_type_t { COAP_SESSION_TYPE_NONE = 0 , COAP_SESSION_TYPE_CLIENT , COAP_SESSION_TYPE_SERVER , COAP_SESSION_TYPE_HELLO }
 coap_session_type_t values More...
 
enum  coap_session_state_t {
  COAP_SESSION_STATE_NONE = 0 , COAP_SESSION_STATE_CONNECTING , COAP_SESSION_STATE_HANDSHAKE , COAP_SESSION_STATE_CSM ,
  COAP_SESSION_STATE_ESTABLISHED
}
 coap_session_state_t values More...
 

Functions

coap_session_tcoap_session_reference (coap_session_t *session)
 Increment reference counter on a session. More...
 
void coap_session_release (coap_session_t *session)
 Decrement reference counter on a session. More...
 
void coap_session_disconnected (coap_session_t *session, coap_nack_reason_t reason)
 Notify session that it has failed. More...
 
void coap_session_set_app_data (coap_session_t *session, void *data)
 Stores data with the given session. More...
 
void * coap_session_get_app_data (const coap_session_t *session)
 Returns any application-specific data that has been stored with session using the function coap_session_set_app_data(). More...
 
const coap_address_tcoap_session_get_addr_remote (const coap_session_t *session)
 Get the remote IP address from the session. More...
 
const coap_address_tcoap_session_get_addr_local (const coap_session_t *session)
 Get the local IP address from the session. More...
 
coap_proto_t coap_session_get_proto (const coap_session_t *session)
 Get the session protocol type. More...
 
coap_session_type_t coap_session_get_type (const coap_session_t *session)
 Get the session type. More...
 
coap_session_state_t coap_session_get_state (const coap_session_t *session)
 Get the session state. More...
 
int coap_session_get_ifindex (const coap_session_t *session)
 Get the session if index. More...
 
void * coap_session_get_tls (const coap_session_t *session, coap_tls_library_t *tls_lib)
 Get the session TLS security ptr (TLS type dependent) More...
 
coap_context_tcoap_session_get_context (const coap_session_t *session)
 Get the session context. More...
 
int coap_session_set_type_client (coap_session_t *session)
 Set the session type to client. More...
 
void coap_session_set_mtu (coap_session_t *session, unsigned mtu)
 Set the session MTU. More...
 
size_t coap_session_max_pdu_size (const coap_session_t *session)
 Get maximum acceptable PDU size. More...
 
coap_session_tcoap_new_client_session (coap_context_t *ctx, const coap_address_t *local_if, const coap_address_t *server, coap_proto_t proto)
 Creates a new client session to the designated server. More...
 
coap_session_tcoap_new_client_session_psk (coap_context_t *ctx, const coap_address_t *local_if, const coap_address_t *server, coap_proto_t proto, const char *identity, const uint8_t *key, unsigned key_len)
 Creates a new client session to the designated server with PSK credentials. More...
 
coap_session_tcoap_new_client_session_psk2 (coap_context_t *ctx, const coap_address_t *local_if, const coap_address_t *server, coap_proto_t proto, coap_dtls_cpsk_t *setup_data)
 Creates a new client session to the designated server with PSK credentials. More...
 
const coap_bin_const_tcoap_session_get_psk_hint (const coap_session_t *session)
 Get the server session's current Identity Hint (PSK). More...
 
const coap_bin_const_tcoap_session_get_psk_key (const coap_session_t *session)
 Get the session's current pre-shared key (PSK). More...
 
coap_session_tcoap_new_client_session_pki (coap_context_t *ctx, const coap_address_t *local_if, const coap_address_t *server, coap_proto_t proto, coap_dtls_pki_t *setup_data)
 Creates a new client session to the designated server with PKI credentials. More...
 
void coap_session_init_token (coap_session_t *session, size_t length, const uint8_t *token)
 Initializes the token value to use as a starting point. More...
 
void coap_session_new_token (coap_session_t *session, size_t *length, uint8_t *token)
 Creates a new token for use. More...
 
const char * coap_session_str (const coap_session_t *session)
 Get session description. More...
 
coap_endpoint_tcoap_new_endpoint (coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto)
 Create a new endpoint for communicating with peers. More...
 
void coap_endpoint_set_default_mtu (coap_endpoint_t *endpoint, unsigned mtu)
 Set the endpoint's default MTU. More...
 
void coap_free_endpoint (coap_endpoint_t *ep)
 
const char * coap_endpoint_str (const coap_endpoint_t *endpoint)
 Get endpoint description. More...
 
coap_session_tcoap_session_get_by_peer (const coap_context_t *ctx, const coap_address_t *remote_addr, int ifindex)
 
void coap_session_set_max_retransmit (coap_session_t *session, unsigned int value)
 Set the CoAP maximum retransmit count before failure. More...
 
void coap_session_set_ack_timeout (coap_session_t *session, coap_fixed_point_t value)
 Set the CoAP initial ack response timeout before the next re-transmit. More...
 
void coap_session_set_ack_random_factor (coap_session_t *session, coap_fixed_point_t value)
 Set the CoAP ack randomize factor. More...
 
unsigned int coap_session_get_max_retransmit (const coap_session_t *session)
 Get the CoAP maximum retransmit before failure. More...
 
coap_fixed_point_t coap_session_get_ack_timeout (const coap_session_t *session)
 Get the CoAP initial ack response timeout before the next re-transmit. More...
 
coap_fixed_point_t coap_session_get_ack_random_factor (const coap_session_t *session)
 Get the CoAP ack randomize factor. More...
 
coap_mid_t coap_session_send_ping (coap_session_t *session)
 Send a ping message for the session. More...
 

Detailed Description

Defines the application visible session information.

Definition in file coap_session.h.

Function Documentation

◆ coap_session_get_ack_random_factor()

coap_fixed_point_t coap_session_get_ack_random_factor ( const coap_session_t session)

Get the CoAP ack randomize factor.

A factor that is used to randomize the wait time before a message is retransmitted to prevent synchronization effects.

Parameters
sessionThe CoAP session.
Returns
Current ack randomize value

Definition at line 65 of file coap_session.c.

◆ coap_session_get_ack_timeout()

coap_fixed_point_t coap_session_get_ack_timeout ( const coap_session_t session)

Get the CoAP initial ack response timeout before the next re-transmit.

Number of seconds when to expect an ACK or a response to an outstanding CON message.

Parameters
sessionThe CoAP session.
Returns
Current ack response timeout value

Definition at line 60 of file coap_session.c.

◆ coap_session_get_by_peer()

coap_session_t* coap_session_get_by_peer ( const coap_context_t ctx,
const coap_address_t remote_addr,
int  ifindex 
)

Definition at line 1360 of file coap_session.c.

+ Here is the call graph for this function:

◆ coap_session_get_max_retransmit()

unsigned int coap_session_get_max_retransmit ( const coap_session_t session)

Get the CoAP maximum retransmit before failure.

Number of message retransmissions before message sending is stopped

Parameters
sessionThe CoAP session.
Returns
Current maximum retransmit value

Definition at line 55 of file coap_session.c.

◆ coap_session_send_ping()

coap_mid_t coap_session_send_ping ( coap_session_t session)

Send a ping message for the session.

Parameters
sessionThe CoAP session.
Returns
COAP_INVALID_MID if there is an error

Definition at line 381 of file coap_session.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_session_set_ack_random_factor()

void coap_session_set_ack_random_factor ( coap_session_t session,
coap_fixed_point_t  value 
)

Set the CoAP ack randomize factor.

A factor that is used to randomize the wait time before a message is retransmitted to prevent synchronization effects.

Parameters
sessionThe CoAP session.
valueThe value to set to. The default is 1.5 and should not normally get changed.

Definition at line 44 of file coap_session.c.

+ Here is the call graph for this function:

◆ coap_session_set_ack_timeout()

void coap_session_set_ack_timeout ( coap_session_t session,
coap_fixed_point_t  value 
)

Set the CoAP initial ack response timeout before the next re-transmit.

Number of seconds when to expect an ACK or a response to an outstanding CON message.

Parameters
sessionThe CoAP session.
valueThe value to set to. The default is 2 and should not normally get changed.

Definition at line 34 of file coap_session.c.

+ Here is the call graph for this function:

◆ coap_session_set_max_retransmit()

void coap_session_set_max_retransmit ( coap_session_t session,
unsigned int  value 
)

Set the CoAP maximum retransmit count before failure.

Number of message retransmissions before message sending is stopped

Parameters
sessionThe CoAP session.
valueThe value to set to. The default is 4 and should not normally get changed.

Definition at line 25 of file coap_session.c.

+ Here is the call graph for this function: