Wed Oct 28 11:46:48 2009

Asterisk developer's documentation


ast_tcptls_session_instance Struct Reference

describes a server instance More...

#include <tcptls.h>

Collaboration diagram for ast_tcptls_session_instance:

Collaboration graph
[legend]

Data Fields

int client
FILE * f
int fd
ast_mutex_t lock
struct server_argsparent
struct sockaddr_in requestor
SSLssl

Detailed Description

describes a server instance

The following code implements a generic mechanism for starting services on a TCP or TLS socket. The service is configured in the struct server_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 IO/, 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.

NOTE: in order to let other parts of asterisk use these services, we need to do the following: + move struct ast_tcptls_session_instance and struct server_args to a common header file, together with prototypes for server_start() and server_root().

Definition at line 123 of file tcptls.h.


Field Documentation

int client

FILE* f

int fd

struct server_args* parent [read]

struct sockaddr_in requestor [read]

SSL* ssl


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

Generated on Wed Oct 28 11:46:48 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6