37 #include <sys/signal.h>
77 static const char tdesc[] =
"Local Proxy Channel Driver";
79 #define IS_OUTBOUND(a,b) (a == b->chan ? 1 : 0)
93 .resync_threshold = -1,
118 .description =
tdesc,
157 #define LOCAL_ALREADY_MASQED (1 << 0)
158 #define LOCAL_LAUNCHED_PBX (1 << 1)
159 #define LOCAL_NO_OPTIMIZATION (1 << 2)
160 #define LOCAL_BRIDGE (1 << 3)
161 #define LOCAL_MOH_PASSTHRU (1 << 4)
190 if (!owner || !chan) {
207 if (p->
owner != owner || p->
chan != chan) {
222 *outowner = p->
owner;
241 ast_log(
LOG_ERROR,
"The chan_write_info_t type has changed, and this channel hasn't been updated!\n");
255 if (!otherchan || otherchan == write_info->
chan) {
259 goto setoption_cleanup;
285 char *
context = NULL, *opts = NULL;
290 if (!(context = strchr(exten,
'@'))) {
291 ast_log(
LOG_WARNING,
"Someone used Local/%s somewhere without a @context. This is bad.\n", exten);
298 if ((opts = strchr(context,
'/')))
301 ast_debug(3,
"Checking if extension %s@%s exists (devicestate)\n", exten, context);
314 is_inuse = !strcmp(exten, lp->
exten)
315 && !strcmp(context, lp->
context)
337 ast_debug(1,
"Asked for bridged channel on '%s'/'%s', returning <none>\n",
441 if (us && us_locked) {
452 if (us && us_locked) {
528 || ast != p->
chan ) {
665 ast_debug(1,
"Not posting to '%s' queue since already masqueraded out\n",
684 if ((p->
owner != oldchan) && (p->
chan != oldchan)) {
689 if (p->
owner == oldchan)
736 this_channel = p->
chan;
737 the_other_channel = p->
owner;
739 this_channel = p->
owner;
740 the_other_channel = p->
chan;
742 if (the_other_channel) {
743 unsigned char frame_data[1024];
781 ast_debug(4,
"Blocked indication %d\n", condition);
911 if (!owner || !chan) {
945 namelen = strlen(varptr->
name);
946 len =
sizeof(
struct ast_var_t) + namelen + strlen(varptr->value) + 2;
948 memcpy(
new, varptr, len);
949 new->value = &(
new->name[0]) + namelen + 1;
958 if ((slash = strrchr(reduced_dest,
'/'))) {
973 ast_log(
LOG_NOTICE,
"No such extension/context %s@%s while calling Local channel\n", exten, context);
1025 int answered_elsewhere = 0;
1040 if (ast != chan && ast != owner) {
1042 goto local_hangup_cleanup;
1048 answered_elsewhere = 1;
1050 ast_debug(2,
"This local call has the ANSWERED_ELSEWHERE flag set.\n");
1056 if (status && p->
owner) {
1067 if (answered_elsewhere) {
1086 goto local_hangup_cleanup;
1095 local_hangup_cleanup:
1134 char *c = NULL, *opts = NULL;
1148 if ((opts = strchr(tmp->
exten,
'/'))) {
1150 if (strchr(opts,
'n'))
1152 if (strchr(opts,
'j')) {
1157 "to use the 'j' option to enable the jitterbuffer\n");
1160 if (strchr(opts,
'b')) {
1163 if (strchr(opts,
'm')) {
1169 if ((c = strchr(tmp->
exten,
'@')))
1182 tmp = local_pvt_destroy(tmp);
1216 if (!(tmp =
ast_channel_alloc(1, state, 0, 0, t, p->
exten, p->
context, linkedid, ama,
"Local/%s@%s-%08x;1", p->
exten, p->
context, (
unsigned)generated_seqno))
1217 || !(tmp2 =
ast_channel_alloc(1,
AST_STATE_RING, 0, 0, t, p->
exten, p->
context, tmp->
linkedid, ama,
"Local/%s@%s-%08x;2", p->
exten, p->
context, (
unsigned)generated_seqno))) {
1233 tmp2->writeformat = fmt;
1235 tmp2->rawwriteformat = fmt;
1237 tmp2->readformat = fmt;
1239 tmp2->rawreadformat = fmt;
1294 e->
command =
"local show channels";
1296 "Usage: local show channels\n"
1297 " Provides summary information on active local proxy channels.\n";
1307 ast_cli(a->
fd,
"No local channels in use\n");
1329 const char *channel;
static void check_bridge(struct ast_channel *ast, struct local_pvt *p)
static char musicclass[MAX_MUSICCLASS]
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
union ast_frame_subclass subclass
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
static char accountcode[AST_MAX_ACCOUNT_CODE]
static const int BUCKET_SIZE
#define LOCAL_MOH_PASSTHRU
#define ast_channel_lock(chan)
static struct ast_frame * local_read(struct ast_channel *ast)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
int ast_connected_line_build_data(unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Build the connected line information data frame.
char * str
Subscriber phone number (Malloced)
struct ast_party_connected_line connected
Channel Connected Line ID information.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_link(arg1, arg2)
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
char * str
Subscriber phone number (Malloced)
void ast_module_unref(struct ast_module *)
struct ast_frame ast_null_frame
struct ast_party_caller caller
Channel Caller ID information.
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
Weird function made for call transfers.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
char context[AST_MAX_CONTEXT]
static const char tdesc[]
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_test_flag(p, flag)
static int local_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
struct ast_party_name name
Subscriber name.
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us, int us_locked)
queue a frame on a to either the p->owner or p->chan
int ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block)
Checks the value of an option.
char context[AST_MAX_CONTEXT]
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
#define ao2_iterator_next(arg1)
#define ast_set_flag(p, flag)
descriptor for a cli entry.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
#define IS_OUTBOUND(a, b)
static struct ast_channel * local_new(struct local_pvt *p, int state, const char *linkedid)
Start new local channel.
struct ast_generator * generator
static char * locals_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command "local show channels".
struct ast_party_redirecting redirecting
Redirecting/Diversion information.
enum ast_control_t38 request_response
Configuration File Parser.
static int unload_module(void)
Unload the local proxy channel from Asterisk.
static struct ast_jb_conf g_jb_conf
unsigned char valid
TRUE if the subaddress information is valid/present.
static struct ast_channel * local_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
Part of PBX interface.
#define LOCAL_LAUNCHED_PBX
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
Create an iterator for a container.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
I/O Management (derived from Cheops-NG)
void ast_cli(int fd, const char *fmt,...)
const ast_string_field linkedid
static int local_digit_begin(struct ast_channel *ast, char digit)
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference co...
struct ast_channel * ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
String fields in structures.
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
struct ast_channel * owner
struct ast_party_id id
Caller party ID.
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
#define EVENT_FLAG_SYSTEM
#define ast_debug(level,...)
Log a DEBUG message.
static int local_call(struct ast_channel *ast, char *dest, int timeout)
Initiate new call, part of PBX interface dest is the dial string.
static int local_queryoption(struct ast_channel *ast, int option, void *data, int *datalen)
struct ast_party_id ani
Automatic Number Identification (ANI)
General Asterisk PBX channel definitions.
struct ast_channel * chan
struct ast_party_dialed::@155 number
Dialed/Called number.
#define AST_OPTION_CHANNEL_WRITE
Handle channel write data If a channel needs to process the data from a func_channel write operation ...
#define ast_manager_register_xml(a, b, c)
Register a manager callback using XML documentation to describe the manager.
static int local_hangup(struct ast_channel *ast)
Hangup a call through the local proxy channel.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
struct ast_audiohook_list * audiohooks
#define AST_CAUSE_ANSWERED_ELSEWHERE
Access Control of various sorts.
#define AST_MAX_EXTENSION
Scheduler Routines (derived from cheops)
static int local_write(struct ast_channel *ast, struct ast_frame *f)
Caller Party information.
#define ao2_ref(o, delta)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
static unsigned int name_sequence
static int locals_cmp_cb(void *obj, void *arg, int flags)
static struct ao2_container * locals
static char language[MAX_LANGUAGE]
struct ast_channel * _bridge
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Core PBX routines and definitions.
int ast_channel_cc_params_init(struct ast_channel *chan, const struct ast_cc_config_params *base_params)
Set up datastore with CCSS parameters for a channel.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
int ast_cdr_update(struct ast_channel *chan)
Update CDR on a channel.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
ast_acf_write_fn_t write_fn
struct ast_party_dialed dialed
Dialed/Called information.
#define LOCAL_ALREADY_MASQED
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define ast_strdupa(s)
duplicate a string in memory from the stack
struct ast_party_subaddress subaddress
Subscriber subaddress.
Dialed/Called Party information.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_CHAN_WRITE_INFO_T_VERSION
ast_chan_write_info_t version. Must be incremented if structure is changed
static struct ast_channel * local_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
Return the bridged channel of a Local channel.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_OPTION_T38_STATE
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
const ast_string_field name
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
static struct local_pvt * local_alloc(const char *data, format_t format)
Create a call structure.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ao2_alloc(data_size, destructor_fn)
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
static void awesome_locking(struct local_pvt *p, struct ast_channel **outchan, struct ast_channel **outowner)
struct ast_bridge * bridge
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static int local_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
#define ast_channel_unlock(chan)
struct ast_var_t::@158 entries
Structure to handle passing func_channel_write info to channels via setoption.
#define CHANNEL_DEADLOCK_AVOIDANCE(chan)
static int local_devicestate(void *data)
Adds devicestate to local channels.
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
if(yyss+yystacksize-1<=yyssp)
struct ast_party_subaddress subaddress
Dialed/Called subaddress.
void ao2_iterator_destroy(struct ao2_iterator *i)
Destroy a container iterator.
#define ast_clear_flag(p, flag)
static struct ast_cli_entry cli_local[]
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
static void hangup_chan(struct chan_list *ch, struct misdn_bchannel *bc)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
static void local_pvt_destructor(void *vdoomed)
int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan)
Update all group counting for a channel to a new one.
static int local_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
#define ast_channel_ref(c)
Increase channel reference count.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
the local pvt structure for all channels
Standard Command Line Interface.
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src)
Copy the caller information to the connected line information.
#define ao2_container_alloc(arg1, arg2, arg3)
struct ast_channel * chan
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
const ast_string_field musicclass
const ast_string_field accountcode
Data structure associated with a single frame of data.
char exten[AST_MAX_EXTENSION]
Internal Asterisk hangup causes.
void ast_connected_line_copy_to_caller(struct ast_party_caller *dest, const struct ast_party_connected_line *src)
Copy the connected line information to the caller information.
static int local_sendtext(struct ast_channel *ast, const char *text)
enum ast_frame_type frametype
#define ast_channel_trylock(chan)
unsigned char valid
TRUE if the name information is valid/present.
static char context[AST_MAX_CONTEXT]
struct ast_channel_monitor * monitor
static int local_setoption(struct ast_channel *chan, int option, void *data, int datalen)
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
#define LOCAL_NO_OPTIMIZATION
static snd_pcm_format_t format
union ast_frame::@172 data
struct ast_channel_tech * tech
struct ast_channel::@156 readq
struct ast_jb_conf jb_conf
unsigned char valid
TRUE if the number information is valid/present.
#define ao2_unlink(arg1, arg2)
General jitterbuffer configuration.
const ast_string_field language
int ast_do_masquerade(struct ast_channel *chan)
Start masquerading a channel.
char exten[AST_MAX_EXTENSION]
int ast_redirecting_build_data(unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Build the redirecting id data frame.
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
int ast_set_cc_interfaces_chanvar(struct ast_channel *chan, const char *const extension)
Set the CC_INTERFACES channel variable for a channel using an extension as a starting point...
int ast_manager_unregister(char *action)
Unregister a registered manager command.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
void ast_party_dialed_copy(struct ast_party_dialed *dest, const struct ast_party_dialed *src)
Copy the source dialed party information to the destination dialed party.
static int local_answer(struct ast_channel *ast)
static int manager_optimize_away(struct mansession *s, const struct message *m)
static int load_module(void)
Load module into PBX, register channel.
static struct ast_channel_tech local_tech
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
struct ast_module * ast_module_ref(struct ast_module *)
struct ast_party_number number
Subscriber phone number.