Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
app_bridgewait.c File Reference

Application to place the channel into a holding Bridge. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/features.h"
#include "asterisk/say.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/bridge.h"
#include "asterisk/musiconhold.h"
#include "asterisk/astobj2.h"
#include "asterisk/causes.h"
Include dependency graph for app_bridgewait.c:

Go to the source code of this file.

Data Structures

struct  wait_bridge_wrapper
 

Macros

#define APP_NAME   "BridgeWait"
 
#define DEFAULT_BRIDGE_NAME   "default"
 

Enumerations

enum  bridgewait_args { OPT_ARG_ENTERTAINMENT , OPT_ARG_MOHCLASS , OPT_ARG_TIMEOUT , OPT_ARG_ARRAY_SIZE }
 
enum  bridgewait_flags { MUXFLAG_MOHCLASS = (1 << 0) , MUXFLAG_ENTERTAINMENT = (1 << 1) , MUXFLAG_TIMEOUT = (1 << 2) , MUXFLAG_NOANSWER = (1 << 3) }
 
enum  wait_bridge_roles { ROLE_PARTICIPANT = 0 , ROLE_ANNOUNCER , ROLE_INVALID }
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int apply_option_entertainment (struct ast_channel *chan, const char *entertainment_arg)
 
static int apply_option_moh (struct ast_channel *chan, const char *class_arg)
 
static int apply_option_timeout (struct ast_bridge_features *features, char *duration_arg)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int bridgewait_exec (struct ast_channel *chan, const char *data)
 
static int bridgewait_timeout_callback (struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 
static struct wait_bridge_wrapperget_wait_bridge_wrapper (const char *bridge_name)
 
static int load_module (void)
 
static int process_options (struct ast_channel *chan, struct ast_flags *flags, char **opts, struct ast_bridge_features *features, enum wait_bridge_roles role)
 
static int unload_module (void)
 
static enum wait_bridge_roles validate_role (const char *role)
 
static int wait_bridge_hash_fn (const void *obj, const int flags)
 
static int wait_bridge_sort_fn (const void *obj_left, const void *obj_right, const int flags)
 
static struct wait_bridge_wrapperwait_bridge_wrapper_alloc (const char *bridge_name, struct ast_bridge *bridge)
 
static void wait_bridge_wrapper_destructor (void *obj)
 
static struct wait_bridge_wrapperwait_bridge_wrapper_find_by_name (const char *bridge_name)
 
static void wait_wrapper_removal (struct wait_bridge_wrapper *wrapper)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Place the channel into a holding bridge application" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const struct ast_app_option bridgewait_opts [128] = { [ 'e' ] = { .flag = MUXFLAG_ENTERTAINMENT , .arg_index = OPT_ARG_ENTERTAINMENT + 1 }, [ 'm' ] = { .flag = MUXFLAG_MOHCLASS , .arg_index = OPT_ARG_MOHCLASS + 1 }, [ 'S' ] = { .flag = MUXFLAG_TIMEOUT , .arg_index = OPT_ARG_TIMEOUT + 1 }, [ 'n' ] = { .flag = MUXFLAG_NOANSWER }, }
 
static struct ao2_containerwait_bridge_wrappers
 

Detailed Description

Application to place the channel into a holding Bridge.

Author
Jonathan Rose jrose.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file app_bridgewait.c.

Macro Definition Documentation

◆ APP_NAME

#define APP_NAME   "BridgeWait"

Definition at line 122 of file app_bridgewait.c.

◆ DEFAULT_BRIDGE_NAME

#define DEFAULT_BRIDGE_NAME   "default"

Definition at line 123 of file app_bridgewait.c.

Enumeration Type Documentation

◆ bridgewait_args

Enumerator
OPT_ARG_ENTERTAINMENT 
OPT_ARG_MOHCLASS 
OPT_ARG_TIMEOUT 
OPT_ARG_ARRAY_SIZE 

Definition at line 198 of file app_bridgewait.c.

198 {
202 OPT_ARG_ARRAY_SIZE, /* Always the last element of the enum */
203};
@ OPT_ARG_MOHCLASS
@ OPT_ARG_ENTERTAINMENT
@ OPT_ARG_TIMEOUT
@ OPT_ARG_ARRAY_SIZE

◆ bridgewait_flags

Enumerator
MUXFLAG_MOHCLASS 
MUXFLAG_ENTERTAINMENT 
MUXFLAG_TIMEOUT 
MUXFLAG_NOANSWER 

Definition at line 191 of file app_bridgewait.c.

191 {
192 MUXFLAG_MOHCLASS = (1 << 0),
193 MUXFLAG_ENTERTAINMENT = (1 << 1),
194 MUXFLAG_TIMEOUT = (1 << 2),
195 MUXFLAG_NOANSWER = (1 << 3),
196};
@ MUXFLAG_ENTERTAINMENT
@ MUXFLAG_NOANSWER
@ MUXFLAG_TIMEOUT
@ MUXFLAG_MOHCLASS

◆ wait_bridge_roles

Enumerator
ROLE_PARTICIPANT 
ROLE_ANNOUNCER 
ROLE_INVALID 

Definition at line 270 of file app_bridgewait.c.

270 {
274};
@ ROLE_ANNOUNCER
@ ROLE_INVALID
@ ROLE_PARTICIPANT

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 520 of file app_bridgewait.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 520 of file app_bridgewait.c.

◆ apply_option_entertainment()

static int apply_option_entertainment ( struct ast_channel chan,
const char *  entertainment_arg 
)
static

Definition at line 249 of file app_bridgewait.c.

250{
251 char entertainment = entertainment_arg[0];
252
253 switch (entertainment) {
254 case 'm':
255 return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "musiconhold");
256 case 'r':
257 return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "ringing");
258 case 's':
259 return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "silence");
260 case 'h':
261 return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "hold");
262 case 'n':
263 return ast_channel_set_bridge_role_option(chan, "holding_participant", "idle_mode", "none");
264 default:
265 ast_log(LOG_ERROR, "Invalid argument for BridgeWait entertainment '%s'\n", entertainment_arg);
266 return -1;
267 }
268}
#define ast_log
Definition astobj2.c:42
int ast_channel_set_bridge_role_option(struct ast_channel *channel, const char *role_name, const char *option, const char *value)
Set a role option on a channel.
#define LOG_ERROR

