| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
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/stasis_bridges.h"#include "asterisk/stasis_channels.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. | |
| struct ast_refer * | ast_refer_destroy (struct ast_refer *refer) | 
| Destroy an ast_refer. | |
| const char * | ast_refer_get_endpoint (const struct ast_refer *refer) | 
| Retrieve the endpoint associated with this refer. | |
| const char * | ast_refer_get_from (const struct ast_refer *refer) | 
| Retrieve the source of this refer. | |
| const char * | ast_refer_get_refer_to (const struct ast_refer *refer) | 
| Get the "refer-to" value of a refer. | |
| const char * | ast_refer_get_tech (const struct ast_refer *refer) | 
| Retrieve the technology associated with this refer. | |
| const char * | ast_refer_get_to (const struct ast_refer *refer) | 
| Retrieve the destination of this refer. | |
| int | ast_refer_get_to_self (const struct ast_refer *refer) | 
| Retrieve the "to_self" value of this refer. | |
| const char * | ast_refer_get_var (struct ast_refer *refer, const char *name) | 
| Get the specified variable on the refer. | |
| 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. | |
| int | ast_refer_init (void) | 
| int | ast_refer_notify_transfer_request (struct ast_channel *source, const char *referred_by, const char *exten, const char *protocol_id, struct ast_channel *dest, struct ast_refer_params *params, enum ast_control_transfer state) | 
| Notify a transfer request. | |
| struct ast_refer * | ast_refer_ref (struct ast_refer *refer) | 
| Bump a refer's ref count. | |
| int | ast_refer_send (struct ast_refer *refer) | 
| Send a refer directly to an endpoint. | |
| int | ast_refer_set_endpoint (struct ast_refer *refer, const char *fmt,...) | 
| Set the technology's endpoint associated with this refer. | |
| int | ast_refer_set_from (struct ast_refer *refer, const char *fmt,...) | 
| Set the 'from' URI of a refer. | |
| int | ast_refer_set_refer_to (struct ast_refer *refer, const char *fmt,...) | 
| Set the 'refer_to' URI of a refer. | |
| int | ast_refer_set_tech (struct ast_refer *refer, const char *fmt,...) | 
| Set the technology associated with this refer. | |
| int | ast_refer_set_to (struct ast_refer *refer, const char *fmt,...) | 
| Set the 'to' URI of a refer. | |
| int | ast_refer_set_to_self (struct ast_refer *refer, int val) | 
| Set the 'to_self' value of a 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. | |
| int | ast_refer_tech_register (const struct ast_refer_tech *tech) | 
| Register a refer technology. | |
| int | ast_refer_tech_unregister (const struct ast_refer_tech *tech) | 
| Unregister a refer technology. | |
| void | ast_refer_var_iterator_destroy (struct ast_refer_var_iterator *iter) | 
| Destroy a refer variable iterator. | |
| struct ast_refer_var_iterator * | ast_refer_var_iterator_init (const struct ast_refer *refer) | 
| Create a new refer variable iterator. | |
| 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. | |
| void | ast_refer_var_unref_current (struct ast_refer_var_iterator *iter) | 
| Unref a refer var from inside an iterator loop. | |
| 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_techvector removal. | |
| Variables | ||
| struct { | ||
| size_t current | ||
| const struct ast_refer_tech ** elems | ||
| size_t max | ||
| } | refer_techs | |
| Vector of refer technologies. | ||
| static ast_rwlock_t | refer_techs_lock | |
| Lock for refer_techsvector. | ||
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 124 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 154 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 246 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 226 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 221 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 241 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 231 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 236 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 317 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 269 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 531 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().
| int ast_refer_notify_transfer_request | ( | struct ast_channel * | originating_chan, | 
| const char * | referred_by, | ||
| const char * | exten, | ||
| const char * | protocol_id, | ||
| struct ast_channel * | dest, | ||
| struct ast_refer_params * | params, | ||
| enum ast_control_transfer | state | ||
| ) | 
Notify a transfer request.
| originating_chan | The channel that received the transfer request | 
| referred_by | Information about the requesting identity | 
| exten | The extension for blind transfers | 
| protocol_id | Technology specific replace indication | 
| dest | The identified replace target for attended requests. | 
| params | List of protocol specific params. | 
| state | The state of the transfer | 
Definition at line 541 of file refer.c.
References ao2_bump, ao2_cleanup, ast_ari_transfer_message_create(), ast_bridge_get_snapshot(), ast_bridge_lock, ast_bridge_peer_nolock(), ast_bridge_transfer_acquire_bridge(), ast_bridge_unlock, ast_channel_cleanup, ast_channel_lock, ast_channel_topic(), ast_channel_transfer_request_type(), ast_channel_unlock, NULL, RAII_VAR, stasis_message_create(), and stasis_publish().
Referenced by ari_notify().
Bump a refer's ref count.
Definition at line 148 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 413 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 210 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 171 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 182 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 199 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 160 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 193 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 312 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 448 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 492 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 378 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 337 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 351 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 372 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 84 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 110 of file refer.c.
References ast_free, and refer_data::value.
Referenced by refer_data_new().
| 
 | static | 
Definition at line 264 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 251 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 116 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 398 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 284 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 515 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 484 of file refer.c.
References ast_refer_tech::name.
Referenced by ast_refer_tech_unregister().
| size_t current | 
Definition at line 82 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 79 of file refer.c.
Referenced by ast_refer_init(), ast_refer_send(), ast_refer_tech_register(), ast_refer_tech_unregister(), and refer_shutdown().