![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
#include "nilorea/n_common.h"#include "nilorea/n_log.h"#include "nilorea/n_network.h"#include "nilorea/n_str.h"#include "nilorea/n_x509.h"#include <poll.h>#include <pthread.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <openssl/bio.h>#include <openssl/pem.h>#include <openssl/ssl.h>#include <openssl/x509.h>Go to the source code of this file.
Data Structures | |
| struct | SRV |
| server worker context More... | |
Macros | |
| #define | MSG "nonblock-client->server" |
| client->server probe (both messages share this fixed length) | |
| #define | MSG_LEN 24 |
| exchanged length: 23 chars + NUL, identical for MSG and REPLY | |
| #define | REPLY "nonblock-server->client" |
| server->client probe | |
Functions | |
| static NETWORK * | bind_free (char *port_out, size_t port_out_len) |
| static int | drive_connect (NETWORK *netw) |
| static int | drive_handshake (NETWORK *netw, int is_server, SSL_CTX *sctx) |
| static int | io_full (NETWORK *netw, char *buf, uint32_t n, int is_send) |
| static void | leave_stale_openssl_error (void) |
| leave a genuine error on this thread's OpenSSL queue (portable: a failed PEM parse, no deprecated ERR_put_error / 3.0-only ERR_raise) | |
| int | main (int argc, char **argv) |
| static SSL_CTX * | make_server_ctx (const N_STR *cert_pem, const N_STR *key_pem) |
| static int | poll_fd (SOCKET fd, int want_write, int timeout_ms) |
| static void | process_args (int argc, char **argv) |
| static void * | server_fn (void *p) |
| struct SRV |
server worker context
Definition at line 67 of file ex_network_alpn.c.
| Data Fields | ||
|---|---|---|
| CA_CTX * | ca | the CA to mint leaves with |
| SSL_CTX * | ctx | shared server ctx (owned by main) |
| char | h2_path[128] | the :path of the last HTTP/2 request |
| int | h2_requests | requests served over HTTP/2 |
| NETWORK * | listen |
the listening socket listening NETWORK |
| int | ok | set to 1 once the server completed the exchange |
| int | rounds_done | how many connections it served |
| char | selected[3][32] | what ALPN the server answered per round |
| #define MSG "nonblock-client->server" |
client->server probe (both messages share this fixed length)
Definition at line 50 of file ex_network_ssl_nonblock.c.
Referenced by main(), and server_fn().
| #define MSG_LEN 24 |
exchanged length: 23 chars + NUL, identical for MSG and REPLY
Definition at line 54 of file ex_network_ssl_nonblock.c.
| #define REPLY "nonblock-server->client" |
server->client probe
Definition at line 52 of file ex_network_ssl_nonblock.c.
Referenced by main(), and server_fn().
|
static |
Definition at line 281 of file ex_network_ssl_nonblock.c.
References netw_close(), netw_make_listening(), and NETWORK_IPALL.
|
static |
Definition at line 211 of file ex_network_ssl_nonblock.c.
References netw, netw_connect_check(), NETW_IO_WANT_WRITE, and poll_fd().
Referenced by main().
|
static |
Definition at line 188 of file ex_network_ssl_nonblock.c.
References netw, NETW_IO_WANT_READ, NETW_IO_WANT_WRITE, netw_ssl_handshake_once(), netw_ssl_server_handshake_once(), and poll_fd().
Referenced by main(), and server_fn().
|
static |
Definition at line 228 of file ex_network_ssl_nonblock.c.
References done, netw, NETW_IO_WANT_READ, NETW_IO_WANT_WRITE, poll_fd(), recv_ssl_data_once(), and send_ssl_data_once().
Referenced by main(), and server_fn().
|
static |
leave a genuine error on this thread's OpenSSL queue (portable: a failed PEM parse, no deprecated ERR_put_error / 3.0-only ERR_raise)
Definition at line 60 of file ex_network_ssl_nonblock.c.
Referenced by main().
| int main | ( | int | argc, |
| char ** | argv ) |
Definition at line 297 of file ex_network_ssl_nonblock.c.
References bind_free(), cert, SRV::ctx, drive_connect(), drive_handshake(), failures, free_nstr, io_full(), key, leave_stale_openssl_error(), SRV::listen, LOG_ERR, LOG_NOTICE, make_server_ctx(), MSG, MSG_LEN, n_log, n_x509_generate_ca(), netw_close(), netw_connect_nonblock(), netw_init_openssl(), NETW_IO_WANT_READ, netw_ssl_set_verify(), netw_ssl_set_versions(), netw_ssl_start_client(), NETW_TLS_MAX_VERSION, netw_unload_openssl(), NETWORK_IPALL, SRV::ok, port, process_args(), recv_ssl_data_once(), REPLY, server_fn(), and set_log_level().
Definition at line 117 of file ex_network_ssl_nonblock.c.
References N_STR::data, NETW_TLS_MAX_VERSION, and N_STR::written.
Referenced by main().
|
static |
Definition at line 159 of file ex_network_ssl_nonblock.c.
Referenced by drive_connect(), drive_handshake(), io_full(), and server_fn().
|
static |
Definition at line 78 of file ex_network_ssl_nonblock.c.
References LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_NOTICE, LOG_NULL, and set_log_level().
|
static |
Definition at line 255 of file ex_network_ssl_nonblock.c.
References SRV::ctx, drive_handshake(), io_full(), NETWORK::link, SRV::listen, LOG_NOTICE, MSG, MSG_LEN, n_log, netw_accept_nonblock_from(), netw_close(), SRV::ok, poll_fd(), REPLY, and N_SOCKET::sock.