Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_network.c File Reference

Network Engine. More...

#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include "nilorea/n_network.h"
#include "nilorea/n_network_msg.h"
#include "nilorea/n_log.h"
#include "nilorea/n_hash.h"
#include "nilorea/n_base64.h"
#include <openssl/sha.h>
#include <openssl/rand.h>
#include <sys/wait.h>
+ Include dependency graph for n_network.c:

Go to the source code of this file.

Macros

#define _Thread_local   __thread
 thread-local pre-connection error buffer (DNS, socket creation)
 
#define neterrno   errno
 get last socket error code, linux version
 
#define netstrerror(code)
 BSD style errno string NO WORKING ON REDHAT.
 
#define NETW_BUFLEN_CAST(x)   ((size_t)(x))
 cast for send/recv buffer length: int on Windows, size_t on POSIX
 
#define NETW_CALL_RETRY(__retvar, __expression, __max_tries)
 network-aware retry macro: retries on EINTR and EAGAIN/EWOULDBLOCK
 

Functions

 __attribute__ ((unused))
 
static void _n_mock_parse_request (const char *buf, N_HTTP_REQUEST *req)
 Parse a raw HTTP request buffer into an N_HTTP_REQUEST.
 
static void _n_mock_request_clean (N_HTTP_REQUEST *req)
 Free the contents of an N_HTTP_REQUEST (does not free the struct itself).
 
static void _n_parse_query_params (N_URL *u, const char *qs)
 
static void _netw_capture_connect_error (const char *fmt,...)
 capture a pre-connection error (thread-local)
 
static void _netw_capture_error (NETWORK *netw, const char *fmt,...)
 capture an error into a NETWORK handle's ring buffer
 
static int _proxy_tcp_connect (const char *host, int port)
 Helper: connect a plain TCP socket to host:port.
 
static ssize_t _sse_read_byte (NETWORK *netw, char *ch, volatile int *stop_flag)
 read one byte from an SSE connection (SSL or plain).
 
static ssize_t _sse_write (NETWORK *netw, const void *buf, size_t len)
 write bytes to an SSE connection (SSL or plain)
 
static ssize_t _ws_read (N_WS_CONN *conn, void *buf, size_t len)
 read exactly len bytes from a WebSocket connection
 
static ssize_t _ws_write (N_WS_CONN *conn, const void *buf, size_t len)
 write bytes to a WebSocket connection (SSL or plain)
 
int deplete_send_buffer (int fd, int timeout)
 wait until the socket is empty or timeout, checking each 100 msec.
 
char * get_in_addr (struct sockaddr *sa)
 get sockaddr, IPv4 or IPv6
 
__netw_code_type size_t htonst (size_t value)
 host to network size_t
 
void n_mock_server_free (N_MOCK_SERVER **server)
 Free a mock server and close the listening socket.
 
void n_mock_server_run (N_MOCK_SERVER *server)
 Run the mock server accept loop.
 
N_MOCK_SERVERn_mock_server_start (int port, void(*on_request)(N_HTTP_REQUEST *, N_HTTP_RESPONSE *, void *), void *user_data)
 Start a mock HTTP server: set up listener and return immediately.
 
void n_mock_server_stop (N_MOCK_SERVER *server)
 Signal the mock server to stop accepting connections.
 
void n_netw_clear_connect_errors (void)
 Clear pre-connection errors on this thread.
 
void n_netw_clear_errors (NETWORK *netw)
 Clear captured errors on a NETWORK handle.
 
const char * n_netw_get_connect_error (int index)
 Get pre-connection error message by index.
 
int n_netw_get_connect_error_count (void)
 Get number of pre-connection errors captured on this thread.
 
const char * n_netw_get_error (NETWORK *netw, int index)
 Get captured error message by index (0 = oldest).
 
int n_netw_get_error_count (NETWORK *netw)
 Get number of captured errors on a NETWORK handle.
 
void n_proxy_cfg_free (N_PROXY_CFG **cfg)
 Free an N_PROXY_CFG created by n_proxy_cfg_parse().
 
