82 static
int refer_data_cmp_fn(
void *obj,
void *arg,
int flags)
86 const char *right_key = arg;
91 right_key = object_right->name;
93 cmp = strcasecmp(object_left->name, right_key);
96 cmp = strncasecmp(object_left->name, right_key, strlen(right_key));
108 static void refer_data_destructor(
void *obj)
111 ast_free(data->value);
114 static void refer_destructor(
void *obj)
119 ao2_cleanup(refer->
vars);
136 NULL, refer_data_cmp_fn);
193 refer->to_self = val;
236 return refer->to_self;
249 static struct refer_data *refer_data_new(
const char *name)
252 int name_len = strlen(name) + 1;
255 data->name = data->stuff;
256 strcpy(data->name, name);
282 static int refer_set_var_full(
struct ast_refer *refer,
const char *name,
const char *value)
286 if (!(data = refer_data_find(refer->
vars, name))) {
287 if (ast_strlen_zero(value)) {
290 if (!(data = refer_data_new(name))) {
297 if (ast_strlen_zero(value)) {
300 ast_free(data->value);
312 return refer_set_var_full(refer, name, value);
318 const char *
val = NULL;
320 if (!(data = refer_data_find(refer->
vars, name))) {
357 data = ao2_iterator_next(&iter->iter);
363 *value = data->value;
365 iter->current_used = data;
372 ao2_cleanup(iter->current_used);
373 iter->current_used = NULL;
396 static const struct ast_refer_tech *refer_find_by_tech_name(
const char *tech_name)
403 if (!strcmp(current->
name, tech_name)) {
413 char *tech_name = NULL;
417 if (ast_strlen_zero(refer->
to)) {
423 tech_name = strsep(&tech_name,
":");
425 ast_rwlock_rdlock(&refer_techs_lock);
426 refer_tech = refer_find_by_tech_name(tech_name);
429 ast_log(LOG_ERROR,
"Unknown refer tech: %s\n", tech_name);
430 ast_rwlock_unlock(&refer_techs_lock);
439 ast_rwlock_unlock(&refer_techs_lock);
450 ast_rwlock_wrlock(&refer_techs_lock);
452 match = refer_find_by_tech_name(tech->
name);
454 ast_log(LOG_ERROR,
"Refer technology already registered for '%s'\n",
456 ast_rwlock_unlock(&refer_techs_lock);
461 ast_log(LOG_ERROR,
"Failed to register refer technology for '%s'\n",
463 ast_rwlock_unlock(&refer_techs_lock);
466 ast_verb(5,
"Refer technology '%s' registered.\n", tech->
name);
468 ast_rwlock_unlock(&refer_techs_lock);
484 if (!vec_elem->
name || !srch->
name) {
485 return (vec_elem->
name == srch->
name) ? 1 : 0;
487 return !strcmp(vec_elem->
name, srch->
name);
494 ast_rwlock_wrlock(&refer_techs_lock);
497 ast_rwlock_unlock(&refer_techs_lock);
500 ast_log(LOG_ERROR,
"No '%s' refer technology found.\n", tech->
name);
504 ast_verb(5,
"Refer technology '%s' unregistered.\n", tech->
name);
513 static void refer_shutdown(
void)
516 ast_rwlock_destroy(&refer_techs_lock);
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
int ast_refer_tech_register(const struct ast_refer_tech *tech)
Register a refer technology.
Out-of-call refer support.
const char * ast_refer_get_from(const struct ast_refer *refer)
Retrieve the source of this refer.
void ast_refer_var_iterator_destroy(struct ast_refer_var_iterator *iter)
Destroy a refer variable iterator.
struct ast_refer * ast_refer_destroy(struct ast_refer *refer)
Destroy an ast_refer.
Asterisk main include file. File version handling, generic pbx functions.
String manipulation functions.
#define AST_VECTOR_REMOVE_CMP_UNORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison.
The arg parameter is a search key, but is not an object.
int ast_refer_get_to_self(const struct ast_refer *refer)
Retrieve the "to_self" value of this refer.
int ast_refer_tech_unregister(const struct ast_refer_tech *tech)
Unregister a refer technology.
int ast_refer_send(struct ast_refer *refer)
Send a refer directly to an endpoint.
int ast_refer_set_refer_to(struct ast_refer *refer, const char *fmt,...)
Set the 'refer_to' URI of a refer.
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
struct ao2_container * vars
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
struct ast_refer * ast_refer_alloc(void)
Allocate a refer.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define ast_strdup(str)
A wrapper for strdup()
int ast_refer_set_tech(struct ast_refer *refer, const char *fmt,...)
Set the technology associated with this refer.
int(*const refer_send)(const struct ast_refer *refer)
Send a refer.
Asterisk datastore objects.
const ast_string_field from
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_strdupa(s)
duplicate a string in memory from the stack
const char * ast_refer_get_to(const struct ast_refer *refer)
Retrieve the destination of this refer.
struct @387 refer_techs
Vector of refer technologies.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define AST_STRING_FIELD(name)
Declare a string field.
const char * ast_refer_get_refer_to(const struct ast_refer *refer)
Get the "refer-to" value of a refer.
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.
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.
#define AST_VECTOR(name, type)
Define a vector structure.
Core PBX routines and definitions.
const char * ast_refer_get_endpoint(const struct ast_refer *refer)
Retrieve the endpoint associated with this refer.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
const ast_string_field refer_to
#define ao2_unlink(container, obj)
Remove an object from a container.
int ast_refer_set_to_self(struct ast_refer *refer, int val)
Set the 'to_self' value of a refer.
int ast_refer_set_endpoint(struct ast_refer *refer, const char *fmt,...)
Set the technology's endpoint associated with this refer.
#define ast_calloc(num, len)
A wrapper for calloc()
const ast_string_field to
const char *const name
Name of this refer technology.
Prototypes for public functions only of internal interest,.
Vector container support.
An API for managing task processing threads that can be shared across modules.
const char * ast_refer_get_tech(const struct ast_refer *refer)
Retrieve the technology associated with this refer.
const ast_string_field tech
The arg parameter is an object of the same type.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
const char * ast_refer_get_var(struct ast_refer *refer, const char *name)
Get the specified variable on the refer.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Structure for rwlock and tracking information.
int ast_refer_set_from(struct ast_refer *refer, const char *fmt,...)
Set the 'from' URI of a refer.
struct ast_refer * ast_refer_ref(struct ast_refer *refer)
Bump a refer's ref count.
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.
Search option field mask.
const ast_string_field endpoint
int ast_refer_set_to(struct ast_refer *refer, const char *fmt,...)
Set the 'to' URI of a refer.
struct ast_refer_var_iterator * ast_refer_var_iterator_init(const struct ast_refer *refer)
Create a new refer variable iterator.
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.
Asterisk module definitions.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static ast_rwlock_t refer_techs_lock
Lock for refer_techs vector.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ast_refer_var_unref_current(struct ast_refer_var_iterator *iter)
Unref a refer var from inside an iterator loop.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define ast_string_field_build_va(x, field, fmt, args)
Set a field to a complex (built) value.
#define ao2_link(container, obj)
Add an object to a container.