diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-01-18 22:04:33 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-01-18 22:04:33 +0000 |
commit | d6e19bdc91b0c4c6b5a069e11898741ec082b289 (patch) | |
tree | d0cb360114e418a612eb2025d270801a1388cd7f /include/asterisk/http.h | |
parent | cc1fcc753900c912d856f3f0498a4f7bfd8344a6 (diff) |
Merge changes from team/group/sip-tcptls
This set of changes introduces TCP and TLS support for chan_sip. There are various
new options in configs/sip.conf.sample that are used to enable these features. Also,
there is a document, doc/siptls.txt that describes some things in more detail.
This code was implemented by Brett Bryant and James Golovich. It was reviewed
by Joshua Colp and myself. A number of other people participated in the testing
of this code, but since it was done outside of the bug tracker, I do not have their
names. If you were one of them, thanks a lot for the help!
(closes issue #4903, but with completely different code that what exists there.)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@99085 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/http.h')
-rw-r--r-- | include/asterisk/http.h | 86 |
1 files changed, 2 insertions, 84 deletions
diff --git a/include/asterisk/http.h b/include/asterisk/http.h index b0215221e..4cda5cacc 100644 --- a/include/asterisk/http.h +++ b/include/asterisk/http.h @@ -20,6 +20,8 @@ #define _ASTERISK_HTTP_H #include "asterisk/config.h" +#include "asterisk/tcptls.h" +#include "asterisk/linkedlists.h" /*! * \file http.h @@ -50,90 +52,6 @@ * be run earlier in the startup process so modules have it available. */ -#if defined(HAVE_OPENSSL) && (defined(HAVE_FUNOPEN) || defined(HAVE_FOPENCOOKIE)) -#define DO_SSL /* comment in/out if you want to support ssl */ -#endif - -#ifdef DO_SSL -#include <openssl/ssl.h> -#include <openssl/err.h> -#else -/* declare dummy types so we can define a pointer to them */ -typedef struct {} SSL; -typedef struct {} SSL_CTX; -#endif /* DO_SSL */ - -/*! SSL support */ -#define AST_CERTFILE "asterisk.pem" - -struct tls_config { - int enabled; - char *certfile; - char *cipher; - SSL_CTX *ssl_ctx; -}; - -/*! - * 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 server_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 server_instance and struct server_args to - * a common header file, together with prototypes for - * server_start() and server_root(). - * + - */ - -/*! - * describes a server instance - */ -struct server_instance { - FILE *f; /* fopen/funopen result */ - int fd; /* the socket returned by accept() */ - SSL *ssl; /* ssl state */ - struct sockaddr_in requestor; - struct server_args *parent; -}; - -/*! - * arguments for the accepting thread - */ -struct server_args { - struct sockaddr_in sin; - struct sockaddr_in oldsin; - struct tls_config *tls_cfg; /* points to the SSL configuration if any */ - int accept_fd; - int poll_timeout; - pthread_t master; - void *(*accept_fn)(void *); /* the function in charge of doing the accept */ - void (*periodic_fn)(void *); /* something we may want to run before after select on the accept socket */ - void *(*worker_fn)(void *); /* the function in charge of doing the actual work */ - const char *name; -}; - -void *server_root(void *); -void server_start(struct server_args *desc); -int ssl_setup(struct tls_config *cfg); /*! \brief HTTP Callbacks take the socket |