References ast_channel_set_bridge_role_option(), ast_log, and LOG_ERROR.

Referenced by process_options().

◆ apply_option_moh()

static int apply_option_moh ( struct ast_channel chan,
const char *  class_arg 
)
static

Definition at line 244 of file app_bridgewait.c.

245{
246 return ast_channel_set_bridge_role_option(chan, "holding_participant", "moh_class", class_arg);
247}

References ast_channel_set_bridge_role_option().

Referenced by process_options().

◆ apply_option_timeout()

static int apply_option_timeout ( struct ast_bridge_features features,
char *  duration_arg 
)
static

Definition at line 220 of file app_bridgewait.c.

221{
222 unsigned int duration;
223
224 if (ast_strlen_zero(duration_arg)) {
225 ast_log(LOG_ERROR, "Timeout option 'S': No value provided.\n");
226 return -1;
227 }
228 if (sscanf(duration_arg, "%u", &duration) != 1 || duration == 0) {
229 ast_log(LOG_ERROR, "Timeout option 'S': Invalid value provided '%s'.\n",
230 duration_arg);
231 return -1;
232 }
233
234 duration *= 1000;
235 if (ast_bridge_interval_hook(features, 0, duration, bridgewait_timeout_callback,
237 ast_log(LOG_ERROR, "Timeout option 'S': Could not create timer.\n");
238 return -1;
239 }
240
241 return 0;
242}
static int bridgewait_timeout_callback(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
int ast_bridge_interval_hook(struct ast_bridge_features *features, enum ast_bridge_hook_timer_option flags, unsigned int interval, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach an interval hook to a bridge features structure.
Definition bridge.c:3398
@ AST_BRIDGE_HOOK_REMOVE_ON_PULL
#define NULL
Definition resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65

References AST_BRIDGE_HOOK_REMOVE_ON_PULL, ast_bridge_interval_hook(), ast_log, ast_strlen_zero(), bridgewait_timeout_callback(), LOG_ERROR, and NULL.

Referenced by process_options().

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 520 of file app_bridgewait.c.

◆ bridgewait_exec()

static int bridgewait_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 424 of file app_bridgewait.c.

425{
426 char *bridge_name = DEFAULT_BRIDGE_NAME;
427 struct ast_bridge_features chan_features;
428 struct ast_flags flags = { 0 };
429 char *parse;
431 char *opts[OPT_ARG_ARRAY_SIZE] = { NULL, };
432 struct wait_bridge_wrapper *bridge_wrapper;
433 int res;
434
437 AST_APP_ARG(role);
439 AST_APP_ARG(other); /* Any remaining unused arguments */
440 );
441
442 parse = ast_strdupa(data);
444
445 if (!ast_strlen_zero(args.name)) {
446 bridge_name = args.name;
447 }
448
449 if (!ast_strlen_zero(args.role)) {
450 role = validate_role(args.role);
451 if (role == ROLE_INVALID) {
452 ast_log(LOG_ERROR, "Requested waiting bridge role '%s' is invalid.\n", args.role);
453 return -1;
454 }
455 }
456
457 if (ast_bridge_features_init(&chan_features)) {
458 ast_bridge_features_cleanup(&chan_features);
459 ast_log(LOG_ERROR, "'%s' failed to enter the waiting bridge - could not set up channel features\n",
460 ast_channel_name(chan));
461 return -1;
462 }
463
464 if (args.options) {
465 ast_app_parse_options(bridgewait_opts, &flags, opts, args.options);
466 }
467
468 /* Answer the channel if needed */
470 ast_answer(chan);
471 }
472
473 if (process_options(chan, &flags, opts, &chan_features, role)) {
474 ast_bridge_features_cleanup(&chan_features);
475 return -1;
476 }
477
478 bridge_wrapper = get_wait_bridge_wrapper(bridge_name);
479 if (!bridge_wrapper) {
480 ast_log(LOG_WARNING, "Failed to find or create waiting bridge '%s' for '%s'.\n", bridge_name, ast_channel_name(chan));
481 ast_bridge_features_cleanup(&chan_features);
482 return -1;
483 }
484
485 ast_verb(3, "%s is entering waiting bridge %s:%s\n", ast_channel_name(chan), bridge_name, bridge_wrapper->bridge->uniqueid);
486 res = ast_bridge_join(bridge_wrapper->bridge, chan, NULL, &chan_features, NULL, 0);
487 wait_wrapper_removal(bridge_wrapper);
488 ast_bridge_features_cleanup(&chan_features);
489
490 if (res) {
491 /* For the lifetime of the bridge wrapper the bridge itself will be valid, if an error occurs it is because
492 * of extreme situations.
493 */
494 ast_log(LOG_WARNING, "Failed to join waiting bridge '%s' for '%s'.\n", bridge_name, ast_channel_name(chan));
495 }
496
497 return (res || ast_check_hangup_locked(chan)) ? -1 : 0;
498}
static enum wait_bridge_roles validate_role(const char *role)
#define DEFAULT_BRIDGE_NAME
static int process_options(struct ast_channel *chan, struct ast_flags *flags, char **opts, struct ast_bridge_features *features, enum wait_bridge_roles role)
wait_bridge_roles
static const struct ast_app_option bridgewait_opts[128]
static struct wait_bridge_wrapper * get_wait_bridge_wrapper(const char *bridge_name)
static void wait_wrapper_removal(struct wait_bridge_wrapper *wrapper)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
int ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, struct ast_bridge_tech_optimizations *tech_args, enum ast_bridge_join_flags flags)
Join a channel to a bridge (blocking)
Definition bridge.c:1690
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
Definition bridge.c:3699
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
Definition bridge.c:3732
const char * ast_channel_name(const struct ast_channel *chan)
int ast_check_hangup_locked(struct ast_channel *chan)
Definition channel.c:459
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition channel.c:2803
ast_channel_state
ast_channel states
@ AST_STATE_UP
static const char name[]
Definition format_mp3.c:68
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition main/app.c:3066
#define ast_verb(level,...)
#define LOG_WARNING
static struct @519 args
Structure that contains features information.
const ast_string_field uniqueid
Definition bridge.h:405
Structure used to handle boolean flags.
Definition utils.h:220
unsigned int flags
Definition utils.h:221
struct ast_bridge * bridge
static struct test_options options
#define ast_test_flag(p, flag)
Definition utils.h:64

