Rename ast_tcptls_server_instance to session_instance, since this pertains to

server and client usage.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@108295 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Russell Bryant 18 years ago
parent ff1527de3d
commit 8bbef5f996

@ -777,7 +777,7 @@ struct sip_socket {
enum sip_transport type; enum sip_transport type;
int fd; int fd;
uint16_t port; uint16_t port;
struct ast_tcptls_server_instance *ser; struct ast_tcptls_session_instance *ser;
}; };
/*! \brief sip_request: The data grabbed from the UDP socket /*! \brief sip_request: The data grabbed from the UDP socket
@ -1551,7 +1551,7 @@ struct sip_registry {
struct sip_threadinfo { struct sip_threadinfo {
int stop; int stop;
pthread_t threadid; pthread_t threadid;
struct ast_tcptls_server_instance *ser; struct ast_tcptls_session_instance *ser;
enum sip_transport type; /* We keep a copy of the type here so we can display it in the connection list */ enum sip_transport type; /* We keep a copy of the type here so we can display it in the connection list */
AST_LIST_ENTRY(sip_threadinfo) list; AST_LIST_ENTRY(sip_threadinfo) list;
}; };
@ -2129,25 +2129,25 @@ static struct ast_rtp_protocol sip_rtp = {
.get_codec = sip_get_codec, .get_codec = sip_get_codec,
}; };
static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_server_instance *ser); static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_session_instance *ser);
static void *sip_tcp_helper_thread(void *data) static void *sip_tcp_helper_thread(void *data)
{ {
struct sip_pvt *pvt = data; struct sip_pvt *pvt = data;
struct ast_tcptls_server_instance *ser = pvt->socket.ser; struct ast_tcptls_session_instance *ser = pvt->socket.ser;
return _sip_tcp_helper_thread(pvt, ser); return _sip_tcp_helper_thread(pvt, ser);
} }
static void *sip_tcp_worker_fn(void *data) static void *sip_tcp_worker_fn(void *data)
{ {
struct ast_tcptls_server_instance *ser = data; struct ast_tcptls_session_instance *ser = data;
return _sip_tcp_helper_thread(NULL, ser); return _sip_tcp_helper_thread(NULL, ser);
} }
/*! \brief SIP TCP helper function */ /*! \brief SIP TCP helper function */
static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_server_instance *ser) static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_session_instance *ser)
{ {
int res, cl; int res, cl;
struct sip_request req = { 0, } , reqcpy = { 0, }; struct sip_request req = { 0, } , reqcpy = { 0, };
@ -2238,7 +2238,7 @@ cleanup:
ast_free(me); ast_free(me);
cleanup2: cleanup2:
fclose(ser->f); fclose(ser->f);
ser = ast_tcptls_server_instance_destroy(ser); ser = ast_tcptls_session_instance_destroy(ser);
if (req.socket.lock) { if (req.socket.lock) {
ast_mutex_destroy(req.socket.lock); ast_mutex_destroy(req.socket.lock);
@ -18084,7 +18084,7 @@ static int sip_standard_port(struct sip_socket s)
} }
/*! \todo document this function. */ /*! \todo document this function. */
static struct ast_tcptls_server_instance *sip_tcp_locate(struct sockaddr_in *s) static struct ast_tcptls_session_instance *sip_tcp_locate(struct sockaddr_in *s)
{ {
struct sip_threadinfo *th; struct sip_threadinfo *th;
@ -18106,7 +18106,7 @@ static int sip_prepare_socket(struct sip_pvt *p)
{ {
struct sip_socket *s = &p->socket; struct sip_socket *s = &p->socket;
static const char name[] = "SIP socket"; static const char name[] = "SIP socket";
struct ast_tcptls_server_instance *ser; struct ast_tcptls_session_instance *ser;
struct server_args ca = { struct server_args ca = {
.name = name, .name = name,
.accept_fd = -1, .accept_fd = -1,

@ -65,7 +65,7 @@
content is specified) content is specified)
\endverbatim \endverbatim
*/ */
typedef struct ast_str *(*ast_http_callback)(struct ast_tcptls_server_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength); typedef struct ast_str *(*ast_http_callback)(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength);
/*! \brief Definition of a URI reachable in the embedded HTTP server */ /*! \brief Definition of a URI reachable in the embedded HTTP server */
struct ast_http_uri { struct ast_http_uri {

@ -102,7 +102,7 @@ struct ast_tls_config {
* or equivalent with a timeout of 'poll_timeout' milliseconds, and if the * or equivalent with a timeout of 'poll_timeout' milliseconds, and if the
* following accept() is successful it creates a thread in charge of * following accept() is successful it creates a thread in charge of
* running the session, whose body is desc->worker_fn(). The argument of * running the session, whose body is desc->worker_fn(). The argument of
* worker_fn() is a struct ast_tcptls_server_instance, which contains the address * 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 * 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 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 * We have both because we want to support plain and SSL sockets, and
@ -111,7 +111,7 @@ struct ast_tls_config {
* *
* NOTE: in order to let other parts of asterisk use these services, * NOTE: in order to let other parts of asterisk use these services,
* we need to do the following: * we need to do the following:
* + move struct ast_tcptls_server_instance and struct server_args to * + move struct ast_tcptls_session_instance and struct server_args to
* a common header file, together with prototypes for * a common header file, together with prototypes for
* server_start() and server_root(). * server_start() and server_root().
*/ */
@ -119,7 +119,7 @@ struct ast_tls_config {
/*! \brief /*! \brief
* describes a server instance * describes a server instance
*/ */
struct ast_tcptls_server_instance { struct ast_tcptls_session_instance {
FILE *f; /* fopen/funopen result */ FILE *f; /* fopen/funopen result */
int fd; /* the socket returned by accept() */ int fd; /* the socket returned by accept() */
SSL *ssl; /* ssl state */ SSL *ssl; /* ssl state */
@ -154,7 +154,7 @@ struct server_args {
#define LEN_T size_t #define LEN_T size_t
#endif #endif
struct ast_tcptls_server_instance *ast_tcptls_client_start(struct server_args *desc); struct ast_tcptls_session_instance *ast_tcptls_client_start(struct server_args *desc);
void *ast_tcptls_server_root(void *); void *ast_tcptls_server_root(void *);
void ast_tcptls_server_start(struct server_args *desc); void ast_tcptls_server_start(struct server_args *desc);
@ -163,14 +163,14 @@ int ast_ssl_setup(struct ast_tls_config *cfg);
void *ast_make_file_from_fd(void *data); void *ast_make_file_from_fd(void *data);
HOOK_T ast_tcptls_server_read(struct ast_tcptls_server_instance *ser, void *buf, size_t count); HOOK_T ast_tcptls_server_read(struct ast_tcptls_session_instance *ser, void *buf, size_t count);
HOOK_T ast_tcptls_server_write(struct ast_tcptls_server_instance *ser, void *buf, size_t count); HOOK_T ast_tcptls_server_write(struct ast_tcptls_session_instance *ser, void *buf, size_t count);
/*! /*!
* \brief Destroy a server instance * \brief Destroy a server instance
* *
* \return NULL for convenience * \return NULL for convenience
*/ */
struct ast_tcptls_server_instance *ast_tcptls_server_instance_destroy(struct ast_tcptls_server_instance *i); struct ast_tcptls_session_instance *ast_tcptls_session_instance_destroy(struct ast_tcptls_session_instance *i);
#endif /* _ASTERISK_SERVER_H */ #endif /* _ASTERISK_SERVER_H */

@ -137,7 +137,7 @@ static const char *ftype2mtype(const char *ftype, char *wkspace, int wkspacelen)
return wkspace; return wkspace;
} }
static struct ast_str *static_callback(struct ast_tcptls_server_instance *ser, const char *uri, struct ast_variable *vars, int *status, char **title, int *contentlength) static struct ast_str *static_callback(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *vars, int *status, char **title, int *contentlength)
{ {
char *path; char *path;
char *ftype; char *ftype;
@ -207,7 +207,7 @@ out403:
} }
static struct ast_str *httpstatus_callback(struct ast_tcptls_server_instance *ser, const char *uri, struct ast_variable *vars, int *status, char **title, int *contentlength) static struct ast_str *httpstatus_callback(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *vars, int *status, char **title, int *contentlength)
{ {
struct ast_str *out = ast_str_create(512); struct ast_str *out = ast_str_create(512);
struct ast_variable *v; struct ast_variable *v;
@ -392,7 +392,7 @@ static void post_raw(struct mm_mimepart *part, const char *post_dir, const char
fclose(f); fclose(f);
} }
static struct ast_str *handle_post(struct ast_tcptls_server_instance *ser, char *uri, static struct ast_str *handle_post(struct ast_tcptls_session_instance *ser, char *uri,
int *status, char **title, int *contentlength, struct ast_variable *headers, int *status, char **title, int *contentlength, struct ast_variable *headers,
struct ast_variable *cookies) struct ast_variable *cookies)
{ {
@ -535,7 +535,7 @@ static struct ast_str *handle_post(struct ast_tcptls_server_instance *ser, char
return ast_http_error(200, "OK", NULL, "File successfully uploaded."); return ast_http_error(200, "OK", NULL, "File successfully uploaded.");
} }
static struct ast_str *handle_uri(struct ast_tcptls_server_instance *ser, char *uri, int *status, static struct ast_str *handle_uri(struct ast_tcptls_session_instance *ser, char *uri, int *status,
char **title, int *contentlength, struct ast_variable **cookies, char **title, int *contentlength, struct ast_variable **cookies,
unsigned int *static_content) unsigned int *static_content)
{ {
@ -683,7 +683,7 @@ static void *httpd_helper_thread(void *data)
{ {
char buf[4096]; char buf[4096];
char cookie[4096]; char cookie[4096];
struct ast_tcptls_server_instance *ser = data; struct ast_tcptls_session_instance *ser = data;
struct ast_variable *var, *prev=NULL, *vars=NULL, *headers = NULL; struct ast_variable *var, *prev=NULL, *vars=NULL, *headers = NULL;
char *uri, *title=NULL; char *uri, *title=NULL;
int status = 200, contentlength = 0; int status = 200, contentlength = 0;
@ -827,7 +827,7 @@ static void *httpd_helper_thread(void *data)
done: done:
fclose(ser->f); fclose(ser->f);
ser = ast_tcptls_server_instance_destroy(ser); ser = ast_tcptls_session_instance_destroy(ser);
return NULL; return NULL;
} }

@ -2887,7 +2887,7 @@ static int do_message(struct mansession *s)
*/ */
static void *session_do(void *data) static void *session_do(void *data)
{ {
struct ast_tcptls_server_instance *ser = data; struct ast_tcptls_session_instance *ser = data;
struct mansession *s = ast_calloc(1, sizeof(*s)); struct mansession *s = ast_calloc(1, sizeof(*s));
int flags; int flags;
int res; int res;
@ -2951,7 +2951,7 @@ static void *session_do(void *data)
destroy_session(s); destroy_session(s);
done: done:
ser = ast_tcptls_server_instance_destroy(ser); ser = ast_tcptls_session_instance_destroy(ser);
return NULL; return NULL;
} }
@ -3631,17 +3631,17 @@ generic_callback_out:
return out; return out;
} }
static struct ast_str *manager_http_callback(struct ast_tcptls_server_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength) static struct ast_str *manager_http_callback(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength)
{ {
return generic_http_callback(FORMAT_HTML, &ser->requestor, uri, params, status, title, contentlength); return generic_http_callback(FORMAT_HTML, &ser->requestor, uri, params, status, title, contentlength);
} }
static struct ast_str *mxml_http_callback(struct ast_tcptls_server_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength) static struct ast_str *mxml_http_callback(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength)
{ {
return generic_http_callback(FORMAT_XML, &ser->requestor, uri, params, status, title, contentlength); return generic_http_callback(FORMAT_XML, &ser->requestor, uri, params, status, title, contentlength);
} }
static struct ast_str *rawman_http_callback(struct ast_tcptls_server_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength) static struct ast_str *rawman_http_callback(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength)
{ {
return generic_http_callback(FORMAT_RAW, &ser->requestor, uri, params, status, title, contentlength); return generic_http_callback(FORMAT_RAW, &ser->requestor, uri, params, status, title, contentlength);
} }

@ -81,7 +81,7 @@ static int ssl_close(void *cookie)
} }
#endif /* DO_SSL */ #endif /* DO_SSL */
HOOK_T ast_tcptls_server_read(struct ast_tcptls_server_instance *ser, void *buf, size_t count) HOOK_T ast_tcptls_server_read(struct ast_tcptls_session_instance *ser, void *buf, size_t count)
{ {
#ifdef DO_SSL #ifdef DO_SSL
if (ser->ssl) if (ser->ssl)
@ -90,7 +90,7 @@ HOOK_T ast_tcptls_server_read(struct ast_tcptls_server_instance *ser, void *buf,
return read(ser->fd, buf, count); return read(ser->fd, buf, count);
} }
HOOK_T ast_tcptls_server_write(struct ast_tcptls_server_instance *ser, void *buf, size_t count) HOOK_T ast_tcptls_server_write(struct ast_tcptls_session_instance *ser, void *buf, size_t count)
{ {
#ifdef DO_SSL #ifdef DO_SSL
if (ser->ssl) if (ser->ssl)
@ -105,7 +105,7 @@ void *ast_tcptls_server_root(void *data)
int fd; int fd;
struct sockaddr_in sin; struct sockaddr_in sin;
socklen_t sinlen; socklen_t sinlen;
struct ast_tcptls_server_instance *ser; struct ast_tcptls_session_instance *ser;
pthread_t launched; pthread_t launched;
for (;;) { for (;;) {
@ -204,10 +204,10 @@ int ast_ssl_setup(struct ast_tls_config *cfg)
/*! \brief A generic client routine for a TCP client /*! \brief A generic client routine for a TCP client
* and starts a thread for handling accept() * and starts a thread for handling accept()
*/ */
struct ast_tcptls_server_instance *ast_tcptls_client_start(struct server_args *desc) struct ast_tcptls_session_instance *ast_tcptls_client_start(struct server_args *desc)
{ {
int flags; int flags;
struct ast_tcptls_server_instance *ser = NULL; struct ast_tcptls_session_instance *ser = NULL;
/* Do nothing if nothing has changed */ /* Do nothing if nothing has changed */
if(!memcmp(&desc->oldsin, &desc->sin, sizeof(desc->oldsin))) { if(!memcmp(&desc->oldsin, &desc->sin, sizeof(desc->oldsin))) {
@ -353,7 +353,7 @@ void ast_tcptls_server_stop(struct server_args *desc)
*/ */
void *ast_make_file_from_fd(void *data) void *ast_make_file_from_fd(void *data)
{ {
struct ast_tcptls_server_instance *ser = data; struct ast_tcptls_session_instance *ser = data;
#ifdef DO_SSL #ifdef DO_SSL
int (*ssl_setup)(SSL *) = (ser->client) ? SSL_connect : SSL_accept; int (*ssl_setup)(SSL *) = (ser->client) ? SSL_connect : SSL_accept;
int ret; int ret;
@ -447,7 +447,7 @@ void *ast_make_file_from_fd(void *data)
return ser; return ser;
} }
struct ast_tcptls_server_instance *ast_tcptls_server_instance_destroy(struct ast_tcptls_server_instance *i) struct ast_tcptls_session_instance *ast_tcptls_session_instance_destroy(struct ast_tcptls_session_instance *i)
{ {
ast_free(i); ast_free(i);
return NULL; return NULL;

@ -323,7 +323,7 @@ static int load_file(const char *filename, char **ret)
} }
/*! \brief Callback that is executed everytime an http request is received by this module */ /*! \brief Callback that is executed everytime an http request is received by this module */
static struct ast_str *phoneprov_callback(struct ast_tcptls_server_instance *ser, const char *uri, struct ast_variable *vars, int *status, char **title, int *contentlength) static struct ast_str *phoneprov_callback(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *vars, int *status, char **title, int *contentlength)
{ {
struct http_route *route; struct http_route *route;
struct http_route search_route = { struct http_route search_route = {

Loading…
Cancel
Save