|  | Nilorea Library
    C utilities for networking, threading, graphics | 
| Data Structures | |
| struct | N_SOCKET | 
| Structure of a N_SOCKET.  More... | |
| struct | NETWORK | 
| Structure of a NETWORK.  More... | |
| struct | NETWORK_HTTP_INFO | 
| structure for splitting HTTP requests  More... | |
| struct | NETWORK_POOL | 
| structure of a network pool  More... | |
| Macros | |
| #define | _OPEN_SYS_SOCK_IPV6 1 | 
| #define | HEAD_CODE 3 | 
| Code of a HEAD message. | |
| #define | HEAD_SIZE 10 | 
| Size of a HEAD message. | |
| #define | N_ENUM_netw_code_type(_) | 
| Network codes definition. | |
| #define | NETW_MAX_RETRIES 8 | 
| Send or recv max number of retries. | |
| #define | NETW_RETRY_DELAY 1000 | 
| Send or recv delay between retries in usec. | |
| #define | NETW_SOCKET_DISCONNECTED -2 | 
| Code for a disconnected recv. | |
| #define | NETW_SOCKET_ERROR -1 | 
| code for a socekt error | |
| #define | NETWORK_CONSECUTIVE_SEND_WAIT 2048 | 
| Flag to set consecutive send waiting timeout | |
| #define | NETWORK_DEPLETE_QUEUES_TIMEOUT 1024 | 
| Flag to set network queues depletion timeout | |
| #define | NETWORK_DEPLETE_SOCKET_TIMEOUT 512 | 
| Flag to set send buffer depletion timeout | |
| #define | NETWORK_IPALL 0 | 
| Flag for auto detection by OS of ip version to use. | |
| #define | NETWORK_IPV4 1 | 
| Flag to force IPV4 | |
| #define | NETWORK_IPV6 2 | 
| Flag to force IPV6 | |
| #define | NETWORK_WAIT_CLOSE_TIMEOUT 4096 | 
| Flag to set network closing wait timeout. | |
| #define | SOCKET_SIZE_FORMAT "%d" | 
| socket associated printf style | |
| Typedefs | |
| typedef ssize_t(* | netw_func) (void *, char *, uint32_t) | 
| send/recv func ptr type | |
| typedef int | SOCKET | 
| default socket declaration | |
| Enumerations | |
| enum | __netw_code_type { NETW_CLIENT = 2 , NETW_SERVER = 4 , NETW_RESTART_TIMER = 8 , NETW_EMPTY_SENDBUF = 16 , NETW_EMPTY_RECVBUF = 32 , NETW_RUN = 64 , NETW_EXIT_ASKED = 128 , NETW_EXITED = 256 , NETW_ERROR = 512 , NETW_ENCRYPT_NONE = 1024 , NETW_ENCRYPT_OPENSSL = 2048 , NETW_THR_ENGINE_STARTED = 4096 , NETW_THR_ENGINE_STOPPED = 8192 , NETW_DESTROY_RECVBUF = 16384 , NETW_DESTROY_SENDBUF = 32768 , ____netw_code_type_UNKNOWN_VALUE__ } | 
| Network codes declaration.  More... | |
| Functions | |
| int | deplete_send_buffer (int fd, int timeout) | 
| wait until the socket is empty or timeout, checking each 100 msec. | |
| size_t | htonst (size_t value) | 
| host to network size_t | |
| NETWORK * | netw_accept_from (NETWORK *from) | 
| make a normal blocking 'accept' . | |
| NETWORK * | netw_accept_from_ex (NETWORK *from, size_t send_list_limit, size_t recv_list_limit, int blocking, int *retval) | 
| make a normal 'accept' . | |
| NETWORK * | netw_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_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_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_STR * | netw_get_msg (NETWORK *netw) | 
| Get a message from aimed NETWORK. | |
| 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 | |
| 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. | |
| int | netw_make_listening (NETWORK **netw, char *addr, char *port, int nbpending, int ip_version) | 
| Make a NETWORK be a Listening network. | |
| NETWORK_POOL * | netw_new_pool (size_t nb_min_element) | 
| return a new network pool of nb_min_element | |
| HASH_TABLE * | netw_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, 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_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_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. | |
| 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 | |
| int | netw_wait_close (NETWORK **netw) | 
| int | netw_wait_close_timed (NETWORK **netw, size_t timeout) | 
| N_STR * | netw_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 | 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 | |
| struct N_SOCKET | 
Structure of a N_SOCKET.
Definition at line 219 of file n_network.h.
 Collaboration diagram for N_SOCKET:
 Collaboration diagram for N_SOCKET:| Data Fields | ||
|---|---|---|
| struct addrinfo | hints | address of local machine | 
| char * | ip | ip of the connected socket | 
| unsigned long int | is_blocking | flag to quickly check socket mode | 
| char * | port | port of socket | 
| struct sockaddr_storage | raddr | connected remote addr | 
| struct addrinfo * | rhost | getaddrinfo results | 
| SOCKET | sock | a normal socket | 
| struct NETWORK | 
Structure of a NETWORK.
Definition at line 239 of file n_network.h.
 Collaboration diagram for NETWORK:
 Collaboration diagram for NETWORK:| Data Fields | ||
