libcoap  4.3.0rc2
Sessions (Internal)

CoAP Session Structures, Enums and Functions that are not exposed to applications. More...

Data Structures

struct  coap_addr_hash_t
 Only used for servers for hashing incoming packets. More...
 
struct  coap_session_t
 Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (server). More...
 
struct  coap_endpoint_t
 Abstraction of virtual endpoint that can be attached to coap_context_t. More...
 

Functions

void coap_session_send_csm (coap_session_t *session)
 Notify session transport has just connected and CSM exchange can now start. More...
 
void coap_session_connected (coap_session_t *session)
 Notify session that it has just connected or reconnected. More...
 
int coap_session_refresh_psk_hint (coap_session_t *session, const coap_bin_const_t *psk_hint)
 Refresh the session's current Identity Hint (PSK). More...
 
int coap_session_refresh_psk_key (coap_session_t *session, const coap_bin_const_t *psk_key)
 Refresh the session's current pre-shared key (PSK). More...
 
coap_session_tcoap_new_server_session (coap_context_t *ctx, coap_endpoint_t *ep)
 Creates a new server session for the specified endpoint. More...
 
ssize_t coap_session_send (coap_session_t *session, const uint8_t *data, size_t datalen)
 Function interface for datagram data transmission. More...
 
ssize_t coap_session_write (coap_session_t *session, const uint8_t *data, size_t datalen)
 Function interface for stream data transmission. More...
 
ssize_t coap_session_send_pdu (coap_session_t *session, coap_pdu_t *pdu)
 Send a pdu according to the session's protocol. More...
 
ssize_t coap_session_delay_pdu (coap_session_t *session, coap_pdu_t *pdu, coap_queue_t *node)
 
coap_session_tcoap_endpoint_get_session (coap_endpoint_t *endpoint, const coap_packet_t *packet, coap_tick_t now)
 Lookup the server session for the packet received on an endpoint, or create a new one. More...
 
void coap_session_free (coap_session_t *session)
 
void coap_session_mfree (coap_session_t *session)
 

Detailed Description

CoAP Session Structures, Enums and Functions that are not exposed to applications.

Function Documentation

◆ coap_endpoint_get_session()

coap_session_t* coap_endpoint_get_session ( coap_endpoint_t endpoint,
const coap_packet_t packet,
coap_tick_t  now 
)

Lookup the server session for the packet received on an endpoint, or create a new one.

Parameters
endpointActive endpoint the packet was received on.
packetReceived packet.
nowThe current time in ticks.
Returns
The CoAP session or NULL if error.

Definition at line 555 of file coap_session.c.

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

◆ coap_new_server_session()

coap_session_t* coap_new_server_session ( coap_context_t ctx,
coap_endpoint_t ep 
)

Creates a new server session for the specified endpoint.

Parameters
ctxThe CoAP context.
epAn endpoint where an incoming connection request is pending.
Returns
A new CoAP session or NULL if failed. Call coap_session_release to add to unused queue.

Definition at line 1107 of file coap_session.c.

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

◆ coap_session_connected()

void coap_session_connected ( coap_session_t session)

Notify session that it has just connected or reconnected.

Parameters
sessionThe CoAP session.

Definition at line 397 of file coap_session.c.

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

◆ coap_session_delay_pdu()

ssize_t coap_session_delay_pdu ( coap_session_t session,
coap_pdu_t pdu,
coap_queue_t node 
)

Definition at line 310 of file coap_session.c.

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

◆ coap_session_free()

void coap_session_free ( coap_session_t session)

Definition at line 223 of file coap_session.c.

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

◆ coap_session_mfree()

void coap_session_mfree ( coap_session_t session)

Definition at line 157 of file coap_session.c.

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

◆ coap_session_refresh_psk_hint()

int coap_session_refresh_psk_hint ( coap_session_t session,
const coap_bin_const_t psk_hint 
)

Refresh the session's current Identity Hint (PSK).

Note: A copy of psk_hint is maintained in the session by libcoap.

Parameters
sessionThe current coap_session_t object.
psk_hintIf NULL, the Identity Hint will revert to the initial Identity Hint used at session setup.
Returns
1 if successful, else 0.

Definition at line 997 of file coap_session.c.

+ Here is the call graph for this function:

◆ coap_session_refresh_psk_key()

int coap_session_refresh_psk_key ( coap_session_t session,
const coap_bin_const_t psk_key 
)

Refresh the session's current pre-shared key (PSK).

Note: A copy of psk_key is maintained in the session by libcoap.

Parameters
sessionThe current coap_session_t object.
psk_keyIf NULL, the pre-shared key will revert to the initial pre-shared key used as session setup.
Returns
1 if successful, else 0.

Definition at line 1026 of file coap_session.c.

+ Here is the call graph for this function:

◆ coap_session_send()

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

Function interface for datagram data transmission.

This function returns the number of bytes that have been transmitted, or a value less than zero on error.

Parameters
sessionSession to send data on.
dataThe data to send.
datalenThe actual length of data.
Returns
The number of bytes written on success, or a value less than zero on error.

Definition at line 275 of file coap_session.c.

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

◆ coap_session_send_csm()

void coap_session_send_csm ( coap_session_t session)

Notify session transport has just connected and CSM exchange can now start.

Parameters
sessionThe CoAP session.

Definition at line 349 of file coap_session.c.

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

◆ coap_session_send_pdu()

ssize_t coap_session_send_pdu ( coap_session_t session,
coap_pdu_t pdu 
)

Send a pdu according to the session's protocol.

This function returns the number of bytes that have been transmitted, or a value less than zero on error.

Parameters
sessionSession to send pdu on.
pduThe pdu to send.
Returns
The number of bytes written on success, or a value less than zero on error.

Definition at line 764 of file net.c.

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

◆ coap_session_write()

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

Function interface for stream data transmission.

This function returns the number of bytes that have been transmitted, or a value less than zero on error. The number of bytes written may be less than datalen because of congestion control.

Parameters
sessionSession to send data on.
dataThe data to send.
datalenThe actual length of data.
Returns
The number of bytes written on success, or a value less than zero on error.

Definition at line 296 of file coap_session.c.

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