Thu Oct 11 06:50:28 2012

Asterisk developer's documentation


ast_tcptls_session_args Struct Reference

arguments for the accepting thread More...

#include <tcptls.h>

Collaboration diagram for ast_tcptls_session_args:

Collaboration graph
[legend]

Data Fields

int accept_fd
void *(* accept_fn )(void *)
char hostname [MAXHOSTNAMELEN]
struct sockaddr_in local_address
pthread_t master
const char * name
struct sockaddr_in old_address
void(* periodic_fn )(void *)
int poll_timeout
struct sockaddr_in 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 115 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 119 of file tcptls.h.

Referenced by handle_tcptls_connection(), and sip_prepare_socket().

struct sockaddr_in local_address [read]

pthread_t master

const char* name

struct sockaddr_in old_address [read]

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

Definition at line 117 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 122 of file tcptls.h.

Referenced by ast_tcptls_server_root().

struct sockaddr_in remote_address [read]

Definition at line 118 of file tcptls.h.

Referenced by ast_tcptls_client_create(), ast_tcptls_client_start(), and sip_prepare_socket().

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 Oct 11 06:50:28 2012 for Asterisk - the Open Source PBX by  doxygen 1.5.6