References args, ast_answer(), AST_APP_ARG, ast_app_parse_options(), ast_bridge_features_cleanup(), ast_bridge_features_init(), ast_bridge_join(), ast_channel_name(), ast_check_hangup_locked(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_verb, wait_bridge_wrapper::bridge, bridgewait_opts, DEFAULT_BRIDGE_NAME, ast_flags::flags, get_wait_bridge_wrapper(), LOG_ERROR, LOG_WARNING, MUXFLAG_NOANSWER, name, NULL, OPT_ARG_ARRAY_SIZE, options, process_options(), ROLE_INVALID, ROLE_PARTICIPANT, ast_bridge::uniqueid, validate_role(), and wait_wrapper_removal().

Referenced by load_module().

◆ bridgewait_timeout_callback()

static int bridgewait_timeout_callback ( struct ast_bridge_channel bridge_channel,
void *  hook_pvt 
)
static

Definition at line 212 of file app_bridgewait.c.

213{
214 ast_verb(3, "Channel %s timed out.\n", ast_channel_name(bridge_channel->chan));
217 return -1;
218}
@ BRIDGE_CHANNEL_STATE_END
void ast_bridge_channel_leave_bridge(struct ast_bridge_channel *bridge_channel, enum bridge_channel_state new_state, int cause)
Set bridge channel state to leave bridge (if not leaving already).
#define AST_CAUSE_NORMAL_CLEARING
Definition causes.h:106
struct ast_channel * chan

References ast_bridge_channel_leave_bridge(), AST_CAUSE_NORMAL_CLEARING, ast_channel_name(), ast_verb, BRIDGE_CHANNEL_STATE_END, and ast_bridge_channel::chan.

Referenced by apply_option_timeout().

◆ get_wait_bridge_wrapper()

static struct wait_bridge_wrapper * get_wait_bridge_wrapper ( const char *  bridge_name)
static

Definition at line 349 of file app_bridgewait.c.

350{
351 struct wait_bridge_wrapper * wrapper;
352 struct ast_bridge *bridge = NULL;
353
355
356 if ((wrapper = wait_bridge_wrapper_find_by_name(bridge_name))) {
357 return wrapper;
358 }
359
360 /*
361 * Holding bridges can allow local channel move/swap
362 * optimization to the bridge. However, we cannot allow it for
363 * this holding bridge because the call will lose the channel
364 * roles and dialplan location as a result.
365 */
370
371 if (!bridge) {
372 return NULL;
373 }
374
375 /* The bridge reference is unconditionally passed. */
376 return wait_bridge_wrapper_alloc(bridge_name, bridge);
377}
static struct wait_bridge_wrapper * wait_bridge_wrapper_find_by_name(const char *bridge_name)
static struct ao2_container * wait_bridge_wrappers
static struct wait_bridge_wrapper * wait_bridge_wrapper_alloc(const char *bridge_name, struct ast_bridge *bridge)
#define APP_NAME
ast_mutex_t lock
Definition app_sla.c:337
struct ast_bridge * ast_bridge_base_new(uint32_t capabilities, unsigned int flags, const char *creator, const char *name, const char *id)
Create a new base class bridge.
Definition bridge.c:999
@ AST_BRIDGE_CAPABILITY_HOLDING
Definition bridge.h:90
@ AST_BRIDGE_FLAG_SWAP_INHIBIT_TO
@ AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM
@ AST_BRIDGE_FLAG_TRANSFER_PROHIBITED
@ AST_BRIDGE_FLAG_MERGE_INHIBIT_TO
@ AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
Definition lock.h:611
Structure that contains information about a bridge.
Definition bridge.h:353

References APP_NAME, ast_bridge_base_new(), AST_BRIDGE_CAPABILITY_HOLDING, AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM, AST_BRIDGE_FLAG_MERGE_INHIBIT_TO, AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM, AST_BRIDGE_FLAG_SWAP_INHIBIT_TO, AST_BRIDGE_FLAG_TRANSFER_PROHIBITED, lock, NULL, SCOPED_AO2LOCK, wait_bridge_wrapper_alloc(), wait_bridge_wrapper_find_by_name(), and wait_bridge_wrappers.

Referenced by bridgewait_exec().

◆ load_module()

static int load_module ( void  )
static

Definition at line 507 of file app_bridgewait.c.

508{
512
514 return -1;
515 }
516
518}
static int wait_bridge_hash_fn(const void *obj, const int flags)
static int bridgewait_exec(struct ast_channel *chan, const char *data)
static int wait_bridge_sort_fn(const void *obj_left, const void *obj_right, const int flags)
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition astobj2.h:363
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition astobj2.h:1303
@ AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT
Reject objects with duplicate keys in container.
Definition astobj2.h:1188
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition module.h:640

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, APP_NAME, ast_register_application_xml, bridgewait_exec(), NULL, wait_bridge_hash_fn(), wait_bridge_sort_fn(), and wait_bridge_wrappers.

