diff --git a/code/logic/fossil/io/framework.h b/code/logic/fossil/io/framework.h index f6d99e8..54288a8 100644 --- a/code/logic/fossil/io/framework.h +++ b/code/logic/fossil/io/framework.h @@ -16,7 +16,6 @@ // Include the necessary headers #include "serialize.h" -#include "network.h" #include "output.h" #include "input.h" #include "error.h" diff --git a/code/logic/fossil/io/network.h b/code/logic/fossil/io/network.h deleted file mode 100644 index 4f7e586..0000000 --- a/code/logic/fossil/io/network.h +++ /dev/null @@ -1,432 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#ifndef FOSSIL_IO_NETWORK_H -#define FOSSIL_IO_NETWORK_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file network.c - * @brief Network logic implementation for handling communication protocols and client types. - * - * This file contains the core logic for managing network communication in the application. - * It is responsible for implementing various protocols and handling different types of clients - * that interact with the system. The following details outline the key aspects of the network - * logic: - * - * ## Supported Protocols: - * 1. **TCP (Transmission Control Protocol):** - * - Provides reliable, ordered, and error-checked delivery of data. - * - Used for persistent connections and critical data exchange. - * - Ensures data integrity and retransmission in case of packet loss. - * - * 2. **UDP (User Datagram Protocol):** - * - Provides connectionless communication with minimal overhead. - * - Suitable for real-time applications where speed is prioritized over reliability. - * - Commonly used for streaming, gaming, and other low-latency scenarios. - * - * 3. **HTTP/HTTPS:** - * - Supports web-based communication using the Hypertext Transfer Protocol. - * - HTTPS ensures secure communication via SSL/TLS encryption. - * - Used for RESTful APIs and web client interactions. - * - * 4. **WebSocket:** - * - Enables full-duplex communication channels over a single TCP connection. - * - Ideal for real-time applications such as chat systems and live updates. - * - * ## Client Types: - * 1. **Standard Clients:** - * - General-purpose clients that use standard protocols like HTTP or WebSocket. - * - Typically include web browsers, mobile apps, and desktop applications. - * - * 2. **Embedded Clients:** - * - Lightweight clients running on embedded systems or IoT devices. - * - Often use UDP or custom lightweight protocols for communication. - * - * 3. **Service Clients:** - * - Backend services or microservices that interact with the system. - * - May use HTTP APIs, gRPC, or other service-to-service communication protocols. - * - * 4. **Real-Time Clients:** - * - Clients requiring low-latency communication, such as gaming or streaming applications. - * - Often rely on WebSocket or UDP for real-time data exchange. - * - * ## Supported Flags: - * - **Protocol Flags:** - * - `tcp`: Specifies the use of the TCP protocol. - * - `udp`: Specifies the use of the UDP protocol. - * - `http`: Specifies the use of the HTTP protocol. - * - `https`: Specifies the use of the HTTPS protocol. - * - `raw`: Specifies the use of raw sockets. - * - `icmp`: Specifies the use of ICMP protocol. - * - `sctp`: Specifies the use of SCTP protocol. - * - `ftp`: Specifies the use of the FTP protocol. - * - `ssh`: Specifies the use of the SSH protocol. - * - `dns`: Specifies the use of the DNS protocol. - * - `ntp`: Specifies the use of the NTP protocol. - * - `smtp`: Specifies the use of the SMTP protocol. - * - `pop3`: Specifies the use of the POP3 protocol. - * - `imap`: Specifies the use of the IMAP protocol. - * - `ldap`: Specifies the use of the LDAP protocol. - * - `mqtt`: Specifies the use of the MQTT protocol. - * - * - **Client Type Flags:** - * - `mail-server`: Represents a mail server client. - * - `server`: Represents a general server client. - * - `mail-client`: Represents a mail client. - * - `client`: Represents a general client. - * - `mail-bot`: Represents an automated mail bot client. - * - `bot`: Represents a general bot client. - * - `multicast`: Represents a multicast client. - * - `broadcast`: Represents a broadcast client. - * - * ## Additional Notes: - * - The implementation ensures scalability and fault tolerance for handling multiple clients - * simultaneously. - * - Security measures, such as encryption and authentication, are integrated to protect - * communication channels. - * - The file is designed to be modular, allowing easy extension for new protocols or client types. - */ - -typedef struct fossil_nstream_t fossil_nstream_t; - -typedef enum { - FOSSIL_PROTO_TCP, - FOSSIL_PROTO_UDP, - FOSSIL_PROTO_RAW, - FOSSIL_PROTO_ICMP, - FOSSIL_PROTO_SCTP, - FOSSIL_PROTO_HTTP, - FOSSIL_PROTO_HTTPS, - FOSSIL_PROTO_FTP, - FOSSIL_PROTO_SSH, - FOSSIL_PROTO_DNS, - FOSSIL_PROTO_NTP, - FOSSIL_PROTO_SMTP, - FOSSIL_PROTO_POP3, - FOSSIL_PROTO_IMAP, - FOSSIL_PROTO_LDAP, - FOSSIL_PROTO_MQTT, - FOSSIL_PROTO_UNKNOWN -} fossil_protocol_t; - -typedef enum { - FOSSIL_CLIENT_MAIL_SERVER, - FOSSIL_CLIENT_SERVER, - FOSSIL_CLIENT_MAIL_CLIENT, - FOSSIL_CLIENT_CLIENT, - FOSSIL_CLIENT_MAIL_BOT, - FOSSIL_CLIENT_BOT, - FOSSIL_CLIENT_MULTICAST, - FOSSIL_CLIENT_BROADCAST, - FOSSIL_CLIENT_UNKNOWN -} fossil_client_type_t; - -/** - * Create a new network stream. - * - * @param protocol_flag The protocol to use (e.g., "tcp", "udp"). - * @param client_type_flag The type of client (e.g., "server", "client"). - * @return A pointer to the newly created network stream, or NULL on failure. - */ -fossil_nstream_t *fossil_nstream_create(const char *protocol_flag, const char *client_type_flag); - -/** - * Connect a network stream to a remote host. - * - * @param stream The network stream to connect. - * @param host The hostname or IP address of the remote host. - * @param port The port number to connect to. - * @return 0 on success, or -1 on failure. - */ -int fossil_nstream_connect(fossil_nstream_t *stream, const char *host, int port); - -/** - * Set up a network stream to listen for incoming connections. - * - * @param stream The network stream to set up. - * @param host The hostname or IP address to bind to. - * @param port The port number to listen on. - * @return 0 on success, or -1 on failure. - */ -int fossil_nstream_listen(fossil_nstream_t *stream, const char *host, int port); - -/** - * Accept a new incoming connection on a listening network stream. - * - * @param server The listening network stream. - * @return A pointer to the new network stream for the accepted connection, or NULL on failure. - */ -fossil_nstream_t *fossil_nstream_accept(fossil_nstream_t *server); - -/** - * Send data through a network stream. - * - * @param stream The network stream to send data through. - * @param buffer The buffer containing the data to send. - * @param size The size of the data to send, in bytes. - * @return The number of bytes sent, or -1 on failure. - */ -ssize_t fossil_nstream_send(fossil_nstream_t *stream, const void *buffer, size_t size); - -/** - * Set the SO_REUSEADDR option on a network stream's underlying socket. - * - * @param stream The network stream to configure. - * @param enable Nonzero to enable SO_REUSEADDR, zero to disable. - * @return 0 on success, or -1 on failure. - */ -int fossil_nstream_set_reuseaddr(fossil_nstream_t *stream, int enable); - -/** - * Receive data through a network stream. - * - * @param stream The network stream to receive data from. - * @param buffer The buffer to store the received data. - * @param size The maximum size of the buffer, in bytes. - * @return The number of bytes received, or -1 on failure. - */ -ssize_t fossil_nstream_recv(fossil_nstream_t *stream, void *buffer, size_t size); - -/** - * Close a network stream. - * - * @param stream The network stream to close. - */ -void fossil_nstream_close(fossil_nstream_t *stream); - -/** - * Destroy a network stream and free its resources. - * - * @param stream The network stream to destroy. - */ -void fossil_nstream_destroy(fossil_nstream_t *stream); - -/** - * Get a string describing the last error that occurred. - * - * @return A string describing the last error. - */ -const char *fossil_nstream_last_error(void); - -/** - * Set the network stream to non-blocking mode. - * - * @param stream The network stream. - * @param enable Nonzero to enable non-blocking mode, zero to disable. - * @return 0 on success, or -1 on failure. - */ -int fossil_nstream_set_nonblocking(fossil_nstream_t *stream, int enable); - -/** - * Retrieve the remote peer's IP address and port. - * - * @param stream The network stream. - * @param out_ip A buffer to store the IP string. - * @param ip_size The size of the buffer. - * @param out_port Optional pointer to store the port. - * @return 0 on success, or -1 on failure. - */ -int fossil_nstream_get_peer_info(fossil_nstream_t *stream, char *out_ip, size_t ip_size, int *out_port); - -/** - * Retrieve basic metrics from the stream. - * - * @param stream The network stream. - * @param bytes_sent Output total bytes sent. - * @param bytes_recv Output total bytes received. - * @return 0 on success, -1 on failure. - */ -int fossil_nstream_get_stats(fossil_nstream_t *stream, size_t *bytes_sent, size_t *bytes_recv); - -#ifdef __cplusplus -} -#include -#include - -/** - * C++ wrapper for the output functions. - */ -namespace fossil { - /** - * Namespace for input/output operations. - */ - namespace io { - /** - * Class for network operations. - */ - /** - * A C++ wrapper class for the Fossil network stream API. - * Provides an object-oriented interface for managing network streams. - */ - class NStream { - public: - /** - * Constructor to create a new network stream. - * - * @param protocol_flag The protocol to use (e.g., "tcp", "udp"). - * @param client_type_flag The type of client (e.g., "server", "client"). - * @throws std::runtime_error If the stream creation fails. - */ - NStream(const std::string &protocol_flag, const std::string &client_type_flag) { - stream_ = fossil_nstream_create(protocol_flag.c_str(), client_type_flag.c_str()); - if (!stream_) { - throw std::runtime_error(fossil_nstream_last_error()); - } - } - - /** - * Destructor to destroy the network stream and free its resources. - */ - ~NStream() { - if (stream_) { - fossil_nstream_destroy(stream_); - } - } - - /** - * Connect the network stream to a remote host. - * - * @param host The hostname or IP address of the remote host. - * @param port The port number to connect to. - * @throws std::runtime_error If the connection fails. - */ - void connect(const std::string &host, int port) { - if (fossil_nstream_connect(stream_, host.c_str(), port) != 0) { - throw std::runtime_error(fossil_nstream_last_error()); - } - } - - /** - * Set up the network stream to listen for incoming connections. - * - * @param host The hostname or IP address to bind to. - * @param port The port number to listen on. - * @throws std::runtime_error If the setup fails. - */ - void listen(const std::string &host, int port) { - if (fossil_nstream_listen(stream_, host.c_str(), port) != 0) { - throw std::runtime_error(fossil_nstream_last_error()); - } - } - - /** - * Accept a new incoming connection on a listening network stream. - * - * @return A pointer to a new NStream object for the accepted connection. - * @throws std::runtime_error If accepting the connection fails. - */ - NStream *accept() { - fossil_nstream_t *accepted_stream = fossil_nstream_accept(stream_); - if (!accepted_stream) { - throw std::runtime_error(fossil_nstream_last_error()); - } - return new NStream(accepted_stream); - } - - /** - * Send data through the network stream. - * - * @param buffer The buffer containing the data to send. - * @param size The size of the data to send, in bytes. - * @return The number of bytes sent. - * @throws std::runtime_error If sending the data fails. - */ - ssize_t send(const void *buffer, size_t size) { - ssize_t bytes_sent = fossil_nstream_send(stream_, buffer, size); - if (bytes_sent < 0) { - throw std::runtime_error(fossil_nstream_last_error()); - } - return bytes_sent; - } - - /** - * Receive data through the network stream. - * - * @param buffer The buffer to store the received data. - * @param size The maximum size of the buffer, in bytes. - * @return The number of bytes received. - * @throws std::runtime_error If receiving the data fails. - */ - ssize_t recv(void *buffer, size_t size) { - ssize_t bytes_received = fossil_nstream_recv(stream_, buffer, size); - if (bytes_received < 0) { - throw std::runtime_error(fossil_nstream_last_error()); - } - return bytes_received; - } - - /** - * Close the network stream. - */ - void close() { - fossil_nstream_close(stream_); - } - - /** - * Get the last error message. - * - * @return A string describing the last error. - */ - std::string last_error() const { - return fossil_nstream_last_error(); - } - - /** - * Set the network stream to non-blocking mode. - * - * @param enable Nonzero to enable non-blocking mode, zero to disable. - * @throws std::runtime_error If setting non-blocking mode fails. - */ - void set_nonblocking(int enable) { - if (fossil_nstream_set_nonblocking(stream_, enable) != 0) { - throw std::runtime_error(fossil_nstream_last_error()); - } - } - - /** - * Retrieve the remote peer's IP address and port. - * - * @param out_ip A buffer to store the IP string. - * @param ip_size The size of the buffer. - * @param out_port Optional pointer to store the port. - * @throws std::runtime_error If retrieving peer info fails. - */ - void get_peer_info(char *out_ip, size_t ip_size, int *out_port) { - if (fossil_nstream_get_peer_info(stream_, out_ip, ip_size, out_port) != 0) { - throw std::runtime_error(fossil_nstream_last_error()); - } - } - - private: - /** - * Private constructor to wrap an existing fossil_nstream_t object. - * - * @param stream A pointer to an existing fossil_nstream_t object. - */ - NStream(fossil_nstream_t *stream) : stream_(stream) {} - - fossil_nstream_t *stream_; /**< Pointer to the underlying network stream. */ - }; - } -} - -#endif - -#endif /* FOSSIL_IO_NETWORK_H */ diff --git a/code/logic/meson.build b/code/logic/meson.build index f85277c..a0684ce 100644 --- a/code/logic/meson.build +++ b/code/logic/meson.build @@ -1,21 +1,14 @@ dir = include_directories('.') cc = meson.get_compiler('c') -# Check if the host system is Windows -if host_machine.system() == 'windows' - winsock_dep = cc.find_library('ws2_32', required: true) -else - winsock_dep = [] -endif - fossil_io_lib = library('fossil_io', - files('serialize.c', 'parser.c', 'input.c', 'output.c', 'error.c', 'soap.c', 'stream.c', 'network.c', 'cstring.c'), + files('serialize.c', 'parser.c', 'input.c', 'output.c', 'error.c', 'soap.c', 'stream.c', 'cstring.c'), install: true, - dependencies: [cc.find_library('m', required: false), winsock_dep], + dependencies: [cc.find_library('m', required: false)], include_directories: dir) fossil_io_dep = declare_dependency( link_with: [fossil_io_lib], include_directories: dir) -meson.override_dependency('fossil-io', fossil_io_dep) \ No newline at end of file +meson.override_dependency('fossil-io', fossil_io_dep) diff --git a/code/logic/network.c b/code/logic/network.c deleted file mode 100644 index 30538bc..0000000 --- a/code/logic/network.c +++ /dev/null @@ -1,529 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include "fossil/io/network.h" - -#include -#include -#include -#include - -#ifdef _WIN32 -#include -#include -typedef SOCKET socket_t; -typedef char fossil_sockopt_t; -#else -#include -#include -#include -#include -#include -#include -#include // <-- Required for struct timeval -#include // for struct ip_mreq -typedef int socket_t; -typedef void fossil_sockopt_t; -#endif - -struct fossil_nstream_t { - socket_t socket_fd; - fossil_protocol_t protocol; - fossil_client_type_t client_type; - char protocol_flag[32]; - char client_type_flag[32]; - int is_connected; - int is_server; - - size_t bytes_sent; - size_t bytes_recv; -}; - -static char fossil_last_error[256] = {0}; - - -static void fossil_set_last_error(const char *msg) { - snprintf(fossil_last_error, sizeof(fossil_last_error), "%s", msg); -} - -const char *fossil_nstream_last_error(void) { - return fossil_last_error; -} - -static int fossil_socket_init(void) { -#ifdef _WIN32 - WSADATA wsa; - return WSAStartup(MAKEWORD(2,2), &wsa); -#else - return 0; -#endif -} - -static void fossil_socket_cleanup(void) { -#ifdef _WIN32 - WSACleanup(); -#endif -} - -typedef struct { - const char *name; - fossil_protocol_t proto; -} proto_entry_t; - -typedef struct { - const char *name; - fossil_client_type_t type; -} client_entry_t; - -static const proto_entry_t proto_table[] = { - {"tcp", FOSSIL_PROTO_TCP}, - {"udp", FOSSIL_PROTO_UDP}, - {"raw", FOSSIL_PROTO_RAW}, - {"icmp", FOSSIL_PROTO_ICMP}, - {"sctp", FOSSIL_PROTO_SCTP}, - {"http", FOSSIL_PROTO_HTTP}, - {"https", FOSSIL_PROTO_HTTPS}, - {"ftp", FOSSIL_PROTO_FTP}, - {"ssh", FOSSIL_PROTO_SSH}, - {"dns", FOSSIL_PROTO_DNS}, - {"ntp", FOSSIL_PROTO_NTP}, - {"smtp", FOSSIL_PROTO_SMTP}, - {"pop3", FOSSIL_PROTO_POP3}, - {"imap", FOSSIL_PROTO_IMAP}, - {"ldap", FOSSIL_PROTO_LDAP}, - {"mqtt", FOSSIL_PROTO_MQTT}, - {NULL, FOSSIL_PROTO_UNKNOWN} -}; - -static const client_entry_t client_table[] = { - {"mail-server", FOSSIL_CLIENT_MAIL_SERVER}, - {"server", FOSSIL_CLIENT_SERVER}, - {"mail-client", FOSSIL_CLIENT_MAIL_CLIENT}, - {"client", FOSSIL_CLIENT_CLIENT}, - {"mail-bot", FOSSIL_CLIENT_MAIL_BOT}, - {"bot", FOSSIL_CLIENT_BOT}, - {"multicast", FOSSIL_CLIENT_MULTICAST}, - {"broadcast", FOSSIL_CLIENT_BROADCAST}, - {NULL, FOSSIL_CLIENT_UNKNOWN} -}; - -fossil_protocol_t fossil_protocol_from_string(const char *str) { - if (!str) return FOSSIL_PROTO_UNKNOWN; - for (int i = 0; proto_table[i].name; ++i) { - if (strcmp(str, proto_table[i].name) == 0) - return proto_table[i].proto; - } - return FOSSIL_PROTO_UNKNOWN; -} - -fossil_client_type_t fossil_client_type_from_string(const char *str) { - if (!str) return FOSSIL_CLIENT_UNKNOWN; - for (int i = 0; client_table[i].name; ++i) { - if (strcmp(str, client_table[i].name) == 0) - return client_table[i].type; - } - return FOSSIL_CLIENT_UNKNOWN; -} - -const char *fossil_protocol_to_string(fossil_protocol_t proto) { - for (int i = 0; proto_table[i].name; ++i) { - if (proto_table[i].proto == proto) - return proto_table[i].name; - } - return "unknown"; -} - -const char *fossil_client_type_to_string(fossil_client_type_t type) { - for (int i = 0; client_table[i].name; ++i) { - if (client_table[i].type == type) - return client_table[i].name; - } - return "unknown"; -} - -fossil_nstream_t *fossil_nstream_create(const char *protocol_flag, const char *client_type_flag) { - if (fossil_socket_init() != 0) { - fossil_set_last_error("Socket system initialization failed"); - return NULL; - } - - if (!protocol_flag || !client_type_flag) { - fossil_set_last_error("Invalid protocol or client type flag"); - return NULL; - } - - fossil_protocol_t protocol = fossil_protocol_from_string(protocol_flag); - fossil_client_type_t client_type = fossil_client_type_from_string(client_type_flag); - - if (protocol == FOSSIL_PROTO_UNKNOWN) { - fossil_set_last_error("Unsupported protocol"); - return NULL; - } - - if (client_type == FOSSIL_CLIENT_UNKNOWN) { - fossil_set_last_error("Unsupported client type"); - return NULL; - } - - fossil_nstream_t *stream = (fossil_nstream_t *)calloc(1, sizeof(fossil_nstream_t)); - if (!stream) { - fossil_set_last_error("Memory allocation failed"); - return NULL; - } - - stream->protocol = protocol; - stream->client_type = client_type; - snprintf(stream->protocol_flag, sizeof(stream->protocol_flag), "%s", protocol_flag); - snprintf(stream->client_type_flag, sizeof(stream->client_type_flag), "%s", client_type_flag); - stream->socket_fd = -1; - stream->is_connected = 0; - stream->is_server = 0; - return stream; -} - -static socket_t fossil_create_socket(fossil_protocol_t proto) { - int type = SOCK_STREAM; - int proto_num = IPPROTO_TCP; - - switch (proto) { - case FOSSIL_PROTO_TCP: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_UDP: type = SOCK_DGRAM; proto_num = IPPROTO_UDP; break; - case FOSSIL_PROTO_RAW: type = SOCK_RAW; proto_num = IPPROTO_RAW; break; - #ifdef IPPROTO_ICMP - case FOSSIL_PROTO_ICMP: type = SOCK_RAW; proto_num = IPPROTO_ICMP; break; - #else - case FOSSIL_PROTO_ICMP: - fossil_set_last_error("ICMP protocol not supported on this platform"); - return -1; - #endif - #ifdef IPPROTO_SCTP - case FOSSIL_PROTO_SCTP: type = SOCK_STREAM; proto_num = IPPROTO_SCTP; break; - #else - case FOSSIL_PROTO_SCTP: - fossil_set_last_error("SCTP protocol not supported on this platform"); - return -1; - #endif - case FOSSIL_PROTO_HTTP: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_HTTPS: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_FTP: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_SSH: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_DNS: type = SOCK_DGRAM; proto_num = IPPROTO_UDP; break; - case FOSSIL_PROTO_NTP: type = SOCK_DGRAM; proto_num = IPPROTO_UDP; break; - case FOSSIL_PROTO_SMTP: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_POP3: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_IMAP: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_LDAP: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - case FOSSIL_PROTO_MQTT: type = SOCK_STREAM; proto_num = IPPROTO_TCP; break; - default: - fossil_set_last_error("Unsupported protocol for socket creation"); - return -1; - } - - return socket(AF_INET, type, proto_num); -} - -int fossil_nstream_connect(fossil_nstream_t *stream, const char *host, int port) { - if (!stream) { - fossil_set_last_error("Stream is NULL"); - return -1; - } - - if (!host || strlen(host) == 0) { - fossil_set_last_error("Host is NULL or empty"); - return -1; - } - - stream->socket_fd = fossil_create_socket(stream->protocol); - if ((int)stream->socket_fd < 0) { - return -1; - } - - struct sockaddr_in addr = {0}; - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - -#ifdef _WIN32 - // Use inet_pton if available, otherwise fallback to inet_addr - #if defined(_MSC_VER) && (_MSC_VER < 1600) - unsigned long ip = inet_addr(host); - if (ip == INADDR_NONE) { - fossil_set_last_error("Invalid address or address not supported"); - return -1; - } - addr.sin_addr.s_addr = ip; - #else - if (inet_pton(AF_INET, host, &addr.sin_addr) <= 0) { - fossil_set_last_error("Invalid address or address not supported"); - return -1; - } - #endif -#else - if (inet_pton(AF_INET, host, &addr.sin_addr) <= 0) { - fossil_set_last_error("Invalid address or address not supported"); - return -1; - } -#endif - - if (connect(stream->socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - fossil_set_last_error("Connection to the server failed"); - return -1; - } - - stream->is_connected = 1; - stream->bytes_sent = 0; - stream->bytes_recv = 0; - return 0; -} - -int fossil_nstream_listen(fossil_nstream_t *stream, const char *host, int port) { - if (!stream) { - fossil_set_last_error("Stream is NULL"); - return -1; - } - - stream->socket_fd = fossil_create_socket(stream->protocol); - if (stream->socket_fd == (socket_t)-1) { - return -1; - } - - int opt = 1; - if (setsockopt(stream->socket_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) < 0) { - fossil_set_last_error("Failed to set socket options"); - return -1; - } - - struct sockaddr_in addr = {0}; - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - if (host == NULL) { - addr.sin_addr.s_addr = INADDR_ANY; - } else { - #ifdef _WIN32 - // Use inet_pton if available, otherwise fallback to inet_addr - #if defined(_MSC_VER) && (_MSC_VER < 1600) - unsigned long ip = inet_addr(host); - if (ip == INADDR_NONE) { - fossil_set_last_error("Invalid address or address not supported"); - return -1; - } - addr.sin_addr.s_addr = ip; - #else - if (inet_pton(AF_INET, host, &addr.sin_addr) <= 0) { - fossil_set_last_error("Invalid address or address not supported"); - return -1; - } - #endif - #else - if (inet_pton(AF_INET, host, &addr.sin_addr) <= 0) { - fossil_set_last_error("Invalid address or address not supported"); - return -1; - } - #endif - } - - if (bind(stream->socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { - fossil_set_last_error("Bind failed"); - return -1; - } - - if (listen(stream->socket_fd, SOMAXCONN) < 0) { - fossil_set_last_error("Listen failed"); - return -1; - } - - stream->is_server = 1; - return 0; -} - -fossil_nstream_t *fossil_nstream_accept(fossil_nstream_t *server) { - if (!server || !server->is_server) { - fossil_set_last_error("Invalid server stream"); - return NULL; - } - - struct sockaddr_in addr; - socklen_t addrlen = sizeof(addr); - - socket_t client_fd = accept(server->socket_fd, (struct sockaddr *)&addr, &addrlen); - if ((int)client_fd < 0) { -#ifdef _WIN32 - int err = WSAGetLastError(); - if (err == WSAEWOULDBLOCK || err == WSAEINTR) { - return NULL; - } -#else - if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR) { - return NULL; - } -#endif - fossil_set_last_error("Accept failed"); - return NULL; - } - - fossil_nstream_t *client = (fossil_nstream_t *)calloc(1, sizeof(fossil_nstream_t)); - if (!client) { - fossil_set_last_error("Memory allocation failed"); -#ifdef _WIN32 - closesocket(client_fd); -#else - close(client_fd); -#endif - return NULL; - } - - // Copy protocol and client type, but not socket state - client->protocol = server->protocol; - client->client_type = server->client_type; - strncpy(client->protocol_flag, server->protocol_flag, sizeof(client->protocol_flag)); - strncpy(client->client_type_flag, server->client_type_flag, sizeof(client->client_type_flag)); - client->socket_fd = client_fd; - client->is_server = 0; - client->is_connected = 1; - client->bytes_sent = 0; - client->bytes_recv = 0; - - return client; -} - -ssize_t fossil_nstream_send(fossil_nstream_t *stream, const void *buffer, size_t size) { - if (!stream || (int)stream->socket_fd < 0) { - fossil_set_last_error("Invalid stream or socket"); - return -1; - } -#ifdef _WIN32 - ssize_t sent_bytes = send(stream->socket_fd, (const char *)buffer, (int)size, 0); -#else - ssize_t sent_bytes = send(stream->socket_fd, buffer, size, 0); -#endif - if (sent_bytes < 0) { - fossil_set_last_error("Failed to send data"); - } else { - stream->bytes_sent += (size_t)sent_bytes; - } - return sent_bytes; -} - -int fossil_nstream_set_reuseaddr(fossil_nstream_t *stream, int enable) { - if (!stream || stream->socket_fd == (socket_t)-1) { - fossil_set_last_error("Invalid stream or socket"); - return -1; - } - - int optval = enable ? 1 : 0; - #ifdef _WIN32 - if (setsockopt(stream->socket_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(optval)) < 0) { - #else - if (setsockopt(stream->socket_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0) { - #endif - fossil_set_last_error("Failed to set SO_REUSEADDR option"); - return -1; - } - - return 0; -} - -ssize_t fossil_nstream_recv(fossil_nstream_t *stream, void *buffer, size_t size) { - if (!stream || stream->socket_fd == (socket_t)-1) { - fossil_set_last_error("Invalid stream or socket"); - return -1; - } -#ifdef _WIN32 - int received_bytes_win = recv(stream->socket_fd, (char *)buffer, (int)size, 0); - ssize_t received_bytes = (ssize_t)received_bytes_win; -#else - ssize_t received_bytes = recv(stream->socket_fd, buffer, size, 0); -#endif - if (received_bytes < 0) { - fossil_set_last_error("Failed to receive data"); - } - return received_bytes; -} - -void fossil_nstream_close(fossil_nstream_t *stream) { - if (!stream || stream->socket_fd == (socket_t)-1) return; -#ifdef _WIN32 - closesocket(stream->socket_fd); -#else - close(stream->socket_fd); -#endif - stream->socket_fd = -1; - stream->is_connected = 0; - stream->is_server = 0; -} - -void fossil_nstream_destroy(fossil_nstream_t *stream) { - if (!stream) return; - fossil_nstream_close(stream); - free(stream); - fossil_socket_cleanup(); -} - -int fossil_nstream_set_nonblocking(fossil_nstream_t *stream, int enable) { - if (!stream) return -1; - -#ifdef _WIN32 - u_long mode = enable ? 1 : 0; - if (ioctlsocket(stream->socket_fd, FIONBIO, &mode) != 0) { - fossil_set_last_error("Failed to set non-blocking mode"); - return -1; - } -#else - int flags = fcntl(stream->socket_fd, F_GETFL, 0); - if (flags == -1) return -1; - if (enable) - flags |= O_NONBLOCK; - else - flags &= ~O_NONBLOCK; - if (fcntl(stream->socket_fd, F_SETFL, flags) == -1) { - fossil_set_last_error("Failed to set non-blocking mode"); - return -1; - } -#endif - return 0; -} - -int fossil_nstream_get_peer_info(fossil_nstream_t *stream, char *out_ip, size_t ip_size, int *out_port) { - if (!stream || !out_ip) return -1; - - struct sockaddr_storage addr; - socklen_t len = sizeof(addr); - if (getpeername(stream->socket_fd, (struct sockaddr*)&addr, &len) != 0) - return -1; - - void *src; - int port; - - if (addr.ss_family == AF_INET) { - struct sockaddr_in *sin = (struct sockaddr_in*)&addr; - src = &sin->sin_addr; - port = ntohs(sin->sin_port); - } else { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)&addr; - src = &sin6->sin6_addr; - port = ntohs(sin6->sin6_port); - } - - if (!inet_ntop(addr.ss_family, src, out_ip, ip_size)) - return -1; - - if (out_port) *out_port = port; - - return 0; -} - -int fossil_nstream_get_stats(fossil_nstream_t *stream, size_t *bytes_sent, size_t *bytes_recv) { - if (!stream) return -1; - if (bytes_sent) *bytes_sent = stream->bytes_sent; - if (bytes_recv) *bytes_recv = stream->bytes_recv; - return 0; -} diff --git a/code/tests/cases/test_network.c b/code/tests/cases/test_network.c deleted file mode 100644 index 1b2a93a..0000000 --- a/code/tests/cases/test_network.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include -#include "fossil/io/framework.h" - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilities -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_SUITE(c_network_suite); - -// Setup function for the test suite -FOSSIL_SETUP(c_network_suite) { - // Setup code (if needed) -} - -// Teardown function for the test suite -FOSSIL_TEARDOWN(c_network_suite) { - // Teardown code (if needed) -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST(c_test_nstream_create_and_destroy) { - const char *protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; - const char *clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; - - for (size_t i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) { - for (size_t j = 0; j < sizeof(clients) / sizeof(clients[0]); j++) { - fossil_nstream_t *stream = fossil_nstream_create(protocols[i], clients[j]); - ASSUME_NOT_CNULL(stream); - fossil_nstream_destroy(stream); - } - } -} - -FOSSIL_TEST(c_test_nstream_connect_invalid_host) { - fossil_nstream_t *stream = fossil_nstream_create("tcp", "client"); - ASSUME_NOT_CNULL(stream); - - // Attempt to connect to an invalid host - ASSUME_ITS_EQUAL_I32(-1, fossil_nstream_connect(stream, "invalid_host", 12345)); - fossil_nstream_destroy(stream); -} - -#if !defined(_WIN32) && !defined(_WIN64) -FOSSIL_TEST(c_test_nstream_listen_and_accept) { - fossil_nstream_t *server = fossil_nstream_create("tcp", "server"); - ASSUME_NOT_CNULL(server); - - // Set SO_REUSEADDR before binding/listening to avoid bind failures - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_set_reuseaddr(server, 1)); - - // Start listening on a local port - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", 12345)); - - // Simulate a client connecting - fossil_nstream_t *client = fossil_nstream_create("tcp", "client"); - ASSUME_NOT_CNULL(client); - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_connect(client, "127.0.0.1", 12345)); - - // Accept the client connection - fossil_nstream_t *accepted_client = fossil_nstream_accept(server); - ASSUME_NOT_CNULL(accepted_client); - - // Cleanup - fossil_nstream_destroy(client); - fossil_nstream_destroy(accepted_client); - fossil_nstream_destroy(server); -} - -FOSSIL_TEST(c_test_nstream_send_and_receive) { - fossil_nstream_t *server = fossil_nstream_create("tcp", "server"); - ASSUME_NOT_CNULL(server); - - // Set SO_REUSEADDR before binding/listening - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_set_reuseaddr(server, 1)); - - // Start listening on a local port - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", 12345)); - - // Simulate a client connecting - fossil_nstream_t *client = fossil_nstream_create("tcp", "client"); - ASSUME_NOT_CNULL(client); - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_connect(client, "127.0.0.1", 12345)); - - // Accept the client connection - fossil_nstream_t *accepted_client = fossil_nstream_accept(server); - ASSUME_NOT_CNULL(accepted_client); - - // Send and receive data - const char *message = "Hello, Fossil!"; - ASSUME_ITS_EQUAL_I32(strlen(message), fossil_nstream_send(client, message, strlen(message))); - - char buffer[1024] = {0}; - ASSUME_ITS_EQUAL_I32(strlen(message), fossil_nstream_recv(accepted_client, buffer, sizeof(buffer))); - ASSUME_ITS_EQUAL_CSTR(message, buffer); - - // Cleanup - fossil_nstream_destroy(client); - fossil_nstream_destroy(accepted_client); - fossil_nstream_destroy(server); -} -#endif - -FOSSIL_TEST(c_test_nstream_protocols) { - const char *protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; - - for (size_t i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) { - fossil_nstream_t *stream = fossil_nstream_create(protocols[i], "client"); - ASSUME_NOT_CNULL(stream); - fossil_nstream_destroy(stream); - } -} - -FOSSIL_TEST(c_test_nstream_client_types) { - const char *clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; - - for (size_t i = 0; i < sizeof(clients) / sizeof(clients[0]); i++) { - fossil_nstream_t *stream = fossil_nstream_create("tcp", clients[i]); - ASSUME_NOT_CNULL(stream); - fossil_nstream_destroy(stream); - } -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Pool -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_GROUP(c_network_tests) { - FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_create_and_destroy); - FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_connect_invalid_host); - #if !defined(_WIN32) && !defined(_WIN64) - FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_listen_and_accept); - FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_send_and_receive); - #endif - - FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_protocols); - FOSSIL_TEST_ADD(c_network_suite, c_test_nstream_client_types); - - FOSSIL_TEST_REGISTER(c_network_suite); -} diff --git a/code/tests/cases/test_network.cpp b/code/tests/cases/test_network.cpp deleted file mode 100644 index aaf2caf..0000000 --- a/code/tests/cases/test_network.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* - * ----------------------------------------------------------------------------- - * Project: Fossil Logic - * - * This file is part of the Fossil Logic project, which aims to develop high- - * performance, cross-platform applications and libraries. The code contained - * herein is subject to the terms and conditions defined in the project license. - * - * Author: Michael Gene Brockus (Dreamer) - * - * Copyright (C) 2024 Fossil Logic. All rights reserved. - * ----------------------------------------------------------------------------- - */ -#include -#include "fossil/io/framework.h" - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Utilities -// * * * * * * * * * * * * * * * * * * * * * * * * -// Setup steps for things like test fixtures and -// mock objects are set here. -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_SUITE(cpp_network_suite); - -// Setup function for the test suite -FOSSIL_SETUP(cpp_network_suite) { - // Setup code (if needed) -} - -// Teardown function for the test suite -FOSSIL_TEARDOWN(cpp_network_suite) { - // Teardown code (if needed) -} - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Cases -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST(cpp_test_nstream_create_and_destroy) { - const char *protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; - const char *clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; - - for (size_t i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) { - for (size_t j = 0; j < sizeof(clients) / sizeof(clients[0]); j++) { - fossil_nstream_t *stream = fossil_nstream_create(protocols[i], clients[j]); - ASSUME_NOT_CNULL(stream); - fossil_nstream_destroy(stream); - } - } -} - -FOSSIL_TEST(cpp_test_nstream_connect_invalid_host) { - fossil_nstream_t *stream = fossil_nstream_create("tcp", "client"); - ASSUME_NOT_CNULL(stream); - - // Attempt to connect to an invalid host - ASSUME_ITS_EQUAL_I32(-1, fossil_nstream_connect(stream, "invalid_host", 12345)); - fossil_nstream_destroy(stream); -} - -#ifndef _WIN32 -FOSSIL_TEST(cpp_test_nstream_listen_and_accept) { - fossil_nstream_t *server = fossil_nstream_create("tcp", "server"); - ASSUME_NOT_CNULL(server); - - // Set SO_REUSEADDR to avoid bind fail on rapid test reruns - fossil_nstream_set_reuseaddr(server, 1); - - // Use a unique port for this test to avoid bind conflicts - const int test_port = 12346; - - // Start listening on a local port - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", test_port)); - - // Simulate a client connecting - fossil_nstream_t *client = fossil_nstream_create("tcp", "client"); - ASSUME_NOT_CNULL(client); - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_connect(client, "127.0.0.1", test_port)); - - // Accept the client connection - fossil_nstream_t *accepted_client = fossil_nstream_accept(server); - ASSUME_NOT_CNULL(accepted_client); - - // Cleanup - fossil_nstream_destroy(client); - fossil_nstream_destroy(accepted_client); - fossil_nstream_destroy(server); -} - -FOSSIL_TEST(cpp_test_nstream_send_and_receive) { - fossil_nstream_t *server = fossil_nstream_create("tcp", "server"); - ASSUME_NOT_CNULL(server); - - // Set SO_REUSEADDR to avoid bind fail on rapid test reruns - fossil_nstream_set_reuseaddr(server, 1); - - // Use a unique port for this test to avoid bind conflicts - const int test_port = 12347; - - // Start listening on a local port - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_listen(server, "127.0.0.1", test_port)); - - // Simulate a client connecting - fossil_nstream_t *client = fossil_nstream_create("tcp", "client"); - ASSUME_NOT_CNULL(client); - ASSUME_ITS_EQUAL_I32(0, fossil_nstream_connect(client, "127.0.0.1", test_port)); - - // Accept the client connection - fossil_nstream_t *accepted_client = fossil_nstream_accept(server); - ASSUME_NOT_CNULL(accepted_client); - - // Send and receive data - const char *message = "Hello, Fossil!"; - ASSUME_ITS_EQUAL_I32(strlen(message), fossil_nstream_send(client, message, strlen(message))); - - char buffer[1024] = {0}; - ASSUME_ITS_EQUAL_I32(strlen(message), fossil_nstream_recv(accepted_client, buffer, sizeof(buffer))); - ASSUME_ITS_EQUAL_CSTR(message, buffer); - - // Cleanup - fossil_nstream_destroy(client); - fossil_nstream_destroy(accepted_client); - fossil_nstream_destroy(server); -} -#endif - -FOSSIL_TEST(cpp_test_nstream_protocols) { - const char *protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; - - for (size_t i = 0; i < sizeof(protocols) / sizeof(protocols[0]); i++) { - fossil_nstream_t *stream = fossil_nstream_create(protocols[i], "client"); - ASSUME_NOT_CNULL(stream); - fossil_nstream_destroy(stream); - } -} - -FOSSIL_TEST(cpp_test_nstream_client_types) { - const char *clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; - - for (size_t i = 0; i < sizeof(clients) / sizeof(clients[0]); i++) { - fossil_nstream_t *stream = fossil_nstream_create("tcp", clients[i]); - ASSUME_NOT_CNULL(stream); - fossil_nstream_destroy(stream); - } -} - -FOSSIL_TEST(cpp_test_nstream_class_create_and_destroy) { - using namespace fossil::io; - - const std::string protocols[] = {"tcp", "udp", "raw", "icmp", "sctp", "http", "https", "ftp", "ssh", "dns", "ntp", "smtp", "pop3", "imap", "ldap", "mqtt"}; - const std::string clients[] = {"mail-server", "server", "mail-client", "client", "mail-bot", "bot", "multicast", "broadcast"}; - - for (const auto &protocol : protocols) { - for (const auto &client : clients) { - NStream stream(protocol, client); - } - } -} - -FOSSIL_TEST(cpp_test_nstream_class_connect_invalid_host) { - using namespace fossil::io; - - try { - NStream stream("tcp", "client"); - stream.connect("invalid_host", 12345); - ASSUME_ITS_FALSE("Expected exception for invalid host"); - } catch (const std::runtime_error &e) { - ASSUME_ITS_TRUE("Caught expected exception"); - } -} - -#ifndef _WIN32 -FOSSIL_TEST(cpp_test_nstream_class_listen_and_accept) { - using namespace fossil::io; - - NStream server("tcp", "server"); - server.listen("127.0.0.1", 12345); - - NStream client("tcp", "client"); - client.connect("127.0.0.1", 12345); - - NStream *accepted_client = server.accept(); - ASSUME_NOT_CNULL(accepted_client); - - delete accepted_client; -} - -FOSSIL_TEST(cpp_test_nstream_class_send_and_receive) { - using namespace fossil::io; - - NStream server("tcp", "server"); - server.listen("127.0.0.1", 12345); - - NStream client("tcp", "client"); - client.connect("127.0.0.1", 12345); - - NStream *accepted_client = server.accept(); - ASSUME_NOT_CNULL(accepted_client); - - const std::string message = "Hello, Fossil!"; - client.send(message.c_str(), message.size()); - - char buffer[1024] = {0}; - ssize_t bytes_received = accepted_client->recv(buffer, sizeof(buffer)); - ASSUME_ITS_EQUAL_I32(message.size(), bytes_received); - ASSUME_ITS_EQUAL_CSTR(message.c_str(), buffer); - - delete accepted_client; -} -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * -// * Fossil Logic Test Pool -// * * * * * * * * * * * * * * * * * * * * * * * * - -FOSSIL_TEST_GROUP(cpp_network_tests) { - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_create_and_destroy); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_connect_invalid_host); - #ifndef _WIN32 - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_listen_and_accept); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_send_and_receive); - #endif - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_protocols); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_client_types); - - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_create_and_destroy); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_connect_invalid_host); - #ifndef _WIN32 - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_listen_and_accept); - FOSSIL_TEST_ADD(cpp_network_suite, cpp_test_nstream_class_send_and_receive); - #endif - - FOSSIL_TEST_REGISTER(cpp_network_suite); -} diff --git a/subprojects/openssl.wrap b/subprojects/openssl.wrap new file mode 100644 index 0000000..4936b92 --- /dev/null +++ b/subprojects/openssl.wrap @@ -0,0 +1,11 @@ +[wrap-file] +directory = openssl-3.0.8 +source_url = https://www.openssl.org/source/openssl-3.0.8.tar.gz +source_filename = openssl-3.0.8.tar.gz +source_hash = 6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e +patch_directory = openssl + +[provide] +libcrypto = libcrypto_dep +libssl = libssl_dep +openssl = openssl_dep \ No newline at end of file