libcoap 4.3.5-develop-72190a8
Loading...
Searching...
No Matches
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)
 
#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.
 
#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.
 
#define COAP_DEFAULT_MAX_RETRANSMIT   (4U)
 Number of message retransmissions before message sending is stopped.
 
#define COAP_DEFAULT_NSTART   (1U)
 The number of simultaneous outstanding interactions that a client maintains to a given server.
 
#define COAP_DEFAULT_DEFAULT_LEISURE   ((coap_fixed_point_t){5,0})
 The number of seconds to use as bounds for multicast traffic RFC 7252, Section 4.8 Default value of DEFAULT_LEISURE is 5.0.
 
#define COAP_DEFAULT_PROBING_RATE   (1U)
 The number of bytes/second allowed when there is no response RFC 7252, Section 4.8 Default value of PROBING_RATE is 1.
 
#define COAP_DEFAULT_MAX_PAYLOADS   (10U)
 Number of Q-Block1 or Q-Block2 payloads that can be sent in a burst before a delay has to kick in.
 
#define COAP_DEFAULT_NON_MAX_RETRANSMIT   (4U)
 The number of times for requests for re-transmission of missing Q-Block1 when no response has been received.
 
#define COAP_DEFAULT_NON_TIMEOUT   ((coap_fixed_point_t){2,0})
 The delay (+ ACK_RANDOM_FACTOR) to introduce once NON MAX_PAYLOADS Q-Block1 or Q-Block2 have been sent to reduce congestion control.
 
#define COAP_DEFAULT_NON_RECEIVE_TIMEOUT   ((coap_fixed_point_t){4,0})
 The time to wait for any missing Q-Block1 or Q-Block2 packets before requesting re-transmission of missing packets.
 
#define COAP_DEFAULT_MAX_LATENCY   (100U)
 The MAX_LATENCY definition.
 

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.
 
typedef enum coap_session_type_t coap_session_type_t
 coap_session_type_t values
 
typedef enum coap_session_state_t coap_session_state_t
 coap_session_state_t values
 

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_API coap_session_tcoap_session_reference (coap_session_t *session)
 Increment reference counter on a session.
 
COAP_API void coap_session_release (coap_session_t *session)
 Decrement reference counter on a session.
 
COAP_API void coap_session_disconnected (coap_session_t *session, coap_nack_reason_t reason)
 Notify session that it has failed.
 
void coap_session_set_app_data (coap_session_t *session, void *data)
 Stores data with the given session.
 
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().
 
const coap_address_tcoap_session_get_addr_remote (const coap_session_t *session)
 Get the remote IP address and port from the session.
 
const coap_address_tcoap_session_get_addr_mcast (const coap_session_t *session)
 Get the remote multicast IP address and port from the session if the original target IP was multicast.
 
const coap_address_tcoap_session_get_addr_local (const coap_session_t *session)
 Get the local IP address and port from the session.
 
coap_proto_t coap_session_get_proto (const coap_session_t *session)
 Get the session protocol type.
 
coap_session_type_t coap_session_get_type (const coap_session_t *session)
 Get the session type.
 
coap_session_state_t coap_session_get_state (const coap_session_t *session)
 Get the session state.
 
int coap_session_get_ifindex (const coap_session_t *session)
 Get the session if index.
 
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)
 
coap_context_tcoap_session_get_context (const coap_session_t *session)
 Get the session context.
 
int coap_session_set_type_client (coap_session_t *session)
 Set the session type to client.
 
void coap_session_set_mtu (coap_session_t *session, unsigned mtu)
 Set the session MTU.
 
COAP_API size_t coap_session_max_pdu_size (const coap_session_t *session)
 Get maximum acceptable PDU size.
 
COAP_API 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.
 
COAP_API 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.
 
COAP_API 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.
 
const coap_bin_const_tcoap_session_get_psk_hint (const coap_session_t *session)
 Get the server session's current Identity Hint (PSK).
 
const coap_bin_const_tcoap_session_get_psk_identity (const coap_session_t *session)
 Get the server session's current PSK identity (PSK).
 
const coap_bin_const_tcoap_session_get_psk_key (const coap_session_t *session)
 Get the session's current pre-shared key (PSK).
 
COAP_API 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.
 
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.
 
void coap_session_new_token (coap_session_t *session, size_t *length, uint8_t *token)
 Creates a new token for use.
 
const char * coap_session_str (const coap_session_t *session)
 Get session description.
 
