|void *(*||accept_fn )(void *)|
|const char *||name|
|void(*||periodic_fn )(void *)|
|struct ast_tls_config *||tls_cfg|
|void *(*||worker_fn )(void *)|
The following code implements a generic mechanism for starting services on a TCP or TLS socket. The service is configured in the struct session_args, and then started by calling server_start(desc) on the descriptor. server_start() first verifies if an instance of the service is active, and in case shuts it down. Then, if the service must be started, creates a socket and a thread in charge of doing the accept().
The body of the thread is desc->accept_fn(desc), which the user can define freely. We supply a sample implementation, server_root(), structured as an infinite loop. At the beginning of each iteration it runs periodic_fn() if defined (e.g. to perform some cleanup etc.) then issues a poll() or equivalent with a timeout of 'poll_timeout' milliseconds, and if the following accept() is successful it creates a thread in charge of running the session, whose body is desc->worker_fn(). The argument of worker_fn() is a struct ast_tcptls_session_instance, which contains the address of the other party, a pointer to desc, the file descriptors (fd) on which we can do a select/poll (but NOT I/O), and a FILE *on which we can do I/O. We have both because we want to support plain and SSL sockets, and going through a FILE * lets us provide the encryption/decryption on the stream without using an auxiliary thread.
|void*(* accept_fn)(void *)|
the function in charge of doing the accept
Referenced by ast_tcptls_server_start().
Referenced by __ast_http_load(), __init_manager(), ast_sip_ouraddrfor(), ast_tcptls_client_create(), ast_tcptls_server_start(), ast_tls_read_conf(), get_address_family_filter(), handle_manager_show_settings(), manager_set_defaults(), mansession_encode_sin_local(), reload_config(), sip_show_settings(), and transmit_register().
|const char* name|
|void(* periodic_fn)(void *)|
something we may want to run before after select on the accept socket
Referenced by ast_tcptls_server_root().
points to the SSL configuration if any
Referenced by __ast_http_load(), __init_manager(), ast_tcptls_client_start(), handle_tcptls_connection(), mansession_get_transport(), reload_config(), sip_prepare_socket(), sip_tcptls_client_args_destructor(), and unload_module().
|void*(* worker_fn)(void *)|