Thu Apr 16 06:48:57 2015

Asterisk developer's documentation

ast_tcptls_session_args Struct Reference

arguments for the accepting th

#include <tcptls.h>

Collaboration diagram for ast_tcptls_session_args:

Collaboration graph

Data Fields

int accept_fd
void *(* accept_fn )(void *)
char hostname [MAXHOSTNAMELEN]
struct ast_sockaddr local_address
pthread_t master
const char * name
struct ast_sockaddr old_address
void(* periodic_fn )(void *)
int poll_timeout
struct ast_sockaddr remote_address
struct ast_tls_configtls_cfg
void *(* worker_fn )(void *)

Detailed Description

arguments for the accepting thread

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.

Definition at line 123 of file tcptls.h.

Field Documentation

int accept_fd

void*(* accept_fn)(void *)

the function in charge of doing the accept

Referenced by ast_tcptls_server_start().

char hostname[MAXHOSTNAMELEN]

only necessary for SSL clients so we can compare to common name

Definition at line 127 of file tcptls.h.

Referenced by handle_tcptls_connection(), and sip_prepare_socket().

struct ast_sockaddr local_address [read]

pthread_t master

Server accept_fn thread ID used for external shutdown requests.

Definition at line 132 of file tcptls.h.

Referenced by ast_tcptls_server_start(), ast_tcptls_server_stop(), and unload_module().

const char* name

struct ast_sockaddr old_address [read]

copy of the local or remote address depending on if its a client or server session

Definition at line 125 of file tcptls.h.

Referenced by ast_tcptls_client_create(), ast_tcptls_server_start(), handle_show_http(), and httpstatus_callback().

void(* periodic_fn)(void *)

something we may want to run before after select on the accept socket

Referenced by ast_tcptls_server_root().

Definition at line 130 of file tcptls.h.

Referenced by ast_tcptls_server_root().

struct ast_tls_config* tls_cfg [read]

void*(* worker_fn)(void *)

the function in charge of doing the actual work

Referenced by ast_tcptls_client_create(), and handle_tcptls_connection().

The documentation for this struct was generated from the following file:

Generated on Thu Apr 16 06:48:57 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6