N_PROXY_CFGn_proxy_cfg_parse (const char *url)
 Parse a proxy URL string into an N_PROXY_CFG struct.
 
int n_proxy_connect_socks5 (const N_PROXY_CFG *proxy, const char *target_host, int target_port)
 Open a TCP connection through a SOCKS5 proxy.
 
int n_proxy_connect_tunnel (const N_PROXY_CFG *proxy, const char *target_host, int target_port)
 Open a TCP connection through an HTTP proxy using CONNECT tunneling.
 
int n_proxy_connect_tunnel_ssl (const N_PROXY_CFG *proxy, const char *target_host, int target_port)
 Open a TCP connection through an HTTPS proxy using CONNECT tunneling.
 
void n_sse_conn_free (N_SSE_CONN **conn)
 Free an SSE connection structure.
 
N_SSE_CONNn_sse_connect (const char *host, const char *port, const char *path, int use_ssl, void(*on_event)(N_SSE_EVENT *, N_SSE_CONN *, void *), void *user_data)
 Connect to an SSE endpoint and start reading events.
 
void n_sse_event_clean (N_SSE_EVENT *event)
 Free the contents of an SSE event (does not free the struct itself).
 
void n_sse_stop (N_SSE_CONN *conn)
 Signal the SSE connection to stop reading.
 
N_STRn_url_build (const N_URL *u)
 build a URL string from parsed components
 
N_STRn_url_decode (const char *str)
 decode a percent-encoded string (returns N_STR)
 
N_STRn_url_encode (const char *str)
 percent-encode a string for use in URLs (returns N_STR)
 
void n_url_free (N_URL **u)
 free a N_URL and all its members
 
N_URLn_url_parse (const char *url)
 parse a URL string into components
 
void n_ws_close (N_WS_CONN *conn)
 Send close frame and close the connection.
 
void n_ws_conn_free (N_WS_CONN **conn)
 Free a WebSocket connection structure.
 