|---|---|---|
| int | addr_infos_loaded | Internal flag to know if we have to free addr infos. | 
| char * | certificate | openssl certificate file | 
| int | crypto_algo | if encryption is on, which one (flags NETW_ENCRYPT_*) | 
| int | crypto_mode | tell if the socket have to be encrypted (flags NETW_CRYPTO_*) | 
| SSL_CTX * | ctx | SSL context holder. | 
| int | deplete_queues_timeout | deplete network queues timeout ( 0 disabled, > 0 wait for timeout and check unset/unack datas) | 
| int | deplete_socket_timeout | deplete socket send buffer timeout ( 0 disabled, > 0 wait for timeout and check unset/unack datas) | 
| pthread_mutex_t | eventbolt | mutex for threaded access of state event | 
| char * | key | openssl key file | 
| N_SOCKET | link | networking socket | 
| const SSL_METHOD * | method | SSL method container. | 
| int | mode | NETWORK mode , 1 listening, 0 connecting. | 
| int | nb_pending | Nb pending connection,if listening. | 
| int | nb_running_threads | nb running threads, if > 0 thread engine is still running | 
| LIST * | pools | pointers to network pools if members of any | 
| LIST * | recv_buf | reveicing buffer (for incomming usage) | 
| netw_func | recv_data | receive func ptr | 
| pthread_t | recv_thr | receiving thread | 
| pthread_mutex_t | recvbolt | mutex for threaded access of recv buf | 
| sem_t | send_blocker | block sending func | 
| LIST * | send_buf | sending buffer (for outgoing queuing ) | 
| netw_func | send_data | send func ptr | 
| int | send_queue_consecutive_wait | send queue consecutive pool interval, used when there are still items to send, in usec | 
| pthread_t | send_thr | sending thread | 
| pthread_mutex_t | sendbolt | mutex for threaded access of send_buf | 
| int | so_keepalive | so keepalive state | 
| int | so_linger | close lingering value (-1 disabled, 0 force close, >0 linger ) | 
| int | so_rcvbuf | size of the socket recv buffer, 0 untouched, else size in bytes | 
| int | so_rcvtimeo | send timeout value | 
| int | so_reuseaddr | so reuseaddr state | 
| int | so_sndbuf | size of the socket send buffer, 0 untouched, else size in bytes | 
| int | so_sndtimeo | send timeout value | 
| SSL * | ssl | SSL handle. | 
| uint32_t | state | state of the connection , NETW_RUN, NETW_QUIT, NETW_STOP , NETW_ERR | 
| int | tcpnodelay | state of naggle algorythm, 0 untouched, 1 forcibly disabled | 
| int | threaded_engine_status | Threaded network engine state for this network. NETW_THR_ENGINE_STARTED or NETW_THR_ENGINE_STOPPED | 
| int | user_id | if part of a user property, id of the user | 
| int | wait_close_timeout | network wait close timeout value ( < 1 disabled, >= 1 timeout sec ) | 
| struct NETWORK_HTTP_INFO | 
structure for splitting HTTP requests
Definition at line 342 of file n_network.h.
 Collaboration diagram for NETWORK_HTTP_INFO:
 Collaboration diagram for NETWORK_HTTP_INFO:| Data Fields | ||
|---|---|---|
| char * | body | |
| size_t | content_length | |
| char | content_type[256] | |
| char * | type | |
| struct NETWORK_POOL | 
structure of a network pool
Definition at line 332 of file n_network.h.
 Collaboration diagram for NETWORK_POOL:
 Collaboration diagram for NETWORK_POOL:| Data Fields | ||
|---|---|---|
| HASH_TABLE * | pool | table of clients | 
| pthread_rwlock_t | rwlock | thread safety | 
| #define _OPEN_SYS_SOCK_IPV6 1 | 
Definition at line 188 of file n_network.h.
| #define HEAD_CODE 3 | 
Code of a HEAD message.
Definition at line 43 of file n_network.h.
| #define HEAD_SIZE 10 | 
Size of a HEAD message.
Definition at line 41 of file n_network.h.
| #define N_ENUM_netw_code_type | ( | _ | ) | 
Network codes definition.
Definition at line 195 of file n_network.h.
| #define NETW_MAX_RETRIES 8 | 
Send or recv max number of retries.
Definition at line 49 of file n_network.h.
| #define NETW_RETRY_DELAY 1000 | 
Send or recv delay between retries in usec.
Definition at line 51 of file n_network.h.
| #define NETW_SOCKET_DISCONNECTED -2 | 
Code for a disconnected recv.
Definition at line 47 of file n_network.h.
| #define NETW_SOCKET_ERROR -1 | 
code for a socekt error
Definition at line 45 of file n_network.h.
| #define NETWORK_CONSECUTIVE_SEND_WAIT 2048 | 
Flag to set consecutive send waiting timeout 
 
Definition at line 37 of file n_network.h.
| #define NETWORK_DEPLETE_QUEUES_TIMEOUT 1024 | 
Flag to set network queues depletion timeout 
 
Definition at line 35 of file n_network.h.
| #define NETWORK_DEPLETE_SOCKET_TIMEOUT 512 | 
Flag to set send buffer depletion timeout 
 
Definition at line 33 of file n_network.h.
| #define NETWORK_IPALL 0 | 
Flag for auto detection by OS of ip version to use.
Definition at line 27 of file n_network.h.
| #define NETWORK_IPV4 1 | 
Flag to force IPV4 
 
Definition at line 29 of file n_network.h.
| #define NETWORK_IPV6 2 | 
Flag to force IPV6 
 
