1 /* coap_session.h -- Session management for libcoap 2 * 3 * Copyright (C) 2017 Jean-Claue Michelou <jcm@spinetix.com> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 * 7 * This file is part of the CoAP library libcoap. Please see 8 * README for terms of use. 9 */ 10 11 /** 12 * @file coap_session.h 13 * @brief Defines the application visible session information 14 */ 15 16 #ifndef COAP_SESSION_H_ 17 #define COAP_SESSION_H_ 18 19 /** 20 * @ingroup application_api 21 * @defgroup session Sessions 22 * API for CoAP Session access 23 * @{ 24 */ 25 26 /** 27 * Abstraction of a fixed point number that can be used where necessary instead 28 * of a float. 1,000 fractional bits equals one integer 29 */ 30 typedef struct coap_fixed_point_t { 31 uint16_t integer_part; /**< Integer part of fixed point variable */ 32 uint16_t fractional_part; /**< Fractional part of fixed point variable 33 1/1000 (3 points) precision */ 34 } coap_fixed_point_t; 35 36 #define COAP_PROTO_NOT_RELIABLE(p) ((p)==COAP_PROTO_UDP || (p)==COAP_PROTO_DTLS) 37 #define COAP_PROTO_RELIABLE(p) ((p)==COAP_PROTO_TCP || (p)==COAP_PROTO_TLS || \ 38 (p)==COAP_PROTO_WS || (p)==COAP_PROTO_WSS) 39 40 /** 41 * coap_session_type_t values 42 */ 43 typedef enum coap_session_type_t { 44 COAP_SESSION_TYPE_NONE = 0, /**< Not defined */ 45 COAP_SESSION_TYPE_CLIENT, /**< client-side */ 46 COAP_SESSION_TYPE_SERVER, /**< server-side */ 47 COAP_SESSION_TYPE_HELLO, /**< server-side ephemeral session for 48 responding to a client hello */ 49 } coap_session_type_t; 50 51 /** 52 * coap_session_state_t values 53 */ 54 typedef enum coap_session_state_t { 55 COAP_SESSION_STATE_NONE = 0, 56 COAP_SESSION_STATE_CONNECTING, 57 COAP_SESSION_STATE_HANDSHAKE, 58 COAP_SESSION_STATE_CSM, 59 COAP_SESSION_STATE_ESTABLISHED, 60 } coap_session_state_t; 61 62 /** 63 * Increment reference counter on a session. 64 * 65 * @param session The CoAP session. 66 * @return same as session 67 */ 68 coap_session_t *coap_session_reference(coap_session_t *session); 69 70 /** 71 * Decrement reference counter on a session. 72 * Note that the session may be deleted as a result and should not be used 73 * after this call. 74 * 75 * @param session The CoAP session. 76 */ 77 void coap_session_release(coap_session_t *session); 78 79 /** 80 * Notify session that it has failed. This cleans up any outstanding / queued 81 * transmissions, observations etc.. 82 * 83 * @param session The CoAP session. 84 * @param reason The reason why the session was disconnected. 85 */ 86 void coap_session_disconnected(coap_session_t *session, 87 coap_nack_reason_t reason); 88 89 /** 90 * Stores @p data with the given session. This function overwrites any value 91 * that has previously been stored with @p session. 92 * 93 * @param session The CoAP session. 94 * @param data The pointer to the data to store. 95 */ 96 void coap_session_set_app_data(coap_session_t *session, void *data); 97 98 /** 99 * Returns any application-specific data that has been stored with @p 100 * session using the function coap_session_set_app_data(). This function will 101 * return @c NULL if no data has been stored. 102 * 103 * @param session The CoAP session. 104 * 105 * @return Pointer to the stored data or @c NULL. 106 */ 107 void *coap_session_get_app_data(const coap_session_t *session); 108 109 /** 110 * Get the remote IP address and port from the session. 111 * 112 * Note: For clients, this can be the responding IP address for a multicast 113 * request before the next coap_send() is called when the multicast address 114 * is restored. 115 * 116 * @param session The CoAP session. 117 * 118 * @return The session's remote address or @c NULL on failure. 119 */ 120 const coap_address_t *coap_session_get_addr_remote( 121 const coap_session_t *session); 122 123 /** 124 * Get the remote multicast IP address and port from the session if the 125 * original target IP was multicast. 126 * 127 * Note: This is only available for a client. 128 * 129 * @param session The CoAP session. 130 * 131 * @return The session's remote multicast address or @c NULL on failure or if 132 * this is not a multicast session. 133 */ 134 const coap_address_t *coap_session_get_addr_mcast( 135 const coap_session_t *session); 136 137 /** 138 * Get the local IP address and port from the session. 139 * 140 * @param session The CoAP session. 141 * 142 * @return The session's local address or @c NULL on failure. 143 */ 144 const coap_address_t *coap_session_get_addr_local( 145 const coap_session_t *session); 146 147 /** 148 * Get the session protocol type 149 * 150 * @param session The CoAP session. 151 * 152 * @return The session's protocol type 153 */ 154 coap_proto_t coap_session_get_proto(const coap_session_t *session); 155 156 /** 157 * Get the session type 158 * 159 * @param session The CoAP session. 160 * 161 * @return The session's type 162 */ 163 coap_session_type_t coap_session_get_type(const coap_session_t *session); 164 165 /** 166 * Get the session state 167 * 168 * @param session The CoAP session. 169 * 170 * @return The session's state 171 */ 172 coap_session_state_t coap_session_get_state(const coap_session_t *session); 173 174 /** 175 * Get the session if index 176 * 177 * @param session The CoAP session. 178 * 179 * @return The session's if index, or @c -1 on error. 180 */ 181 int coap_session_get_ifindex(const coap_session_t *session); 182 183 /** 184 * Get the session TLS security ptr (TLS type dependent) 185 * 186 * OpenSSL: SSL* 187 * GnuTLS: gnutls_session_t (implicit *) 188 * Mbed TLS: mbedtls_ssl_context* 189 * TinyDTLS: struct dtls_context* 190 * 191 * @param session The CoAP session. 192 * @param tls_lib Updated with the library type. 193 * 194 * @return The session TLS ptr or @c NULL if not set up 195 */ 196 void *coap_session_get_tls(const coap_session_t *session, 197 coap_tls_library_t *tls_lib); 198 199 /** 200 * Get the session context 201 * 202 * @param session The CoAP session. 203 * 204 * @return The session's context 205 */ 206 coap_context_t *coap_session_get_context(const coap_session_t *session); 207 208 /** 209 * Set the session type to client. Typically used in a call-home server. 210 * The session needs to be of type COAP_SESSION_TYPE_SERVER. 211 * Note: If this function is successful, the session reference count is 212 * incremented and a subsequent coap_session_release() taking the 213 * reference count to 0 will cause the session to be freed off. 214 * 215 * @param session The CoAP session. 216 * 217 * @return @c 1 if updated, @c 0 on failure. 218 */ 219 int coap_session_set_type_client(coap_session_t *session); 220 221 /** 222 * Set the session MTU. This is the maximum message size that can be sent, 223 * excluding IP and UDP overhead. 224 * 225 * @param session The CoAP session. 226 * @param mtu maximum message size 227 */ 228 void coap_session_set_mtu(coap_session_t *session, unsigned mtu); 229 230 /** 231 * Get maximum acceptable PDU size 232 * 233 * @param session The CoAP session. 234 * @return maximum PDU size, not including header (but including token). 235 */ 236 size_t coap_session_max_pdu_size(const coap_session_t *session); 237 238 /** 239 * Creates a new client session to the designated server. 240 * @param ctx The CoAP context. 241 * @param 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. 242 * @param server The server's address. If the port number is zero, the default port for the protocol will be used. 243 * @param proto Protocol. 244 * 245 * @return A new CoAP session or NULL if failed. Call coap_session_release to free. 246 */ 247 coap_session_t *coap_new_client_session( 248 coap_context_t *ctx, 249 const coap_address_t *local_if, 250 const coap_address_t *server, 251 coap_proto_t proto 252 ); 253 254 /** 255 * Creates a new client session to the designated server with PSK credentials 256 * 257 * @deprecated Use coap_new_client_session_psk2() instead. 258 * 259 * @param ctx The CoAP context. 260 * @param 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. 261 * @param server The server's address. If the port number is zero, the default port for the protocol will be used. 262 * @param proto Protocol. 263 * @param identity PSK client identity 264 * @param key PSK shared key 265 * @param key_len PSK shared key length 266 * 267 * @return A new CoAP session or NULL if failed. Call coap_session_release to free. 268 */ 269 coap_session_t *coap_new_client_session_psk( 270 coap_context_t *ctx, 271 const coap_address_t *local_if, 272 const coap_address_t *server, 273 coap_proto_t proto, 274 const char *identity, 275 const uint8_t *key, 276 unsigned key_len 277 ); 278 279 /** 280 * Creates a new client session to the designated server with PSK credentials 281 * @param ctx The CoAP context. 282 * @param local_if Address of local interface. It is recommended to use NULL to 283 * let the operating system choose a suitable local interface. 284 * If an address is specified, the port number should be zero, 285 * which means that a free port is automatically selected. 286 * @param server The server's address. If the port number is zero, the default 287 * port for the protocol will be used. 288 * @param proto CoAP Protocol. 289 * @param setup_data PSK parameters. 290 * 291 * @return A new CoAP session or NULL if failed. Call coap_session_release() 292 * to free. 293 */ 294 coap_session_t *coap_new_client_session_psk2( 295 coap_context_t *ctx, 296 const coap_address_t *local_if, 297 const coap_address_t *server, 298 coap_proto_t proto, 299 coap_dtls_cpsk_t *setup_data 300 ); 301 302 /** 303 * Get the server session's current Identity Hint (PSK). 304 * 305 * @param session The current coap_session_t object. 306 * 307 * @return @c hint if successful, else @c NULL. 308 */ 309 const coap_bin_const_t *coap_session_get_psk_hint( 310 const coap_session_t *session); 311 312 /** 313 * Get the server session's current PSK identity (PSK). 314 * 315 * @param session The current coap_session_t object. 316 * 317 * @return PSK identity if successful, else @c NULL. 318 */ 319 const coap_bin_const_t *coap_session_get_psk_identity( 320 const coap_session_t *session); 321 /** 322 * Get the session's current pre-shared key (PSK). 323 * 324 * @param session The current coap_session_t object. 325 * 326 * @return @c psk_key if successful, else @c NULL. 327 */ 328 const coap_bin_const_t *coap_session_get_psk_key( 329 const coap_session_t *session); 330 331 /** 332 * Creates a new client session to the designated server with PKI credentials 333 * @param ctx The CoAP context. 334 * @param local_if Address of local interface. It is recommended to use NULL to 335 * let the operating system choose a suitable local interface. 336 * If an address is specified, the port number should be zero, 337 * which means that a free port is automatically selected. 338 * @param server The server's address. If the port number is zero, the default 339 * port for the protocol will be used. 340 * @param proto CoAP Protocol. 341 * @param setup_data PKI parameters. 342 * 343 * @return A new CoAP session or NULL if failed. Call coap_session_release() 344 * to free. 345 */ 346 coap_session_t *coap_new_client_session_pki( 347 coap_context_t *ctx, 348 const coap_address_t *local_if, 349 const coap_address_t *server, 350 coap_proto_t proto, 351 coap_dtls_pki_t *setup_data 352 ); 353 354 /** 355 * Initializes the token value to use as a starting point. 356 * 357 * @param session The current coap_session_t object. 358 * @param length The length of the token (0 - 8 bytes). 359 * @param token The token data. 360 * 361 */ 362 void coap_session_init_token(coap_session_t *session, size_t length, 363 const uint8_t *token); 364 365 /** 366 * Creates a new token for use. 367 * 368 * @param session The current coap_session_t object. 369 * @param length Updated with the length of the new token. 370 * @param token Updated with the new token data (must be 8 bytes long). 371 * 372 */ 373 void coap_session_new_token(coap_session_t *session, size_t *length, 374 uint8_t *token); 375 376 /** 377 * @ingroup logging 378 * Get session description. 379 * 380 * @param session The CoAP session. 381 * @return description string. 382 */ 383 const char *coap_session_str(const coap_session_t *session); 384 385 /** 386 * Create a new endpoint for communicating with peers. 387 * 388 * @param context The coap context that will own the new endpoint, 389 * @param listen_addr Address the endpoint will listen for incoming requests 390 * on or originate outgoing requests from. Use NULL to 391 * specify that no incoming request will be accepted and 392 * use a random endpoint. 393 * @param proto Protocol used on this endpoint, 394 * 395 * @return The new endpoint or @c NULL on failure. 396 */ 397 coap_endpoint_t *coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, 398 coap_proto_t proto); 399 400 /** 401 * Set the endpoint's default MTU. This is the maximum message size that can be 402 * sent, excluding IP and UDP overhead. 403 * 404 * @param endpoint The CoAP endpoint. 405 * @param mtu maximum message size 406 */ 407 void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu); 408 409 /** 410 * Release an endpoint and all the structures associated with it. 411 * 412 * @param endpoint The endpoint to release. 413 */ 414 void coap_free_endpoint(coap_endpoint_t *endpoint); 415 416 /** 417 * Get the session associated with the specified @p remote_addr and @p index. 418 * 419 * @param context The context to search. 420 * @param remote_addr The remote (peer) address to search for. 421 * @param ifindex The Interface index that is used to access remote_addr. 422 * 423 * @return The found session or @c NULL if not found. 424 */ 425 coap_session_t *coap_session_get_by_peer(const coap_context_t *context, 426 const coap_address_t *remote_addr, 427 int ifindex); 428 429 /** @} */ 430 431 /** 432 * @ingroup logging 433 * Get endpoint description. 434 * 435 * @param endpoint The CoAP endpoint. 436 * @return description string. 437 */ 438 const char *coap_endpoint_str(const coap_endpoint_t *endpoint); 439 440 /** 441 * @ingroup application_api 442 * @defgroup cc Rate Control 443 * API for updating transmission parameters for CoAP rate control. 444 * The transmission parameters for CoAP rate control ("Congestion 445 * Control" in stream-oriented protocols) are defined in 446 * https://rfc-editor.org/rfc/rfc7252#section-4.8 and 447 * https://rfc-editor.org/rfc/rfc9177#section-6.2 448 * @{ 449 */ 450 451 /** 452 * Number of seconds when to expect an ACK or a response to an 453 * outstanding CON message. 454 * RFC 7252, Section 4.8 Default value of ACK_TIMEOUT is 2 455 * 456 * Configurable using coap_session_set_ack_timeout() 457 */ 458 #define COAP_DEFAULT_ACK_TIMEOUT ((coap_fixed_point_t){2,0}) 459 460 /** 461 * A factor that is used to randomize the wait time before a message 462 * is retransmitted to prevent synchronization effects. 463 * RFC 7252, Section 4.8 Default value of ACK_RANDOM_FACTOR is 1.5 464 * 465 * Configurable using coap_session_set_ack_random_factor() 466 */ 467 #define COAP_DEFAULT_ACK_RANDOM_FACTOR ((coap_fixed_point_t){1,500}) 468 469 /** 470 * Number of message retransmissions before message sending is stopped. 471 * RFC 7252, Section 4.8 Default value of MAX_RETRANSMIT is 4 472 * 473 * Configurable using coap_session_set_max_retransmit() 474 */ 475 #define COAP_DEFAULT_MAX_RETRANSMIT (4U) 476 477 /** 478 * The number of simultaneous outstanding interactions that a client 479 * maintains to a given server. 480 * RFC 7252, Section 4.8 Default value of NSTART is 1 481 * 482 * Configurable using coap_session_set_nstart() 483 */ 484 #define COAP_DEFAULT_NSTART (1U) 485 486 /** 487 * The number of seconds to use as bounds for multicast traffic 488 * RFC 7252, Section 4.8 Default value of DEFAULT_LEISURE is 5.0 489 * 490 * Configurable using coap_session_set_default_leisure() 491 */ 492 #define COAP_DEFAULT_DEFAULT_LEISURE ((coap_fixed_point_t){5,0}) 493 494 /** 495 * The number of bytes/second allowed when there is no response 496 * RFC 7252, Section 4.8 Default value of PROBING_RATE is 1 497 * 498 * Configurable using coap_session_set_probing_rate() 499 */ 500 #define COAP_DEFAULT_PROBING_RATE (1U) 501 502 /** 503 * Number of Q-Block1 or Q-Block2 payloads that can be sent in a burst 504 * before a delay has to kick in. 505 * RFC9177 Section 6.2 Default value of MAX_PAYLOAD is 10 506 * 507 * Configurable using coap_session_set_max_payloads() 508 */ 509 #define COAP_DEFAULT_MAX_PAYLOADS (10U) 510 511 /** 512 * The number of times for requests for re-transmission of missing Q-Block1 513 * when no response has been received. 514 * RFC9177 Section 6.2 Default value of NON_MAX_RETRANSMIT is 4 515 * 516 * Configurable using coap_session_set_non_max_retransmit() 517 */ 518 #define COAP_DEFAULT_NON_MAX_RETRANSMIT (4U) 519 520 /** 521 * The delay (+ ACK_RANDOM_FACTOR) to introduce once NON MAX_PAYLOADS 522 * Q-Block1 or Q-Block2 have been sent to reduce congestion control. 523 * RFC9177 Section 6.2 Default value of NON_TIMEOUT is 2. 524 * 525 * Configurable using coap_session_set_non_timeout() 526 */ 527 #define COAP_DEFAULT_NON_TIMEOUT ((coap_fixed_point_t){2,0}) 528 529 /** 530 * The time to wait for any missing Q-Block1 or Q-Block2 packets before 531 * requesting re-transmission of missing packets. 532 * RFC9177 Section 6.2 Default value of NON_RECEIVE_TIMEOUT is 4. 533 * 534 * Configurable using coap_session_set_non_receive_timeout() 535 */ 536 #define COAP_DEFAULT_NON_RECEIVE_TIMEOUT ((coap_fixed_point_t){4,0}) 537 538 /** 539 * The MAX_LATENCY definition. 540 * RFC 7252, Section 4.8.2 MAX_LATENCY is 100. 541 */ 542 #define COAP_DEFAULT_MAX_LATENCY (100U) 543 544 /** 545 * Set the CoAP initial ack response timeout before the next re-transmit 546 * 547 * Number of seconds when to expect an ACK or a response to an 548 * outstanding CON message. 549 * RFC7252 ACK_TIMEOUT 550 * 551 * @param session The CoAP session. 552 * @param value The value to set to. The default is 2.0 and should not normally 553 * get changed. 554 */ 555 void coap_session_set_ack_timeout(coap_session_t *session, 556 coap_fixed_point_t value); 557 558 /** 559 * Get the CoAP initial ack response timeout before the next re-transmit 560 * 561 * Number of seconds when to expect an ACK or a response to an 562 * outstanding CON message. 563 * RFC7252 ACK_TIMEOUT 564 * 565 * @param session The CoAP session. 566 * 567 * @return Current ack response timeout value 568 */ 569 coap_fixed_point_t coap_session_get_ack_timeout(const coap_session_t *session); 570 571 /** 572 * Set the CoAP ack randomize factor 573 * 574 * A factor that is used to randomize the wait time before a message 575 * is retransmitted to prevent synchronization effects. 576 * RFC7252 ACK_RANDOM_FACTOR 577 * 578 * @param session The CoAP session. 579 * @param value The value to set to. The default is 1.5 and should not normally 580 * get changed. 581 */ 582 void coap_session_set_ack_random_factor(coap_session_t *session, 583 coap_fixed_point_t value); 584 585 /** 586 * Get the CoAP ack randomize factor 587 * 588 * A factor that is used to randomize the wait time before a message 589 * is retransmitted to prevent synchronization effects. 590 * RFC7252 ACK_RANDOM_FACTOR 591 * 592 * @param session The CoAP session. 593 * 594 * @return Current ack randomize value 595 */ 596 coap_fixed_point_t coap_session_get_ack_random_factor( 597 const coap_session_t *session); 598 599 /** 600 * Set the CoAP maximum retransmit count before failure 601 * 602 * Number of message retransmissions before message sending is stopped 603 * RFC7252 MAX_RETRANSMIT 604 * 605 * @param session The CoAP session. 606 * @param value The value to set to. The default is 4 and should not normally 607 * get changed. 608 */ 609 void coap_session_set_max_retransmit(coap_session_t *session, 610 uint16_t value); 611 612 /** 613 * Get the CoAP maximum retransmit before failure 614 * 615 * Number of message retransmissions before message sending is stopped 616 * RFC7252 MAX_RETRANSMIT 617 * 618 * @param session The CoAP session. 619 * 620 * @return Current maximum retransmit value 621 */ 622 uint16_t coap_session_get_max_retransmit(const coap_session_t *session); 623 624 /** 625 * Set the CoAP maximum concurrent transmission count of Confirmable messages 626 * RFC7252 NSTART 627 * 628 * @param session The CoAP session. 629 * @param value The value to set to. The default is 1 and should not normally 630 * get changed. 631 */ 632 void coap_session_set_nstart(coap_session_t *session, 633 uint16_t value); 634 635 /** 636 * Get the CoAP maximum concurrent transmission count of Confirmable messages 637 * RFC7252 NSTART 638 * 639 * @param session The CoAP session. 640 * 641 * @return Current nstart value 642 */ 643 uint16_t coap_session_get_nstart(const coap_session_t *session); 644 645 /** 646 * Set the CoAP default leisure time (for multicast) 647 * RFC7252 DEFAULT_LEISURE 648 * 649 * @param session The CoAP session. 650 * @param value The value to set to. The default is 5.0 and should not normally 651 * get changed. 652 */ 653 void coap_session_set_default_leisure(coap_session_t *session, 654 coap_fixed_point_t value); 655 656 /** 657 * Get the CoAP default leisure time 658 * RFC7252 DEFAULT_LEISURE 659 * 660 * @param session The CoAP session. 661 * 662 * @return Current default_leisure value 663 */ 664 coap_fixed_point_t coap_session_get_default_leisure( 665 const coap_session_t *session); 666 667 /** 668 * Set the CoAP probing rate when there is no response 669 * RFC7252 PROBING_RATE 670 * 671 * @param session The CoAP session. 672 * @param value The value to set to. The default is 1 and should not normally 673 * get changed. 674 */ 675 void coap_session_set_probing_rate(coap_session_t *session, uint32_t value); 676 677 /** 678 * Get the CoAP probing rate when there is no response 679 * RFC7252 PROBING_RATE 680 * 681 * @param session The CoAP session. 682 * 683 * @return Current probing_rate value 684 */ 685 uint32_t coap_session_get_probing_rate(const coap_session_t *session); 686 687 /** 688 * Set the CoAP maximum payloads count of Q-Block1 or Q-Block2 before delay 689 * is introduced 690 * RFC9177 MAX_PAYLOADS 691 * 692 * @param session The CoAP session. 693 * @param value The value to set to. The default is 10 and should not normally 694 * get changed. 695 */ 696 void coap_session_set_max_payloads(coap_session_t *session, 697 uint16_t value); 698 699 /** 700 * Get the CoAP maximum payloads count of Q-Block1 or Q-Block2 before delay 701 * is introduced 702 * RFC9177 MAX_PAYLOADS 703 * 704 * @param session The CoAP session. 705 * 706 * @return Current maximum payloads value 707 */ 708 uint16_t coap_session_get_max_payloads(const coap_session_t *session); 709 710 /** 711 * Set the CoAP NON maximum retransmit count of missing Q-Block1 or Q-Block2 712 * requested before there is any response 713 * RFC9177 NON_MAX_RETRANSMIT 714 * 715 * @param session The CoAP session. 716 * @param value The value to set to. The default is 4 and should not normally 717 * get changed. 718 */ 719 void coap_session_set_non_max_retransmit(coap_session_t *session, 720 uint16_t value); 721 722 /** 723 * Get the CoAP NON maximum retransmit count of missing Q-Block1 or Q-Block2 724 * requested before there is any response 725 * RFC9177 NON_MAX_RETRANSMIT 726 * 727 * @param session The CoAP session. 728 * 729 * @return Current maximum NON max retransmit value 730 */ 731 uint16_t coap_session_get_non_max_retransmit(const coap_session_t *session); 732 733 /** 734 * Set the CoAP non timeout delay timeout 735 * 736 * Number of seconds to delay (+ ACK_RANDOM_FACTOR) before sending off the next 737 * set of NON MAX_PAYLOADS 738 * RFC9177 NON_TIMEOUT 739 * 740 * @param session The CoAP session. 741 * @param value The value to set to. The default is 2.0 and should not normally 742 * get changed. 743 */ 744 void coap_session_set_non_timeout(coap_session_t *session, 745 coap_fixed_point_t value); 746 747 /** 748 * Get the CoAP MAX_PAYLOADS limit delay timeout 749 * 750 * Number of seconds to delay (+ ACK_RANDOM_FACTOR) before sending off the next 751 * set of NON MAX_PAYLOADS 752 * RFC9177 NON_TIMEOUT 753 * 754 * @param session The CoAP session. 755 * 756 * @return NON MAX_PAYLOADS delay 757 */ 758 coap_fixed_point_t coap_session_get_non_timeout(const coap_session_t *session); 759 760 /** 761 * Set the CoAP non receive timeout delay timeout 762 * 763 * Number of seconds to delay before requesting missing packets 764 * RFC9177 NON_RECEIVE_TIMEOUT 765 * 766 * @param session The CoAP session. 767 * @param value The value to set to. The default is 4.0 and should not normally 768 * get changed. Must be 1 sec greater than NON_TIMEOUT_RANDOM 769 */ 770 void coap_session_set_non_receive_timeout(coap_session_t *session, 771 coap_fixed_point_t value); 772 773 /** 774 * Get the CoAP non receive timeout delay timeout 775 * 776 * Number of seconds to delay before requesting missing packets 777 * RFC9177 NON_RECEIVE_TIMEOUT 778 * 779 * @param session The CoAP session. 780 * 781 * @return NON_RECEIVE_TIMEOUT delay 782 */ 783 coap_fixed_point_t coap_session_get_non_receive_timeout( 784 const coap_session_t *session); 785 786 /** @} */ 787 /** 788 * Send a ping message for the session. 789 * @param session The CoAP session. 790 * 791 * @return COAP_INVALID_MID if there is an error 792 */ 793 coap_mid_t coap_session_send_ping(coap_session_t *session); 794 795 /** 796 * Disable client automatically sending observe cancel on session close 797 * 798 * @param session The CoAP session. 799 */ 800 void coap_session_set_no_observe_cancel(coap_session_t *session); 801 802 #endif /* COAP_SESSION_H */ 803