N_WS_CONNn_ws_connect (const char *host, const char *port, const char *path, int use_ssl)
 Connect to a WebSocket server (ws:// or wss://).
 
int n_ws_recv (N_WS_CONN *conn, N_WS_MESSAGE *msg_out)
 Receive one WebSocket frame.
 
int n_ws_send (N_WS_CONN *conn, const char *payload, size_t len, int opcode)
 Send a WebSocket frame (client always masks).
 
NETWORKnetw_accept_from (NETWORK *from)
 make a normal blocking 'accept' .
 
NETWORKnetw_accept_from_ex (NETWORK *from, size_t send_list_limit, size_t recv_list_limit, int blocking, int *retval)
 make a normal 'accept' .
 
NETWORKnetw_accept_nonblock_from (NETWORK *from, int blocking)
 make a normal blocking 'accept' .
 
int netw_add_msg (NETWORK *netw, N_STR *msg)
 Add a message to send in aimed NETWORK.
 
int netw_add_msg_ex (NETWORK *netw, char *str, unsigned int length)
 Add a message to send in aimed NETWORK.
 
int netw_bind_udp (NETWORK **netw, char *addr, char *port, int ip_version)
 Create a UDP bound socket for receiving datagrams.
 
int netw_build_http_response (N_STR **http_response, int status_code, const char *server_name, const char *content_type, char *additional_headers, N_STR *body)
 function to dynamically generate an HTTP response
 
size_t netw_calculate_urlencoded_size (const char *str, size_t len)
 function to calculate the required size for the URL-encoded string
 
int netw_close (NETWORK **netw)
 Closing a specified Network, destroy queues, free the structure.
 
int netw_connect (NETWORK **netw, char *host, char *port, int ip_version)
 Use this to connect a NETWORK to any listening one, unrestricted send/recv lists.
 
int netw_connect_ex (NETWORK **netw, char *host, char *port, size_t send_list_limit, size_t recv_list_limit, int ip_version, char *ssl_key_file, char *ssl_cert_file)
 Use this to connect a NETWORK to any listening one.
 
int netw_connect_udp (NETWORK **netw, char *host, char *port, int ip_version)
 Connect a UDP socket to a remote host.
 
int netw_destroy_pool (NETWORK_POOL **netw_pool)
 free a NETWORK_POOL *pool
 
NETWORK_HTTP_INFO netw_extract_http_info (char *request)
 extract a lot of informations, mostly as pointers, and populate a NETWORK_HTTP_INFO structure
 
char * netw_extract_http_request_type (const char *request)
 function to extract the request method from an http request
 
int netw_get_http_date (char *buffer, size_t buffer_size)
 helper function to generate the current date in HTTP format
 
const char * netw_get_http_status_message (int status_code)
 helper function to convert status code to a human-readable message
 
N_STRnetw_get_msg (NETWORK *netw)
 Get a message from aimed NETWORK.
 
char * netw_get_openssl_error_string ()
 get the OpenSSL error string
 
int netw_get_queue_status (NETWORK *netw, size_t *nb_to_send, size_t *nb_to_read)
 retrieve network send queue status
 
int netw_get_state (NETWORK *netw, uint32_t *state, int *thr_engine_status)
 Get the state of a network.
 
int netw_get_url_from_http_request (const char *request, char *url, size_t size)
 Helper function to extract the URL from the HTTP request line.
 
const char * netw_guess_http_content_type (const char *url)
 function to guess the content type based on URL extension
 
int netw_info_destroy (NETWORK_HTTP_INFO http_request)
 destroy a NETWORK_HTTP_INFO loaded informations
 
static void netw_init_locks (void)
 
int netw_init_openssl (void)
 Do not directly use, internal api.
 
int netw_init_wsa (int mode, int v1, int v2)
 Do not directly use, internal api.
 
static void netw_kill_locks (void)
 
int netw_make_listening (NETWORK **netw, char *addr, char *port, int nbpending, int ip_version)
 Make a NETWORK be a Listening network.
 
NETWORKnetw_new (size_t send_list_limit, size_t recv_list_limit)
 Return an empty allocated network ready to be netw_closed.
 
NETWORK_POOLnetw_new_pool (size_t nb_min_element)
 return a new network pool of nb_min_element
 
HASH_TABLEnetw_parse_post_data (const char *post_data)
 Function to parse POST data.
 
int netw_pool_add (NETWORK_POOL *netw_pool, NETWORK *netw)
 add a NETWORK *netw to a NETWORK_POOL *pool
 
int netw_pool_broadcast (NETWORK_POOL *netw_pool, const NETWORK *from, N_STR *net_msg)
 add net_msg to all network in netork pool
 
size_t netw_pool_nbclients (NETWORK_POOL *netw_pool)
 return the number of networks in netw_pool
 
void netw_pool_netw_close (void *netw_ptr)
 close a network from a network pool
 
int netw_pool_remove (NETWORK_POOL *netw_pool, NETWORK *netw)
 remove a NETWORK *netw to a NETWORK_POOL *pool
 
void * netw_recv_func (void *NET)
 To Thread Receiving function.
 
void * netw_send_func (void *NET)
 Thread send function.
 
int netw_send_ident (NETWORK *netw, int type, int id, N_STR *name, N_STR *passwd)
 Add a formatted NETWMSG_IDENT message to the specified network.
 
int netw_send_ping (NETWORK *netw, int type, int id_from, int id_to, int time)
 Add a ping reply to the network.
 
int netw_send_position (NETWORK *netw, int id, double X, double Y, double vx, double vy, double acc_x, double acc_y, int time_stamp)
 Add a formatted NETWMSG_IDENT message to the specified network.
 
int netw_send_quit (NETWORK *netw)
 Add a formatted NETMSG_QUIT message to the specified network.
 
int netw_send_string_to (NETWORK *netw, int id_to, N_STR *name, N_STR *chan, N_STR *txt, int color)
 Add a string to the network, aiming a specific user.
 
int netw_send_string_to_all (NETWORK *netw, N_STR *name, N_STR *chan, N_STR *txt, int color)
 Add a string to the network, aiming all server-side users.
 
int netw_set (NETWORK *netw, int flag)
 Restart or reset the specified network ability.
 
int netw_set_blocking (NETWORK *netw, unsigned long int is_blocking)
 Modify blocking socket mode.
 
int netw_set_crypto (NETWORK *netw, char *key, char *certificate)
 activate SSL encryption on selected network, using key and certificate
 
int netw_set_crypto_chain (NETWORK *netw, char *key, char *certificate, char *ca_file)
 activate SSL encryption using key/certificate files and a CA file for chain verification
 
int netw_set_crypto_chain_pem (NETWORK *netw, const char *key_pem, const char *cert_pem, const char *ca_pem)
 activate SSL encryption using PEM strings for key, certificate, and CA
 
int netw_set_crypto_pem (NETWORK *netw, const char *key_pem, const char *cert_pem)
 activate SSL encryption using PEM-formatted key and certificate strings loaded from memory
 
int netw_set_user_id (NETWORK *netw, int id)
 associate an id and a network
 
int netw_setsockopt (NETWORK *netw, int optname, int value)
 Modify common socket options on the given netw.
 
int netw_ssl_connect (NETWORK **netw, char *host, char *port, int ip_version, char *ssl_key_file, char *ssl_cert_file)
 Use this to connect a NETWORK to any listening one, unrestricted send/recv lists.
 
int netw_ssl_connect_client (NETWORK **netw, char *host, char *port, int ip_version)
 Connect as an SSL client without providing a client certificate.
 
int netw_ssl_do_handshake (NETWORK *netw, const char *sni_hostname)
 Complete the SSL handshake on an already-connected NETWORK.
 
void netw_ssl_print_errors (SOCKET socket)
 print OpenSSL errors for a given socket
 
int netw_ssl_set_ca (NETWORK *netw, const char *ca_file, const char *ca_path)
 set custom CA verify location for SSL context
 
int netw_ssl_set_client_cert (NETWORK *netw, const char *cert_file, const char *key_file)
 load a client certificate and private key for mTLS
 
int netw_ssl_set_verify (NETWORK *netw, int enable)
 enable or disable SSL peer certificate verification
 
int netw_start_thr_engine (NETWORK *netw)
 Start the NETWORK netw Threaded Engine.
 
int netw_stop_thr_engine (NETWORK *netw)
 Stop a NETWORK connection sending and receing thread.
 
ssize_t netw_udp_recvfrom (NETWORK *netw, char *buf, uint32_t n, struct sockaddr *src_addr, socklen_t *src_len)
 recv data via UDP and capture the source address
 
ssize_t netw_udp_sendto (NETWORK *netw, char *buf, uint32_t n, struct sockaddr *dest_addr, socklen_t dest_len)
 send data via UDP to a specific destination address
 
int netw_unload_openssl (void)
 Do not directly use, internal api.
 
char * netw_urldecode (const char *str)
 Function to decode URL-encoded data.
 
char * netw_urlencode (const char *str, size_t len)
 function to perform URL encoding
 
N_STRnetw_wait_msg (NETWORK *netw, unsigned int refresh, size_t timeout)
 Wait a message from aimed NETWORK.
 
size_t ntohst (size_t value)
 network to host size_t
 
ssize_t recv_data (void *netw, char *buf, uint32_t n)
 recv data from the socket
 
ssize_t recv_php (SOCKET s, int *_code, char **buf)
 recv data from the socket
 
ssize_t recv_ssl_data (void *netw, char *buf, uint32_t n)
 recv data from the socket
 
ssize_t recv_udp_data (void *netw, char *buf, uint32_t n)
 recv data via UDP from a connected socket
 
ssize_t send_data (void *netw, char *buf, uint32_t n)
 send data onto the socket
 
ssize_t send_php (SOCKET s, int _code, char *buf, int n)
 send data onto the socket
 
ssize_t send_ssl_data (void *netw, char *buf, uint32_t n)
 send data onto the socket
 
ssize_t send_udp_data (void *netw, char *buf, uint32_t n)
 send data via UDP on a connected socket
 

Variables

 N_ENUM_netw_code_type
 network error code
 
static pthread_mutex_t * netw_ssl_lockarray
 
static int OPENSSL_IS_INITIALIZED = 0
 
static __thread int s_connect_err_count = 0
 
static __thread int s_connect_err_next = 0
 
static __thread char s_connect_errors [8][512]
 

Detailed Description

Network Engine.

Author
Castagnier Mickael
Version
1.0
Date
10/05/2005

Definition in file n_network.c.

Macro Definition Documentation

◆ _Thread_local

#define _Thread_local   __thread

thread-local pre-connection error buffer (DNS, socket creation)

Definition at line 66 of file n_network.c.

◆ neterrno

#define neterrno   errno

get last socket error code, linux version

Definition at line 670 of file n_network.c.

◆ netstrerror

#define netstrerror (   code)
Value:
({ \
char* __errmsg = NULL; \
errno = 0; \
__errmsg = strdup(strerror(code)); \
if (errno == ENOMEM) { \
__errmsg = NULL; \
} \
__errmsg; \
})

BSD style errno string NO WORKING ON REDHAT.

get last socket error code as a string, linux version

Definition at line 685 of file n_network.c.

◆ NETW_BUFLEN_CAST

#define NETW_BUFLEN_CAST (   x)    ((size_t)(x))

cast for send/recv buffer length: int on Windows, size_t on POSIX

Definition at line 656 of file n_network.c.

◆ NETW_CALL_RETRY

#define NETW_CALL_RETRY (   __retvar,
  __expression,
  __max_tries 
)
Value:
do { \
int __nb_retries = 0; \
do { \
__retvar = (__expression); \
__nb_retries++; \
} while (__retvar == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) && __nb_retries < (__max_tries)); \
if (__retvar == -1 && __nb_retries >= (__max_tries)) __retvar = -2; \
} while (0)