◆ process_options()

static int process_options ( struct ast_channel chan,
struct ast_flags flags,
char **  opts,
struct ast_bridge_features features,
enum wait_bridge_roles  role 
)
static

Definition at line 276 of file app_bridgewait.c.

277{
278 if (ast_test_flag(flags, MUXFLAG_TIMEOUT)) {
279 if (apply_option_timeout(features, opts[OPT_ARG_TIMEOUT])) {
280 return -1;
281 }
282 }
283
284 switch (role) {
285 case ROLE_PARTICIPANT:
286 if (ast_channel_add_bridge_role(chan, "holding_participant")) {
287 return -1;
288 }
289
290 if (ast_test_flag(flags, MUXFLAG_MOHCLASS)) {
291 if (apply_option_moh(chan, opts[OPT_ARG_MOHCLASS])) {
292 return -1;
293 }
294 }
295
298 return -1;
299 }
300 }
301
302 break;
303 case ROLE_ANNOUNCER:
304 if (ast_channel_add_bridge_role(chan, "announcer")) {
305 return -1;
306 }
307 break;
308 case ROLE_INVALID:
309 ast_assert(0);
310 return -1;
311 }
312
313 return 0;
314}
static int apply_option_timeout(struct ast_bridge_features *features, char *duration_arg)
static int apply_option_moh(struct ast_channel *chan, const char *class_arg)
static int apply_option_entertainment(struct ast_channel *chan, const char *entertainment_arg)
int ast_channel_add_bridge_role(struct ast_channel *chan, const char *role_name)
Adds a bridge role to a channel.
#define ast_assert(a)
Definition utils.h:779