Definition at line 31 of file n_network.h.
| #define NETWORK_WAIT_CLOSE_TIMEOUT 4096 | 
Flag to set network closing wait timeout.
Definition at line 39 of file n_network.h.
| #define SOCKET_SIZE_FORMAT "%d" | 
| typedef ssize_t(* netw_func) (void *, char *, uint32_t) | 
send/recv func ptr type
Definition at line 216 of file n_network.h.
| typedef int SOCKET | 
| enum __netw_code_type | 
Network codes declaration.
Definition at line 213 of file n_network.h.
| int deplete_send_buffer | ( | int | fd, | 
| int | timeout | ||
| ) | 
wait until the socket is empty or timeout, checking each 100 msec.
Not as reliable as expected.
| fd | socket descriptor | 
| timeout | timeout value in msec , value <= 0 : disabled | 
Definition at line 1472 of file n_network.c.
References LOG_ERR, and n_log.
Referenced by netw_close().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| size_t htonst | ( | size_t | value | ) | 
host to network size_t
| value | the size_t value to convert to network order | 
Definition at line 30 of file n_network.c.
make a normal blocking 'accept' .
Network 'from' must be allocated with netw_make_listening.
| from | The network from which to obtaion the connection | 
Definition at line 1910 of file n_network.c.
References MAX_LIST_ITEMS, and netw_accept_from_ex().
Referenced by main().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| NETWORK * netw_accept_from_ex | ( | NETWORK * | from, | 
| size_t | send_list_limit, | ||
| size_t | recv_list_limit, | ||
| int | blocking, | ||
| int * | retval | ||
| ) | 
make a normal 'accept' .
Network 'from' must be allocated with netw_make_listening.
| from | the network from where we accept | 
| send_list_limit | Internal sending list maximum number of item. 0 for unrestricted | 
| recv_list_limit | Internal receiving list maximum number of item. 0 for unrestricted | 
| blocking | set to -1 to make it non blocking, to 0 for blocking, else it's the select timeout value in msecs. | 
| retval | EAGAIN ou EWOULDBLOCK or neterrno (use netstrerr( retval) to obtain a string describing the code ) | 
Definition at line 1753 of file n_network.c.
References __n_assert, _str, NETWORK::crypto_algo, NETWORK::ctx, FreeNoLog, get_in_addr(), N_SOCKET::ip, N_SOCKET::is_blocking, NETWORK::link, LOG_DEBUG, LOG_ERR, Malloc, n_log, neterrno, netstrerror, netw, netw_close(), NETW_ENCRYPT_OPENSSL, netw_init_wsa(), netw_new(), NETW_RUN, NETW_SERVER, netw_set(), netw_set_blocking(), netw_setsockopt(), netw_ssl_print_errors(), NETW_THR_ENGINE_STOPPED, N_SOCKET::port, N_SOCKET::raddr, NETWORK::recv_data, recv_ssl_data(), NETWORK::send_data, send_ssl_data(), N_SOCKET::sock, and NETWORK::ssl.
Referenced by main(), main(), netw_accept_from(), and netw_accept_nonblock_from().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:make a normal blocking 'accept' .
Network 'from' must be allocated with netw_make_listening.
| from | The network from which to obtaion the connection | 
| blocking | set to -1 to make it non blocking, to 0 for blocking, else it's the select timeout value in mseconds. | 
Definition at line 1920 of file n_network.c.
References MAX_LIST_ITEMS, and netw_accept_from_ex().
 Here is the call graph for this function:
 Here is the call graph for this function:Add a message to send in aimed NETWORK.
| netw | NETWORK where add the message | 
| msg | the message to add | 
Definition at line 1930 of file n_network.c.
References __n_assert, N_STR::data, free_nstr_ptr(), N_STR::length, list_push(), LOG_ERR, n_log, netw, NETWORK::send_blocker, NETWORK::send_buf, and NETWORK::sendbolt.
Referenced by netw_pool_broadcast(), netw_send_ident(), netw_send_ping(), netw_send_position(), netw_send_quit(), netw_send_string_to(), netw_send_string_to_all(), send_net_datas(), userlist_add_msg_to_ex(), userlist_send_waiting_msgs(), and userlist_user_send_waiting_msgs().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_add_msg_ex | ( | NETWORK * | netw, | 
| char * | str, | ||
| unsigned int | length | ||
| ) | 
Add a message to send in aimed NETWORK.
| netw | NETWORK where add the message | 
| str | the message to add | 
| length | the size of the message to add | 
Definition at line 1961 of file n_network.c.
References __n_assert, N_STR::data, free_nstr_ptr(), N_STR::length, list_push(), LOG_ERR, Malloc, n_log, netw, NETWORK::send_blocker, NETWORK::send_buf, NETWORK::sendbolt, and N_STR::written.
 Here is the call graph for this function:
 Here is the call graph for this function:| 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