network-aware retry macro: retries on EINTR and EAGAIN/EWOULDBLOCK

Definition at line 659 of file n_network.c.

Function Documentation

◆ __attribute__()

__attribute__ ( (unused)  )
Examples
ex_fluid.c, ex_gui_dictionary.c, and ex_gui_particles.c.

Definition at line 1233 of file n_network.c.

References mode, and netw_ssl_lockarray.

Referenced by main().

+ Here is the caller graph for this function:

◆ _n_mock_parse_request()

static void _n_mock_parse_request ( const char *  buf,
N_HTTP_REQUEST req 
)
static

Parse a raw HTTP request buffer into an N_HTTP_REQUEST.

Parameters
bufraw request data (null-terminated)
reqoutput request structure (must be zeroed by caller)

Definition at line 5352 of file n_network.c.

References N_HTTP_REQUEST::body, char_to_nstr(), N_HTTP_REQUEST::headers, list_push(), N_HTTP_REQUEST::method, new_generic_list(), N_HTTP_REQUEST::path, and N_HTTP_REQUEST::query.

Referenced by n_mock_server_run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _n_mock_request_clean()

static void _n_mock_request_clean ( N_HTTP_REQUEST req)
static

Free the contents of an N_HTTP_REQUEST (does not free the struct itself).