COAP_API 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.
 
void coap_endpoint_set_default_mtu (coap_endpoint_t *endpoint, unsigned mtu)
 Set the endpoint's default MTU.
 
COAP_API void coap_free_endpoint (coap_endpoint_t *endpoint)
 Release an endpoint and all the structures associated with it.
 
coap_session_tcoap_session_get_by_peer (const coap_context_t *context, const coap_address_t *remote_addr, int ifindex)
 Get the session associated with the specified remote_addr and index.
 
const char * coap_endpoint_str (const coap_endpoint_t *endpoint)
 Get endpoint description.
 
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.
 
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.
 
void coap_session_set_ack_random_factor (coap_session_t *session, coap_fixed_point_t value)
 Set the CoAP ack randomize factor.
 
coap_fixed_point_t coap_session_get_ack_random_factor (const coap_session_t *session)
 Get the CoAP ack randomize factor.
 
void coap_session_set_max_retransmit (coap_session_t *session, uint16_t value)
 Set the CoAP maximum retransmit count before failure.
 
uint16_t coap_session_get_max_retransmit (const coap_session_t *session)
 Get the CoAP maximum retransmit before failure.
 
void coap_session_set_nstart (coap_session_t *session, uint16_t value)
 Set the CoAP maximum concurrent transmission count of Confirmable messages RFC7252 NSTART.
 
uint16_t coap_session_get_nstart (const coap_session_t *session)
 Get the CoAP maximum concurrent transmission count of Confirmable messages RFC7252 NSTART.
 
void coap_session_set_default_leisure (coap_session_t *session, coap_fixed_point_t value)
 Set the CoAP default leisure time (for multicast) RFC7252 DEFAULT_LEISURE.
 
coap_fixed_point_t coap_session_get_default_leisure (const coap_session_t *session)
 Get the CoAP default leisure time RFC7252 DEFAULT_LEISURE.
 
void coap_session_set_probing_rate (coap_session_t *session, uint32_t value)
 Set the CoAP probing rate when there is no response RFC7252 PROBING_RATE.
 
uint32_t coap_session_get_probing_rate (const coap_session_t *session)
 Get the CoAP probing rate when there is no response RFC7252 PROBING_RATE.
 
void coap_session_set_max_payloads (coap_session_t *session, uint16_t value)
 Set the CoAP maximum payloads count of Q-Block1 or Q-Block2 before delay is introduced RFC9177 MAX_PAYLOADS.
 
uint16_t coap_session_get_max_payloads (const coap_session_t *session)
 Get the CoAP maximum payloads count of Q-Block1 or Q-Block2 before delay is introduced RFC9177 MAX_PAYLOADS.
 
void coap_session_set_non_max_retransmit (coap_session_t *session, uint16_t value)
 Set the CoAP NON maximum retransmit count of missing Q-Block1 or Q-Block2 requested before there is any response RFC9177 NON_MAX_RETRANSMIT.
 
uint16_t coap_session_get_non_max_retransmit (const coap_session_t *session)
 Get the CoAP NON maximum retransmit count of missing Q-Block1 or Q-Block2 requested before there is any response RFC9177 NON_MAX_RETRANSMIT.
 
void coap_session_set_non_timeout (coap_session_t *session, coap_fixed_point_t value)
 Set the CoAP non timeout delay timeout.
 
coap_fixed_point_t coap_session_get_non_timeout (const coap_session_t *session)
 Get the CoAP MAX_PAYLOADS limit delay timeout.
 
void coap_session_set_non_receive_timeout (coap_session_t *session, coap_fixed_point_t value)
 Set the CoAP non receive timeout delay timeout.
 
coap_fixed_point_t coap_session_get_non_receive_timeout (const coap_session_t *session)
 Get the CoAP non receive timeout delay timeout.
 
COAP_API coap_mid_t coap_session_send_ping (coap_session_t *session)
 Send a ping message for the session.
 
void coap_session_set_no_observe_cancel (coap_session_t *session)
 Disable client automatically sending observe cancel on session close.
 

Detailed Description

Defines the application visible session information.

Definition in file coap_session.h.

Function Documentation

◆ coap_session_send_ping()

COAP_API 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 786 of file coap_session.c.

+ Here is the call graph for this function:

◆ coap_session_set_no_observe_cancel()

void coap_session_set_no_observe_cancel ( coap_session_t session)

Disable client automatically sending observe cancel on session close.

Parameters
sessionThe CoAP session.