| http_response | pointer to a N_STR *response. Will be set to the response, or NULL | 
| status_code | response http status code | 
| server_name | response 'Server' in headers | 
| content_type | response 'Content-Type' in headers | 
| additional_headers | additional response headers, can be "" if no additional headers, else 'backslash r backslash n' separated key: values | 
| body | response 'Server' in headers | 
Definition at line 3544 of file n_network.c.
References __n_assert, LOG_DEBUG, n_log, netw_get_http_date(), netw_get_http_status_message(), nstrcat, nstrprintf, and N_STR::written.
Referenced by handle_request().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| size_t netw_calculate_urlencoded_size | ( | const char * | str, | 
| size_t | len | ||
| ) | 
function to calculate the required size for the URL-encoded string
| str | clear string from which we want to know the urlencoded size | 
| len | length of the input string | 
Definition at line 3132 of file n_network.c.
References __n_assert.
Referenced by netw_urlencode().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_close | ( | NETWORK ** | netw | ) | 
Closing a specified Network, destroy queues, free the structure.
| netw | A NETWORK *network to close | 
Definition at line 1503 of file n_network.c.
References __n_assert, _str, deplete_send_buffer(), Free, FreeNoLog, list_destroy(), list_foreach, LOG_DEBUG, LOG_ERR, N_ENUM_ENTRY, n_log, neterrno, netstrerror, netw, NETW_DESTROY_RECVBUF, NETW_DESTROY_SENDBUF, NETW_ENCRYPT_OPENSSL, netw_get_state(), netw_pool_remove(), netw_set(), netw_stop_thr_engine(), and NETW_THR_ENGINE_STARTED.
Referenced by handle_request(), main(), main(), manage_client(), netw_accept_from_ex(), netw_connect_ex(), netw_make_listening(), netw_new(), netw_set_blocking(), and ssl_network_thread().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
| netw | a NETWORK *object | 
| host | Host or IP to connect to | 
| port | Port to use to connect | 
| ip_version | NETWORK_IPALL for both ipv4 and ipv6 , NETWORK_IPV4 or NETWORK_IPV6 | 
Definition at line 1359 of file n_network.c.
References _str, ip_version, LOG_INFO, MAX_LIST_ITEMS, n_log, netw, netw_connect_ex(), and port.
Referenced by main().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
| netw | a NETWORK *object | 
| host | Host or IP to connect to | 
| port | Port to use to connect | 
| send_list_limit | Internal sending list maximum number of item. From UNLIMITED_LIST_ITEMS (0) to MAX_LIST_ITEMS (SIZE_MAX). | 
| recv_list_limit | Internal receiving list maximum number of item. From UNLIMITED_LIST_ITEMS (0) to MAX_LIST_ITEMS (SIZE_MAX). | 
| ip_version | NETWORK_IPALL for both ipv4 and ipv6 , NETWORK_IPV4 or NETWORK_IPV6 | 
| ssl_key_file | NULL or the path to the SSL key file to use. If set, a ssl_cert_file must also be provided | 
| ssl_cert_file | NULL or the path to the SSL certificate file to use. If set, a ssl_key_file must also be provided | 
Definition at line 1222 of file n_network.c.
References __n_assert, _str, Free, FreeNoLog, get_in_addr(), ip_version, LOG_DEBUG, LOG_ERR, LOG_INFO, Malloc, n_log, neterrno, netstrerror, netw, NETW_CLIENT, netw_close(), netw_init_wsa(), netw_new(), NETW_RUN, netw_set(), netw_set_crypto(), NETW_THR_ENGINE_STOPPED, NETWORK_IPV4, NETWORK_IPV6, and port.
Referenced by netw_connect(), and netw_ssl_connect().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_destroy_pool | ( | NETWORK_POOL ** | netw_pool | ) | 
free a NETWORK_POOL *pool
| netw_pool | the address of a NETWORK_POOL *pointer to free | 
Definition at line 2848 of file n_network.c.
References __n_assert, destroy_ht(), Free, rw_lock_destroy, unlock, and write_lock.
 Here is the call graph for this function:
 Here is the call graph for this function:| NETWORK_HTTP_INFO netw_extract_http_info | ( | char * | request | ) | 
extract a lot of informations, mostly as pointers, and populate a NETWORK_HTTP_INFO structure
| request | the raw http request string | 
Definition at line 3221 of file n_network.c.
References __n_assert, NETWORK_HTTP_INFO::body, NETWORK_HTTP_INFO::content_length, NETWORK_HTTP_INFO::content_type, LOG_ERR, n_log, netw_extract_http_request_type(), and NETWORK_HTTP_INFO::type.
Referenced by handle_request().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| char * netw_extract_http_request_type | ( | const char * | request | ) | 
function to extract the request method from an http request
| request | the raw http request | 
Definition at line 3188 of file n_network.c.
References __n_assert.
Referenced by netw_extract_http_info().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_get_http_date | ( | char * | buffer, | 
| size_t | buffer_size | ||
| ) | 
helper function to generate the current date in HTTP format
| buffer | the target buffer, must be big enough to hold the date | 
| buffer_size | the size of the target buffer | 
Definition at line 3512 of file n_network.c.
References __n_assert, LOG_ERR, and n_log.
Referenced by netw_build_http_response().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| const char * netw_get_http_status_message | ( | int | status_code | ) | 
helper function to convert status code to a human-readable message
| status_code | the code to convert into a human-readable message | 
Definition at line 3488 of file n_network.c.
Referenced by netw_build_http_response().
 Here is the caller graph for this function:
 Here is the caller graph for this function:Get a message from aimed NETWORK.