References apply_option_entertainment(), apply_option_moh(), apply_option_timeout(), ast_assert, ast_channel_add_bridge_role(), ast_test_flag, MUXFLAG_ENTERTAINMENT, MUXFLAG_MOHCLASS, MUXFLAG_TIMEOUT, OPT_ARG_ENTERTAINMENT, OPT_ARG_MOHCLASS, OPT_ARG_TIMEOUT, ROLE_ANNOUNCER, ROLE_INVALID, and ROLE_PARTICIPANT.

Referenced by bridgewait_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 500 of file app_bridgewait.c.

501{
503
505}
#define ao2_cleanup(obj)
Definition astobj2.h:1934
int ast_unregister_application(const char *app)
Unregister an application.
Definition pbx_app.c:392

References ao2_cleanup, APP_NAME, ast_unregister_application(), and wait_bridge_wrappers.

◆ validate_role()

static enum wait_bridge_roles validate_role ( const char *  role)
static

Definition at line 402 of file app_bridgewait.c.

403{
404 if (!strcmp(role, "participant")) {
405 return ROLE_PARTICIPANT;
406 } else if (!strcmp(role, "announcer")) {
407 return ROLE_ANNOUNCER;
408 } else {
409 return ROLE_INVALID;
410 }
411}

References ROLE_ANNOUNCER, ROLE_INVALID, and ROLE_PARTICIPANT.

Referenced by bridgewait_exec().

◆ wait_bridge_hash_fn()

static int wait_bridge_hash_fn ( const void *  obj,
const int  flags 
)
static

Definition at line 146 of file app_bridgewait.c.

147{
148 const struct wait_bridge_wrapper *entry;
149 const char *key;
150
151 switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
152 case OBJ_KEY:
153 key = obj;
154 return ast_str_hash(key);
155 case OBJ_POINTER:
156 entry = obj;
157 return ast_str_hash(entry->name);
158 default:
159 /* Hash can only work on something with a full key. */
160 ast_assert(0);
161 return 0;
162 }
163}
#define OBJ_KEY
Definition astobj2.h:1151
#define OBJ_POINTER
Definition astobj2.h:1150
#define OBJ_PARTIAL_KEY
Definition astobj2.h:1152
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition strings.h:1259

References ast_assert, ast_str_hash(), wait_bridge_wrapper::name, OBJ_KEY, OBJ_PARTIAL_KEY, and OBJ_POINTER.

Referenced by load_module().

◆ wait_bridge_sort_fn()

static int wait_bridge_sort_fn ( const void *  obj_left,
const void *  obj_right,
const int  flags 
)
static

Definition at line 165 of file app_bridgewait.c.

166{
167 const struct wait_bridge_wrapper *left = obj_left;
168 const struct wait_bridge_wrapper *right = obj_right;
169 const char *right_key = obj_right;
170 int cmp;
171
172 switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
173 case OBJ_POINTER:
174 right_key = right->name;
175 /* Fall through */
176 case OBJ_KEY:
177 cmp = strcmp(left->name, right_key);
178 break;
179 case OBJ_PARTIAL_KEY:
180 cmp = strncmp(left->name, right_key, strlen(right_key));
181 break;
182 default:
183 /* Sort can only work on something with a full or partial key. */
184 ast_assert(0);
185 cmp = 0;
186 break;
187 }
188 return cmp;
189}