Parameters
reqrequest to clean

Definition at line 5429 of file n_network.c.

References N_HTTP_REQUEST::body, free_nstr, N_HTTP_REQUEST::headers, and list_destroy().

Referenced by n_mock_server_run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _n_parse_query_params()

static void _n_parse_query_params ( N_URL u,
const char *  qs 
)
static

Definition at line 5579 of file n_network.c.

References N_URL_PARAM::key, N_URL_MAX_PARAMS, N_URL::nb_params, N_URL::params, and N_URL_PARAM::value.

Referenced by n_url_parse().

+ Here is the caller graph for this function:

◆ _netw_capture_connect_error()

static void _netw_capture_connect_error ( const char *  fmt,
  ... 
)
static

capture a pre-connection error (thread-local)

Definition at line 84 of file n_network.c.

References s_connect_err_count, s_connect_err_next, and s_connect_errors.

Referenced by netw_connect_ex().

+ Here is the caller graph for this function:

◆ _netw_capture_error()

◆ _proxy_tcp_connect()

static int _proxy_tcp_connect ( const char *  host,
int  port 
)
static

Helper: connect a plain TCP socket to host:port.

Parameters
hosthostname
portport number
Returns
socket fd on success, -1 on failure.

Definition at line 5711 of file n_network.c.