| netw | NETWORK where get the msg | 
Definition at line 1997 of file n_network.c.
References __n_assert, list_shift, netw, NETWORK::recv_buf, and NETWORK::recvbolt.
Referenced by manage_client(), and netw_wait_msg().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_get_queue_status | ( | NETWORK * | netw, | 
| size_t * | nb_to_send, | ||
| size_t * | nb_to_read | ||
| ) | 
retrieve network send queue status
| netw | NETWORK object | 
| nb_to_send | Number of messages still in send buffer (not yet submitted to kernel) | 
| nb_to_read | Number of message already read by the kernel, waiting in the local message list | 
Definition at line 2810 of file n_network.c.
References __n_assert, LIST::nb_items, netw, NETWORK::recv_buf, NETWORK::recvbolt, NETWORK::send_buf, and NETWORK::sendbolt.
| int netw_get_state | ( | NETWORK * | netw, | 
| uint32_t * | state, | ||
| int * | thr_engine_status | ||
| ) | 
Get the state of a network.
| netw | The NETWORK *connection to query | 
| state | pointer to network status storage , NETW_RUN , NETW_EXIT_ASKED , NETW_EXITED | 
| thr_engine_status | pointer to network thread engine status storage ,NETW_THR_ENGINE_STARTED , NETW_THR_ENGINE_STOPPED | 
Definition at line 1388 of file n_network.c.
References LOG_ERR, n_log, netw, NETWORK::sendbolt, NETWORK::state, and NETWORK::threaded_engine_status.
Referenced by manage_client(), netw_close(), netw_recv_func(), netw_send_func(), netw_stop_thr_engine(), and netw_wait_msg().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
| request | raw http request to decode | 
| url | pointer to an allocated char *holder | 
| size | the size of the url holder | 
Definition at line 3303 of file n_network.c.
References __n_assert.
Referenced by handle_request().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| const char * netw_guess_http_content_type | ( | const char * | url | ) | 
function to guess the content type based on URL extension
| url | the url from which we want to guess the content type | 
Definition at line 3424 of file n_network.c.
References __n_assert.
Referenced by handle_request().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_info_destroy | ( | NETWORK_HTTP_INFO | http_request | ) | 
destroy a NETWORK_HTTP_INFO loaded informations
| http_request | the parsed NETWORK_HTTP_INFO request | 
Definition at line 3290 of file n_network.c.
References NETWORK_HTTP_INFO::body, FreeNoLog, and NETWORK_HTTP_INFO::type.
Referenced by handle_request().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_init_openssl | ( | void | ) | 
Do not directly use, internal api.
Initialize openssl
Definition at line 1116 of file n_network.c.
References netw_init_locks().
Referenced by netw_set_crypto().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_init_wsa | ( | int | mode, | 
| int | v1, | ||
| int | v2 | ||
| ) | 
Do not directly use, internal api.
Initialize winsock dll loading on windows if needed.
| mode | 1 for opening 0 for close 2 for status | 
| v1 | First digit of version requested | 
| v2 | Second digit of version requested | 
Definition at line 693 of file n_network.c.
References mode.
Referenced by netw_accept_from_ex(), netw_connect_ex(), and netw_make_listening().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_make_listening | ( | NETWORK ** | netw, | 
| char * | addr, | ||
| char * | port, | ||
| int | nbpending, | ||
| int | ip_version | ||
| ) | 
Make a NETWORK be a Listening network.
| netw | A NETWORK **network to make listening | 
| addr | Address to bind, NULL for automatic address filling | 
| port | For choosing a PORT to listen to | 
| nbpending | Number of pending connection when listening | 
| ip_version | NETWORK_IPALL for both ipv4 and ipv6 , NETWORK_IPV4 or NETWORK_IPV6 | 
Definition at line 1644 of file n_network.c.
References __n_assert, _str, addr, FreeNoLog, get_in_addr(), ip_version, LOG_ERR, Malloc, MAX_LIST_ITEMS, n_log, neterrno, netstrerror, netw, netw_close(), netw_init_wsa(), netw_new(), NETW_RUN, NETW_SERVER, netw_set(), netw_setsockopt(), NETW_THR_ENGINE_STOPPED, NETWORK_IPV4, NETWORK_IPV6, and port.
Referenced by main(), and main().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| NETWORK_POOL * netw_new_pool | ( | size_t | nb_min_element | ) | 
return a new network pool of nb_min_element
| nb_min_element | size of internal hash table for network pool | 
Definition at line 2829 of file n_network.c.
References __n_assert, Free, init_lock, Malloc, new_ht(), NETWORK_POOL::pool, and NETWORK_POOL::rwlock.
 Here is the call graph for this function:
 Here is the call graph for this function:| HASH_TABLE * netw_parse_post_data | ( | const char * | post_data | ) | 
Function to parse POST data.
| post_data | the post data to parse | 
Definition at line 3377 of file n_network.c.
References __n_assert, ht_put_string(), key, netw_urldecode(), and new_ht().
Referenced by handle_request().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_pool_add | ( | NETWORK_POOL * | netw_pool, | 
| NETWORK * | netw | ||
| ) | 
add a NETWORK *netw to a NETWORK_POOL *pool
| netw_pool | targeted network pool | 
| netw | network to add | 
Definition at line 2880 of file n_network.c.
References __n_assert, _nstr, free_nstr, ht_get_ptr(), ht_put_ptr(), key, NETWORK::link, list_push(), LOG_DEBUG, LOG_ERR, n_log, netw, netw_pool_netw_close(), nstrprintf, NETWORK_POOL::pool, NETWORK::pools, NETWORK_POOL::rwlock, N_SOCKET::sock, unlock, and write_lock.
 Here is the call graph for this function:
 Here is the call graph for this function:| int netw_pool_broadcast | ( | NETWORK_POOL * | netw_pool, | 
| NETWORK * | from, | ||
| N_STR * | net_msg | ||
| ) | 
add net_msg to all network in netork pool
| netw_pool | targeted network pool | 
| from | source network | 
| net_msg | mesage to broadcast | 
Definition at line 2958 of file n_network.c.
References __n_assert, hash_val, ht_foreach, NETWORK::link, netw, netw_add_msg(), nstrdup(), NETWORK_POOL::pool, read_lock, NETWORK_POOL::rwlock, N_SOCKET::sock, and unlock.
 Here is the call graph for this function:
 Here is the call graph for this function:| size_t netw_pool_nbclients | ( | NETWORK_POOL * | netw_pool | ) | 