References ast_assert, wait_bridge_wrapper::name, OBJ_KEY, OBJ_PARTIAL_KEY, and OBJ_POINTER.

Referenced by load_module().

◆ wait_bridge_wrapper_alloc()

static struct wait_bridge_wrapper * wait_bridge_wrapper_alloc ( const char *  bridge_name,
struct ast_bridge bridge 
)
static

Definition at line 327 of file app_bridgewait.c.

328{
329 struct wait_bridge_wrapper *bridge_wrapper;
330
331 bridge_wrapper = ao2_alloc_options(sizeof(*bridge_wrapper) + strlen(bridge_name) + 1,
333 if (!bridge_wrapper) {
335 return NULL;
336 }
337
338 strcpy(bridge_wrapper->name, bridge_name);
339 bridge_wrapper->bridge = bridge;
340
341 if (!ao2_link(wait_bridge_wrappers, bridge_wrapper)) {
342 ao2_cleanup(bridge_wrapper);
343 return NULL;
344 }
345
346 return bridge_wrapper;
347}
static void wait_bridge_wrapper_destructor(void *obj)
#define ao2_link(container, obj)
Add an object to a container.
Definition astobj2.h:1532
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition astobj2.h:367
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition astobj2.h:404
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
Definition bridge.c:1009

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_link, ast_bridge_destroy(), wait_bridge_wrapper::bridge, wait_bridge_wrapper::name, NULL, wait_bridge_wrapper_destructor(), and wait_bridge_wrappers.

Referenced by get_wait_bridge_wrapper().

◆ wait_bridge_wrapper_destructor()

static void wait_bridge_wrapper_destructor ( void *  obj)
static

Definition at line 132 of file app_bridgewait.c.

133{
134 struct wait_bridge_wrapper *wrapper = obj;
135
136 if (wrapper->bridge) {
137 ast_bridge_destroy(wrapper->bridge, 0);
138 }
139}

References ast_bridge_destroy(), and wait_bridge_wrapper::bridge.

Referenced by wait_bridge_wrapper_alloc().

◆ wait_bridge_wrapper_find_by_name()

static struct wait_bridge_wrapper * wait_bridge_wrapper_find_by_name ( const char *  bridge_name)
static

Definition at line 141 of file app_bridgewait.c.

142{
143 return ao2_find(wait_bridge_wrappers, bridge_name, OBJ_KEY);
144}
#define ao2_find(container, arg, flags)
Definition astobj2.h:1736

References ao2_find, OBJ_KEY, and wait_bridge_wrappers.

Referenced by get_wait_bridge_wrapper().

◆ wait_wrapper_removal()

static void wait_wrapper_removal ( struct wait_bridge_wrapper wrapper)
static

Definition at line 386 of file app_bridgewait.c.

387{
388 if (!wrapper) {
389 return;
390 }
391
393 if (ao2_ref(wrapper, 0) == 2) {
394 /* Either we have the only real reference or else wrapper isn't in the container anyway. */
396 }
398
399 ao2_cleanup(wrapper);
400}
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition astobj2.h:1578
#define ao2_unlock(a)
Definition astobj2.h:729
#define ao2_lock(a)
Definition astobj2.h:717
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459

References ao2_cleanup, ao2_lock, ao2_ref, ao2_unlink, ao2_unlock, and wait_bridge_wrappers.

Referenced by bridgewait_exec().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Place the channel into a holding bridge application" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 520 of file app_bridgewait.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 520 of file app_bridgewait.c.

◆ bridgewait_opts

const struct ast_app_option bridgewait_opts[128] = { [ 'e' ] = { .flag = MUXFLAG_ENTERTAINMENT , .arg_index = OPT_ARG_ENTERTAINMENT + 1 }, [ 'm' ] = { .flag = MUXFLAG_MOHCLASS , .arg_index = OPT_ARG_MOHCLASS + 1 }, [ 'S' ] = { .flag = MUXFLAG_TIMEOUT , .arg_index = OPT_ARG_TIMEOUT + 1 }, [ 'n' ] = { .flag = MUXFLAG_NOANSWER }, }
static

Definition at line 210 of file app_bridgewait.c.

Referenced by bridgewait_exec().

◆ wait_bridge_wrappers

struct ao2_container* wait_bridge_wrappers
static