Line data Source code
1 : /* SPDX-FileCopyrightText: Copyright 2026 Cozens Software Solutions Limited
2 : * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 OR LicenseRef-PolyForm-Internal-Use-1.0.0 OR LicenseRef-COSOSO-Commercial
3 : */
4 :
5 : #ifndef SOLIDSYSLOGLWIPRAWTCPSTREAMPRIVATE_H
6 : #define SOLIDSYSLOGLWIPRAWTCPSTREAMPRIVATE_H
7 :
8 : #include <stdint.h>
9 :
10 : #include <stdbool.h>
11 : #include <stddef.h>
12 :
13 : #include "SolidSyslogError.h"
14 : #include "SolidSyslogLwipRawTcpStream.h"
15 : #include "SolidSyslogLwipRawTcpStreamErrors.h"
16 : #include "SolidSyslogPrival.h"
17 : #include "SolidSyslogStreamDefinition.h"
18 : #include "SolidSyslogStreamOpenHealth.h"
19 : #include "SolidSyslogTunables.h"
20 : #include "lwip/err.h"
21 :
22 : struct tcp_pcb;
23 : struct pbuf;
24 :
25 : struct SolidSyslogLwipRawTcpStream
26 : {
27 : struct SolidSyslogStream Base;
28 : struct SolidSyslogLwipRawTcpStreamConfig Config;
29 : struct SolidSyslogStreamOpenHealth OpenHealth;
30 : struct tcp_pcb* Pcb;
31 : bool Connected;
32 : bool Errored;
33 : /* The err_t behind Errored: the one the stack handed the connected or
34 : error callback, or ERR_CLSD for the close the receive callback saw.
35 : Written on the lwIP thread, and read there too, by a marshalled hop, so
36 : it reaches the caller's thread with Errored. */
37 : err_t LastError;
38 : struct pbuf* RxQueue[SOLIDSYSLOG_LWIP_RAW_TCP_RX_QUEUE_SIZE];
39 : size_t RxQueueHead;
40 : size_t RxQueueCount;
41 : size_t RxHeadOffset;
42 : };
43 :
44 : void SolidSyslogLwipRawTcpStream_Initialise(
45 : struct SolidSyslogStream* base,
46 : const struct SolidSyslogLwipRawTcpStreamConfig* config
47 : );
48 : void SolidSyslogLwipRawTcpStream_Cleanup(struct SolidSyslogStream* base);
49 :
50 : /* Applies the SOLIDSYSLOG_TCP_KEEPALIVE_* tunables to a fresh pcb. Defined by
51 : whichever of the two keepalive translation units the lwIP build selects. */
52 : void SolidSyslogLwipRawTcpStream_ApplyKeepalive(struct tcp_pcb* pcb);
53 :
54 21 : static inline void LwipRawTcpStream_Report(
55 : enum SolidSyslogSeverity severity,
56 : uint16_t category,
57 : enum SolidSyslogTcpStreamErrors code
58 : )
59 : {
60 21 : SolidSyslog_Error(severity, &SolidSyslogLwipRawTcpStreamErrorSource, category, (int32_t) code);
61 21 : }
62 :
63 : #endif /* SOLIDSYSLOGLWIPRAWTCPSTREAMPRIVATE_H */
|