return the number of networks in netw_pool
| netw_pool | targeted network pool | 
Definition at line 2982 of file n_network.c.
References __n_assert, HASH_TABLE::nb_keys, NETWORK_POOL::pool, read_lock, NETWORK_POOL::rwlock, and unlock.
| void netw_pool_netw_close | ( | void * | netw_ptr | ) | 
close a network from a network pool
| netw_ptr | NETWORK *network pointer | 
Definition at line 2867 of file n_network.c.
References __n_assert, NETWORK::link, LOG_DEBUG, n_log, netw, and N_SOCKET::sock.
Referenced by netw_pool_add().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_pool_remove | ( | NETWORK_POOL * | netw_pool, | 
| NETWORK * | netw | ||
| ) | 
remove a NETWORK *netw to a NETWORK_POOL *pool
| netw_pool | targeted network pool | 
| netw | network to remove | 
Definition at line 2923 of file n_network.c.
References __n_assert, _nstr, free_nstr, ht_remove(), key, NETWORK::link, list_search(), LOG_DEBUG, LOG_ERR, n_log, netw, nstrprintf, NETWORK_POOL::pool, NETWORK::pools, remove_list_node, NETWORK_POOL::rwlock, N_SOCKET::sock, unlock, and write_lock.
Referenced by netw_close().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| void * netw_recv_func | ( | void * | NET | ) | 
To Thread Receiving function.
| NET | the NETWORK connection to use | 
Definition at line 2225 of file n_network.c.
References __n_assert, _str, N_STR::data, DONE, NETWORK::eventbolt, free_nstr_ptr(), N_SOCKET::ip, N_STR::length, NETWORK::link, list_push(), LOG_DEBUG, LOG_ERR, Malloc, n_log, NETWORK::nb_running_threads, netw, NETW_ERROR, NETW_EXIT_ASKED, NETW_EXITED, netw_get_state(), netw_set(), NETW_SOCKET_DISCONNECTED, NETWORK::recv_buf, NETWORK::recv_data, NETWORK::recvbolt, N_SOCKET::sock, and N_STR::written.
Referenced by netw_start_thr_engine().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| void * netw_send_func | ( | void * | NET | ) | 
Thread send function.
| NET | the NETWORK connection to use, casted into (void*) | 
Definition at line 2104 of file n_network.c.
References __n_assert, _str, N_STR::data, DONE, NETWORK::eventbolt, free_nstr, N_SOCKET::ip, N_STR::length, NETWORK::link, list_shift, LOG_DEBUG, LOG_ERR, n_log, NETWORK::nb_running_threads, netw, NETW_ERROR, NETW_EXIT_ASKED, NETW_EXITED, netw_get_state(), netw_set(), NETW_SOCKET_DISCONNECTED, NETWORK::send_blocker, NETWORK::send_buf, NETWORK::send_data, NETWORK::send_queue_consecutive_wait, NETWORK::sendbolt, N_SOCKET::sock, NETWORK::state, u_sleep(), and N_STR::written.
Referenced by netw_start_thr_engine().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:Add a formatted NETWMSG_IDENT message to the specified network.
| netw | The aimed NETWORK where we want to add something to send | 
| type | type of identification ( NETW_IDENT_REQUEST , NETW_IDENT_NEW ) | 
| id | The ID of the sending client | 
| name | Username | 
| passwd | Password | 
Definition at line 3033 of file n_network.c.
References __n_assert, netmsg_make_ident(), netw, and netw_add_msg().
 Here is the call graph for this function:
 Here is the call graph for this function:| int netw_send_ping | ( | NETWORK * | netw, | 
| int | type, | ||
| int | id_from, | ||
| int | id_to, | ||
| int | time | ||
| ) | 
Add a ping reply to the network.
| netw | The aimed NETWORK where we want to add something to send | 
| id_from | Identifiant of the sender | 
| id_to | Identifiant of the destination, -1 if the serveur itslef is targetted | 
| time | The time it was when the ping was sended | 
| type | NETW_PING_REQUEST or NETW_PING_REPLY | 
Definition at line 3014 of file n_network.c.
References __n_assert, netmsg_make_ping(), netw, and netw_add_msg().
 Here is the call graph for this function:
 Here is the call graph for this function:| 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.
| netw | The aimed NETWORK where we want to add something to send | 
| id | The ID of the sending client | 
| X | X position inside a big grid | 
| Y | Y position inside a big grid | 
| vx | X speed | 
| vy | Y speed | 
| acc_x | Y acceleration | 
| acc_y | X acceleration | 
| time_stamp | Current Time when sending (for some delta we would want to compute ) | 
Definition at line 3057 of file n_network.c.
References __n_assert, netmsg_make_position_msg(), netw, and netw_add_msg().
 Here is the call graph for this function:
 Here is the call graph for this function:| int netw_send_quit | ( | NETWORK * | netw | ) | 
Add a formatted NETMSG_QUIT message to the specified network.
| netw | The aimed NETWORK | 
Definition at line 3115 of file n_network.c.
References __n_assert, netmsg_make_quit_msg(), netw, and netw_add_msg().
 Here is the call graph for this function:
 Here is the call graph for this function:| 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.
| netw | The aimed NETWORK where we want to add something to send | 
| id_to | The ID of the targetted client | 
| name | Sender Name | 
| chan | channel to use | 
| txt | Sender text | 
| color | Sender text color | 
Definition at line 3079 of file n_network.c.
References __n_assert, netmsg_make_string_msg(), netw, netw_add_msg(), and NETWORK::user_id.
 Here is the call graph for this function:
 Here is the call graph for this function:Add a string to the network, aiming all server-side users.
