| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef MQTT_WEBSOCKETS_COMMON_PUBLIC_H |
| 4 | #define MQTT_WEBSOCKETS_COMMON_PUBLIC_H |
| 5 | |
| 6 | #include <stddef.h> |
| 7 | #include <stdint.h> |
| 8 | |
| 9 | /* free_fnc_t in general (in whatever function or struct it is used) |
| 10 | * decides how the related data will be handled. |
| 11 | * - If NULL the data are copied internally (causing malloc and later free) |
| 12 | * - If pointer provided the free function pointed will be called when data are no longer needed |
| 13 | * to free associated memory. This is effectively transfering ownership of that pointer to the library. |
| 14 | * This also allows caller to provide custom free function other than system one. |
| 15 | * - If == CALLER_RESPONSIBILITY the library will not copy the data pointed to and will not call free |
| 16 | * at the end. This is usefull to avoid copying memory (and associated malloc/free) when data are for |
| 17 | * example static. In this case caller has to guarantee the memory pointed to will be valid for entire duration |
| 18 | * it is needed. For example by freeing the data after PUBACK is received or by data being static. |
| 19 | */ |
| 20 | typedef void (*free_fnc_t)(void *ptr); |
| 21 | void _caller_responsibility(void *ptr); |
| 22 | #define CALLER_RESPONSIBILITY ((free_fnc_t)&_caller_responsibility) |
| 23 | |
| 24 | struct mqtt_ng_stats { |
| 25 | size_t tx_bytes_queued; |
| 26 | int tx_messages_queued; |
| 27 | int tx_messages_sent; |
| 28 | int rx_messages_rcvd; |
| 29 | int packets_waiting_puback; |
| 30 | size_t tx_buffer_used; |
| 31 | size_t tx_buffer_free; |
| 32 | size_t tx_buffer_size; |
| 33 | // part of transaction buffer that containes mesages we can free alredy during the garbage colleciton step |
| 34 | size_t tx_buffer_reclaimable; |
| 35 | // maximum time (in microseconds) a QoS1 message is currently waiting for PUBACK |
| 36 | uint64_t max_puback_wait_us; |
| 37 | // maximum time (in microseconds) a message has been waiting in the send queue without starting transmission |
| 38 | uint64_t max_send_queue_wait_us; |
| 39 | // split of send-queue wait into unsent and partial (diagnostics) |
| 40 | uint64_t max_unsent_wait_us; |
| 41 | uint64_t max_partial_wait_us; |
| 42 | }; |
| 43 | |
| 44 | #endif /* MQTT_WEBSOCKETS_COMMON_PUBLIC_H */ |