13 #ifndef COAP_SESSION_C_
14 #define COAP_SESSION_C_
18 #ifdef COAP_EPOLL_SUPPORT
19 #include <sys/epoll.h>
20 #include <sys/timerfd.h>
79 assert(session->
ref > 0);
88 __coverity_negative_sink__(session->
ref);
91 __coverity_free__(session);
100 session->
app = app_data;
117 memset(session, 0,
sizeof(*session));
118 session->
proto = proto;
119 session->
type = type;
167 LL_FOREACH_SAFE(session->
lg_crcv, cq, etmp) {
175 if (queue->
session == session) {
183 LL_DELETE(session->
lg_crcv, cq);
191 #if !COAP_DISABLE_TCP
210 LL_FOREACH_SAFE(session->
delayqueue, q, tmp) {
215 LL_FOREACH_SAFE(session->
lg_xmit, lq, ltmp) {
216 LL_DELETE(session->
lg_xmit, lq);
219 LL_FOREACH_SAFE(session->
lg_srcv, sq, stmp) {
220 LL_DELETE(session->
lg_srcv, sq);
228 assert(session->
ref == 0);
245 size_t max_with_header = (size_t)(session->
mtu - session->
tls_overhead);
247 return max_with_header > 4 ? max_with_header - 4 : 0;
250 return max_with_header > 4 ? max_with_header - 4 : 0;
252 if (max_with_header <= 2)
255 return max_with_header - 2;
257 return max_with_header - 3;
259 return max_with_header - 4;
261 return max_with_header - 6;
266 #if defined(WITH_CONTIKI) || defined(WITH_LWIP)
278 ssize_t bytes_written;
287 if (bytes_written == (ssize_t)datalen) {
295 return bytes_written;
300 if (bytes_written > 0) {
304 }
else if (bytes_written < 0) {
308 return bytes_written;
318 assert(removed == node);
326 if (q->
id == pdu->
mid) {
350 #if !COAP_DISABLE_TCP
358 if (session->
mtu == 0)
389 #if !COAP_DISABLE_TCP
419 ssize_t bytes_written;
440 if (bytes_written < 0)
443 if (bytes_written <= 0 || (
size_t)bytes_written < q->pdu->used_size + q->
pdu->
hdr_size) {
446 if (bytes_written > 0)
457 #if !COAP_DISABLE_TCP
468 #if !COAP_DISABLE_TCP
527 #if !COAP_DISABLE_TCP
550 addr_hash->
proto = proto;
558 unsigned int num_idle = 0;
559 unsigned int num_hs = 0;
586 if (oldest_hs == NULL ||
597 if (oldest_hs == NULL ||
609 else if (oldest_hs) {
620 "Oustanding sessions in COAP_SESSION_STATE_HANDSHAKE too "
621 "large. New request ignored\n");
642 #define OFF_CONTENT_TYPE 0
643 #define DTLS_CT_ALERT 21
644 #define DTLS_CT_HANDSHAKE 22
645 #define OFF_HANDSHAKE_TYPE 13
646 #define DTLS_HT_CLIENT_HELLO 1
649 const uint8_t *payload = (
const uint8_t*)packet->pbuf->
payload;
650 size_t length = packet->pbuf->len;
652 const uint8_t *payload = (
const uint8_t*)packet->
payload;
653 size_t length = packet->
length;
657 "coap_dtls_hello: ContentType %d Short Packet (%zu < %d) dropped\n",
667 "coap_dtls_hello: ContentType %d Handshake %d dropped\n",
707 #ifdef COAP_EPOLL_SUPPORT
714 struct epoll_event event;
726 memset(&event, 0,
sizeof(event));
727 event.events = events;
728 event.data.ptr = sock;
730 ret = epoll_ctl(context->epfd, EPOLL_CTL_ADD, sock->
fd, &event);
733 "%s: epoll_ctl ADD failed: %s (%d)\n",
778 local_if, server, 0, ctx, NULL);
790 #if !COAP_DISABLE_TCP
800 #ifdef COAP_EPOLL_SUPPORT
802 coap_epoll_ctl_add(&session->
sock,
837 #if !COAP_DISABLE_TCP
870 #if !COAP_DISABLE_TCP
918 const char *identity,
924 memset (&setup_data, 0,
sizeof(setup_data));
931 if (key && key_len > 0) {
1002 if (psk_hint && psk_hint->
s) {
1031 if (psk_key && psk_key->
s) {
1082 "coap_new_client_session_pki: Wrong version of setup_data\n");
1112 NULL, NULL, NULL, 0, ctx, ep );
1116 #if !COAP_DISABLE_TCP
1126 #ifdef COAP_EPOLL_SUPPORT
1128 coap_epoll_ctl_add(&session->
sock,
1147 const uint8_t *data) {
1159 return ++session->
tx_mid;
1186 return session->
proto;
1193 return session->
type;
1210 return session->
state;
1233 assert(listen_addr);
1254 "coap_new_endpoint: one of coap_context_set_psk() or "
1255 "coap_context_set_pki() not called\n");
1274 #if !COAP_DISABLE_TCP
1286 #ifndef INET6_ADDRSTRLEN
1287 #define INET6_ADDRSTRLEN 40
1304 #ifdef COAP_EPOLL_SUPPORT
1306 coap_epoll_ctl_add(&ep->
sock,
1329 assert(session->
ref == 0);
1330 if (session->
ref == 0) {
1345 #ifdef COAP_EPOLL_SUPPORT
1382 char *p = szSession, *end = szSession +
sizeof(szSession);
1384 (
unsigned char*)p, end - p) > 0)
1392 (
unsigned char*)p, end - p) > 0)
1395 if (session->
ifindex > 0 && p + 1 < end)
1396 p += snprintf(p, end - p,
" (if%d)", session->
ifindex);
1420 static char szEndpoint[128];
1421 char *p = szEndpoint, *end = szEndpoint +
sizeof(szEndpoint);
void coap_address_init(coap_address_t *addr)
Resets the given coap_address_t object addr to its default values.
uint16_t coap_address_get_port(const coap_address_t *addr)
Returns the port from addr in host byte order.
int coap_address_equals(const coap_address_t *a, const coap_address_t *b)
Compares given address objects a and b.
COAP_STATIC_INLINE void coap_address_copy(coap_address_t *dst, const coap_address_t *src)
Pulls together all the internal only header files.
int coap_socket_connect_udp(coap_socket_t *sock, const coap_address_t *local_if, const coap_address_t *server, int default_port, coap_address_t *local_addr, coap_address_t *remote_addr)
void coap_socket_close(coap_socket_t *sock)
ssize_t coap_socket_send(coap_socket_t *sock, coap_session_t *session, const uint8_t *data, size_t data_len)
ssize_t coap_socket_write(coap_socket_t *sock, const uint8_t *data, size_t data_len)
int coap_socket_bind_udp(coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr)
const char * coap_socket_strerror(void)
void coap_mfree_endpoint(coap_endpoint_t *ep)
coap_endpoint_t * coap_malloc_endpoint(void)
@ COAP_NACK_NOT_DELIVERABLE
#define COAP_SOCKET_WANT_ACCEPT
non blocking server socket is waiting for accept
#define COAP_SOCKET_NOT_EMPTY
the socket is not empty
#define COAP_SOCKET_BOUND
the socket is bound
#define COAP_SOCKET_WANT_READ
non blocking socket is waiting for reading
#define COAP_SOCKET_WANT_CONNECT
non blocking client socket is waiting for connect
#define COAP_SOCKET_CONNECTED
the socket is connected
#define COAP_SOCKET_EMPTY
coap_socket_flags_t values
void * coap_dtls_new_server_session(coap_session_t *session COAP_UNUSED)
int coap_dtls_context_set_pki(coap_context_t *ctx COAP_UNUSED, const coap_dtls_pki_t *setup_data COAP_UNUSED, const coap_dtls_role_t role COAP_UNUSED)
void * coap_dtls_new_client_session(coap_session_t *session COAP_UNUSED)
unsigned int coap_dtls_get_overhead(coap_session_t *session COAP_UNUSED)
void * coap_tls_new_client_session(coap_session_t *session COAP_UNUSED, int *connected COAP_UNUSED)
void * coap_tls_new_server_session(coap_session_t *session COAP_UNUSED, int *connected COAP_UNUSED)
int coap_dtls_context_check_keys_enabled(coap_context_t *ctx COAP_UNUSED)
int coap_dtls_context_set_cpsk(coap_context_t *ctx COAP_UNUSED, coap_dtls_cpsk_t *setup_data COAP_UNUSED)
void coap_dtls_free_session(coap_session_t *coap_session COAP_UNUSED)
void * coap_dtls_get_tls(const coap_session_t *c_session COAP_UNUSED, coap_tls_library_t *tls_lib)
void coap_tls_free_session(coap_session_t *coap_session COAP_UNUSED)
void coap_session_set_max_retransmit(coap_session_t *session, unsigned int value)
Set the CoAP maximum retransmit count before failure.
coap_mid_t coap_session_send_ping(coap_session_t *session)
Send a ping message for the session.
#define DTLS_HT_CLIENT_HELLO
#define OFF_HANDSHAKE_TYPE
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.
static void coap_make_addr_hash(coap_addr_hash_t *addr_hash, coap_proto_t proto, const coap_addr_tuple_t *addr_info)
#define DTLS_CT_HANDSHAKE
static coap_session_t * coap_session_create_client(coap_context_t *ctx, const coap_address_t *local_if, const coap_address_t *server, coap_proto_t proto)
coap_session_t * coap_session_get_by_peer(const coap_context_t *ctx, const coap_address_t *remote_addr, int ifindex)
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.
static coap_session_t * coap_make_session(coap_proto_t proto, coap_session_type_t type, const coap_addr_hash_t *addr_hash, const coap_address_t *local_addr, const coap_address_t *remote_addr, int ifindex, coap_context_t *context, coap_endpoint_t *endpoint)
static coap_session_t * coap_session_accept(coap_session_t *session)
static coap_session_t * coap_session_connect(coap_session_t *session)
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.
unsigned int coap_session_get_max_retransmit(const coap_session_t *session)
Get the CoAP maximum retransmit before failure.
#define SESSIONS_ADD(e, obj)
#define SESSIONS_ITER_SAFE(e, el, rtmp)
#define COAP_PARTIAL_SESSION_TIMEOUT_TICKS
#define SESSIONS_DELETE(e, obj)
#define COAP_DEFAULT_MAX_HANDSHAKE_SESSIONS
#define SESSIONS_ITER(e, el, rtmp)
#define SESSIONS_FIND(e, k, res)
int coap_tcp_is_supported(void)
Check whether TCP is available.
void coap_block_delete_lg_srcv(coap_session_t *session, coap_lg_srcv_t *lg_srcv)
void coap_block_delete_lg_crcv(coap_session_t *session, coap_lg_crcv_t *lg_crcv)
void coap_block_delete_lg_xmit(coap_session_t *session, coap_lg_xmit_t *lg_xmit)
int coap_cancel_observe(coap_session_t *session, coap_binary_t *token, coap_pdu_type_t type)
Cancel an observe that is being tracked by the client large receive logic.
void coap_delete_cache_entry(coap_context_t *ctx, coap_cache_entry_t *cache_entry)
Remove a cache-entry from the hash list and free off all the appropriate contents apart from app_data...
#define COAP_DEFAULT_ACK_RANDOM_FACTOR
A factor that is used to randomize the wait time before a message is retransmitted to prevent synchro...
#define COAP_DEFAULT_MAX_RETRANSMIT
Number of message retransmissions before message sending is stopped RFC 7252, Section 4....
#define COAP_DEFAULT_ACK_TIMEOUT
Number of seconds when to expect an ACK or a response to an outstanding CON message.
#define COAP_DEFAULT_NSTART
The number of simultaneous outstanding interactions that a client maintains to a given server.
void coap_ticks(coap_tick_t *t)
Sets t to the internal time with COAP_TICKS_PER_SECOND resolution.
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
int coap_prng(void *buf, size_t len)
Fills buf with len random bytes using the default pseudo random number generator.
int coap_remove_from_queue(coap_queue_t **queue, coap_session_t *session, coap_mid_t id, coap_queue_t **node)
This function removes the element with given id from the list given list.
int coap_delete_node(coap_queue_t *node)
Destroys specified node.
coap_queue_t * coap_new_node(void)
Creates a new node suitable for adding to the CoAP sendqueue.
coap_mid_t coap_send_internal(coap_session_t *session, coap_pdu_t *pdu)
Sends a CoAP message to given peer.
unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r)
Calculates the initial timeout based on the session CoAP transmission parameters 'ack_timeout',...
coap_mid_t coap_wait_ack(coap_context_t *context, coap_session_t *session, coap_queue_t *node)
void coap_cancel_session_messages(coap_context_t *context, coap_session_t *session, coap_nack_reason_t reason)
Cancels all outstanding messages for session session.
uint16_t coap_new_message_id(coap_session_t *session)
Returns a new message id and updates session->tx_mid accordingly.
int coap_handle_event(coap_context_t *context, coap_event_t event, coap_session_t *session)
Invokes the event handler of context for the given event and data.
coap_session_t * coap_session_new_dtls_session(coap_session_t *session, coap_tick_t now)
Create a new DTLS session for the session.
int coap_tls_is_supported(void)
Check whether TLS is available.
#define COAP_DTLS_PKI_SETUP_VERSION
Latest PKI setup version.
int coap_dtls_is_supported(void)
Check whether DTLS is available.
@ COAP_DTLS_ROLE_CLIENT
Internal function invoked for client.
unsigned int coap_encode_var_safe(uint8_t *buf, size_t length, unsigned int val)
Encodes multiple-length byte sequences.
uint64_t coap_decode_var_bytes8(const uint8_t *buf, size_t len)
Decodes multiple-length byte sequences.
unsigned int coap_encode_var_safe8(uint8_t *buf, size_t length, uint64_t val)
Encodes multiple-length byte sequences.
#define COAP_EVENT_TCP_CLOSED
#define COAP_EVENT_SESSION_CONNECTED
CSM exchange events for reliable protocols only.
#define COAP_EVENT_SESSION_FAILED
#define COAP_EVENT_TCP_FAILED
#define COAP_EVENT_SESSION_CLOSED
#define COAP_EVENT_DTLS_CONNECTED
#define COAP_EVENT_TCP_CONNECTED
TCP events for COAP_PROTO_TCP and COAP_PROTO_TLS.
coap_log_t coap_get_log_level(void)
Get the current logging level.
const char * coap_session_str(const coap_session_t *session)
Get session description.
size_t coap_print_addr(const coap_address_t *addr, unsigned char *buf, size_t len)
Print the address into the defined buffer.
const char * coap_endpoint_str(const coap_endpoint_t *endpoint)
Get endpoint description.
#define coap_log(level,...)
Logging function.
#define COAP_MAX_MESSAGE_SIZE_TCP8
#define COAP_DEFAULT_MAX_PDU_RX_SIZE
#define COAP_MAX_MESSAGE_SIZE_TCP0
size_t coap_pdu_encode_header(coap_pdu_t *pdu, coap_proto_t proto)
Compose the protocol specific header for the specified PDU.
#define COAP_MAX_MESSAGE_SIZE_TCP16
#define COAP_DEFAULT_PORT
void coap_delete_pdu(coap_pdu_t *pdu)
Dispose of an CoAP PDU and frees associated storage.
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
coap_proto_t
CoAP protocol types.
#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER
size_t coap_add_option(coap_pdu_t *pdu, coap_option_num_t number, size_t len, const uint8_t *data)
Adds option of given number to pdu that is passed as first parameter.
#define COAPS_DEFAULT_PORT
#define COAP_INVALID_MID
Indicates an invalid message id.
coap_pdu_t * coap_pdu_init(coap_pdu_type_t type, coap_pdu_code_t code, coap_mid_t mid, size_t size)
Creates a new CoAP PDU with at least enough storage space for the given size maximum message size.
#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE
@ COAP_SIGNALING_CODE_CSM
@ COAP_SIGNALING_CODE_PING
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.
ssize_t coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu, coap_queue_t *node)
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).
void coap_session_send_csm(coap_session_t *session)
Notify session transport has just connected and CSM exchange can now start.
coap_session_t * coap_new_server_session(coap_context_t *ctx, coap_endpoint_t *ep)
Creates a new server session for the specified endpoint.
ssize_t coap_session_send(coap_session_t *session, const uint8_t *data, size_t datalen)
Function interface for datagram data transmission.
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).
void coap_session_connected(coap_session_t *session)
Notify session that it has just connected or reconnected.
ssize_t coap_session_send_pdu(coap_session_t *session, coap_pdu_t *pdu)
Send a pdu according to the session's protocol.
void coap_session_free(coap_session_t *session)
void coap_session_mfree(coap_session_t *session)
ssize_t coap_session_write(coap_session_t *session, const uint8_t *data, size_t datalen)
Function interface for stream data transmission.
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_session_type_t
coap_session_type_t values
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_sessi...
void coap_free_endpoint(coap_endpoint_t *ep)
const coap_address_t * coap_session_get_addr_local(const coap_session_t *session)
Get the local IP address from the session.
void coap_session_set_mtu(coap_session_t *session, unsigned mtu)
Set the session MTU.
const coap_bin_const_t * coap_session_get_psk_key(const coap_session_t *session)
Get the session's current pre-shared key (PSK).
coap_proto_t coap_session_get_proto(const coap_session_t *session)
Get the session protocol type.
coap_context_t * coap_session_get_context(const coap_session_t *session)
Get the session context.
size_t coap_session_max_pdu_size(const coap_session_t *session)
Get maximum acceptable PDU size.
coap_session_state_t coap_session_get_state(const coap_session_t *session)
Get the session state.
coap_session_state_t
coap_session_state_t values
coap_session_t * coap_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.
#define COAP_PROTO_NOT_RELIABLE(p)
coap_session_t * coap_session_reference(coap_session_t *session)
Increment reference counter on a session.
coap_session_t * coap_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.
void coap_session_init_token(coap_session_t *session, size_t len, const uint8_t *data)
Initializes the token value to use as a starting point.
#define COAP_PROTO_RELIABLE(p)
void coap_session_new_token(coap_session_t *session, size_t *len, uint8_t *data)
Creates a new token for use.
void coap_session_set_app_data(coap_session_t *session, void *app_data)
Stores data with the given session.
void coap_session_release(coap_session_t *session)
Decrement reference counter on a session.
coap_session_t * coap_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_endpoint_set_default_mtu(coap_endpoint_t *ep, unsigned mtu)
Set the endpoint's default MTU.
const coap_address_t * coap_session_get_addr_remote(const coap_session_t *session)
Get the remote IP address from the session.
const coap_bin_const_t * coap_session_get_psk_hint(const coap_session_t *session)
Get the server session's current Identity Hint (PSK).
coap_endpoint_t * coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, coap_proto_t proto)
Create a new endpoint for communicating with peers.
int coap_session_set_type_client(coap_session_t *session)
Set the session type to client.
coap_session_t * coap_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.
void coap_session_disconnected(coap_session_t *session, coap_nack_reason_t reason)
Notify session that it has failed.
int coap_session_get_ifindex(const coap_session_t *session)
Get the session if index.
coap_session_type_t coap_session_get_type(const coap_session_t *session)
Get the session type.
@ COAP_SESSION_TYPE_HELLO
server-side ephemeral session for responding to a client hello
@ COAP_SESSION_TYPE_SERVER
server-side
@ COAP_SESSION_TYPE_CLIENT
client-side
@ COAP_SESSION_STATE_HANDSHAKE
@ COAP_SESSION_STATE_ESTABLISHED
@ COAP_SESSION_STATE_NONE
@ COAP_SESSION_STATE_CONNECTING
void coap_delete_bin_const(coap_bin_const_t *s)
Deletes the given const binary data and releases any memory allocated.
#define coap_binary_equal(binary1, binary2)
Compares the two binary data for equality.
coap_bin_const_t * coap_new_bin_const(const uint8_t *data, size_t size)
Take the specified byte array (text) and create a coap_bin_const_t * Returns a new const binary objec...
void coap_delete_observers(coap_context_t *context, coap_session_t *session)
Removes any subscription for session and releases the allocated storage.
int coap_socket_bind_tcp(coap_socket_t *sock, const coap_address_t *listen_addr, coap_address_t *bound_addr)
Create a new TCP socket and then listen for new incoming TCP sessions.
int coap_socket_connect_tcp1(coap_socket_t *sock, const coap_address_t *local_if, const coap_address_t *server, int default_port, coap_address_t *local_addr, coap_address_t *remote_addr)
Create a new TCP socket and initiate the connection.
int coap_socket_accept_tcp(coap_socket_t *server, coap_socket_t *new_client, coap_address_t *local_addr, coap_address_t *remote_addr)
Accept a new incoming TCP session.
void * coap_malloc_type(coap_memory_tag_t type, size_t size)
Allocates a chunk of size bytes and returns a pointer to the newly allocated memory.
COAP_STATIC_INLINE void coap_free(void *object)
Wrapper function to coap_free_type() for backwards compatibility.
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().
Only used for servers for hashing incoming packets.
coap_address_t remote
remote address and port
coap_proto_t proto
CoAP protocol.
coap_address_t remote
remote address and port
coap_address_t local
local address and port
multi-purpose address abstraction
CoAP binary data definition with const data.
size_t length
length of binary data
const uint8_t * s
read-only binary data
The CoAP stack's global state is stored in a coap_context_t object.
coap_session_t * sessions
client sessions
coap_nack_handler_t nack_handler
unsigned int max_handshake_sessions
Maximum number of simultaneous negotating sessions per endpoint.
coap_cache_entry_t * cache
CoAP cache-entry cache.
coap_endpoint_t * endpoint
the endpoints used for listening
uint8_t block_mode
Zero or more COAP_BLOCK_ or'd options.
unsigned int max_idle_sessions
Maximum number of simultaneous unused sessions per endpoint.
coap_bin_const_t identity
The structure used for defining the Client PSK setup data to be used.
coap_dtls_cpsk_info_t psk_info
Client PSK definition.
The structure used for defining the PKI setup data to be used.
Abstraction of virtual endpoint that can be attached to coap_context_t.
coap_context_t * context
endpoint's context
uint16_t default_mtu
default mtu for this interface
coap_session_t * sessions
hash table or list of active sessions
coap_address_t bind_addr
local interface address
coap_socket_t sock
socket object for the interface, if any
coap_proto_t proto
protocol used on this interface
Abstraction of a fixed point number that can be used where necessary instead of a float.
uint16_t fractional_part
Fractional part of fixed point variable 1/1000 (3 points) precision.
uint16_t integer_part
Integer part of fixed point variable.
Structure to hold large body (many blocks) client receive information.
coap_binary_t * app_token
app requesting PDU token
uint8_t observe_set
Set if this is an observe receive PDU.
Structure to hold large body (many blocks) server receive information.
Structure to hold large body (many blocks) transmission information.
size_t length
length of payload
coap_addr_tuple_t addr_info
local and remote addresses
unsigned char payload[COAP_RXBUFFER_SIZE]
payload
int ifindex
the interface index
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
uint8_t hdr_size
actual size used for protocol-specific header
coap_mid_t mid
message id, if any, in regular host byte order
size_t used_size
used bytes of storage for token, options and payload
coap_pdu_type_t type
message type
coap_session_t * session
the CoAP session
coap_pdu_t * pdu
the CoAP PDU to send
unsigned int timeout
the randomized timeout value
struct coap_queue_t * next
coap_mid_t id
CoAP message id.
coap_tick_t t
when to send PDU for the next time
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
coap_lg_xmit_t * lg_xmit
list of large transmissions
coap_bin_const_t * psk_key
If client, this field contains the current pre-shared key for server; When this field is NULL,...
coap_endpoint_t * endpoint
session's endpoint
coap_socket_t sock
socket object for the session, if any
unsigned int max_retransmit
maximum re-transmit count (default 4)
coap_pdu_t * partial_pdu
incomplete incoming pdu
coap_bin_const_t * psk_identity
If client, this field contains the current identity for server; When this field is NULL,...
coap_session_state_t state
current state of relationaship with peer
uint64_t tx_token
Next token number to use.
uint8_t block_mode
Zero or more COAP_BLOCK_ or'd options.
coap_addr_tuple_t addr_info
key: remote/local address info
coap_proto_t proto
protocol used
uint16_t tx_mid
the last message id that was used in this session
coap_bin_const_t * psk_hint
If client, this field contains the server provided identity hint.
coap_dtls_cpsk_t cpsk_setup_data
client provided PSK initial setup data
size_t mtu
path or CSM mtu
size_t partial_read
if > 0 indicates number of bytes already read for an incoming message
int dtls_event
Tracking any (D)TLS events on this sesison.
void * tls
security parameters
coap_fixed_point_t ack_random_factor
ack random factor backoff (default 1.5)
uint8_t con_active
Active CON request sent.
coap_queue_t * delayqueue
list of delayed messages waiting to be sent
size_t tls_overhead
overhead of TLS layer
void * app
application-specific data
coap_mid_t last_ping_mid
the last keepalive message id that was used in this session
coap_lg_srcv_t * lg_srcv
Server list of expected large receives.
coap_lg_crcv_t * lg_crcv
Client list of expected large receives.
coap_fixed_point_t ack_timeout
timeout waiting for ack (default 2 secs)
coap_session_type_t type
client or server side socket
coap_context_t * context
session's context
size_t partial_write
if > 0 indicates number of bytes already written from the pdu at the head of sendqueue
coap_addr_hash_t addr_hash
Address hash for server incoming packets.
int ifindex
interface index
coap_endpoint_t * endpoint
coap_socket_flags_t flags