| netw | The aimed NETWORK where we want to add something to send | 
| name | Name of user | 
| chan | Target Channel, if any. Pass "ALL" to target the default channel | 
| txt | The text to send | 
| color | The color of the text | 
Definition at line 3099 of file n_network.c.
References __n_assert, netmsg_make_string_msg(), netw, netw_add_msg(), and NETWORK::user_id.
 Here is the call graph for this function:
 Here is the call graph for this function:| int netw_set | ( | NETWORK * | netw, | 
| int | flag | ||
| ) | 
Restart or reset the specified network ability.
| netw | The NETWORK *connection to modify | 
| flag | NETW_EMPTY_SENDBUF, NETW_EMPTY_RECVBUF, NETW_RUN , NETW_EXIT_ASKED , NETW_EXITED | 
Definition at line 1409 of file n_network.c.
References NETWORK::eventbolt, list_destroy(), list_empty(), NETWORK::mode, netw, NETW_CLIENT, NETW_DESTROY_RECVBUF, NETW_DESTROY_SENDBUF, NETW_EMPTY_RECVBUF, NETW_EMPTY_SENDBUF, NETW_ERROR, NETW_EXIT_ASKED, NETW_EXITED, NETW_RUN, NETW_SERVER, NETW_THR_ENGINE_STARTED, NETW_THR_ENGINE_STOPPED, NETWORK::recv_buf, NETWORK::recvbolt, NETWORK::send_blocker, NETWORK::send_buf, NETWORK::sendbolt, NETWORK::state, and NETWORK::threaded_engine_status.
Referenced by netw_accept_from_ex(), netw_close(), netw_connect_ex(), netw_make_listening(), netw_recv_func(), netw_send_func(), and netw_stop_thr_engine().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_set_blocking | ( | NETWORK * | netw, | 
| unsigned long int | is_blocking | ||
| ) | 
Modify blocking socket mode.
| netw | The network to configure | 
| is_blocking | 0 NON BLOCk , 1 BLOCK | 
Definition at line 739 of file n_network.c.
References __n_assert, _str, FreeNoLog, N_SOCKET::is_blocking, NETWORK::link, LOG_DEBUG, LOG_ERR, n_log, neterrno, netstrerror, netw, netw_close(), and N_SOCKET::sock.
Referenced by netw_accept_from_ex().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_set_crypto | ( | NETWORK * | netw, | 
| char * | key, | ||
| char * | certificate | ||
| ) | 
activate SSL encryption on selected network, using key and certificate
| key | path to the key file | 
| certificate | path to the certificate file | 
Definition at line 1160 of file n_network.c.
References __n_assert, NETWORK::certificate, NETWORK::crypto_algo, NETWORK::ctx, key, NETWORK::key, NETWORK::link, NETWORK::method, netw, NETW_ENCRYPT_OPENSSL, netw_init_openssl(), netw_ssl_print_errors(), NETWORK::recv_data, recv_ssl_data(), NETWORK::send_data, send_ssl_data(), and N_SOCKET::sock.
Referenced by main(), main(), and netw_connect_ex().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_set_user_id | ( | NETWORK * | netw, | 
| int | id | ||
| ) | 
associate an id and a network
| netw | targeted network | 
| id | id we want to associated with | 
Definition at line 2999 of file n_network.c.
References __n_assert, netw, and NETWORK::user_id.
| int netw_setsockopt | ( | NETWORK * | netw, | 
| int | optname, | ||
| int | value | ||
| ) | 
Modify common socket options on the given netw.
| netw | The socket to configure | 
| optname | NETWORK_DEPLETE_SOCKET_TIMEOUT,NETWORK_DEPLETE_QUEUES_TIMEOUT,NETWORK_WAIT_CLOSE_TIMEOUT,NETWORK_CONSECUTIVE_SEND_WAIT ,SO_REUSEADDR,SO_REUSEPORT,SO_KEEPALIVE,TCP_NODELAY,SO_SNDBUF,SO_RCVBUF,SO_LINGER,SO_RCVTIMEO,SO_SNDTIMEO,TCP_USER_TIMEOUT. Please refer to man setsockopt for details | 
| value | The value of the socket parameter | 
Definition at line 794 of file n_network.c.
References __n_assert, _str, NETWORK::deplete_queues_timeout, NETWORK::deplete_socket_timeout, FreeNoLog, NETWORK::link, LOG_ERR, n_log, neterrno, netstrerror, netw, NETWORK_CONSECUTIVE_SEND_WAIT, NETWORK_DEPLETE_QUEUES_TIMEOUT, NETWORK_DEPLETE_SOCKET_TIMEOUT, NETWORK_WAIT_CLOSE_TIMEOUT, NETWORK::send_queue_consecutive_wait, 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::tcpnodelay, and NETWORK::wait_close_timeout.
Referenced by main(), netw_accept_from_ex(), and netw_make_listening().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| 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.
| netw | a NETWORK *object | 
| host | Host or IP to connect to | 
| port | Port to use to connect | 
| ip_version | NETWORK_IPALL for both ipv4 and ipv6 , NETWORK_IPV4 or NETWORK_IPV6 | 
| ssl_key_file | NULL or the path to the SSL key file to use. If set, a ssl_cert_file must also be provided | 
| ssl_cert_file | NULL or the path to the SSL certificate file to use. If set, a ssl_key_file must also be provided | 
Definition at line 1375 of file n_network.c.
References _str, ip_version, LOG_INFO, MAX_LIST_ITEMS, n_log, netw, netw_connect_ex(), and port.
Referenced by main().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_start_thr_engine | ( | NETWORK * | netw | ) | 
Start the NETWORK netw Threaded Engine.
Create a sending & receiving thread.
| netw | The aimed NETWORK connection to start receiving data | 
Definition at line 2069 of file n_network.c.
References __n_assert, _str, NETWORK::eventbolt, N_SOCKET::ip, NETWORK::link, LOG_ERR, n_log, NETWORK::nb_running_threads, netw, netw_recv_func(), netw_send_func(), NETW_THR_ENGINE_STARTED, NETWORK::recv_thr, NETWORK::send_thr, and NETWORK::threaded_engine_status.
Referenced by main(), and manage_client().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_stop_thr_engine | ( | NETWORK * | netw | ) | 
Stop a NETWORK connection sending and receing thread.
| netw | The aimed NETWORK conection to stop | 
Definition at line 2342 of file n_network.c.
References __n_assert, NETWORK::link, LOG_DEBUG, LOG_ERR, n_log, netw, NETW_EXIT_ASKED, NETW_EXITED, netw_get_state(), netw_set(), NETW_THR_ENGINE_STARTED, NETW_THR_ENGINE_STOPPED, NETWORK::recv_thr, NETWORK::send_blocker, NETWORK::send_thr, and N_SOCKET::sock.
Referenced by netw_close().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| int netw_unload_openssl | ( | void | ) | 
Do not directly use, internal api.
Initialize openssl
Definition at line 1140 of file n_network.c.
References netw_kill_locks().
 Here is the call graph for this function:
 Here is the call graph for this function:| char * netw_urldecode | ( | const char * | str | ) | 