References LOG_ERR, n_log, port, and port_str.

Referenced by n_proxy_connect_socks5(), n_proxy_connect_tunnel(), and n_proxy_connect_tunnel_ssl().

+ Here is the caller graph for this function:

◆ _sse_read_byte()

static ssize_t _sse_read_byte ( NETWORK netw,
char *  ch,
volatile int *  stop_flag 
)
static

read one byte from an SSE connection (SSL or plain).

Uses a short poll timeout so the caller can check stop_flag.

Parameters
netwNETWORK connection
choutput byte
stop_flagpointer to atomic stop flag (checked on timeout)
Returns
1 on success, 0 on timeout (retry), -1 on error or EOF

Definition at line 5112 of file n_network.c.

References __n_assert, NETWORK::crypto_algo, NETWORK::link, netw, NETW_ENCRYPT_OPENSSL, N_SOCKET::sock, and NETWORK::ssl.

Referenced by n_sse_connect().

+ Here is the caller graph for this function:

◆ _sse_write()

static ssize_t _sse_write ( NETWORK netw,
const void *  buf,
size_t  len 
)
static

write bytes to an SSE connection (SSL or plain)

Parameters
netwNETWORK connection
bufdata to write
lennumber of bytes
Returns
number of bytes written, or -1 on error

Definition at line 5155 of file n_network.c.

References __n_assert, NETWORK::crypto_algo, NETWORK::link, netw, NETW_ENCRYPT_OPENSSL, N_SOCKET::sock, and NETWORK::ssl.

Referenced by n_sse_connect().

+ Here is the caller graph for this function:

◆ _ws_read()

static ssize_t _ws_read ( N_WS_CONN conn,
void *  buf,
size_t  len 
)
static

read exactly len bytes from a WebSocket connection

Parameters
connWebSocket connection
bufoutput buffer
lennumber of bytes to read
Returns
number of bytes read, or -1 on error

Definition at line 4645 of file n_network.c.

References __n_assert, NETWORK::crypto_algo, NETWORK::link, N_WS_CONN::netw, NETW_ENCRYPT_OPENSSL, N_SOCKET::sock, and NETWORK::ssl.

Referenced by n_ws_recv().

+ Here is the caller graph for this function:

◆ _ws_write()

static ssize_t _ws_write ( N_WS_CONN conn,
const void *  buf,
size_t  len 
)
static

write bytes to a WebSocket connection (SSL or plain)

Parameters
connWebSocket connection
bufdata to write
lennumber of bytes
Returns
number of bytes written, or -1 on error

Definition at line 4629 of file n_network.c.

References __n_assert, NETWORK::crypto_algo, NETWORK::link, N_WS_CONN::netw, NETW_ENCRYPT_OPENSSL, N_SOCKET::sock, and NETWORK::ssl.

Referenced by n_ws_connect(), and n_ws_send().

+ Here is the caller graph for this function:

◆ get_in_addr()

char * get_in_addr ( struct sockaddr *  sa)

get sockaddr, IPv4 or IPv6

Parameters
saaddrinfo to get
Returns
socket address

Definition at line 811 of file n_network.c.

Referenced by netw_accept_from_ex(), netw_bind_udp(), netw_connect_ex(), netw_connect_udp(), and netw_make_listening().

+ Here is the caller graph for this function:

◆ netw_get_openssl_error_string()

char * netw_get_openssl_error_string ( )

get the OpenSSL error string

Returns
allocated string containing the error messages, or NULL

Definition at line 1160 of file n_network.c.

◆ netw_init_locks()

static void netw_init_locks ( void  )
static

Definition at line 1250 of file n_network.c.

References netw_ssl_lockarray.

Referenced by netw_init_openssl().

+ Here is the caller graph for this function:

◆ netw_kill_locks()

