Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Bdd/Targets/Common/BddTargetTlsSender_OpenSsl_PosixTcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

struct SolidSyslogResolver;

static SolidSyslogPosixTcpStreamStorage underlyingStreamStorage;
static struct SolidSyslogStream* underlyingStream;
static SolidSyslogTlsStreamStorage tlsStreamStorage;
static struct SolidSyslogStream* tlsStream;
static struct SolidSyslogSender* sender;

struct SolidSyslogSender* BddTargetTlsSender_Create(struct SolidSyslogResolver* resolver, bool mtls)
{
underlyingStream = SolidSyslogPosixTcpStream_Create(&underlyingStreamStorage);
underlyingStream = SolidSyslogPosixTcpStream_Create();

static struct SolidSyslogTlsStreamConfig tlsStreamConfig;
tlsStreamConfig = (struct SolidSyslogTlsStreamConfig) {0};
Expand Down
20 changes: 11 additions & 9 deletions Bdd/Targets/Linux/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ static const char* const STORE_PATH_PREFIX = "/tmp/STORE";
static const char* const THRESHOLD_MARKER_PATH = "/tmp/solidsyslog_threshold_marker.log";
static struct SolidSyslogFile* storeFile;
static struct SolidSyslogBlockDevice* storeBlockDevice;
static SolidSyslogPosixTcpStreamStorage plainTcpStreamStorage;
static struct SolidSyslogStream* plainTcpStream;
static struct SolidSyslogSender* plainTcpSender;
static struct SolidSyslogSender* udpSender;
static struct SolidSyslogSender* switchingSender;
static struct SolidSyslogDatagram* udpDatagram;
static struct SolidSyslogResolver* sharedResolver;

static void GetTimeQuality(struct SolidSyslogTimeQuality* timeQuality)
{
Expand All @@ -77,16 +78,18 @@ static struct SolidSyslogSender* CreateSender(const struct BddTargetOptions* opt
{
bool mtlsModeActive = (strcmp(options->Transport, "mtls") == 0);

struct SolidSyslogResolver* resolver = SolidSyslogGetAddrInfoResolver_Create();
sharedResolver = SolidSyslogGetAddrInfoResolver_Create();
struct SolidSyslogResolver* resolver = sharedResolver;

udpDatagram = SolidSyslogPosixDatagram_Create();
static struct SolidSyslogUdpSenderConfig udpConfig = {0};
udpConfig.Resolver = resolver;
udpConfig.Datagram = SolidSyslogPosixDatagram_Create();
udpConfig.Datagram = udpDatagram;
udpConfig.Endpoint = BddTargetUdpConfig_GetEndpoint;
udpConfig.EndpointVersion = BddTargetUdpConfig_GetEndpointVersion;
udpSender = SolidSyslogUdpSender_Create(&udpConfig);

plainTcpStream = SolidSyslogPosixTcpStream_Create(&plainTcpStreamStorage);
plainTcpStream = SolidSyslogPosixTcpStream_Create();
static struct SolidSyslogStreamSenderConfig tcpConfig = {0};
tcpConfig.Resolver = resolver;
tcpConfig.Stream = plainTcpStream;
Expand Down Expand Up @@ -157,8 +160,7 @@ static struct SolidSyslogStore* CreateStore(const struct BddTargetOptions* optio

if (useFile)
{
static SolidSyslogPosixFileStorage fileStorage;
storeFile = SolidSyslogPosixFile_Create(&fileStorage);
storeFile = SolidSyslogPosixFile_Create();

storeBlockDevice = SolidSyslogFileBlockDevice_Create(storeFile, STORE_PATH_PREFIX);

Expand Down Expand Up @@ -188,8 +190,8 @@ static void DestroySender(void)
SolidSyslogStreamSender_Destroy(plainTcpSender);
SolidSyslogPosixTcpStream_Destroy(plainTcpStream);
SolidSyslogUdpSender_Destroy(udpSender);
SolidSyslogPosixDatagram_Destroy();
SolidSyslogGetAddrInfoResolver_Destroy();
SolidSyslogPosixDatagram_Destroy(udpDatagram);
SolidSyslogGetAddrInfoResolver_Destroy(sharedResolver);
}

static void DestroyStore(struct SolidSyslogStore* store, const struct BddTargetOptions* options)
Expand Down Expand Up @@ -289,7 +291,7 @@ int main(int argc, char* argv[])
SolidSyslogMetaSd_Destroy(metaSd);
SolidSyslogStdAtomicCounter_Destroy(counter);
DestroyStore(store, &options);
SolidSyslogPosixMessageQueueBuffer_Destroy();
SolidSyslogPosixMessageQueueBuffer_Destroy(buffer);
DestroySender();

return 0;
Expand Down
13 changes: 9 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,33 +325,38 @@ live under `Core/Interface/`; platform-specific helpers (the `SolidSyslogPosix*`
| `SolidSyslogTransport.h` | Any code selecting a transport or needing default port constants | `SolidSyslogTransport` enum (`UDP`, `TCP`), `SOLIDSYSLOG_UDP_DEFAULT_PORT`, `SOLIDSYSLOG_TCP_DEFAULT_PORT` |
| `SolidSyslogResolver.h` | Any code that needs to resolve a destination | `SolidSyslogResolver_Resolve(resolver, transport, host, port, *out)` |
| `SolidSyslogResolverDefinition.h` | Resolver implementors (extension point) | `SolidSyslogResolver` vtable struct (`Resolve`) |
| `SolidSyslogNullResolver.h` | Any code installing a no-op resolver slot (Resolve returns `false` so the caller's unresolved-host error path runs naturally) | `SolidSyslogNullResolver_Get` |
| `SolidSyslogFreeRtosStaticResolver.h` | System setup code on FreeRTOS targets pinned to a hardcoded IPv4 destination (no DNS) | `SolidSyslogFreeRtosStaticResolverStorage`, `SOLIDSYSLOG_FREERTOSSTATICRESOLVER_SIZE`, `SolidSyslogFreeRtosStaticResolver_Create(storage, ipv4Octets)`, `_Destroy(resolver)` (ignores host and transport at Resolve time; port is taken from each call) |
| `SolidSyslogDatagram.h` | Sender implementors using datagram transport | `SolidSyslogDatagram_Open`, `_SendTo`, `_Close` |
| `SolidSyslogDatagramDefinition.h` | Datagram implementors (extension point) | `SolidSyslogDatagram` vtable struct (`Open`, `SendTo`, `Close`) |
| `SolidSyslogNullDatagram.h` | Any code installing a no-op datagram slot (Open/Close are no-ops, SendTo returns `SENT` to drop on the floor so the Store does not fill with undeliverables, MaxPayload returns the IPv6-safe default) | `SolidSyslogNullDatagram_Get` |
| `SolidSyslogFreeRtosDatagram.h` | System setup code on FreeRTOS targets using FreeRTOS-Plus-TCP for UDP | `SolidSyslogFreeRtosDatagramStorage`, `SOLIDSYSLOG_FREERTOSDATAGRAM_SIZE`, `SolidSyslogFreeRtosDatagram_Create(storage)`, `_Destroy(datagram)` (wraps `FreeRTOS_socket` / `FreeRTOS_sendto` / `FreeRTOS_closesocket`) |
| `SolidSyslogStream.h` | Sender implementors using stream transport | `SolidSyslogStream_Open`, `_Send`, `_Read`, `_Close`, `SolidSyslogSsize` |
| `SolidSyslogStreamDefinition.h` | Stream implementors (extension point) | `SolidSyslogStream` vtable struct (`Open`, `Send`, `Read`, `Close`) |
| `SolidSyslogNullStream.h` | Any code installing a no-op stream slot (Open/Close are no-ops, Send returns `true` to drop on the floor so the Store does not fill with undeliverables, Read returns `0` for would-block so the caller does not tear the connection down) | `SolidSyslogNullStream_Get` |
| `SolidSyslogFreeRtosTcpStream.h` | System setup code on FreeRTOS targets using FreeRTOS-Plus-TCP for TCP | `SolidSyslogFreeRtosTcpStreamStorage`, `SOLIDSYSLOG_FREERTOSTCPSTREAM_SIZE`, `SolidSyslogFreeRtosTcpStream_Create(storage)`, `_Destroy(stream)` (wraps `FreeRTOS_socket` / `FreeRTOS_connect` / `FreeRTOS_send` / `FreeRTOS_recv` / `FreeRTOS_closesocket`; bounded blocking connect via `SO_SNDTIMEO=200ms`, cleared post-connect so Send/Read are non-blocking) |
| `SolidSyslogUdpSender.h` | System setup code using UDP transport | `SolidSyslogUdpSenderConfig` (resolver, datagram, endpoint, endpointVersion), `SolidSyslogUdpSender_Create(config)`, `_Destroy(sender)`. Instance struct lives in a library-internal static pool (E11); `_Destroy` takes the handle returned by `_Create`. Pool-exhaustion and bad-config fallback is the shared `SolidSyslogNullSender`. |
| `SolidSyslogPosixTcpStream.h` | System setup code on POSIX targets using non-blocking TCP with bounded connect/keepalive | `SolidSyslogPosixTcpStream_Create(void)`, `_Destroy(base)`. Instance struct lives in a library-internal static pool (E11); default pool size 2 to support the BDD-target plain-TCP + TLS-underlying-TCP pair. Pool-exhaustion fallback is the shared `SolidSyslogNullStream`. |
| `SolidSyslogStreamSender.h` | System setup code using octet-framed transport (RFC 6587) over any Stream — `SolidSyslogPosixTcpStream` (POSIX TCP), `SolidSyslogWinsockTcpStream` (Windows TCP), `SolidSyslogFreeRtosTcpStream` (FreeRTOS-Plus-TCP), `SolidSyslogTlsStream` (TLS; OpenSSL reference integration), or a caller-supplied Stream backend | `SolidSyslogStreamSenderConfig` (resolver, stream, endpoint, endpointVersion), `SolidSyslogStreamSender_Create(config)`, `_Destroy(base)`. Instance struct lives in a library-internal static pool (E11); `_Destroy` takes the handle returned by `_Create`. Pool exhaustion resolves to the shared `SolidSyslogNullSender`. |
| `SolidSyslogSwitchingSender.h` | System setup code composing multiple inner senders | `SolidSyslogSwitchingSenderConfig` (senders, senderCount, selector), `SolidSyslogSwitchingSenderSelector`, `SolidSyslogSwitchingSender_Create(config)`, `_Destroy(sender)`. Instance struct lives in a library-internal static pool (E11); `_Destroy` takes the handle returned by `_Create`. Out-of-range selector and pool exhaustion both resolve to the shared `SolidSyslogNullSender`. |
| `SolidSyslogBuffer.h` | Library internals consuming a buffer (Service algorithm) | `SolidSyslogBuffer_Write`, `_Read` |
| `SolidSyslogNullBuffer.h` | Any code installing a no-op buffer slot (Read returns `false`/`bytesRead=0`; Write swallows the record) | `SolidSyslogNullBuffer_Get` |
| `SolidSyslogBufferDefinition.h` | Buffer implementors (extension point) | `SolidSyslogBuffer` vtable struct |
| `SolidSyslogPassthroughBuffer.h` | System setup code (single-task, no buffering) | `SolidSyslogPassthroughBuffer_Create(sender)`, `_Destroy(buffer)`. Instance struct lives in a library-internal static pool (E11); `_Destroy` takes the handle returned by `_Create` to release the slot. Pool exhaustion resolves to the shared `SolidSyslogNullBuffer`. |
| `SolidSyslogPosixMessageQueueBuffer.h` | System setup code using POSIX message queue buffer | `SolidSyslogPosixMessageQueueBuffer_Create`, `_Destroy` |
| `SolidSyslogPosixMessageQueueBuffer.h` | System setup code using POSIX message queue buffer | `SolidSyslogPosixMessageQueueBuffer_Create(maxMessageSize, maxMessages)`, `_Destroy(base)`. Instance struct lives in a library-internal static pool (E11); each slot's queue name is `/solidsyslog_<pid>_<slotIndex>` so multiple in-process slots remain isolated. Pool-exhaustion fallback is the shared `SolidSyslogNullBuffer`. |
| `SolidSyslogCircularBuffer.h` | System setup code using an in-memory ring buffer (bare-metal / RTOS / Windows) | `SOLIDSYSLOG_CIRCULAR_BUFFER_HEADER_BYTES`, `SOLIDSYSLOG_CIRCULAR_BUFFER_RING_BYTES(maxMessages)` (friendly: N max-sized messages → ring bytes), `SolidSyslogCircularBuffer_Create(mutex, ring, ringBytes)`, `_Destroy(buffer)` (uint16-length-prefixed records, drop-newest on overflow, no-split wrap, mutex-injected synchronisation). Instance struct lives in a library-internal static pool (E11); caller supplies the ring memory only. Pool exhaustion resolves to the shared `SolidSyslogNullBuffer`. |
| `SolidSyslogMutex.h` | Any code holding a mutex handle | `SolidSyslogMutex_Lock`, `_Unlock` |
| `SolidSyslogMutexDefinition.h` | Mutex implementors (extension point) | `SolidSyslogMutex` vtable struct (`Lock`, `Unlock`) |
| `SolidSyslogNullMutex.h` | System setup code (single-task, no synchronisation) | `SolidSyslogNullMutex_Create`, `_Destroy` |
| `SolidSyslogPosixMutex.h` | System setup code on POSIX targets needing thread-safe buffering | `SolidSyslogPosixMutexStorage`, `SOLIDSYSLOG_POSIXMUTEX_SIZE`, `SolidSyslogPosixMutex_Create(storage)`, `_Destroy(mutex)` (wraps `pthread_mutex_t`) |
| `SolidSyslogNullMutex.h` | System setup code (single-task, no synchronisation) | `SolidSyslogNullMutex_Get` |
| `SolidSyslogPosixMutex.h` | System setup code on POSIX targets needing thread-safe buffering | `SolidSyslogPosixMutex_Create(void)`, `_Destroy(base)` (wraps `pthread_mutex_t`). Instance struct lives in a library-internal static pool (E11). Pool-exhaustion fallback is the shared `SolidSyslogNullMutex`. |
| `SolidSyslogWindowsMutex.h` | System setup code on Windows targets needing thread-safe buffering | `SolidSyslogWindowsMutexStorage`, `SOLIDSYSLOG_WINDOWSMUTEX_SIZE`, `SolidSyslogWindowsMutex_Create(storage)`, `_Destroy(mutex)` (wraps `CRITICAL_SECTION`) |
| `SolidSyslogFreeRtosMutex.h` | System setup code on FreeRTOS targets needing thread-safe buffering | `SolidSyslogFreeRtosMutexStorage`, `SOLIDSYSLOG_FREERTOSMUTEX_SIZE`, `SolidSyslogFreeRtosMutex_Create(storage)`, `_Destroy(mutex)` (wraps `xSemaphoreCreateMutexStatic` — caller's `StaticSemaphore_t` lives inside the injected storage; requires `configSUPPORT_STATIC_ALLOCATION=1`) |
| `SolidSyslogStore.h` | Library internals consuming a store (Service algorithm) and integrator code querying capacity | `SolidSyslogStore_Write`, `_ReadNextUnsent`, `_MarkSent`, `_HasUnsent`, `_IsHalted`, `_GetTotalBytes`, `_GetUsedBytes` |
| `SolidSyslogStoreDefinition.h` | Store implementors (extension point) | `SolidSyslogStore` vtable struct (`Write`, `ReadNextUnsent`, `MarkSent`, `HasUnsent`, `IsHalted`, `GetTotalBytes`, `GetUsedBytes`) |
| `SolidSyslogNullStore.h` | System setup code (no store-and-forward) | `SolidSyslogNullStore_Get` |
| `SolidSyslogFileDefinition.h` | File implementors (extension point) | `SolidSyslogFile` vtable struct |
| `SolidSyslogFile.h` | Any code using the file abstraction | `SolidSyslogFile_Open`, `_Close`, `_IsOpen`, `_Read`, `_Write`, `_SeekTo`, `_Size`, `_Truncate` |
| `SolidSyslogNullFile.h` | Any code installing a no-op file slot (Open/IsOpen/Read/Exists return `false`, Write/Delete return `true` so callers' success paths are not tripped, SeekTo/Truncate/Close are no-ops, Size returns `0`) | `SolidSyslogNullFile_Get` |
| `SolidSyslogBlockDevice.h` | Library internals consuming a block device (BlockSequence inside BlockStore) and integrator code addressing blocks directly | `SolidSyslogBlockDevice_Acquire`, `_Dispose`, `_Exists`, `_Read`, `_Append`, `_WriteAt`, `_Size` (block-indexed I/O; Acquire makes a block ready for fresh writes, Dispose releases it) |
| `SolidSyslogNullBlockDevice.h` | Any code installing a no-op block device slot (every method returns `false` / `0` — disk doesn't exist) | `SolidSyslogNullBlockDevice_Get` |
| `SolidSyslogBlockDeviceDefinition.h` | BlockDevice implementors (extension point) | `SolidSyslogBlockDevice` vtable struct (`Acquire`, `Dispose`, `Exists`, `Read`, `Append`, `WriteAt`, `Size`) |
Expand All @@ -361,7 +366,7 @@ live under `Core/Interface/`; platform-specific helpers (the `SolidSyslogPosix*`
| `SolidSyslogNullSecurityPolicy.h` | System setup code (no integrity checking) | `SolidSyslogNullSecurityPolicy_Get` |
| `SolidSyslogCrc16Policy.h` | System setup code using CRC-16 integrity | `SolidSyslogCrc16Policy_Create`, `_Destroy` |
| `SolidSyslogCrc16.h` | Any code needing CRC-16 computation | `SolidSyslogCrc16_Compute` |
| `SolidSyslogPosixFile.h` | System setup code using POSIX file I/O | `SolidSyslogPosixFile_Create`, `_Destroy` |
| `SolidSyslogPosixFile.h` | System setup code using POSIX file I/O | `SolidSyslogPosixFile_Create(void)`, `_Destroy(base)`. Instance struct lives in a library-internal static pool (E11). Pool-exhaustion fallback is the shared `SolidSyslogNullFile`. |
| `SolidSyslogWindowsFile.h` | System setup code using Windows file I/O (MSVC `<io.h>`) | `SolidSyslogWindowsFile_Create`, `_Destroy` |
| `SolidSyslogFatFsFile.h` | System setup code on targets using ChaN FatFs as the file layer (bare-metal flash / SD / eMMC, FreeRTOS, Zephyr, NuttX, …) | `SolidSyslogFatFsFileStorage`, `SOLIDSYSLOG_FATFS_FILE_SIZE`, `SolidSyslogFatFsFile_Create(storage)`, `_Destroy(file)` (wraps `f_open` / `f_close` / `f_read` / `f_write` with `f_sync` after every successful write so a power loss never loses a record the BlockStore claimed it stored; integrator supplies `diskio.c` and — if `FF_FS_REENTRANT=1` — `ffsystem.c`) |
| `SolidSyslogPosixClock.h` | System setup code using POSIX clock | `SolidSyslogPosixClock_GetTimestamp` |
Expand Down
12 changes: 12 additions & 0 deletions Core/Interface/SolidSyslogNullDatagram.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef SOLIDSYSLOGNULLDATAGRAM_H
#define SOLIDSYSLOGNULLDATAGRAM_H

#include "ExternC.h"

EXTERN_C_BEGIN

struct SolidSyslogDatagram* SolidSyslogNullDatagram_Get(void);

EXTERN_C_END

#endif /* SOLIDSYSLOGNULLDATAGRAM_H */
12 changes: 12 additions & 0 deletions Core/Interface/SolidSyslogNullFile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef SOLIDSYSLOGNULLFILE_H
#define SOLIDSYSLOGNULLFILE_H

#include "ExternC.h"

EXTERN_C_BEGIN

struct SolidSyslogFile* SolidSyslogNullFile_Get(void);

EXTERN_C_END

#endif /* SOLIDSYSLOGNULLFILE_H */
5 changes: 1 addition & 4 deletions Core/Interface/SolidSyslogNullMutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

EXTERN_C_BEGIN

struct SolidSyslogMutex;

struct SolidSyslogMutex* SolidSyslogNullMutex_Create(void);
void SolidSyslogNullMutex_Destroy(void);
struct SolidSyslogMutex* SolidSyslogNullMutex_Get(void);

EXTERN_C_END

Expand Down
12 changes: 12 additions & 0 deletions Core/Interface/SolidSyslogNullResolver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef SOLIDSYSLOGNULLRESOLVER_H
#define SOLIDSYSLOGNULLRESOLVER_H

#include "ExternC.h"

EXTERN_C_BEGIN

struct SolidSyslogResolver* SolidSyslogNullResolver_Get(void);

EXTERN_C_END

#endif /* SOLIDSYSLOGNULLRESOLVER_H */
12 changes: 12 additions & 0 deletions Core/Interface/SolidSyslogNullStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef SOLIDSYSLOGNULLSTREAM_H
#define SOLIDSYSLOGNULLSTREAM_H

#include "ExternC.h"

EXTERN_C_BEGIN

struct SolidSyslogStream* SolidSyslogNullStream_Get(void);

EXTERN_C_END

#endif /* SOLIDSYSLOGNULLSTREAM_H */
Loading
Loading