Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Out-of-call refer support. More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/module.h"
#include "asterisk/datastore.h"
#include "asterisk/pbx.h"
#include "asterisk/manager.h"
#include "asterisk/strings.h"
#include "asterisk/astobj2.h"
#include "asterisk/vector.h"
#include "asterisk/app.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/refer.h"
Go to the source code of this file.
Data Structures | |
struct | ast_refer |
A refer. More... | |
struct | ast_refer_var_iterator |
struct | refer_data |
Functions | |
struct ast_refer * | ast_refer_alloc (void) |
Allocate a refer. More... | |
struct ast_refer * | ast_refer_destroy (struct ast_refer *refer) |
Destroy an ast_refer. More... | |
const char * | ast_refer_get_endpoint (const struct ast_refer *refer) |
Retrieve the endpoint associated with this refer. More... | |
const char * | ast_refer_get_from (const struct ast_refer *refer) |
Retrieve the source of this refer. More... | |
const char * | ast_refer_get_refer_to (const struct ast_refer *refer) |
Get the "refer-to" value of a refer. More... | |
const char * | ast_refer_get_tech (const struct ast_refer *refer) |
Retrieve the technology associated with this refer. More... | |
const char * | ast_refer_get_to (const struct ast_refer *refer) |
Retrieve the destination of this refer. More... | |
int | ast_refer_get_to_self (const struct ast_refer *refer) |
Retrieve the "to_self" value of this refer. More... | |
const char * | ast_refer_get_var (struct ast_refer *refer, const char *name) |
Get the specified variable on the refer. More... | |
char * | ast_refer_get_var_and_unlink (struct ast_refer *refer, const char *name) |
Get the specified variable on the refer and unlink it from the container of variables. More... | |
int | ast_refer_init (void) |
struct ast_refer * | ast_refer_ref (struct ast_refer *refer) |
Bump a refer's ref count. More... | |
int | ast_refer_send (struct ast_refer *refer) |
Send a refer directly to an endpoint. More... | |
int | ast_refer_set_endpoint (struct ast_refer *refer, const char *fmt,...) |
Set the technology's endpoint associated with this refer. More... | |
int | ast_refer_set_from (struct ast_refer *refer, const char *fmt,...) |
Set the 'from' URI of a refer. More... | |
int | ast_refer_set_refer_to (struct ast_refer *refer, const char *fmt,...) |
Set the 'refer_to' URI of a refer. More... | |
int | ast_refer_set_tech (struct ast_refer *refer, const char *fmt,...) |
Set the technology associated with this refer. More... | |
int | ast_refer_set_to (struct ast_refer *refer, const char *fmt,...) |
Set the 'to' URI of a refer. More... | |
int | ast_refer_set_to_self (struct ast_refer *refer, int val) |
Set the 'to_self' value of a refer. More... | |
int | ast_refer_set_var_outbound (struct ast_refer *refer, const char *name, const char *value) |
Set a variable on the refer being sent to a refer tech directly. More... | |
int | ast_refer_tech_register (const struct ast_refer_tech *tech) |
Register a refer technology. More... | |
int | ast_refer_tech_unregister (const struct ast_refer_tech *tech) |
Unregister a refer technology. More... | |
void | ast_refer_var_iterator_destroy (struct ast_refer_var_iterator *iter) |
Destroy a refer variable iterator. More... | |
struct ast_refer_var_iterator * | ast_refer_var_iterator_init (const struct ast_refer *refer) |
Create a new refer variable iterator. More... | |
int | ast_refer_var_iterator_next (struct ast_refer_var_iterator *iter, const char **name, const char **value) |
Get the next variable name and value. More... | |
void | ast_refer_var_unref_current (struct ast_refer_var_iterator *iter) |
Unref a refer var from inside an iterator loop. More... | |
static int | refer_data_cmp_fn (void *obj, void *arg, int flags) |
static void | refer_data_destructor (void *obj) |
static struct refer_data * | refer_data_find (struct ao2_container *vars, const char *name) |
static struct refer_data * | refer_data_new (const char *name) |
static void | refer_destructor (void *obj) |
static const struct ast_refer_tech * | refer_find_by_tech_name (const char *tech_name) |
static int | refer_set_var_full (struct ast_refer *refer, const char *name, const char *value) |
static void | refer_shutdown (void) |
static int | refer_tech_cmp (const struct ast_refer_tech *vec_elem, const struct ast_refer_tech *srch) |
Comparison callback for ast_refer_tech vector removal. More... | |
Variables | |
struct { | |
size_t current | |
const struct ast_refer_tech ** elems | |
size_t max | |
} | refer_techs |
Vector of refer technologies. More... | |
static ast_rwlock_t | refer_techs_lock |
Lock for refer_techs vector. More... | |
Out-of-call refer support.
Definition in file refer.c.
struct ast_refer * ast_refer_alloc | ( | void | ) |
Allocate a refer.
Allocate a refer for the purposes of passing it into the Asterisk core to be routed through the dialplan. This refer must be destroyed using ast_refer_destroy().
Definition at line 122 of file refer.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_container_alloc_list, ao2_ref, ast_string_field_init, NULL, refer_data_cmp_fn(), refer_destructor(), ast_refer::to_self, and ast_refer::vars.
Referenced by send_refer().
Destroy an ast_refer.
NULL | always. |
Definition at line 152 of file refer.c.
Referenced by refer_data_destroy(), and send_refer().
const char * ast_refer_get_endpoint | ( | const struct ast_refer * | refer | ) |
Retrieve the endpoint associated with this refer.
refer | The refer to get the endpoint from |
NULL | or empty string if the refer has no associated endpoint |
Definition at line 244 of file refer.c.
References ast_refer::endpoint.
const char * ast_refer_get_from | ( | const struct ast_refer * | refer | ) |
Retrieve the source of this refer.
refer | The refer to get the soure from |
NULL | or empty string if the refer has no source |
Definition at line 224 of file refer.c.
References ast_refer::from.
Referenced by refer_data_create().
const char * ast_refer_get_refer_to | ( | const struct ast_refer * | refer | ) |
Get the "refer-to" value of a refer.
refer | The refer to get the "refer-to" value from |
Definition at line 219 of file refer.c.
References ast_refer::refer_to.
Referenced by refer_data_create().
const char * ast_refer_get_tech | ( | const struct ast_refer * | refer | ) |
Retrieve the technology associated with this refer.
refer | The refer to get the technology from |
NULL | or empty string if the refer has no associated technology |
Definition at line 239 of file refer.c.
References ast_refer::tech.
const char * ast_refer_get_to | ( | const struct ast_refer * | refer | ) |
Retrieve the destination of this refer.
refer | The refer to get the destination from |
NULL | or empty string if the refer has no destination |
Definition at line 229 of file refer.c.
References ast_refer::to.
Referenced by refer_data_create(), and sip_refer_send().
int ast_refer_get_to_self | ( | const struct ast_refer * | refer | ) |
Retrieve the "to_self" value of this refer.
refer | The refer to get the destination from |
Definition at line 234 of file refer.c.
References ast_refer::to_self.
Referenced by refer_data_create().
const char * ast_refer_get_var | ( | struct ast_refer * | refer, |
const char * | name | ||
) |
Get the specified variable on the refer.
refer | |
name | Name of variable to get |
Definition at line 315 of file refer.c.
References ao2_ref, name, NULL, refer_data::refer, refer_data_find(), refer_data::value, and ast_refer::vars.
char * ast_refer_get_var_and_unlink | ( | struct ast_refer * | refer, |
const char * | name | ||
) |
Get the specified variable on the refer and unlink it from the container of variables.
refer | |
name | Name of variable to get |
Definition at line 267 of file refer.c.
References ao2_find, ao2_ref, ast_strdup, name, NULL, OBJ_SEARCH_KEY, OBJ_UNLINK, refer_data::refer, refer_data::value, and ast_refer::vars.
Referenced by refer_send().
int ast_refer_init | ( | void | ) |
Provided by refer.c
Definition at line 529 of file refer.c.
References ast_register_cleanup(), ast_rwlock_init, AST_VECTOR_INIT, refer_shutdown(), refer_techs, and refer_techs_lock.
Referenced by asterisk_daemon().
Bump a refer's ref count.
Definition at line 146 of file refer.c.
References ao2_ref.
Referenced by refer_data_create().
int ast_refer_send | ( | struct ast_refer * | refer | ) |
Send a refer directly to an endpoint.
Regardless of the return value of this function, this function will take care of ensuring that the refer object is properly destroyed when needed.
0 | refer successfully queued to be sent out |
non-zero | failure, refer not get sent out. |
Definition at line 411 of file refer.c.
References ao2_lock, ao2_ref, ao2_unlock, ast_log, ast_rwlock_rdlock, ast_rwlock_unlock, ast_strdupa, ast_strlen_zero(), LOG_ERROR, NULL, refer_find_by_tech_name(), ast_refer_tech::refer_send, refer_tech, refer_techs_lock, strsep(), and ast_refer::to.
Referenced by send_refer().
int ast_refer_set_endpoint | ( | struct ast_refer * | refer, |
const char * | fmt, | ||
... | |||
) |
Set the technology's endpoint associated with this refer.
0 | success |
-1 | failure |
Definition at line 208 of file refer.c.
References ast_string_field_build_va, and ast_refer::endpoint.
int ast_refer_set_from | ( | struct ast_refer * | refer, |
const char * | fmt, | ||
... | |||
) |
Set the 'from' URI of a refer.
0 | success |
-1 | failure |
Definition at line 169 of file refer.c.
References ast_string_field_build_va, and ast_refer::from.
Referenced by send_refer().
int ast_refer_set_refer_to | ( | struct ast_refer * | refer, |
const char * | fmt, | ||
... | |||
) |
Set the 'refer_to' URI of a refer.
0 | success |
-1 | failure |
Definition at line 180 of file refer.c.
References ast_string_field_build_va, and ast_refer::refer_to.
Referenced by send_refer().
int ast_refer_set_tech | ( | struct ast_refer * | refer, |
const char * | fmt, | ||
... | |||
) |
Set the technology associated with this refer.
0 | success |
-1 | failure |
Definition at line 197 of file refer.c.
References ast_string_field_build_va, and ast_refer::tech.
int ast_refer_set_to | ( | struct ast_refer * | refer, |
const char * | fmt, | ||
... | |||
) |
Set the 'to' URI of a refer.
0 | success |
-1 | failure |
Definition at line 158 of file refer.c.
References ast_string_field_build_va, and ast_refer::to.
Referenced by send_refer().
int ast_refer_set_to_self | ( | struct ast_refer * | refer, |
int | val | ||
) |
Set the 'to_self' value of a refer.
0 | success |
-1 | failure |
Definition at line 191 of file refer.c.
References ast_refer::to_self.
Referenced by send_refer().
int ast_refer_set_var_outbound | ( | struct ast_refer * | refer, |
const char * | name, | ||
const char * | value | ||
) |
Set a variable on the refer being sent to a refer tech directly.
refer | |
name | Name of variable to set |
value | Value of variable to set |
0 | success |
-1 | failure |
Definition at line 310 of file refer.c.
References name, refer_data::refer, refer_set_var_full(), and value.
Referenced by send_refer().
int ast_refer_tech_register | ( | const struct ast_refer_tech * | tech | ) |
Register a refer technology.
0 | success |
non-zero | failure |
Definition at line 446 of file refer.c.
References ast_log, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_APPEND, ast_verb, LOG_ERROR, match(), ast_refer_tech::name, refer_find_by_tech_name(), refer_techs, and refer_techs_lock.
Referenced by load_module().
int ast_refer_tech_unregister | ( | const struct ast_refer_tech * | tech | ) |
Unregister a refer technology.
0 | success |
non-zero | failure |
Definition at line 490 of file refer.c.
References ast_log, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_ELEM_CLEANUP_NOOP, AST_VECTOR_REMOVE_CMP_UNORDERED, ast_verb, LOG_ERROR, match(), ast_refer_tech::name, refer_tech_cmp(), refer_techs, and refer_techs_lock.
Referenced by load_module().
void ast_refer_var_iterator_destroy | ( | struct ast_refer_var_iterator * | iter | ) |
Destroy a refer variable iterator.
iter | Iterator to be destroyed |
Definition at line 376 of file refer.c.
References ao2_iterator_destroy(), ast_free, ast_refer_var_unref_current(), and ast_refer_var_iterator::iter.
Referenced by vars_to_headers().
struct ast_refer_var_iterator * ast_refer_var_iterator_init | ( | const struct ast_refer * | refer | ) |
Create a new refer variable iterator.
refer | A refer whose variables are to be iterated over |
Definition at line 335 of file refer.c.
References ao2_iterator_init(), ast_calloc, ast_refer_var_iterator::iter, NULL, and ast_refer::vars.
Referenced by vars_to_headers().
int ast_refer_var_iterator_next | ( | struct ast_refer_var_iterator * | iter, |
const char ** | name, | ||
const char ** | value | ||
) |
Get the next variable name and value.
iter | An iterator created with ast_refer_var_iterator_init |
name | A pointer to the name result pointer |
value | A pointer to the value result pointer |
0 | No more entries |
1 | Valid entry |
Definition at line 349 of file refer.c.
References ao2_iterator_next, ast_refer_var_iterator::current_used, ast_refer_var_iterator::iter, name, refer_data::name, refer_data::value, and value.
Referenced by vars_to_headers().
void ast_refer_var_unref_current | ( | struct ast_refer_var_iterator * | iter | ) |
Unref a refer var from inside an iterator loop.
Definition at line 370 of file refer.c.
References ao2_cleanup, ast_refer_var_iterator::current_used, and NULL.
Referenced by ast_refer_var_iterator_destroy(), and vars_to_headers().
|
static |
Definition at line 82 of file refer.c.
References CMP_MATCH, refer_data::name, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and OBJ_SEARCH_PARTIAL_KEY.
Referenced by ast_refer_alloc().
|
static |
Definition at line 108 of file refer.c.
References ast_free, and refer_data::value.
Referenced by refer_data_new().
|
static |
Definition at line 262 of file refer.c.
References ao2_find, name, and OBJ_SEARCH_KEY.
Referenced by ast_refer_get_var(), and refer_set_var_full().
|
static |
Definition at line 249 of file refer.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, name, refer_data::name, refer_data_destructor(), and refer_data::stuff.
Referenced by refer_set_var_full().
|
static |
Definition at line 114 of file refer.c.
References ao2_cleanup, ast_string_field_free_memory, and ast_refer::vars.
Referenced by ast_refer_alloc().
|
static |
Definition at line 396 of file refer.c.
References AST_VECTOR_GET, AST_VECTOR_SIZE, current, NULL, and refer_techs.
Referenced by ast_refer_send(), and ast_refer_tech_register().
|
static |
Definition at line 282 of file refer.c.
References ao2_link, ao2_ref, ao2_unlink, ast_free, ast_strdup, ast_strlen_zero(), name, refer_data::refer, refer_data_find(), refer_data_new(), refer_data::value, value, and ast_refer::vars.
Referenced by ast_refer_set_var_outbound().
|
static |
Definition at line 513 of file refer.c.
References ast_rwlock_destroy, AST_VECTOR_FREE, refer_techs, and refer_techs_lock.
Referenced by ast_refer_init().
|
static |
Comparison callback for ast_refer_tech
vector removal.
vec_elem | The element in the vector being compared |
srch | The element being looked up |
non-zero | The items are equal |
0 | The items are not equal |
Definition at line 482 of file refer.c.
References ast_refer_tech::name.
Referenced by ast_refer_tech_unregister().
size_t current |
Definition at line 80 of file refer.c.
Referenced by refer_find_by_tech_name().
const struct ast_refer_tech* * elems |
struct { ... } refer_techs |
Vector of refer technologies.
Referenced by ast_refer_init(), ast_refer_tech_register(), ast_refer_tech_unregister(), refer_find_by_tech_name(), and refer_shutdown().
|
static |
Lock for refer_techs
vector.
Definition at line 77 of file refer.c.
Referenced by ast_refer_init(), ast_refer_send(), ast_refer_tech_register(), ast_refer_tech_unregister(), and refer_shutdown().