Function to decode URL-encoded data.
| str | input string to decode | 
Definition at line 3340 of file n_network.c.
References __n_assert, Free, LOG_ERR, and n_log.
Referenced by netw_parse_post_data().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| char * netw_urlencode | ( | const char * | str, | 
| size_t | len | ||
| ) | 
function to perform URL encoding
| str | input string | 
| len | input string length | 
Definition at line 3155 of file n_network.c.
References __n_assert, and netw_calculate_urlencoded_size().
 Here is the call graph for this function:
 Here is the call graph for this function:| int netw_wait_close | ( | NETWORK ** | netw | ) | 
| int netw_wait_close_timed | ( | NETWORK ** | netw, | 
| size_t | timeout | ||
| ) | 
Wait a message from aimed NETWORK.
Recheck each usec until a valid
| netw | The link on which we wait a message | 
| refresh | The time in usec between each check until there is a message | 
| timeout | in usecs , maximum amount of time to wait before return. 0 to disable. | 
Definition at line 2018 of file n_network.c.
References __n_assert, NETWORK::link, LOG_DEBUG, LOG_ERR, N_ENUM_ENTRY, n_log, netw, NETW_ERROR, NETW_EXITED, netw_get_msg(), netw_get_state(), NETW_RUN, N_SOCKET::sock, and u_sleep().
Referenced by main().
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| size_t ntohst | ( | size_t | value | ) | 
network to host size_t
| value | the size_t value to convert to host order | 
Definition at line 47 of file n_network.c.
| ssize_t recv_data | ( | void * | netw, | 
| char * | buf, | ||
| uint32_t | n | ||
| ) | 
recv data from the socket
| netw | connected NETWORK | 
| buf | pointer to buffer | 
| n | number of characters we want | 
Definition at line 2432 of file n_network.c.
References __n_assert, _str, CALL_RETRY, FreeNoLog, LOG_DEBUG, LOG_ERR, n_log, neterrno, netstrerror, netw, NETW_MAX_RETRIES, NETW_RETRY_DELAY, NETW_SOCKET_DISCONNECTED, and NETW_SOCKET_ERROR.
Referenced by netw_new().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| ssize_t recv_php | ( | SOCKET | s, | 
| int * | _code, | ||
| char ** | buf | ||
| ) | 
| ssize_t recv_ssl_data | ( | void * | netw, | 
| char * | buf, | ||
| uint32_t | n | ||
| ) | 
recv data from the socket
| netw | connected NETWORK | 
| buf | pointer to buffer | 
| n | number of characters we want | 
Definition at line 2549 of file n_network.c.
References __n_assert, _str, FreeNoLog, LOG_ERR, n_log, neterrno, netstrerror, and netw.
Referenced by netw_accept_from_ex(), and netw_set_crypto().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| ssize_t send_data | ( | void * | netw, | 
| char * | buf, | ||
| uint32_t | n | ||
| ) | 
send data onto the socket
| netw | connected NETWORK | 
| buf | pointer to buffer | 
| n | number of characters we want to send | 
Definition at line 2381 of file n_network.c.
References __n_assert, _str, CALL_RETRY, FreeNoLog, LOG_DEBUG, LOG_ERR, n_log, neterrno, netstrerror, netw, NETW_MAX_RETRIES, NETW_RETRY_DELAY, NETW_SOCKET_DISCONNECTED, and NETW_SOCKET_ERROR.
Referenced by netw_new().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| ssize_t send_php | ( | SOCKET | s, | 
| int | _code, | ||
| char * | buf, | ||
| int | n | ||
| ) | 
send data onto the socket
| s | connected socket | 
| buf | pointer to buffer | 
| n | number of characters we want to send | 
| _code | Code for php decoding rule | 
Definition at line 2616 of file n_network.c.
References _str, FreeNoLog, HEAD_CODE, HEAD_SIZE, LOG_ERR, n_log, neterrno, and netstrerror.
| ssize_t send_ssl_data | ( | void * | netw, | 
| char * | buf, | ||
| uint32_t | n | ||
| ) | 
send data onto the socket
| netw | connected NETWORK in SSL mode | 
| buf | pointer to buffer | 
| n | number of characters we want to send | 
Definition at line 2483 of file n_network.c.
References __n_assert, _str, FreeNoLog, LOG_ERR, n_log, neterrno, netstrerror, and netw.
Referenced by netw_accept_from_ex(), and netw_set_crypto().
 Here is the caller graph for this function:
 Here is the caller graph for this function: