Loading...
Searching...
No Matches
Sessions
Libcoap Internal API

Internal API for handling Sessions. More...

Collaboration diagram for Sessions:

## 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...

## Macros

#define | COAP_SESSION_REF(s)
#define | COAP_ACK_TIMEOUT(s)
#define | COAP_ACK_RANDOM_FACTOR(s)
#define | COAP_MAX_RETRANSMIT(s)
#define | COAP_NSTART(s)
#define | COAP_DEFAULT_LEISURE(s)
#define | COAP_PROBING_RATE(s)
#define | COAP_MAX_PAYLOADS(s)
#define | COAP_NON_MAX_RETRANSMIT(s)
#define | COAP_NON_TIMEOUT(s)
#define | COAP_NON_TIMEOUT_TICKS(s)
#define | COAP_NON_RECEIVE_TIMEOUT(s)
#define | COAP_NON_PROBING_WAIT_BASE(s)
#define | COAP_NON_PARTIAL_TIMEOUT(s)
#define | COAP_DEFAULT_LEISURE_TICKS(s)
| The DEFAULT_LEISURE definition for the session (s).
#define | COAP_MAX_TRANSMIT_SPAN(s)
| The MAX_TRANSMIT_SPAN definition for the session (s).
#define | COAP_MAX_TRANSMIT_WAIT(s)
| The MAX_TRANSMIT_WAIT definition for the session (s).
#define | COAP_MAX_TRANSMIT_WAIT_TICKS(s)
#define | COAP_PROCESSING_DELAY(s)
| The PROCESSING_DELAY definition for the session (s).
#define | COAP_MAX_RTT(s)
| The MAX_RTT definition for the session (s).
#define | COAP_EXCHANGE_LIFETIME(s)
| The EXCHANGE_LIFETIME definition for the session (s).
#define | COAP_NON_LIFETIME(s)
| The NON_LIFETIME definition for the session (s).
#define | COAP_NON_RECEIVE_TIMEOUT_TICKS(s)
| The NON_RECEIVE_TIMEOUT definition for the session (s).
#define | COAP_NON_PROBING_WAIT(s)
| The NON_PROBING_WAIT definition for the session (s).
#define | COAP_NON_PROBING_WAIT_TICKS(s)
#define | COAP_NON_PARTIAL_TIMEOUT_TICKS(s)
| The NON_PARTIAL_TIMEOUT definition for the session (s).
#define | COAP_NON_TIMEOUT_RANDOM(s)
| The NON_TIMEOUT_RANDOM definition for the session (s).

## Typedefs

typedef enum coap_ext_token_check_t | coap_ext_token_check_t
| coap_ext_token_check_t values

## Enumerations

enum | COAP_OSCORE_B_2_STEP { COAP_OSCORE_B_2_NONE = 0 , COAP_OSCORE_B_2_STEP_1 , COAP_OSCORE_B_2_STEP_2 , COAP_OSCORE_B_2_STEP_3 , COAP_OSCORE_B_2_STEP_4 , COAP_OSCORE_B_2_STEP_5 }
enum | coap_ext_token_check_t { COAP_EXT_T_NOT_CHECKED = 0 , COAP_EXT_T_CHECKED , COAP_EXT_T_CHECKING }
| coap_ext_token_check_t values More...

## Functions

coap_fixed_point_t | coap_multi_fixed_fixed (coap_fixed_point_t fp1, coap_fixed_point_t fp2)
coap_fixed_point_t | coap_multi_fixed_uint (coap_fixed_point_t fp1, uint32_t u2)
coap_fixed_point_t | coap_add_fixed_fixed (coap_fixed_point_t fp1, coap_fixed_point_t fp2)
coap_fixed_point_t | coap_add_fixed_uint (coap_fixed_point_t fp1, uint32_t u2)
coap_fixed_point_t | coap_sub_fixed_uint (coap_fixed_point_t fp1, uint32_t u2)
coap_fixed_point_t | coap_div_fixed_uint (coap_fixed_point_t fp1, uint32_t u2)
coap_fixed_point_t | coap_get_non_timeout_random (coap_session_t *session)
coap_tick_t | coap_get_non_timeout_random_ticks (coap_session_t *session)
void | coap_session_send_csm (coap_session_t *session)
| Notify session transport has just connected and CSM exchange can now start.
void | coap_session_connected (coap_session_t *session)
| Notify session that it has just connected or reconnected.
void | coap_session_disconnected_lkd (coap_session_t *session, coap_nack_reason_t reason)
| Notify session that it has failed.
coap_mid_t | coap_session_send_ping_lkd (coap_session_t *session)
| Send a ping message for the session.
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).
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).
int | coap_session_refresh_psk_identity (coap_session_t *session, const coap_bin_const_t *psk_identity)
| Refresh the session's current pre-shared identity (PSK).
coap_session_t * | coap_new_server_session (coap_context_t *ctx, coap_endpoint_t *ep, void *extra)
| Creates a new server session for the specified endpoint.
void | coap_session_establish (coap_session_t *session)
| Layer function interface for layer below session accept/connect being established.
coap_session_t * | coap_session_reference_lkd (coap_session_t *session)
| Increment reference counter on a session.
void | coap_session_release_lkd (coap_session_t *session)
| Decrement reference counter on a session.
ssize_t | coap_session_send_pdu (coap_session_t *session, coap_pdu_t *pdu)
| Send a pdu according to the session's protocol.
ssize_t | coap_session_delay_pdu (coap_session_t *session, coap_pdu_t *pdu, coap_queue_t *node)
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.
coap_endpoint_t * | coap_new_endpoint_lkd (coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto)
| Create a new endpoint for communicating with peers.
void | coap_free_endpoint_lkd (coap_endpoint_t *endpoint)
| Release an endpoint and all the structures associated with it.
size_t | coap_session_max_pdu_rcv_size (const coap_session_t *session)
| Get maximum acceptable receive PDU size.
size_t | coap_session_max_pdu_size_lkd (const coap_session_t *session)
| Get maximum acceptable PDU size.
coap_session_t * | coap_new_client_session_lkd (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_session_t * | coap_new_client_session_pki_lkd (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.
coap_session_t * | coap_new_client_session_psk_lkd (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_session_t * | coap_new_client_session_psk2_lkd (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.
void | coap_session_free (coap_session_t *session)
void | coap_session_mfree (coap_session_t *session)
void | coap_read_session (coap_context_t *ctx, coap_session_t *session, coap_tick_t now)
void | coap_connect_session (coap_session_t *session, coap_tick_t now)

## Detailed Description

Internal API for handling Sessions.

## Macro Definition Documentation

## COAP_ACK_RANDOM_FACTOR

#define COAP_ACK_RANDOM_FACTOR | ( |  | s | ) |

Value:
((s)->ack_random_factor)

Definition at line 592 of file coap_session_internal.h.

## COAP_ACK_TIMEOUT

#define COAP_ACK_TIMEOUT | ( |  | s | ) |

Value:
((s)->ack_timeout)

Definition at line 591 of file coap_session_internal.h.

## COAP_DEFAULT_LEISURE

#define COAP_DEFAULT_LEISURE | ( |  | s | ) |

Value:
((s)->default_leisure)

Definition at line 595 of file coap_session_internal.h.

## COAP_DEFAULT_LEISURE_TICKS

#define COAP_DEFAULT_LEISURE_TICKS | ( |  | s | ) |

Value:
(COAP_DEFAULT_LEISURE(s).integer_part * COAP_TICKS_PER_SECOND + \
COAP_DEFAULT_LEISURE(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
COAP_TICKS_PER_SECOND
#define COAP_TICKS_PER_SECOND
Use ms resolution on POSIX systems.
Definition coap_time.h:158
COAP_DEFAULT_LEISURE
#define COAP_DEFAULT_LEISURE(s)
Definition coap_session_internal.h:595

The DEFAULT_LEISURE definition for the session (s).

RFC 7252, Section 4.8 Initial value 5.0 seconds

Definition at line 614 of file coap_session_internal.h.

## COAP_EXCHANGE_LIFETIME

#define COAP_EXCHANGE_LIFETIME | ( |  | s | ) |

Value:
(COAP_MAX_TRANSMIT_SPAN(s) + (2 * COAP_DEFAULT_MAX_LATENCY) + \
COAP_PROCESSING_DELAY(s))
COAP_DEFAULT_MAX_LATENCY
#define COAP_DEFAULT_MAX_LATENCY
The MAX_LATENCY definition.
Definition coap_session.h:552
COAP_PROCESSING_DELAY
#define COAP_PROCESSING_DELAY(s)
The PROCESSING_DELAY definition for the session (s).
Definition coap_session_internal.h:652
COAP_MAX_TRANSMIT_SPAN
#define COAP_MAX_TRANSMIT_SPAN(s)
The MAX_TRANSMIT_SPAN definition for the session (s).
Definition coap_session_internal.h:623

The EXCHANGE_LIFETIME definition for the session (s).

RFC 7252, Section 4.8.2 Calculation of EXCHANGE_LIFETIME MAX_TRANSMIT_SPAN + (2 * MAX_LATENCY) + PROCESSING_DELAY

Definition at line 671 of file coap_session_internal.h.

## COAP_MAX_PAYLOADS

#define COAP_MAX_PAYLOADS | ( |  | s | ) |

Value:
((s)->max_payloads)

Definition at line 598 of file coap_session_internal.h.

## COAP_MAX_RETRANSMIT

#define COAP_MAX_RETRANSMIT | ( |  | s | ) |

Value:
((s)->max_retransmit)

Definition at line 593 of file coap_session_internal.h.

## COAP_MAX_RTT

#define COAP_MAX_RTT | ( |  | s | ) |

Value:
((2 * COAP_DEFAULT_MAX_LATENCY) + COAP_PROCESSING_DELAY(s))

The MAX_RTT definition for the session (s).

RFC 7252, Section 4.8.2 Calculation of MAX_RTT (2 * MAX_LATENCY) + PROCESSING_DELAY

Definition at line 662 of file coap_session_internal.h.

## COAP_MAX_TRANSMIT_SPAN

#define COAP_MAX_TRANSMIT_SPAN | ( |  | s | ) |

Value:
(((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part) * \
((1 << ((s)->max_retransmit)) -1) * \
((s)->ack_random_factor.integer_part * 1000 + \
(s)->ack_random_factor.fractional_part) \
/ 1000000)

The MAX_TRANSMIT_SPAN definition for the session (s).

RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_SPAN ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT)) - 1) * ACK_RANDOM_FACTOR

Definition at line 623 of file coap_session_internal.h.

## COAP_MAX_TRANSMIT_WAIT

#define COAP_MAX_TRANSMIT_WAIT | ( |  | s | ) |

Value:
(((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part) * \
((1 << ((s)->max_retransmit + 1)) -1) * \
((s)->ack_random_factor.integer_part * 1000 + \
(s)->ack_random_factor.fractional_part) \
/ 1000000)

The MAX_TRANSMIT_WAIT definition for the session (s).

RFC 7252, Section 4.8.2 Calculation of MAX_TRAMSMIT_WAIT ACK_TIMEOUT * ((2 ** (MAX_RETRANSMIT + 1)) - 1) * ACK_RANDOM_FACTOR

Definition at line 636 of file coap_session_internal.h.

## COAP_MAX_TRANSMIT_WAIT_TICKS

#define COAP_MAX_TRANSMIT_WAIT_TICKS | ( |  | s | ) |

Value:
(COAP_MAX_TRANSMIT_WAIT(s) * COAP_TICKS_PER_SECOND)
COAP_MAX_TRANSMIT_WAIT
#define COAP_MAX_TRANSMIT_WAIT(s)
The MAX_TRANSMIT_WAIT definition for the session (s).
Definition coap_session_internal.h:636

Definition at line 643 of file coap_session_internal.h.

## COAP_NON_LIFETIME

#define COAP_NON_LIFETIME | ( |  | s | ) |

Value:
(COAP_MAX_TRANSMIT_SPAN(s) + COAP_DEFAULT_MAX_LATENCY)

The NON_LIFETIME definition for the session (s).

RFC 7252, Section 4.8.2 Calculation of NON_LIFETIME MAX_TRANSMIT_SPAN + MAX_LATENCY

Definition at line 681 of file coap_session_internal.h.

## COAP_NON_MAX_RETRANSMIT

#define COAP_NON_MAX_RETRANSMIT | ( |  | s | ) |

Value:
((s)->non_max_retransmit)

Definition at line 599 of file coap_session_internal.h.

## COAP_NON_PARTIAL_TIMEOUT

#define COAP_NON_PARTIAL_TIMEOUT | ( |  | s | ) |

Value:
((s)->non_partial_timeout)

Definition at line 606 of file coap_session_internal.h.

## COAP_NON_PARTIAL_TIMEOUT_TICKS

#define COAP_NON_PARTIAL_TIMEOUT_TICKS | ( |  | s | ) |

Value:
(COAP_NON_PARTIAL_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \
COAP_NON_PARTIAL_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
COAP_NON_PARTIAL_TIMEOUT
#define COAP_NON_PARTIAL_TIMEOUT(s)
Definition coap_session_internal.h:606

The NON_PARTIAL_TIMEOUT definition for the session (s).

RFC9177 Section 6.2 Initial value EXCHANGE_LIFETIME (247 seconds)

Definition at line 716 of file coap_session_internal.h.

## COAP_NON_PROBING_WAIT

#define COAP_NON_PROBING_WAIT | ( |  | s | ) |

Value:
coap_add_fixed_fixed(COAP_NON_PROBING_WAIT_BASE(s), \
COAP_NON_TIMEOUT_RANDOM(s))
COAP_NON_PROBING_WAIT_BASE
#define COAP_NON_PROBING_WAIT_BASE(s)
Definition coap_session_internal.h:605
COAP_NON_TIMEOUT_RANDOM
#define COAP_NON_TIMEOUT_RANDOM(s)
The NON_TIMEOUT_RANDOM definition for the session (s).
Definition coap_session_internal.h:726
coap_add_fixed_fixed
coap_fixed_point_t coap_add_fixed_fixed(coap_fixed_point_t fp1, coap_fixed_point_t fp2)
Definition coap_session.c:50

The NON_PROBING_WAIT definition for the session (s).

RFC9177 Section 6.2 NON_PROBING_WAIT = NON_TIMEOUT * ((2 ** NON_MAX_RETRANSMIT) - 1) * ACK_RANDOM_FACTOR + (2 * MAX_LATENCY) + NON_TIMEOUT_RANDOM Default is 247-248 seconds

Definition at line 702 of file coap_session_internal.h.

## COAP_NON_PROBING_WAIT_BASE

#define COAP_NON_PROBING_WAIT_BASE | ( |  | s | ) |

Value:
((s)->non_probing_wait_base)

Definition at line 605 of file coap_session_internal.h.

## COAP_NON_PROBING_WAIT_TICKS

#define COAP_NON_PROBING_WAIT_TICKS | ( |  | s | ) |

Value:
(COAP_NON_PROBING_WAIT(s).integer_part * COAP_TICKS_PER_SECOND + \
COAP_NON_PROBING_WAIT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
COAP_NON_PROBING_WAIT
#define COAP_NON_PROBING_WAIT(s)
The NON_PROBING_WAIT definition for the session (s).
Definition coap_session_internal.h:702

Definition at line 706 of file coap_session_internal.h.

## COAP_NON_RECEIVE_TIMEOUT

#define COAP_NON_RECEIVE_TIMEOUT | ( |  | s | ) |

Value:
((s)->non_receive_timeout)

Definition at line 604 of file coap_session_internal.h.

## COAP_NON_RECEIVE_TIMEOUT_TICKS

#define COAP_NON_RECEIVE_TIMEOUT_TICKS | ( |  | s | ) |

Value:
( \
COAP_NON_RECEIVE_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \
COAP_NON_RECEIVE_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)

The NON_RECEIVE_TIMEOUT definition for the session (s).

RFC9177 Section 6.2 2 * NON_TIMEOUT

Definition at line 690 of file coap_session_internal.h.

## COAP_NON_TIMEOUT

#define COAP_NON_TIMEOUT | ( |  | s | ) |

Value:
((s)->non_timeout)

Definition at line 600 of file coap_session_internal.h.

## COAP_NON_TIMEOUT_RANDOM

#define COAP_NON_TIMEOUT_RANDOM | ( |  | s | ) |

Value:
coap_get_non_timeout_random(s)
coap_get_non_timeout_random
coap_fixed_point_t coap_get_non_timeout_random(coap_session_t *session)

The NON_TIMEOUT_RANDOM definition for the session (s).

RFC9177 Section 6.2 Default is 2-3 seconds

Definition at line 726 of file coap_session_internal.h.

## COAP_NON_TIMEOUT_TICKS

#define COAP_NON_TIMEOUT_TICKS | ( |  | s | ) |

Value:
(COAP_NON_TIMEOUT(s).integer_part * COAP_TICKS_PER_SECOND + \
COAP_NON_TIMEOUT(s).fractional_part * COAP_TICKS_PER_SECOND / 1000)
COAP_NON_TIMEOUT
#define COAP_NON_TIMEOUT(s)
Definition coap_session_internal.h:600

Definition at line 601 of file coap_session_internal.h.

## COAP_NSTART

#define COAP_NSTART | ( |  | s | ) |

Value:
((s)->nstart)

Definition at line 594 of file coap_session_internal.h.

## COAP_PROBING_RATE

#define COAP_PROBING_RATE | ( |  | s | ) |

Value:
((s)->probing_rate)

Definition at line 596 of file coap_session_internal.h.

## COAP_PROCESSING_DELAY

#define COAP_PROCESSING_DELAY | ( |  | s | ) |

Value:
(((s)->ack_timeout.integer_part * 1000 + (s)->ack_timeout.fractional_part + \
500) / 1000)

The PROCESSING_DELAY definition for the session (s).

RFC 7252, Section 4.8.2 Calculation of PROCESSING_DELAY PROCESSING_DELAY set to ACK_TIMEOUT

Definition at line 652 of file coap_session_internal.h.

## COAP_SESSION_REF

#define COAP_SESSION_REF | ( |  | s | ) |

Value:
((s)->ref

Definition at line 588 of file coap_session_internal.h.

## Typedef Documentation

## coap_ext_token_check_t

typedef enum coap_ext_token_check_t coap_ext_token_check_t

coap_ext_token_check_t values

## Enumeration Type Documentation

## coap_ext_token_check_t

enum coap_ext_token_check_t

coap_ext_token_check_t values

Enumerator
COAP_EXT_T_NOT_CHECKED | Not checked.
COAP_EXT_T_CHECKED | Token size valid.
COAP_EXT_T_CHECKING | Token size check request sent.

Definition at line 58 of file coap_session_internal.h.

## COAP_OSCORE_B_2_STEP

enum COAP_OSCORE_B_2_STEP

Enumerator
COAP_OSCORE_B_2_NONE |
COAP_OSCORE_B_2_STEP_1 |
COAP_OSCORE_B_2_STEP_2 |
COAP_OSCORE_B_2_STEP_3 |
COAP_OSCORE_B_2_STEP_4 |
COAP_OSCORE_B_2_STEP_5 |

Definition at line 46 of file coap_session_internal.h.

## Function Documentation

## coap_add_fixed_fixed()

coap_fixed_point_t coap_add_fixed_fixed | ( | coap_fixed_point_t | fp1,
|  | coap_fixed_point_t | fp2 )

Definition at line 50 of file coap_session.c.

## coap_add_fixed_uint()

coap_fixed_point_t coap_add_fixed_uint | ( | coap_fixed_point_t | fp1,
|  | uint32_t | u2 )

Definition at line 60 of file coap_session.c.

## coap_connect_session()

void coap_connect_session | ( | coap_session_t * | session,
|  | coap_tick_t | now )

Here is the caller graph for this function:

## coap_div_fixed_uint()

coap_fixed_point_t coap_div_fixed_uint | ( | coap_fixed_point_t | fp1,
|  | uint32_t | u2 )

Definition at line 76 of file coap_session.c.

## 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

  endpoint | Active endpoint the packet was received on.
  packet | Received packet.
  now | The current time in ticks.

Returns
  The CoAP session or `NULL` if error.

## coap_free_endpoint_lkd()

void coap_free_endpoint_lkd | ( | coap_endpoint_t * | endpoint | ) |

Release an endpoint and all the structures associated with it.

Note: This function must be called in the locked state.

Parameters

  endpoint | The endpoint to release.

Here is the caller graph for this function:

## coap_get_non_timeout_random()

coap_fixed_point_t coap_get_non_timeout_random | ( | coap_session_t * | session | ) |

## coap_get_non_timeout_random_ticks()

coap_tick_t coap_get_non_timeout_random_ticks | ( | coap_session_t * | session | ) |

Here is the caller graph for this function:

## coap_multi_fixed_fixed()

coap_fixed_point_t coap_multi_fixed_fixed | ( | coap_fixed_point_t | fp1,
|  | coap_fixed_point_t | fp2 )

Definition at line 30 of file coap_session.c.

## coap_multi_fixed_uint()

coap_fixed_point_t coap_multi_fixed_uint | ( | coap_fixed_point_t | fp1,
|  | uint32_t | u2 )

Definition at line 40 of file coap_session.c.

## coap_new_client_session_lkd()

coap_session_t * coap_new_client_session_lkd | ( | 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.

Note: This function must be called in the locked state.

Parameters

  ctx | The CoAP context.
  local_if | Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected.
  server | The server's address. If the port number is zero, the default port for the protocol will be used.
  proto | Protocol.

Returns
  A new CoAP session or NULL if failed. Call coap_session_release_lkd to free.

## coap_new_client_session_pki_lkd()

coap_session_t * coap_new_client_session_pki_lkd | ( | 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.

Note: This function must be called in the locked state.

Parameters

  ctx | The CoAP context.
  local_if | Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected.
  server | The server's address. If the port number is zero, the default port for the protocol will be used.
  proto | CoAP Protocol.
  setup_data | PKI parameters.

Returns
  A new CoAP session or NULL if failed. Call coap_session_release_lkd() to free.

## coap_new_client_session_psk2_lkd()

coap_session_t * coap_new_client_session_psk2_lkd | ( | 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.

Note: This function must be called in the locked state.

Parameters

  ctx | The CoAP context.
  local_if | Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected.
  server | The server's address. If the port number is zero, the default port for the protocol will be used.
  proto | CoAP Protocol.
  setup_data | PSK parameters.

Returns
  A new CoAP session or NULL if failed. Call coap_session_release_lkd() to free.

## coap_new_client_session_psk_lkd()

coap_session_t * coap_new_client_session_psk_lkd | ( | 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.

Note: This function must be called in the locked state.

Deprecated
  Use coap_new_client_session_psk2_lkd() instead.

Parameters

  ctx | The CoAP context.
  local_if | Address of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected.
  server | The server's address. If the port number is zero, the default port for the protocol will be used.
  proto | Protocol.
  identity | PSK client identity
  key | PSK shared key
  key_len | PSK shared key length

Returns
  A new CoAP session or NULL if failed. Call coap_session_release_lkd to free.

## coap_new_endpoint_lkd()

coap_endpoint_t * coap_new_endpoint_lkd | ( | coap_context_t * | context,
|  | const coap_address_t * | listen_addr,
|  | coap_proto_t | proto )

Create a new endpoint for communicating with peers.

Note: This function must be called in the locked state.

Parameters

  context | The coap context that will own the new endpoint,
  listen_addr | Address the endpoint will listen for incoming requests on or originate outgoing requests from. Use NULL to specify that no incoming request will be accepted and use a random endpoint.
  proto | Protocol used on this endpoint,

Returns
  The new endpoint or `NULL` on failure.

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,
|  | void * | extra )

Creates a new server session for the specified endpoint.

Parameters

  ctx | The CoAP context.
  ep | An endpoint where an incoming connection request is pending.
  extra | Available for use by any underlying network stack.

Returns
  A new CoAP session or NULL if failed. Call coap_session_release_lkd to add to unused queue.

## coap_read_session()

void coap_read_session | ( | coap_context_t * | ctx,
|  | coap_session_t * | session,
|  | coap_tick_t | now )

Definition at line 2080 of file coap_net.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

  session | The CoAP session.

Definition at line 815 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 695 of file coap_session.c.

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

## coap_session_disconnected_lkd()

void coap_session_disconnected_lkd | ( | coap_session_t * | session,
|  | coap_nack_reason_t | reason )

Notify session that it has failed.

This cleans up any outstanding / queued transmissions, observations etc..

Note: This function must be called in the locked state.

Parameters

  session | The CoAP session.
  reason | The reason why the session was disconnected.

Definition at line 911 of file coap_session.c.

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

## coap_session_establish()

void coap_session_establish | ( | coap_session_t * | session | ) |

Layer function interface for layer below session accept/connect being established.

This function initiates a CSM request for reliable protocols, or coap_session_connect() for un-reliable protocols.

Parameters

  session | Session that the lower layer accept/connect was done on.

Definition at line 1395 of file coap_session.c.

Here is the call graph for this function:

## coap_session_free()

void coap_session_free | ( | coap_session_t * | session | ) |

Definition at line 570 of file coap_session.c.

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

## coap_session_max_pdu_rcv_size()

size_t coap_session_max_pdu_rcv_size | ( | const coap_session_t * | session | ) |

Get maximum acceptable receive PDU size.

Parameters

  session | The CoAP session.

Returns
  maximum PDU size, not including header (but including token).

Definition at line 626 of file coap_session.c.

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

## coap_session_max_pdu_size_lkd()

size_t coap_session_max_pdu_size_lkd | ( | const coap_session_t * | session | ) |

Get maximum acceptable PDU size.

Note: This function must be called in the locked state.

Parameters

  session | The CoAP session.

Returns
  maximum PDU size, not including header (but including token).

Definition at line 652 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 488 of file coap_session.c.

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

## coap_session_reference_lkd()

coap_session_t * coap_session_reference_lkd | ( | coap_session_t * | session | ) |

Increment reference counter on a session.

Note: This function must be called in the locked state.

Parameters

  session | The CoAP session.

Returns
  same as session

Definition at line 356 of file coap_session.c.

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

  session | The current coap_session_t object.
  psk_hint | If NULL, the Identity Hint will revert to the initial Identity Hint used at session setup.

Returns
  `1` if successful, else `0`.

Definition at line 1665 of file coap_session.c.

Here is the call graph for this function:

## coap_session_refresh_psk_identity()

int coap_session_refresh_psk_identity | ( | coap_session_t * | session,
|  | const coap_bin_const_t * | psk_identity )

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

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

Parameters

  session | The current coap_session_t object.
  psk_identity | If NULL, the pre-shared identity will revert to the initial pre-shared key used as session setup.

Returns
  `1` if successful, else `0`.

Definition at line 1722 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

  session | The current coap_session_t object.
  psk_key | If NULL, the pre-shared key will revert to the initial pre-shared key used at session setup.

Returns
  `1` if successful, else `0`.

Definition at line 1694 of file coap_session.c.

Here is the call graph for this function:

## coap_session_release_lkd()

void coap_session_release_lkd | ( | coap_session_t * | session | ) |

Decrement reference counter on a session.

Note that the session may be deleted as a result and should not be used after this call.

Note: This function must be called in the locked state.

Parameters

  session | The CoAP session.

Definition at line 376 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

  session | The CoAP session.

Definition at line 736 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

  session | Session to send pdu on.
  pdu | The pdu to send.

Returns
  The number of bytes written on success, or a value less than zero on error.

Definition at line 1001 of file coap_net.c.

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

## coap_session_send_ping_lkd()

coap_mid_t coap_session_send_ping_lkd | ( | coap_session_t * | session | ) |

Send a ping message for the session.

Parameters

  session | The CoAP session.

Note: This function must be called in the locked state.

Returns
  COAP_INVALID_MID if there is an error

Definition at line 793 of file coap_session.c.

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

## coap_sub_fixed_uint()

coap_fixed_point_t coap_sub_fixed_uint | ( | coap_fixed_point_t | fp1,
|  | uint32_t | u2 )

Definition at line 68 of file coap_session.c.