static void netw_kill_locks ( void  )
static

Definition at line 1264 of file n_network.c.

References netw_ssl_lockarray.

Referenced by netw_unload_openssl().

+ Here is the caller graph for this function:

◆ netw_new()

NETWORK * netw_new ( size_t  send_list_limit,
size_t  recv_list_limit 
)

Return an empty allocated network ready to be netw_closed.

Parameters
send_list_limitThread engine number of tosend message limit. From UNLIMITED_LIST_ITEMS (0) to MAX_LIST_ITEMS (SIZE_MAX).
recv_list_limitThread engine number of received message limit. From UNLIMITED_LIST_ITEMS (0) to MAX_LIST_ITEMS (SIZE_MAX).
Returns
NULL or a new empty network

Definition at line 703 of file n_network.c.

References __n_assert, NETWORK::addr_infos_loaded, NETWORK::certificate, NETWORK::crypto_algo, NETWORK::ctx, NETWORK::deplete_queues_timeout, NETWORK::deplete_socket_timeout, NETWORK::eventbolt, Free, N_SOCKET::hints, N_SOCKET::ip, N_SOCKET::is_blocking, NETWORK::key, NETWORK::link, LOG_ERR, Malloc, MAX_LIST_ITEMS, NETWORK::method, NETWORK::mode, n_log, NETWORK::nb_pending, NETWORK::nb_running_threads, netw, netw_atomic_write_state, netw_close(), NETW_ENCRYPT_NONE, NETW_EXITED, NETW_THR_ENGINE_STOPPED, NETWORK_TCP, new_generic_list(), NETWORK::pools, N_SOCKET::port, N_SOCKET::raddr, NETWORK::recv_buf, NETWORK::recv_data, recv_data(), NETWORK::recvbolt, NETWORK::send_blocker, NETWORK::send_buf, NETWORK::send_data, send_data(), NETWORK::send_queue_consecutive_wait, NETWORK::sendbolt, NETWORK::so_keepalive, NETWORK::so_linger, NETWORK::so_rcvbuf, NETWORK::so_rcvtimeo, NETWORK::so_reuseaddr, NETWORK::so_sndbuf, NETWORK::so_sndtimeo, N_SOCKET::sock, NETWORK::ssl, NETWORK::tcpnodelay, NETWORK::threaded_engine_status, NETWORK::transport_type, NETWORK::user_id, and NETWORK::wait_close_timeout.

Referenced by netw_accept_from_ex(), netw_bind_udp(), netw_connect_ex(), netw_connect_udp(), and netw_make_listening().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ netw_ssl_print_errors()

void netw_ssl_print_errors ( SOCKET  socket)

print OpenSSL errors for a given socket

Parameters
socketthe socket to report errors for

Definition at line 1187 of file n_network.c.

References LOG_ERR, and n_log.

Referenced by netw_accept_from_ex(), netw_set_crypto(), netw_set_crypto_chain(), netw_set_crypto_pem(), netw_ssl_connect_client(), netw_ssl_do_handshake(), netw_ssl_set_ca(), and netw_ssl_set_client_cert().

+ Here is the caller graph for this function:

Variable Documentation

◆ N_ENUM_netw_code_type

N_ENUM_netw_code_type

network error code

Definition at line 127 of file n_network.c.

◆ netw_ssl_lockarray

pthread_mutex_t* netw_ssl_lockarray
static

Definition at line 1231 of file n_network.c.

Referenced by __attribute__(), netw_init_locks(), and netw_kill_locks().

◆ OPENSSL_IS_INITIALIZED

int OPENSSL_IS_INITIALIZED = 0
static

Definition at line 1274 of file n_network.c.

Referenced by netw_init_openssl(), and netw_unload_openssl().

◆ s_connect_err_count

__thread int s_connect_err_count = 0
static

◆ s_connect_err_next

__thread int s_connect_err_next = 0
static

◆ s_connect_errors

__thread char s_connect_errors[8][512]
static

Definition at line 68 of file n_network.c.

Referenced by _netw_capture_connect_error(), and n_netw_get_connect_error().