#include "asterisk.h"
#include <stdio.h>
#include <string.h>
#include <sys/signal.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <math.h>
#include <ctype.h>
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"
#include "asterisk/file.h"
#include "asterisk/ulaw.h"
#include "asterisk/alaw.h"
#include "asterisk/callerid.h"
#include "asterisk/adsi.h"
#include "asterisk/cli.h"
#include "asterisk/cdr.h"
#include "asterisk/features.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/tdd.h"
#include "asterisk/app.h"
#include "asterisk/dsp.h"
#include "asterisk/astdb.h"
#include "asterisk/manager.h"
#include "asterisk/causes.h"
#include "asterisk/term.h"
#include "asterisk/utils.h"
#include "asterisk/transcap.h"
#include "asterisk/stringfields.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/smdi.h"
#include "asterisk/astobj.h"
#include "asterisk/dahdi_compat.h"
#include "asterisk/tonezone_compat.h"

Go to the source code of this file.
Data Structures | |
| struct | dahdi_chan_conf |
| Channel configuration from chan_dahdi.conf . This struct is used for parsing the [channels] section of chan_dahdi.conf. Generally there is a field here for every possible configuration item. More... | |
| struct | dahdi_distRings |
| struct | dahdi_pvt |
| struct | dahdi_subchannel |
| struct | distRingData |
| struct | ringContextData |
Defines | |
| #define | ASCII_BYTES_PER_CHAR 80 |
| #define | AST_LAW(p) (((p)->law == DAHDI_LAW_ALAW) ? AST_FORMAT_ALAW : AST_FORMAT_ULAW) |
| #define | CALLWAITING_REPEAT_SAMPLES ( (10000 * 8) / READ_SIZE) |
| #define | CALLWAITING_SILENT_SAMPLES ( (300 * 8) / READ_SIZE) |
| #define | CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */) |
| #define | CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */) |
| #define | CHAN_PSEUDO -2 |
| #define | CHANNEL_PSEUDO -12 |
| #define | CIDCW_EXPIRE_SAMPLES ( (500 * 8) / READ_SIZE) |
| #define | CONF_USER_REAL (1 << 0) |
| #define | CONF_USER_THIRDCALL (1 << 1) |
| #define | DAHDI_EVENT_DTMFDOWN 0 |
| #define | DAHDI_EVENT_DTMFUP 0 |
| #define | DCHAN_AVAILABLE (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP) |
| #define | DCHAN_NOTINALARM (1 << 1) |
| #define | DCHAN_PROVISIONED (1 << 0) |
| #define | DCHAN_UP (1 << 2) |
| #define | DEFAULT_CIDRINGS 1 |
| Typically, how many rings before we should send Caller*ID. | |
| #define | DEFAULT_RINGT ( (8000 * 8) / READ_SIZE) |
| #define | END_SILENCE_LEN 400 |
| #define | FORMAT "%-40.40s %-10.10s %-10d %-10d %-10d\n" |
| #define | FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s\n" |
| #define | FORMAT2 "%-40.40s %-10.10s %-10.10s %-10.10s %-10.10s\n" |
| #define | FORMAT2 "%7s %-10.10s %-15.15s %-10.10s %-20.20s\n" |
| #define | GET_CHANNEL(p) ((p)->channel) |
| #define | HANGUP 1 |
| #define | HEADER_LEN ((HEADER_MS + TRAILER_MS) * 8) |
| #define | HEADER_MS 50 |
| #define | ISTRUNK(p) |
| #define | local_astman_ack(s, m, msg, zap) do { if (!zap) astman_send_ack(s, m, "DAHDI" msg); else astman_send_ack(s, m, "Zap" msg); } while (0) |
| #define | local_astman_header(m, hdr, zap) astman_get_header(m, (!zap) ? "DAHDI" hdr : "Zap" hdr) |
| #define | local_astman_register(a, b, c, d) |
| #define | local_astman_unregister(a) |
| #define | MASK_AVAIL (1 << 0) |
| #define | MASK_INUSE (1 << 1) |
| #define | MAX_CHANLIST_LEN 80 |
| #define | MAX_CHANNELS 672 |
| #define | MAX_SLAVES 4 |
| #define | MIN_MS_SINCE_FLASH ( (2000) ) |
| #define | NEED_MFDETECT(p) (((p)->sig == SIG_FEATDMF) || ((p)->sig == SIG_FEATDMF_TA) || ((p)->sig == SIG_E911) || ((p)->sig == SIG_FGC_CAMA) || ((p)->sig == SIG_FGC_CAMAMF) || ((p)->sig == SIG_FEATB)) |
| Signaling types that need to use MF detection should be placed in this macro. | |
| #define | NUM_CADENCE_MAX 25 |
| #define | NUM_DCHANS 4 |
| #define | NUM_SPANS 32 |
| #define | POLARITY_IDLE 0 |
| #define | POLARITY_REV 1 |
| #define | READ_SIZE 160 |
| #define | sig2str dahdi_sig2str |
| #define | SIG_E911 (0x1000000 | DAHDI_SIG_EM) |
| #define | SIG_EM DAHDI_SIG_EM |
| #define | SIG_EM_E1 DAHDI_SIG_EM_E1 |
| #define | SIG_EMWINK (0x0100000 | DAHDI_SIG_EM) |
| #define | SIG_FEATB (0x0800000 | DAHDI_SIG_EM) |
| #define | SIG_FEATD (0x0200000 | DAHDI_SIG_EM) |
| #define | SIG_FEATDMF (0x0400000 | DAHDI_SIG_EM) |
| #define | SIG_FEATDMF_TA (0x2000000 | DAHDI_SIG_EM) |
| #define | SIG_FGC_CAMA (0x4000000 | DAHDI_SIG_EM) |
| #define | SIG_FGC_CAMAMF (0x8000000 | DAHDI_SIG_EM) |
| #define | SIG_FXOGS DAHDI_SIG_FXOGS |
| #define | SIG_FXOKS DAHDI_SIG_FXOKS |
| #define | SIG_FXOLS DAHDI_SIG_FXOLS |
| #define | SIG_FXSGS DAHDI_SIG_FXSGS |
| #define | SIG_FXSKS DAHDI_SIG_FXSKS |
| #define | SIG_FXSLS DAHDI_SIG_FXSLS |
| #define | SIG_GR303FXOKS (0x0100000 | DAHDI_SIG_FXOKS) |
| #define | SIG_GR303FXSKS (0x0100000 | DAHDI_SIG_FXSKS) |
| #define | SIG_PRI DAHDI_SIG_CLEAR |
| #define | SIG_SF DAHDI_SIG_SF |
| #define | SIG_SF_FEATB (0x0800000 | DAHDI_SIG_SF) |
| #define | SIG_SF_FEATD (0x0200000 | DAHDI_SIG_SF) |
| #define | SIG_SF_FEATDMF (0x0400000 | DAHDI_SIG_SF) |
| #define | SIG_SFWINK (0x0100000 | DAHDI_SIG_SF) |
| #define | SMDI_MD_WAIT_TIMEOUT 1500 |
| #define | SUB_CALLWAIT 1 |
| #define | SUB_REAL 0 |
| #define | SUB_THREEWAY 2 |
| #define | tdesc "DAHDI Telephony" |
| #define | TRAILER_MS 5 |
| #define | TRANSFER 0 |
Functions | |
| static int | __action_dialoffhook (struct mansession *s, const struct message *m, int zap_mode) |
| static int | __action_dnd (struct mansession *s, const struct message *m, int zap_mode, int dnd) |
| static int | __action_restart (struct mansession *s, const struct message *m, int zap_mode) |
| static int | __action_showchannels (struct mansession *s, const struct message *m, int zap_mode) |
| static int | __action_transfer (struct mansession *s, const struct message *m, int zap_mode) |
| static int | __action_transferhangup (struct mansession *s, const struct message *m, int zap_mode) |
| static struct ast_frame * | __dahdi_exception (struct ast_channel *ast) |
| static void | __reg_module (void) |
| static int | __unload_module (void) |
| static void | __unreg_module (void) |
| static char * | alarm2str (int alarm) |
| static int | alloc_sub (struct dahdi_pvt *p, int x) |
| static int | attempt_transfer (struct dahdi_pvt *p) |
| static int | available (struct dahdi_pvt *p, int channelmatch, ast_group_t groupmatch, int *busy, int *channelmatched, int *groupmatched) |
| static int | build_channels (struct dahdi_chan_conf *conf, int iscrv, const char *value, int reload, int lineno, int *found_pseudo) |
| static int | bump_gains (struct dahdi_pvt *p) |
| static struct dahdi_pvt * | chandup (struct dahdi_pvt *src) |
| static int | check_for_conference (struct dahdi_pvt *p) |
| static int | conf_add (struct dahdi_pvt *p, struct dahdi_subchannel *c, int index, int slavechannel) |
| static int | conf_del (struct dahdi_pvt *p, struct dahdi_subchannel *c, int index) |
| static int | dahdi_action_dialoffhook (struct mansession *s, const struct message *m) |
| static int | dahdi_action_dndoff (struct mansession *s, const struct message *m) |
| static int | dahdi_action_dndon (struct mansession *s, const struct message *m) |
| static int | dahdi_action_restart (struct mansession *s, const struct message *m) |
| static int | dahdi_action_showchannels (struct mansession *s, const struct message *m) |
| static int | dahdi_action_transfer (struct mansession *s, const struct message *m) |
| static int | dahdi_action_transferhangup (struct mansession *s, const struct message *m) |
| static int | dahdi_answer (struct ast_channel *ast) |
| static enum ast_bridge_result | dahdi_bridge (struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms) |
| static int | dahdi_call (struct ast_channel *ast, char *rdest, int timeout) |
| static int | dahdi_callwait (struct ast_channel *ast) |
| static struct dahdi_chan_conf | dahdi_chan_conf_default (void) |
| static void | dahdi_close (int fd) |
| static void | dahdi_close_sub (struct dahdi_pvt *chan_pvt, int sub_num) |
| static int | dahdi_confmute (struct dahdi_pvt *p, int muted) |
| static int | dahdi_destroy_channel (int fd, int argc, char **argv) |
| static int | dahdi_destroy_channel_bynum (int channel) |
| static int | dahdi_digit_begin (struct ast_channel *ast, char digit) |
| static int | dahdi_digit_end (struct ast_channel *ast, char digit, unsigned int duration) |
| static void | dahdi_disable_ec (struct dahdi_pvt *p) |
| static void | dahdi_enable_ec (struct dahdi_pvt *p) |
| static struct ast_frame * | dahdi_exception (struct ast_channel *ast) |
| static int | dahdi_fake_event (struct dahdi_pvt *p, int mode) |
| static int | dahdi_fixup (struct ast_channel *oldchan, struct ast_channel *newchan) |
| static int | dahdi_func_read (struct ast_channel *chan, char *function, char *data, char *buf, size_t len) |
| static int | dahdi_get_event (int fd) |
| Avoid the silly dahdi_getevent which ignores a bunch of events. | |
| static int | dahdi_get_index (struct ast_channel *ast, struct dahdi_pvt *p, int nullok) |
| static void | dahdi_handle_dtmfup (struct ast_channel *ast, int index, struct ast_frame **dest) |
| static struct ast_frame * | dahdi_handle_event (struct ast_channel *ast) |
| static int | dahdi_hangup (struct ast_channel *ast) |
| static int | dahdi_indicate (struct ast_channel *chan, int condition, const void *data, size_t datalen) |
| static void | dahdi_link (struct dahdi_pvt *slave, struct dahdi_pvt *master) |
| static struct ast_channel * | dahdi_new (struct dahdi_pvt *, int, int, int, int, int) |
| static int | dahdi_open (char *fn) |
| static void | dahdi_queue_frame (struct dahdi_pvt *p, struct ast_frame *f, void *pri) |
| static struct ast_frame * | dahdi_read (struct ast_channel *ast) |
| static struct ast_channel * | dahdi_request (const char *type, int format, void *data, int *cause) |
| static int | dahdi_restart (void) |
| static int | dahdi_restart_cmd (int fd, int argc, char **argv) |
| static int | dahdi_ring_phone (struct dahdi_pvt *p) |
| static int | dahdi_sendtext (struct ast_channel *c, const char *text) |
| static int | dahdi_set_hook (int fd, int hs) |
| static int | dahdi_setlinear (int dfd, int linear) |
| static int | dahdi_setoption (struct ast_channel *chan, int option, void *data, int datalen) |
| static int | dahdi_show_channel (int fd, int argc, char **argv) |
| static int | dahdi_show_channels (int fd, int argc, char **argv) |
| static int | dahdi_show_status (int fd, int argc, char *argv[]) |
| static char * | dahdi_sig2str (int sig) |
| static void | dahdi_softhangup_all (void) |
| static void | dahdi_train_ec (struct dahdi_pvt *p) |
| static void | dahdi_unlink (struct dahdi_pvt *slave, struct dahdi_pvt *master, int needlock) |
| static int | dahdi_wait_event (int fd) |
| Avoid the silly dahdi_waitevent which ignores a bunch of events. | |
| static int | dahdi_wink (struct dahdi_pvt *p, int index) |
| static int | dahdi_write (struct ast_channel *ast, struct ast_frame *frame) |
| static void | destroy_all_channels (void) |
| static int | destroy_channel (struct dahdi_pvt *prev, struct dahdi_pvt *cur, int now) |
| static void | destroy_dahdi_pvt (struct dahdi_pvt **pvt) |
| static int | digit_to_dtmfindex (char digit) |
| static void | disable_dtmf_detect (struct dahdi_pvt *p) |
| static void * | do_monitor (void *data) |
| static void | enable_dtmf_detect (struct dahdi_pvt *p) |
| static char * | event2str (int event) |
| static void | fill_rxgain (struct dahdi_gains *g, float gain, int law) |
| static void | fill_txgain (struct dahdi_gains *g, float gain, int law) |
| static struct dahdi_pvt * | find_channel (int channel) |
| static int | get_alarms (struct dahdi_pvt *p) |
| static void | handle_alarms (struct dahdi_pvt *p, int alarms) |
| static int | handle_dahdi_show_cadences (int fd, int argc, char *argv[]) |
| static int | handle_init_event (struct dahdi_pvt *i, int event) |
| static int | has_voicemail (struct dahdi_pvt *p) |
| static int | isourconf (struct dahdi_pvt *p, struct dahdi_subchannel *c) |
| static int | isslavenative (struct dahdi_pvt *p, struct dahdi_pvt **out) |
| static int | load_module (void) |
| static struct dahdi_pvt * | mkintf (int channel, const struct dahdi_chan_conf *conf, struct dahdi_pri *pri, int reloading) |
| static int | my_dahdi_write (struct dahdi_pvt *p, unsigned char *buf, int len, int index, int linear) |
| static int | my_getsigstr (struct ast_channel *chan, char *str, const char *term, int ms) |
| static int | process_dahdi (struct dahdi_chan_conf *confp, const char *cat, struct ast_variable *v, int reload, int skipchannels) |
| static int | reload (void) |
| static int | reset_conf (struct dahdi_pvt *p) |
| static int | restart_monitor (void) |
| Start the channel monitor thread. | |
| static int | restore_conference (struct dahdi_pvt *p) |
| static int | restore_gains (struct dahdi_pvt *p) |
| static int | save_conference (struct dahdi_pvt *p) |
| static int | send_callerid (struct dahdi_pvt *p) |
| static int | send_cwcidspill (struct dahdi_pvt *p) |
| static int | set_actual_gain (int fd, int chan, float rxgain, float txgain, int law) |
| static int | set_actual_rxgain (int fd, int chan, float gain, int law) |
| static int | set_actual_txgain (int fd, int chan, float gain, int law) |
| static int | setup_dahdi (int reload) |
| static void * | ss_thread (void *data) |
| static void | swap_subs (struct dahdi_pvt *p, int a, int b) |
| static int | unalloc_sub (struct dahdi_pvt *p, int x) |
| static int | unload_module (void) |
| static int | update_conf (struct dahdi_pvt *p) |
| static void | wakeup_sub (struct dahdi_pvt *p, int a, void *pri) |
| static int | zap_action_dialoffhook (struct mansession *s, const struct message *m) |
| static int | zap_action_dndoff (struct mansession *s, const struct message *m) |
| static int | zap_action_dndon (struct mansession *s, const struct message *m) |
| static int | zap_action_restart (struct mansession *s, const struct message *m) |
| static int | zap_action_showchannels (struct mansession *s, const struct message *m) |
| static int | zap_action_transfer (struct mansession *s, const struct message *m) |
| static int | zap_action_transferhangup (struct mansession *s, const struct message *m) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "DAHDI Telephony" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } |
| struct { | |
| int alarm | |
| char * name | |
| } | alarms [] |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static struct dahdi_ring_cadence | cadences [NUM_CADENCE_MAX] |
| static struct ast_channel_tech * | chan_tech |
| static int | cidrings [NUM_CADENCE_MAX] |
| cidrings says in which pause to transmit the cid information, where the first pause is 1, the second pause is 2 and so on. | |
| static struct ast_cli_entry | cli_zap_destroy_channel_deprecated |
| static struct ast_cli_entry | cli_zap_restart_deprecated |
| static struct ast_cli_entry | cli_zap_show_cadences_deprecated |
| static struct ast_cli_entry | cli_zap_show_channel_deprecated |
| static struct ast_cli_entry | cli_zap_show_channels_deprecated |
| static struct ast_cli_entry | cli_zap_show_status_deprecated |
| static struct ast_cli_entry | dahdi_cli [] |
| static char | dahdi_restart_usage [] |
| static char | dahdi_show_cadences_usage [] |
| static char | dahdi_show_status_usage [] |
| static struct ast_channel_tech | dahdi_tech |
| static struct ast_jb_conf | default_jbconf |
| static char | defaultcic [64] = "" |
| static char | defaultozz [64] = "" |
| static char | destroy_channel_usage [] |
| static int | distinctiveringaftercid = 0 |
| static struct dahdi_distRings | drings |
| static char * | events [] |
| static int | firstdigittimeout = 16000 |
| Wait up to 16 seconds for first digit (FXO logic). | |
| static int | gendigittimeout = 8000 |
| How long to wait for following digits (FXO logic). | |
| static struct ast_jb_conf | global_jbconf |
| static int | ifcount = 0 |
| static struct dahdi_pvt * | ifend |
| static struct dahdi_pvt * | iflist |
| static ast_mutex_t | iflock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) |
| Protect the interface list (of dahdi_pvt's). | |
| static int | matchdigittimeout = 3000 |
| How long to wait for an extra digit, if there is an ambiguous match. | |
| static pthread_t | monitor_thread = AST_PTHREADT_NULL |
| This is the thread for the monitor which checks for input on the channels which are not currently in use. | |
| static ast_mutex_t | monlock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) |
| Protect the monitoring thread, so only one process can kill or start it, and not when it's doing something critical. | |
| static int | num_cadence = 4 |
| static int | num_restart_pending = 0 |
| static int | numbufs = 4 |
| static char | progzone [10] = "" |
| static ast_mutex_t | restart_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) |
| static int | ringt_base = DEFAULT_RINGT |
| struct dahdi_pvt * | round_robin [32] |
| static char | show_channel_usage [] |
| static char | show_channels_usage [] |
| static ast_cond_t | ss_thread_complete |
| static int | ss_thread_count = 0 |
| static ast_mutex_t | ss_thread_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) |
| static char * | subnames [] |
| static const char | tdesc [] = "DAHDI Telephony Driver" |
| static int | user_has_defined_cadences = 0 |
| static struct ast_channel_tech | zap_tech |
Connects to the DAHDI telephony library as well as libpri. Libpri is optional and needed only if you are going to use ISDN connections.
You need to install libraries before you attempt to compile and install the DAHDI channel.
Definition in file chan_dahdi.c.
| #define ASCII_BYTES_PER_CHAR 80 |
Referenced by dahdi_sendtext().
| #define AST_LAW | ( | p | ) | (((p)->law == DAHDI_LAW_ALAW) ? AST_FORMAT_ALAW : AST_FORMAT_ULAW) |
Definition at line 151 of file chan_dahdi.c.
Referenced by dahdi_call(), dahdi_callwait(), dahdi_sendtext(), do_monitor(), send_cwcidspill(), and ss_thread().
| #define CALLWAITING_REPEAT_SAMPLES ( (10000 * 8) / READ_SIZE) |
| #define CALLWAITING_SILENT_SAMPLES ( (300 * 8) / READ_SIZE) |
300 ms
Definition at line 282 of file chan_dahdi.c.
| #define CANBUSYDETECT | ( | p | ) | (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */) |
| #define CANPROGRESSDETECT | ( | p | ) | (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */) |
| #define CHAN_PSEUDO -2 |
Definition at line 191 of file chan_dahdi.c.
Referenced by build_channels(), dahdi_new(), dahdi_request(), enable_dtmf_detect(), mkintf(), and process_dahdi().
| #define CHANNEL_PSEUDO -12 |
Definition at line 149 of file chan_dahdi.c.
| #define CIDCW_EXPIRE_SAMPLES ( (500 * 8) / READ_SIZE) |
| #define CONF_USER_REAL (1 << 0) |
Definition at line 409 of file chan_dahdi.c.
| #define CONF_USER_THIRDCALL (1 << 1) |
Definition at line 410 of file chan_dahdi.c.
| #define DAHDI_EVENT_DTMFDOWN 0 |
| #define DAHDI_EVENT_DTMFUP 0 |
| #define DCHAN_AVAILABLE (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP) |
Definition at line 197 of file chan_dahdi.c.
| #define DCHAN_NOTINALARM (1 << 1) |
Definition at line 194 of file chan_dahdi.c.
| #define DCHAN_PROVISIONED (1 << 0) |
Definition at line 193 of file chan_dahdi.c.
| #define DCHAN_UP (1 << 2) |
Definition at line 195 of file chan_dahdi.c.
| #define DEFAULT_CIDRINGS 1 |
Typically, how many rings before we should send Caller*ID.
Define if you want to check the hook state for an FXO (FXS signalled) interface before dialing on it. Certain FXO interfaces always think they're out of service with this method however.
Definition at line 147 of file chan_dahdi.c.
Referenced by dahdi_chan_conf_default().
| #define DEFAULT_RINGT ( (8000 * 8) / READ_SIZE) |
8,000 ms
Definition at line 286 of file chan_dahdi.c.
| #define END_SILENCE_LEN 400 |
Referenced by dahdi_sendtext().
| #define FORMAT "%-40.40s %-10.10s %-10d %-10d %-10d\n" |
| #define FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s\n" |
| #define FORMAT2 "%-40.40s %-10.10s %-10.10s %-10.10s %-10.10s\n" |
| #define FORMAT2 "%7s %-10.10s %-15.15s %-10.10s %-20.20s\n" |
| #define GET_CHANNEL | ( | p | ) | ((p)->channel) |
| #define HANGUP 1 |
Definition at line 10557 of file chan_dahdi.c.
Referenced by __action_transferhangup(), and dahdi_fake_event().
| #define HEADER_LEN ((HEADER_MS + TRAILER_MS) * 8) |
Referenced by build_alerting(), build_connect(), build_connect_acknowledge(), build_disconnect(), build_facility(), build_hold(), build_hold_acknowledge(), build_hold_reject(), build_information(), build_notify(), build_proceeding(), build_progress(), build_release(), build_release_complete(), build_restart(), build_resume(), build_resume_acknowledge(), build_resume_reject(), build_retrieve(), build_retrieve_acknowledge(), build_retrieve_reject(), build_setup(), build_setup_acknowledge(), build_status(), build_status_enquiry(), build_suspend(), build_suspend_acknowledge(), build_suspend_reject(), build_timeout(), build_user_information(), dahdi_sendtext(), parse_alerting(), parse_connect(), parse_disconnect(), parse_facility(), parse_information(), parse_proceeding(), parse_progress(), parse_release(), parse_release_complete(), parse_restart(), parse_setup(), parse_setup_acknowledge(), and parse_status().
| #define HEADER_MS 50 |
Referenced by dahdi_sendtext().
| #define ISTRUNK | ( | p | ) |
Value:
Definition at line 788 of file chan_dahdi.c.
Referenced by dahdi_indicate(), and ss_thread().
| #define local_astman_ack | ( | s, | |||
| m, | |||||
| msg, | |||||
| zap | ) | do { if (!zap) astman_send_ack(s, m, "DAHDI" msg); else astman_send_ack(s, m, "Zap" msg); } while (0) |
Definition at line 10587 of file chan_dahdi.c.
Referenced by __action_dialoffhook(), __action_dnd(), __action_restart(), __action_showchannels(), __action_transfer(), and __action_transferhangup().
| #define local_astman_header | ( | m, | |||
| hdr, | |||||
| zap | ) | astman_get_header(m, (!zap) ? "DAHDI" hdr : "Zap" hdr) |
Definition at line 10588 of file chan_dahdi.c.
Referenced by __action_dialoffhook(), __action_dnd(), __action_transfer(), and __action_transferhangup().
| #define local_astman_register | ( | a, | |||
| b, | |||||
| c, | |||||
| d | ) |
| #define local_astman_unregister | ( | a | ) |
| #define MASK_AVAIL (1 << 0) |
Channel available for PRI use
Definition at line 279 of file chan_dahdi.c.
| #define MASK_INUSE (1 << 1) |
Channel currently in use
Definition at line 280 of file chan_dahdi.c.
| #define MAX_CHANLIST_LEN 80 |
The length of the parameters list of 'dahdichan'.
Definition at line 10975 of file chan_dahdi.c.
Referenced by process_dahdi().
| #define MAX_CHANNELS 672 |
No more than a DS3 per trunk group
Definition at line 189 of file chan_dahdi.c.
Referenced by mkintf().
| #define MAX_SLAVES 4 |
Definition at line 412 of file chan_dahdi.c.
Referenced by dahdi_link(), dahdi_show_channel(), dahdi_unlink(), isslavenative(), and update_conf().
| #define MIN_MS_SINCE_FLASH ( (2000) ) |
| #define NEED_MFDETECT | ( | p | ) | (((p)->sig == SIG_FEATDMF) || ((p)->sig == SIG_FEATDMF_TA) || ((p)->sig == SIG_E911) || ((p)->sig == SIG_FGC_CAMA) || ((p)->sig == SIG_FGC_CAMAMF) || ((p)->sig == SIG_FEATB)) |
Signaling types that need to use MF detection should be placed in this macro.
Definition at line 154 of file chan_dahdi.c.
Referenced by dahdi_new(), and ss_thread().
| #define NUM_CADENCE_MAX 25 |
| #define NUM_DCHANS 4 |
No more than 4 d-channels
Definition at line 188 of file chan_dahdi.c.
| #define NUM_SPANS 32 |
Definition at line 187 of file chan_dahdi.c.
| #define POLARITY_IDLE 0 |
Definition at line 367 of file chan_dahdi.c.
Referenced by dahdi_handle_event(), dahdi_hangup(), ss_thread(), and unalloc_sub().
| #define POLARITY_REV 1 |
Definition at line 368 of file chan_dahdi.c.
Referenced by dahdi_handle_event(), handle_init_event(), and ss_thread().
| #define READ_SIZE 160 |
Chunk size to read -- we use 20ms chunks to make things happy.
Definition at line 277 of file chan_dahdi.c.
Referenced by dahdi_callwait(), dahdi_open(), dahdi_read(), dahdi_sendtext(), dahdi_setoption(), my_dahdi_write(), process_dahdi(), and send_cwcidspill().
| #define sig2str dahdi_sig2str |
Definition at line 1270 of file chan_dahdi.c.
Referenced by __action_showchannels(), build_channels(), dahdi_handle_event(), dahdi_show_channel(), handle_init_event(), mkintf(), and ss_thread().
| #define SIG_E911 (0x1000000 | DAHDI_SIG_EM) |
Definition at line 167 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_EM DAHDI_SIG_EM |
Definition at line 162 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_EM_E1 DAHDI_SIG_EM_E1 |
Definition at line 183 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_EMWINK (0x0100000 | DAHDI_SIG_EM) |
Definition at line 163 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FEATB (0x0800000 | DAHDI_SIG_EM) |
Definition at line 166 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FEATD (0x0200000 | DAHDI_SIG_EM) |
Definition at line 164 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FEATDMF (0x0400000 | DAHDI_SIG_EM) |
Definition at line 165 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FEATDMF_TA (0x2000000 | DAHDI_SIG_EM) |
Definition at line 168 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FGC_CAMA (0x4000000 | DAHDI_SIG_EM) |
Definition at line 169 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FGC_CAMAMF (0x8000000 | DAHDI_SIG_EM) |
Definition at line 170 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FXOGS DAHDI_SIG_FXOGS |
Definition at line 175 of file chan_dahdi.c.
Referenced by available(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_hangup(), dahdi_new(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FXOKS DAHDI_SIG_FXOKS |
Definition at line 176 of file chan_dahdi.c.
Referenced by available(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_hangup(), dahdi_new(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FXOLS DAHDI_SIG_FXOLS |
Definition at line 174 of file chan_dahdi.c.
Referenced by available(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_hangup(), dahdi_new(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FXSGS DAHDI_SIG_FXSGS |
Definition at line 172 of file chan_dahdi.c.
Referenced by available(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_sig2str(), handle_init_event(), process_dahdi(), and ss_thread().
| #define SIG_FXSKS DAHDI_SIG_FXSKS |
Definition at line 173 of file chan_dahdi.c.
Referenced by available(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_new(), dahdi_request(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_FXSLS DAHDI_SIG_FXSLS |
Definition at line 171 of file chan_dahdi.c.
Referenced by available(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_GR303FXOKS (0x0100000 | DAHDI_SIG_FXOKS) |
Definition at line 184 of file chan_dahdi.c.
Referenced by dahdi_sig2str(), handle_init_event(), mkintf(), and process_dahdi().
| #define SIG_GR303FXSKS (0x0100000 | DAHDI_SIG_FXSKS) |
Definition at line 185 of file chan_dahdi.c.
Referenced by dahdi_sig2str(), handle_init_event(), mkintf(), and process_dahdi().
| #define SIG_PRI DAHDI_SIG_CLEAR |
Definition at line 177 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_confmute(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_enable_ec(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_new(), dahdi_read(), dahdi_sig2str(), dahdi_write(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_SF DAHDI_SIG_SF |
Definition at line 178 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_SF_FEATB (0x0800000 | DAHDI_SIG_SF) |
Definition at line 182 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SIG_SF_FEATD (0x0200000 | DAHDI_SIG_SF) |
Definition at line 180 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), and ss_thread().
| #define SIG_SF_FEATDMF (0x0400000 | DAHDI_SIG_SF) |
Definition at line 181 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), and ss_thread().
| #define SIG_SFWINK (0x0100000 | DAHDI_SIG_SF) |
Definition at line 179 of file chan_dahdi.c.
Referenced by dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_sig2str(), handle_init_event(), mkintf(), process_dahdi(), and ss_thread().
| #define SMDI_MD_WAIT_TIMEOUT 1500 |
| #define SUB_CALLWAIT 1 |
Call-Waiting call on hold
Definition at line 363 of file chan_dahdi.c.
Referenced by available(), dahdi_bridge(), dahdi_call(), dahdi_get_index(), dahdi_handle_event(), dahdi_hangup(), dahdi_read(), dahdi_request(), dahdi_show_channel(), features_hangup(), and ss_thread().
| #define SUB_REAL 0 |
Active call
Definition at line 362 of file chan_dahdi.c.
Referenced by __dahdi_exception(), attempt_transfer(), available(), bump_gains(), chandup(), check_for_conference(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_confmute(), dahdi_destroy_channel_bynum(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_disable_ec(), dahdi_enable_ec(), dahdi_get_index(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_new(), dahdi_read(), dahdi_request(), dahdi_ring_phone(), dahdi_setoption(), dahdi_train_ec(), dahdi_unlink(), destroy_dahdi_pvt(), disable_dtmf_detect(), do_monitor(), enable_dtmf_detect(), features_hangup(), features_request(), get_alarms(), handle_init_event(), mkintf(), reset_conf(), restore_conference(), restore_gains(), save_conference(), send_callerid(), ss_thread(), and update_conf().
| #define SUB_THREEWAY 2 |
Three-way call
Definition at line 364 of file chan_dahdi.c.
Referenced by attempt_transfer(), available(), dahdi_answer(), dahdi_bridge(), dahdi_get_index(), dahdi_handle_event(), dahdi_hangup(), dahdi_show_channel(), features_hangup(), and ss_thread().
| #define tdesc "DAHDI Telephony" |
| #define TRAILER_MS 5 |
Referenced by dahdi_sendtext().
| #define TRANSFER 0 |
Definition at line 10556 of file chan_dahdi.c.
Referenced by __action_transfer(), and dahdi_fake_event().
| static int __action_dialoffhook | ( | struct mansession * | s, | |
| const struct message * | m, | |||
| int | zap_mode | |||
| ) | [static] |
Definition at line 10686 of file chan_dahdi.c.
References AST_FRAME_DTMF, ast_strlen_zero(), astman_get_header(), astman_send_error(), dahdi_queue_frame(), find_channel(), local_astman_ack, local_astman_header, and dahdi_pvt::owner.
Referenced by dahdi_action_dialoffhook(), and zap_action_dialoffhook().
10687 { 10688 struct dahdi_pvt *p = NULL; 10689 const char *channel = local_astman_header(m, "Channel", zap_mode); 10690 const char *number = astman_get_header(m, "Number"); 10691 int i; 10692 10693 if (ast_strlen_zero(channel)) { 10694 astman_send_error(s, m, "No channel specified"); 10695 return 0; 10696 } 10697 if (ast_strlen_zero(number)) { 10698 astman_send_error(s, m, "No number specified"); 10699 return 0; 10700 } 10701 if (!(p = find_channel(atoi(channel)))) { 10702 astman_send_error(s, m, "No such channel"); 10703 return 0; 10704 } 10705 if (!p->owner) { 10706 astman_send_error(s, m, "Channel does not have an owner"); 10707 return 0; 10708 } 10709 for (i = 0; i < strlen(number); i++) { 10710 struct ast_frame f = { AST_FRAME_DTMF, number[i] }; 10711 10712 dahdi_queue_frame(p, &f, NULL); 10713 } 10714 local_astman_ack(s, m, "DialOffHook", zap_mode); 10715 10716 return 0; 10717 }
| static int __action_dnd | ( | struct mansession * | s, | |
| const struct message * | m, | |||
| int | zap_mode, | |||
| int | dnd | |||
| ) | [static] |
Definition at line 10590 of file chan_dahdi.c.
References ast_strlen_zero(), astman_send_error(), dahdi_pvt::dnd, find_channel(), local_astman_ack, and local_astman_header.
Referenced by dahdi_action_dndoff(), dahdi_action_dndon(), zap_action_dndoff(), and zap_action_dndon().
10591 { 10592 struct dahdi_pvt *p = NULL; 10593 const char *channel = local_astman_header(m, "Channel", zap_mode); 10594 10595 if (ast_strlen_zero(channel)) { 10596 astman_send_error(s, m, "No channel specified"); 10597 return 0; 10598 } 10599 if (!(p = find_channel(atoi(channel)))) { 10600 astman_send_error(s, m, "No such channel"); 10601 return 0; 10602 } 10603 p->dnd = dnd; 10604 local_astman_ack(s, m, "DND", zap_mode); 10605 10606 return 0; 10607 }
| static int __action_restart | ( | struct mansession * | s, | |
| const struct message * | m, | |||
| int | zap_mode | |||
| ) | [static] |
Definition at line 10784 of file chan_dahdi.c.
References astman_send_error(), dahdi_restart(), and local_astman_ack.
Referenced by dahdi_action_restart(), and zap_action_restart().
10785 { 10786 if (dahdi_restart() != 0) { 10787 if (zap_mode) { 10788 astman_send_error(s, m, "Failed to restart Zap"); 10789 } else { 10790 astman_send_error(s, m, "Failed to restart DAHDI"); 10791 } 10792 return 1; 10793 } 10794 local_astman_ack(s, m, "Restart: Success", zap_mode); 10795 return 0; 10796 }
| static int __action_showchannels | ( | struct mansession * | s, | |
| const struct message * | m, | |||
| int | zap_mode | |||
| ) | [static] |
Definition at line 10729 of file chan_dahdi.c.
References alarm, alarm2str(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), astman_append(), astman_get_header(), dahdi_pvt::channel, dahdi_pvt::context, dahdi_chan_name, dahdi_pvt::dnd, get_alarms(), iflist, iflock, local_astman_ack, dahdi_pvt::next, dahdi_pvt::sig, and sig2str.
Referenced by dahdi_action_showchannels(), and zap_action_showchannels().
10730 { 10731 struct dahdi_pvt *tmp = NULL; 10732 const char *id = astman_get_header(m, "ActionID"); 10733 char idText[256] = ""; 10734 10735 local_astman_ack(s, m, " channel status will follow", zap_mode); 10736 if (!ast_strlen_zero(id)) 10737 snprintf(idText, sizeof(idText) - 1, "ActionID: %s\r\n", id); 10738 10739 ast_mutex_lock(&iflock); 10740 10741 tmp = iflist; 10742 while (tmp) { 10743 if (tmp->channel > 0) { 10744 int alarm = get_alarms(tmp); 10745 astman_append(s, 10746 "Event: %sShowChannels\r\n" 10747 "Channel: %d\r\n" 10748 "Signalling: %s\r\n" 10749 "Context: %s\r\n" 10750 "DND: %s\r\n" 10751 "Alarm: %s\r\n" 10752 "%s" 10753 "\r\n", 10754 dahdi_chan_name, 10755 tmp->channel, sig2str(tmp->sig), tmp->context, 10756 tmp->dnd ? "Enabled" : "Disabled", 10757 alarm2str(alarm), idText); 10758 } 10759 10760 tmp = tmp->next; 10761 } 10762 10763 ast_mutex_unlock(&iflock); 10764 10765 astman_append(s, 10766 "Event: %sShowChannelsComplete\r\n" 10767 "%s" 10768 "\r\n", 10769 dahdi_chan_name, 10770 idText); 10771 return 0; 10772 }
| static int __action_transfer | ( | struct mansession * | s, | |
| const struct message * | m, | |||
| int | zap_mode | |||
| ) | [static] |
Definition at line 10629 of file chan_dahdi.c.
References ast_strlen_zero(), astman_send_error(), dahdi_fake_event(), find_channel(), local_astman_ack, local_astman_header, and TRANSFER.
Referenced by dahdi_action_transfer(), and zap_action_transfer().
10630 { 10631 struct dahdi_pvt *p = NULL; 10632 const char *channel = local_astman_header(m, "Channel", zap_mode); 10633 10634 if (ast_strlen_zero(channel)) { 10635 astman_send_error(s, m, "No channel specified"); 10636 return 0; 10637 } 10638 if (!(p = find_channel(atoi(channel)))) { 10639 astman_send_error(s, m, "No such channel"); 10640 return 0; 10641 } 10642 dahdi_fake_event(p,TRANSFER); 10643 local_astman_ack(s, m, "Transfer", zap_mode); 10644 10645 return 0; 10646 }
| static int __action_transferhangup | ( | struct mansession * | s, | |
| const struct message * | m, | |||
| int | zap_mode | |||
| ) | [static] |
Definition at line 10658 of file chan_dahdi.c.
References ast_strlen_zero(), astman_send_error(), dahdi_fake_event(), find_channel(), HANGUP, local_astman_ack, and local_astman_header.
Referenced by dahdi_action_transferhangup(), and zap_action_transferhangup().
10659 { 10660 struct dahdi_pvt *p = NULL; 10661 const char *channel = local_astman_header(m, "Channel", zap_mode); 10662 10663 if (ast_strlen_zero(channel)) { 10664 astman_send_error(s, m, "No channel specified"); 10665 return 0; 10666 } 10667 if (!(p = find_channel(atoi(channel)))) { 10668 astman_send_error(s, m, "No such channel"); 10669 return 0; 10670 } 10671 dahdi_fake_event(p, HANGUP); 10672 local_astman_ack(s, m, "Hangup", zap_mode); 10673 return 0; 10674 }
| static struct ast_frame* __dahdi_exception | ( | struct ast_channel * | ast | ) | [static, read] |
Definition at line 4631 of file chan_dahdi.c.
References ast_channel::_state, ast_bridged_channel(), AST_CONTROL_UNHOLD, AST_FRAME_NULL, ast_log(), ast_queue_control(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, ast_tv(), ast_verbose(), dahdi_pvt::callwaitingrepeat, dahdi_pvt::channel, dahdi_pvt::cidcwexpire, dahdi_disable_ec(), dahdi_enable_ec(), dahdi_get_event(), dahdi_get_index(), dahdi_handle_event(), dahdi_ring_phone(), dahdi_set_hook(), ast_frame::data, ast_frame::datalen, ast_frame::delivery, dahdi_subchannel::dfd, dahdi_pvt::dialing, event2str(), dahdi_subchannel::f, dahdi_pvt::fake_event, ast_channel::fds, dahdi_pvt::flashtime, ast_frame::frametype, LOG_DEBUG, LOG_WARNING, ast_frame::mallocd, ast_channel::name, dahdi_subchannel::needanswer, dahdi_subchannel::needunhold, ast_frame::offset, dahdi_pvt::oprmode, option_debug, option_verbose, dahdi_subchannel::owner, dahdi_pvt::owner, dahdi_pvt::radio, ast_frame::samples, ast_frame::src, SUB_REAL, ast_frame::subclass, dahdi_pvt::subs, ast_channel::tech_pvt, update_conf(), and VERBOSE_PREFIX_3.
Referenced by dahdi_exception(), and dahdi_read().
04632 { 04633 struct dahdi_pvt *p = ast->tech_pvt; 04634 int res; 04635 int usedindex=-1; 04636 int index; 04637 struct ast_frame *f; 04638 04639 04640 index = dahdi_get_index(ast, p, 1); 04641 04642 p->subs[index].f.frametype = AST_FRAME_NULL; 04643 p->subs[index].f.datalen = 0; 04644 p->subs[index].f.samples = 0; 04645 p->subs[index].f.mallocd = 0; 04646 p->subs[index].f.offset = 0; 04647 p->subs[index].f.subclass = 0; 04648 p->subs[index].f.delivery = ast_tv(0,0); 04649 p->subs[index].f.src = "dahdi_exception"; 04650 p->subs[index].f.data = NULL; 04651 04652 04653 if ((!p->owner) && (!(p->radio || (p->oprmode < 0)))) { 04654 /* If nobody owns us, absorb the event appropriately, otherwise 04655 we loop indefinitely. This occurs when, during call waiting, the 04656 other end hangs up our channel so that it no longer exists, but we 04657 have neither FLASH'd nor ONHOOK'd to signify our desire to 04658 change to the other channel. */ 04659 if (p->fake_event) { 04660 res = p->fake_event; 04661 p->fake_event = 0; 04662 } else 04663 res = dahdi_get_event(p->subs[SUB_REAL].dfd); 04664 /* Switch to real if there is one and this isn't something really silly... */ 04665 if ((res != DAHDI_EVENT_RINGEROFF) && (res != DAHDI_EVENT_RINGERON) && 04666 (res != DAHDI_EVENT_HOOKCOMPLETE)) { 04667 ast_log(LOG_DEBUG, "Restoring owner of channel %d on event %d\n", p->channel, res); 04668 p->owner = p->subs[SUB_REAL].owner; 04669 if (p->owner && ast_bridged_channel(p->owner)) 04670 ast_queue_control(p->owner, AST_CONTROL_UNHOLD); 04671 p->subs[SUB_REAL].needunhold = 1; 04672 } 04673 switch (res) { 04674 case DAHDI_EVENT_ONHOOK: 04675 dahdi_disable_ec(p); 04676 if (p->owner) { 04677 if (option_verbose > 2) 04678 ast_verbose(VERBOSE_PREFIX_3 "Channel %s still has call, ringing phone\n", p->owner->name); 04679 dahdi_ring_phone(p); 04680 p->callwaitingrepeat = 0; 04681 p->cidcwexpire = 0; 04682 } else 04683 ast_log(LOG_WARNING, "Absorbed on hook, but nobody is left!?!?\n"); 04684 update_conf(p); 04685 break; 04686 case DAHDI_EVENT_RINGOFFHOOK: 04687 dahdi_enable_ec(p); 04688 dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_OFFHOOK); 04689 if (p->owner && (p->owner->_state == AST_STATE_RINGING)) { 04690 p->subs[SUB_REAL].needanswer = 1; 04691 p->dialing = 0; 04692 } 04693 break; 04694 case DAHDI_EVENT_HOOKCOMPLETE: 04695 case DAHDI_EVENT_RINGERON: 04696 case DAHDI_EVENT_RINGEROFF: 04697 /* Do nothing */ 04698 break; 04699 case DAHDI_EVENT_WINKFLASH: 04700 gettimeofday(&p->flashtime, NULL); 04701 if (p->owner) { 04702 if (option_verbose > 2) 04703 ast_verbose(VERBOSE_PREFIX_3 "Channel %d flashed to other channel %s\n", p->channel, p->owner->name); 04704 if (p->owner->_state != AST_STATE_UP) { 04705 /* Answer if necessary */ 04706 usedindex = dahdi_get_index(p->owner, p, 0); 04707 if (usedindex > -1) { 04708 p->subs[usedindex].needanswer = 1; 04709 } 04710 ast_setstate(p->owner, AST_STATE_UP); 04711 } 04712 p->callwaitingrepeat = 0; 04713 p->cidcwexpire = 0; 04714 if (ast_bridged_channel(p->owner)) 04715 ast_queue_control(p->owner, AST_CONTROL_UNHOLD); 04716 p->subs[SUB_REAL].needunhold = 1; 04717 } else 04718 ast_log(LOG_WARNING, "Absorbed on hook, but nobody is left!?!?\n"); 04719 update_conf(p); 04720 break; 04721 default: 04722 ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", event2str(res)); 04723 } 04724 f = &p->subs[index].f; 04725 return f; 04726 } 04727 if (!(p->radio || (p->oprmode < 0)) && option_debug) 04728 ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel); 04729 /* If it's not us, return NULL immediately */ 04730 if (ast != p->owner) { 04731 ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name); 04732 f = &p->subs[index].f; 04733 return f; 04734 } 04735 f = dahdi_handle_event(ast); 04736 return f; 04737 }
| static void __reg_module | ( | void | ) | [static] |
Definition at line 12011 of file chan_dahdi.c.
| static int __unload_module | ( | void | ) | [static] |
Definition at line 10815 of file chan_dahdi.c.
References ast_channel_unregister(), ast_cli_unregister_multiple(), ast_cond_destroy(), ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_NULL, AST_PTHREADT_STOP, ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_unregister_application(), CHAN_DAHDI_PLUS_ZAP_MODE, dahdi_chan_mode, destroy_all_channels(), iflist, iflock, local_astman_unregister, master, monlock, dahdi_pvt::next, and dahdi_pvt::owner.
Referenced by load_module(), and unload_module().
10816 { 10817 struct dahdi_pvt *p; 10818 10819 #ifdef HAVE_PRI 10820 int i, j; 10821 for (i = 0; i < NUM_SPANS; i++) { 10822 if (pris[i].master != AST_PTHREADT_NULL) 10823 pthread_cancel(pris[i].master); 10824 } 10825 ast_cli_unregister_multiple(dahdi_pri_cli, sizeof(dahdi_pri_cli) / sizeof(struct ast_cli_entry)); 10826 10827 if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { 10828 ast_unregister_application(dahdi_send_keypad_facility_app); 10829 } 10830 ast_unregister_application(zap_send_keypad_facility_app); 10831 #endif 10832 ast_cli_unregister_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry)); 10833 local_astman_unregister("DialOffHook"); 10834 local_astman_unregister("Hangup"); 10835 local_astman_unregister("Transfer"); 10836 local_astman_unregister("DNDoff"); 10837 local_astman_unregister("DNDon"); 10838 local_astman_unregister("ShowChannels"); 10839 local_astman_unregister("Restart"); 10840 ast_channel_unregister(chan_tech); 10841 ast_mutex_lock(&iflock); 10842 /* Hangup all interfaces if they have an owner */ 10843 p = iflist; 10844 while (p) { 10845 if (p->owner) 10846 ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD); 10847 p = p->next; 10848 } 10849 ast_mutex_unlock(&iflock); 10850 ast_mutex_lock(&monlock); 10851 if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) { 10852 pthread_cancel(monitor_thread); 10853 pthread_kill(monitor_thread, SIGURG); 10854 pthread_join(monitor_thread, NULL); 10855 } 10856 monitor_thread = AST_PTHREADT_STOP; 10857 ast_mutex_unlock(&monlock); 10858 10859 destroy_all_channels(); 10860 #ifdef HAVE_PRI 10861 for (i = 0; i < NUM_SPANS; i++) { 10862 if (pris[i].master && (pris[i].master != AST_PTHREADT_NULL)) 10863 pthread_join(pris[i].master, NULL); 10864 for (j = 0; j < NUM_DCHANS; j++) { 10865 dahdi_close_pri_fd(&(pris[i]), j); 10866 } 10867 } 10868 #endif 10869 ast_cond_destroy(&ss_thread_complete); 10870 return 0; 10871 }
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 12011 of file chan_dahdi.c.
| static char* alarm2str | ( | int | alarm | ) | [static] |
Definition at line 1181 of file chan_dahdi.c.
References alarms.
Referenced by __action_showchannels(), and handle_alarms().
01182 { 01183 int x; 01184 for (x = 0; x < sizeof(alarms) / sizeof(alarms[0]); x++) { 01185 if (alarms[x].alarm & alarm) 01186 return alarms[x].name; 01187 } 01188 return alarm ? "Unknown Alarm" : "No Alarm"; 01189 }
| static int alloc_sub | ( | struct dahdi_pvt * | p, | |
| int | x | |||
| ) | [static] |
Definition at line 979 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::buf_no, dahdi_pvt::buf_policy, dahdi_subchannel::chan, dahdi_pvt::channel, dahdi_close_sub(), dahdi_open(), dahdi_subchannel::dfd, errno, LOG_DEBUG, LOG_WARNING, option_debug, and dahdi_pvt::subs.
Referenced by dahdi_handle_event(), dahdi_request(), and ss_thread().
00980 { 00981 struct dahdi_bufferinfo bi; 00982 int res; 00983 if (p->subs[x].dfd < 0) { 00984 #ifdef HAVE_ZAPTEL 00985 p->subs[x].dfd = dahdi_open("/dev/zap/pseudo"); 00986 #else 00987 p->subs[x].dfd = dahdi_open("/dev/dahdi/pseudo"); 00988 #endif 00989 if (p->subs[x].dfd > -1) { 00990 res = ioctl(p->subs[x].dfd, DAHDI_GET_BUFINFO, &bi); 00991 if (!res) { 00992 bi.txbufpolicy = p->buf_policy; 00993 bi.rxbufpolicy = p->buf_policy; 00994 bi.numbufs = p->buf_no; 00995 res = ioctl(p->subs[x].dfd, DAHDI_SET_BUFINFO, &bi); 00996 if (res < 0) { 00997 ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d: %s\n", x, strerror(errno)); 00998 } 00999 } else 01000 ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d: %s\n", x, strerror(errno)); 01001 if (ioctl(p->subs[x].dfd, DAHDI_CHANNO, &p->subs[x].chan) == 1) { 01002 ast_log(LOG_WARNING, "Unable to get channel number for pseudo channel on FD %d: %s\n", p->subs[x].dfd, strerror(errno)); 01003 dahdi_close_sub(p, x); 01004 return -1; 01005 } 01006 if (option_debug) 01007 ast_log(LOG_DEBUG, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].dfd, p->subs[x].chan); 01008 return 0; 01009 } else 01010 ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno)); 01011 return -1; 01012 } 01013 ast_log(LOG_WARNING, "%s subchannel of %d already in use\n", subnames[x], p->channel); 01014 return -1; 01015 }
| static int attempt_transfer | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 3593 of file chan_dahdi.c.
References ast_channel::_softhangup, ast_channel::_state, ast_bridged_channel(), ast_channel_masquerade(), AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, ast_indicate(), ast_log(), ast_mutex_unlock(), ast_queue_control(), AST_SOFTHANGUP_DEV, AST_STATE_RING, AST_STATE_RINGING, dahdi_subchannel::dfd, ast_channel::lock, LOG_DEBUG, LOG_WARNING, ast_channel::name, dahdi_subchannel::owner, SUB_REAL, SUB_THREEWAY, dahdi_pvt::subs, swap_subs(), and unalloc_sub().
Referenced by dahdi_handle_event(), handle_onhook_message(), and handle_soft_key_event_message().
03594 { 03595 /* In order to transfer, we need at least one of the channels to 03596 actually be in a call bridge. We can't conference two applications 03597 together (but then, why would we want to?) */ 03598 if (ast_bridged_channel(p->subs[SUB_REAL].owner)) { 03599 /* The three-way person we're about to transfer to could still be in MOH, so 03600 stop if now if appropriate */ 03601 if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) 03602 ast_queue_control(p->subs[SUB_THREEWAY].owner, AST_CONTROL_UNHOLD); 03603 if (p->subs[SUB_REAL].owner->_state == AST_STATE_RINGING) { 03604 ast_indicate(ast_bridged_channel(p->subs[SUB_REAL].owner), AST_CONTROL_RINGING); 03605 } 03606 if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RING) { 03607 tone_zone_play_tone(p->subs[SUB_THREEWAY].dfd, DAHDI_TONE_RINGTONE); 03608 } 03609 if (ast_channel_masquerade(p->subs[SUB_THREEWAY].owner, ast_bridged_channel(p->subs[SUB_REAL].owner))) { 03610 ast_log(LOG_WARNING, "Unable to masquerade %s as %s\n", 03611 ast_bridged_channel(p->subs[SUB_REAL].owner)->name, p->subs[SUB_THREEWAY].owner->name); 03612 return -1; 03613 } 03614 /* Orphan the channel after releasing the lock */ 03615 ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); 03616 unalloc_sub(p, SUB_THREEWAY); 03617 } else if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) { 03618 ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD); 03619 if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RINGING) { 03620 ast_indicate(ast_bridged_channel(p->subs[SUB_THREEWAY].owner), AST_CONTROL_RINGING); 03621 } 03622 if (p->subs[SUB_REAL].owner->_state == AST_STATE_RING) { 03623 tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_RINGTONE); 03624 } 03625 if (ast_channel_masquerade(p->subs[SUB_REAL].owner, ast_bridged_channel(p->subs[SUB_THREEWAY].owner))) { 03626 ast_log(LOG_WARNING, "Unable to masquerade %s as %s\n", 03627 ast_bridged_channel(p->subs[SUB_THREEWAY].owner)->name, p->subs[SUB_REAL].owner->name); 03628 return -1; 03629 } 03630 /* Three-way is now the REAL */ 03631 swap_subs(p, SUB_THREEWAY, SUB_REAL); 03632 ast_mutex_unlock(&p->subs[SUB_REAL].owner->lock); 03633 unalloc_sub(p, SUB_THREEWAY); 03634 /* Tell the caller not to hangup */ 03635 return 1; 03636 } else { 03637 ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n", 03638 p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name); 03639 p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; 03640 return -1; 03641 } 03642 return 0; 03643 }
| static int available | ( | struct dahdi_pvt * | p, | |
| int | channelmatch, | |||
| ast_group_t | groupmatch, | |||
| int * | busy, | |||
| int * | channelmatched, | |||
| int * | groupmatched | |||
| ) | [inline, static] |
Definition at line 7776 of file chan_dahdi.c.
References ast_channel::_state, ast_log(), AST_STATE_RINGING, AST_STATE_UP, dahdi_pvt::callwaiting, dahdi_pvt::channel, dahdi_subchannel::dfd, dahdi_pvt::dnd, errno, dahdi_pvt::group, dahdi_pvt::guardtime, dahdi_subchannel::inthreeway, LOG_DEBUG, LOG_WARNING, dahdi_pvt::oprmode, dahdi_pvt::outgoing, dahdi_subchannel::owner, dahdi_pvt::owner, dahdi_pvt::radio, dahdi_pvt::sig, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SUB_CALLWAIT, SUB_REAL, SUB_THREEWAY, and dahdi_pvt::subs.
Referenced by dahdi_request().
07777 { 07778 int res; 07779 struct dahdi_params par; 07780 07781 /* First, check group matching */ 07782 if (groupmatch) { 07783 if ((p->group & groupmatch) != groupmatch) 07784 return 0; 07785 *groupmatched = 1; 07786 } 07787 /* Check to see if we have a channel match */ 07788 if (channelmatch != -1) { 07789 if (p->channel != channelmatch) 07790 return 0; 07791 *channelmatched = 1; 07792 } 07793 /* We're at least busy at this point */ 07794 if (busy) { 07795 if ((p->sig == SIG_FXOKS) || (p->sig == SIG_FXOLS) || (p->sig == SIG_FXOGS)) 07796 *busy = 1; 07797 } 07798 /* If do not disturb, definitely not */ 07799 if (p->dnd) 07800 return 0; 07801 /* If guard time, definitely not */ 07802 if (p->guardtime && (time(NULL) < p->guardtime)) 07803 return 0; 07804 07805 /* If no owner definitely available */ 07806 if (!p->owner) { 07807 #ifdef HAVE_PRI 07808 /* Trust PRI */ 07809 if (p->pri) { 07810 if (p->resetting || p->call) 07811 return 0; 07812 else 07813 return 1; 07814 } 07815 #endif 07816 if (!(p->radio || (p->oprmode < 0))) 07817 { 07818 if (!p->sig || (p->sig == SIG_FXSLS)) 07819 return 1; 07820 /* Check hook state */ 07821 if (p->subs[SUB_REAL].dfd > -1) 07822 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &par); 07823 else { 07824 /* Assume not off hook on CVRS */ 07825 res = 0; 07826 par.rxisoffhook = 0; 07827 } 07828 if (res) { 07829 ast_log(LOG_WARNING, "Unable to check hook state on channel %d: %s\n", p->channel, strerror(errno)); 07830 } else if ((p->sig == SIG_FXSKS) || (p->sig == SIG_FXSGS)) { 07831 /* When "onhook" that means no battery on the line, and thus 07832 it is out of service..., if it's on a TDM card... If it's a channel 07833 bank, there is no telling... */ 07834 if (par.rxbits > -1) 07835 return 1; 07836 if (par.rxisoffhook) 07837 return 1; 07838 else 07839 #ifdef DAHDI_CHECK_HOOKSTATE 07840 return 0; 07841 #else 07842 return 1; 07843 #endif 07844 } else if (par.rxisoffhook) { 07845 ast_log(LOG_DEBUG, "Channel %d off hook, can't use\n", p->channel); 07846 /* Not available when the other end is off hook */ 07847 return 0; 07848 } 07849 } 07850 return 1; 07851 } 07852 07853 /* If it's not an FXO, forget about call wait */ 07854 if ((p->sig != SIG_FXOKS) && (p->sig != SIG_FXOLS) && (p->sig != SIG_FXOGS)) 07855 return 0; 07856 07857 if (!p->callwaiting) { 07858 /* If they don't have call waiting enabled, then for sure they're unavailable at this point */ 07859 return 0; 07860 } 07861 07862 if (p->subs[SUB_CALLWAIT].dfd > -1) { 07863 /* If there is already a call waiting call, then we can't take a second one */ 07864 return 0; 07865 } 07866 07867 if ((p->owner->_state != AST_STATE_UP) && 07868 ((p->owner->_state != AST_STATE_RINGING) || p->outgoing)) { 07869 /* If the current call is not up, then don't allow the call */ 07870 return 0; 07871 } 07872 if ((p->subs[SUB_THREEWAY].owner) && (!p->subs[SUB_THREEWAY].inthreeway)) { 07873 /* Can't take a call wait when the three way calling hasn't been merged yet. */ 07874 return 0; 07875 } 07876 /* We're cool */ 07877 return 1; 07878 }
| static int build_channels | ( | struct dahdi_chan_conf * | conf, | |
| int | iscrv, | |||
| const char * | value, | |||
| int | reload, | |||
| int | lineno, | |||
| int * | found_pseudo | |||
| ) | [static] |
Definition at line 10883 of file chan_dahdi.c.
References ast_log(), ast_strdupa, ast_verbose(), dahdi_chan_conf::chan, CHAN_PSEUDO, LOG_ERROR, LOG_WARNING, mkintf(), option_verbose, dahdi_pvt::sig, sig2str, and VERBOSE_PREFIX_3.
Referenced by process_dahdi().
10884 { 10885 char *c, *chan; 10886 int x, start, finish; 10887 struct dahdi_pvt *tmp; 10888 #ifdef HAVE_PRI 10889 struct dahdi_pri *pri; 10890 int trunkgroup, y; 10891 #endif 10892 10893 if ((reload == 0) && (conf->chan.sig < 0)) { 10894 ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n"); 10895 return -1; 10896 } 10897 10898 c = ast_strdupa(value); 10899 10900 #ifdef HAVE_PRI 10901 pri = NULL; 10902 if (iscrv) { 10903 if (sscanf(c, "%d:%n", &trunkgroup, &y) != 1) { 10904 ast_log(LOG_WARNING, "CRV must begin with trunkgroup followed by a colon at line %d\n", lineno); 10905 return -1; 10906 } 10907 if (trunkgroup < 1) { 10908 ast_log(LOG_WARNING, "CRV trunk group must be a positive number at line %d\n", lineno); 10909 return -1; 10910 } 10911 c += y; 10912 for (y = 0; y < NUM_SPANS; y++) { 10913 if (pris[y].trunkgroup == trunkgroup) { 10914 pri = pris + y; 10915 break; 10916 } 10917 } 10918 if (!pri) { 10919 ast_log(LOG_WARNING, "No such trunk group %d at CRV declaration at line %d\n", trunkgroup, lineno); 10920 return -1; 10921 } 10922 } 10923 #endif 10924 10925 while ((chan = strsep(&c, ","))) { 10926 if (sscanf(chan, "%d-%d", &start, &finish) == 2) { 10927 /* Range */ 10928 } else if (sscanf(chan, "%d", &start)) { 10929 /* Just one */ 10930 finish = start; 10931 } else if (!strcasecmp(chan, "pseudo")) { 10932 finish = start = CHAN_PSEUDO; 10933 if (found_pseudo) 10934 *found_pseudo = 1; 10935 } else { 10936 ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'\n", value, chan); 10937 return -1; 10938 } 10939 if (finish < start) { 10940 ast_log(LOG_WARNING, "Sillyness: %d < %d\n", start, finish); 10941 x = finish; 10942 finish = start; 10943 start = x; 10944 } 10945 10946 for (x = start; x <= finish; x++) { 10947 #ifdef HAVE_PRI 10948 tmp = mkintf(x, conf, pri, reload); 10949 #else 10950 tmp = mkintf(x, conf, NULL, reload); 10951 #endif 10952 10953 if (tmp) { 10954 if (option_verbose > 2) { 10955 #ifdef HAVE_PRI 10956 if (pri) 10957 ast_verbose(VERBOSE_PREFIX_3 "%s CRV %d:%d, %s signalling\n", reload ? "Reconfigured" : "Registered", trunkgroup, x, sig2str(tmp->sig)); 10958 else 10959 #endif 10960 ast_verbose(VERBOSE_PREFIX_3 "%s channel %d, %s signalling\n", reload ? "Reconfigured" : "Registered", x, sig2str(tmp->sig)); 10961 } 10962 } else { 10963 ast_log(LOG_ERROR, "Unable to %s channel '%s'\n", 10964 (reload == 1) ? "reconfigure" : "register", value); 10965 return -1; 10966 } 10967 } 10968 } 10969 10970 return 0; 10971 }
| static int bump_gains | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1632 of file chan_dahdi.c.
References ast_log(), dahdi_subchannel::dfd, errno, dahdi_pvt::law, LOG_WARNING, dahdi_pvt::rxgain, set_actual_gain(), SUB_REAL, dahdi_pvt::subs, and dahdi_pvt::txgain.
Referenced by ss_thread().
01633 { 01634 int res; 01635 01636 /* Bump receive gain by 5.0db */ 01637 res = set_actual_gain(p->subs[SUB_REAL].dfd, 0, p->rxgain + 5.0, p->txgain, p->law); 01638 if (res) { 01639 ast_log(LOG_WARNING, "Unable to bump gain: %s\n", strerror(errno)); 01640 return -1; 01641 } 01642 01643 return 0; 01644 }
Definition at line 7880 of file chan_dahdi.c.
References ast_log(), ast_malloc, ast_mutex_init(), dahdi_pvt::buf_no, dahdi_pvt::buf_policy, dahdi_open(), dahdi_pvt::destroy, destroy_dahdi_pvt(), dahdi_subchannel::dfd, errno, iflist, dahdi_pvt::lock, LOG_ERROR, LOG_WARNING, dahdi_pvt::next, dahdi_pvt::prev, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_request().
07881 { 07882 struct dahdi_pvt *p; 07883 struct dahdi_bufferinfo bi; 07884 int res; 07885 07886 if ((p = ast_malloc(sizeof(*p)))) { 07887 memcpy(p, src, sizeof(struct dahdi_pvt)); 07888 ast_mutex_init(&p->lock); 07889 #ifdef HAVE_ZAPTEL 07890 p->subs[SUB_REAL].dfd = dahdi_open("/dev/zap/pseudo"); 07891 #else 07892 p->subs[SUB_REAL].dfd = dahdi_open("/dev/dahdi/pseudo"); 07893 #endif 07894 /* Allocate a DAHDI structure */ 07895 if (p->subs[SUB_REAL].dfd < 0) { 07896 ast_log(LOG_ERROR, "Unable to dup channel: %s\n", strerror(errno)); 07897 destroy_dahdi_pvt(&p); 07898 return NULL; 07899 } 07900 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_BUFINFO, &bi); 07901 if (!res) { 07902 bi.txbufpolicy = p->buf_policy; 07903 bi.rxbufpolicy = p->buf_policy; 07904 bi.numbufs = p->buf_no; 07905 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SET_BUFINFO, &bi); 07906 if (res < 0) { 07907 ast_log(LOG_WARNING, "Unable to set buffer policy on dup channel: %s\n", strerror(errno)); 07908 } 07909 } else 07910 ast_log(LOG_WARNING, "Unable to check buffer policy on dup channel: %s\n", strerror(errno)); 07911 } 07912 p->destroy = 1; 07913 p->next = iflist; 07914 p->prev = NULL; 07915 iflist = p; 07916 if (iflist->next) 07917 iflist->next->prev = p; 07918 return p; 07919 }
| static int check_for_conference | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 3645 of file chan_dahdi.c.
References ast_log(), ast_verbose(), dahdi_pvt::channel, dahdi_pvt::confno, dahdi_subchannel::curconf, dahdi_subchannel::dfd, errno, LOG_WARNING, dahdi_pvt::master, option_verbose, SUB_REAL, dahdi_pvt::subs, and VERBOSE_PREFIX_3.
Referenced by dahdi_handle_event().
03646 { 03647 struct dahdi_confinfo ci; 03648 /* Fine if we already have a master, etc */ 03649 if (p->master || (p->confno > -1)) 03650 return 0; 03651 memset(&ci, 0, sizeof(ci)); 03652 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_GETCONF, &ci)) { 03653 ast_log(LOG_WARNING, "Failed to get conference info on channel %d: %s\n", p->channel, strerror(errno)); 03654 return 0; 03655 } 03656 /* If we have no master and don't have a confno, then 03657 if we're in a conference, it's probably a MeetMe room or 03658 some such, so don't let us 3-way out! */ 03659 if ((p->subs[SUB_REAL].curconf.confno != ci.confno) || (p->subs[SUB_REAL].curconf.confmode != ci.confmode)) { 03660 if (option_verbose > 2) 03661 ast_verbose(VERBOSE_PREFIX_3 "Avoiding 3-way call when in an external conference\n"); 03662 return 1; 03663 } 03664 return 0; 03665 }
| static int conf_add | ( | struct dahdi_pvt * | p, | |
| struct dahdi_subchannel * | c, | |||
| int | index, | |||
| int | slavechannel | |||
| ) | [static] |
Definition at line 1272 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::confno, dahdi_subchannel::curconf, dahdi_subchannel::dfd, errno, LOG_DEBUG, and LOG_WARNING.
Referenced by update_conf().
01273 { 01274 /* If the conference already exists, and we're already in it 01275 don't bother doing anything */ 01276 struct dahdi_confinfo zi; 01277 01278 memset(&zi, 0, sizeof(zi)); 01279 zi.chan = 0; 01280 01281 if (slavechannel > 0) { 01282 /* If we have only one slave, do a digital mon */ 01283 zi.confmode = DAHDI_CONF_DIGITALMON; 01284 zi.confno = slavechannel; 01285 } else { 01286 if (!index) { 01287 /* Real-side and pseudo-side both participate in conference */ 01288 zi.confmode = DAHDI_CONF_REALANDPSEUDO | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER | 01289 DAHDI_CONF_PSEUDO_TALKER | DAHDI_CONF_PSEUDO_LISTENER; 01290 } else 01291 zi.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER; 01292 zi.confno = p->confno; 01293 } 01294 if ((zi.confno == c->curconf.confno) && (zi.confmode == c->curconf.confmode)) 01295 return 0; 01296 if (c->dfd < 0) 01297 return 0; 01298 if (ioctl(c->dfd, DAHDI_SETCONF, &zi)) { 01299 ast_log(LOG_WARNING, "Failed to add %d to conference %d/%d: %s\n", c->dfd, zi.confmode, zi.confno, strerror(errno)); 01300 return -1; 01301 } 01302 if (slavechannel < 1) { 01303 p->confno = zi.confno; 01304 } 01305 memcpy(&c->curconf, &zi, sizeof(c->curconf)); 01306 ast_log(LOG_DEBUG, "Added %d to conference %d/%d\n", c->dfd, c->curconf.confmode, c->curconf.confno); 01307 return 0; 01308 }
| static int conf_del | ( | struct dahdi_pvt * | p, | |
| struct dahdi_subchannel * | c, | |||
| int | index | |||
| ) | [static] |
Definition at line 1321 of file chan_dahdi.c.
References ast_log(), dahdi_subchannel::curconf, dahdi_subchannel::dfd, errno, isourconf(), LOG_DEBUG, and LOG_WARNING.
Referenced by dahdi_unlink(), and update_conf().
01322 { 01323 struct dahdi_confinfo zi; 01324 if (/* Can't delete if there's no dfd */ 01325 (c->dfd < 0) || 01326 /* Don't delete from the conference if it's not our conference */ 01327 !isourconf(p, c) 01328 /* Don't delete if we don't think it's conferenced at all (implied) */ 01329 ) return 0; 01330 memset(&zi, 0, sizeof(zi)); 01331 zi.chan = 0; 01332 zi.confno = 0; 01333 zi.confmode = 0; 01334 if (ioctl(c->dfd, DAHDI_SETCONF, &zi)) { 01335 ast_log(LOG_WARNING, "Failed to drop %d from conference %d/%d: %s\n", c->dfd, c->curconf.confmode, c->curconf.confno, strerror(errno)); 01336 return -1; 01337 } 01338 ast_log(LOG_DEBUG, "Removed %d from conference %d/%d\n", c->dfd, c->curconf.confmode, c->curconf.confno); 01339 memcpy(&c->curconf, &zi, sizeof(c->curconf)); 01340 return 0; 01341 }
| static int dahdi_action_dialoffhook | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10724 of file chan_dahdi.c.
References __action_dialoffhook().
10725 { 10726 return __action_dialoffhook(s, m, 0); 10727 }
| static int dahdi_action_dndoff | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10624 of file chan_dahdi.c.
References __action_dnd().
10625 { 10626 return __action_dnd(s, m, 0, 0); 10627 }
| static int dahdi_action_dndon | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10614 of file chan_dahdi.c.
References __action_dnd().
10615 { 10616 return __action_dnd(s, m, 0, 1); 10617 }
| static int dahdi_action_restart | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10803 of file chan_dahdi.c.
References __action_restart().
10804 { 10805 return __action_restart(s, m, 0); 10806 }
| static int dahdi_action_showchannels | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10779 of file chan_dahdi.c.
References __action_showchannels().
10780 { 10781 return __action_showchannels(s, m, 0); 10782 }
| static int dahdi_action_transfer | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10653 of file chan_dahdi.c.
References __action_transfer().
10654 { 10655 return __action_transfer(s, m, 0); 10656 }
| static int dahdi_action_transferhangup | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10681 of file chan_dahdi.c.
References __action_transferhangup().
10682 { 10683 return __action_transferhangup(s, m, 0); 10684 }
| static int dahdi_answer | ( | struct ast_channel * | ast | ) | [static] |
Definition at line 2839 of file chan_dahdi.c.
References ast_channel::_state, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, dahdi_pvt::channel, dahdi_enable_ec(), dahdi_get_index(), dahdi_set_hook(), dahdi_train_ec(), dahdi_subchannel::dfd, dahdi_pvt::dialing, dahdi_pvt::digital, dahdi_pvt::hanguponpolarityswitch, dahdi_subchannel::inthreeway, dahdi_pvt::lock, LOG_DEBUG, LOG_WARNING, ast_channel::name, dahdi_pvt::oprmode, dahdi_subchannel::owner, dahdi_pvt::owner, dahdi_pvt::polaritydelaytv, dahdi_pvt::radio, dahdi_pvt::ringt, dahdi_pvt::sig, SIG_E911, SIG_EM, SIG_EM_E1, SIG_EMWINK, SIG_FEATB, SIG_FEATD, SIG_FEATDMF, SIG_FEATDMF_TA, SIG_FGC_CAMA, SIG_FGC_CAMAMF, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_PRI, SIG_SF, SIG_SF_FEATB, SIG_SF_FEATD, SIG_SF_FEATDMF, SIG_SFWINK, dahdi_pvt::span, SUB_REAL, SUB_THREEWAY, dahdi_pvt::subs, swap_subs(), and ast_channel::tech_pvt.
02840 { 02841 struct dahdi_pvt *p = ast->tech_pvt; 02842 int res = 0; 02843 int index; 02844 int oldstate = ast->_state; 02845 ast_setstate(ast, AST_STATE_UP); 02846 ast_mutex_lock(&p->lock); 02847 index = dahdi_get_index(ast, p, 0); 02848 if (index < 0) 02849 index = SUB_REAL; 02850 /* nothing to do if a radio channel */ 02851 if ((p->radio || (p->oprmode < 0))) { 02852 ast_mutex_unlock(&p->lock); 02853 return 0; 02854 } 02855 switch (p->sig) { 02856 case SIG_FXSLS: 02857 case SIG_FXSGS: 02858 case SIG_FXSKS: 02859 p->ringt = 0; 02860 /* Fall through */ 02861 case SIG_EM: 02862 case SIG_EM_E1: 02863 case SIG_EMWINK: 02864 case SIG_FEATD: 02865 case SIG_FEATDMF: 02866 case SIG_FEATDMF_TA: 02867 case SIG_E911: 02868 case SIG_FGC_CAMA: 02869 case SIG_FGC_CAMAMF: 02870 case SIG_FEATB: 02871 case SIG_SF: 02872 case SIG_SFWINK: 02873 case SIG_SF_FEATD: 02874 case SIG_SF_FEATDMF: 02875 case SIG_SF_FEATB: 02876 case SIG_FXOLS: 02877 case SIG_FXOGS: 02878 case SIG_FXOKS: 02879 /* Pick up the line */ 02880 ast_log(LOG_DEBUG, "Took %s off hook\n", ast->name); 02881 if (p->hanguponpolarityswitch) { 02882 gettimeofday(&p->polaritydelaytv, NULL); 02883 } 02884 res = dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_OFFHOOK); 02885 tone_zone_play_tone(p->subs[index].dfd, -1); 02886 p->dialing = 0; 02887 if ((index == SUB_REAL) && p->subs[SUB_THREEWAY].inthreeway) { 02888 if (oldstate == AST_STATE_RINGING) { 02889 ast_log(LOG_DEBUG, "Finally swapping real and threeway\n"); 02890 tone_zone_play_tone(p->subs[SUB_THREEWAY].dfd, -1); 02891 swap_subs(p, SUB_THREEWAY, SUB_REAL); 02892 p->owner = p->subs[SUB_REAL].owner; 02893 } 02894 } 02895 if (p->sig & __DAHDI_SIG_FXS) { 02896 dahdi_enable_ec(p); 02897 dahdi_train_ec(p); 02898 } 02899 break; 02900 #ifdef HAVE_PRI 02901 case SIG_PRI: 02902 /* Send a pri acknowledge */ 02903 if (!pri_grab(p, p->pri)) { 02904 p->proceeding = 1; 02905 res = pri_answer(p->pri->pri, p->call, 0, !p->digital); 02906 pri_rel(p->pri); 02907 } else { 02908 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 02909 res = -1; 02910 } 02911 break; 02912 #endif 02913 case 0: 02914 ast_mutex_unlock(&p->lock); 02915 return 0; 02916 default: 02917 ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel); 02918 res = -1; 02919 } 02920 ast_mutex_unlock(&p->lock); 02921 return res; 02922 }
| static enum ast_bridge_result dahdi_bridge | ( | struct ast_channel * | c0, | |
| struct ast_channel * | c1, | |||
| int | flags, | |||
| struct ast_frame ** | fo, | |||
| struct ast_channel ** | rc, | |||
| int | timeoutms | |||
| ) | [static] |
Definition at line 3246 of file chan_dahdi.c.
References ast_channel::_state, AST_BRIDGE_COMPLETE, AST_BRIDGE_DTMF_CHANNEL_0, AST_BRIDGE_DTMF_CHANNEL_1, AST_BRIDGE_FAILED, AST_BRIDGE_FAILED_NOWARN, AST_BRIDGE_RETRY, AST_FRAME_CONTROL, AST_FRAME_DTMF, ast_frfree, ast_log(), ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), ast_read(), AST_STATE_RINGING, ast_verbose(), ast_waitfor_n(), ast_write(), dahdi_pvt::channel, dahdi_disable_ec(), dahdi_enable_ec(), dahdi_get_index(), dahdi_link(), dahdi_unlink(), DEADLOCK_AVOIDANCE, dahdi_subchannel::dfd, disable_dtmf_detect(), dahdi_pvt::echocanbridged, enable_dtmf_detect(), ast_channel::fds, ast_frame::frametype, dahdi_pvt::inconference, dahdi_subchannel::inthreeway, dahdi_pvt::lock, ast_channel::lock, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, master, ast_channel::name, option_verbose, dahdi_subchannel::owner, dahdi_pvt::owner, dahdi_pvt::pulsedial, dahdi_pvt::sig, SUB_CALLWAIT, SUB_REAL, SUB_THREEWAY, dahdi_pvt::subs, ast_channel::tech_pvt, dahdi_pvt::transfer, update_conf(), and VERBOSE_PREFIX_3.
03247 { 03248 struct ast_channel *who; 03249 struct dahdi_pvt *p0, *p1, *op0, *op1; 03250 struct dahdi_pvt *master = NULL, *slave = NULL; 03251 struct ast_frame *f; 03252 int inconf = 0; 03253 int nothingok = 1; 03254 int ofd0, ofd1; 03255 int oi0, oi1, i0 = -1, i1 = -1, t0, t1; 03256 int os0 = -1, os1 = -1; 03257 int priority = 0; 03258 struct ast_channel *oc0, *oc1; 03259 enum ast_bridge_result res; 03260 03261 #ifdef PRI_2BCT 03262 int triedtopribridge = 0; 03263 q931_call *q931c0 = NULL, *q931c1 = NULL; 03264 #endif 03265 03266 /* For now, don't attempt to native bridge if either channel needs DTMF detection. 03267 There is code below to handle it properly until DTMF is actually seen, 03268 but due to currently unresolved issues it's ignored... 03269 */ 03270 03271 if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1)) 03272 return AST_BRIDGE_FAILED_NOWARN; 03273 03274 ast_mutex_lock(&c0->lock); 03275 while (ast_mutex_trylock(&c1->lock)) { 03276 DEADLOCK_AVOIDANCE(&c0->lock); 03277 } 03278 03279 p0 = c0->tech_pvt; 03280 p1 = c1->tech_pvt; 03281 /* cant do pseudo-channels here */ 03282 if (!p0 || (!p0->sig) || !p1 || (!p1->sig)) { 03283 ast_mutex_unlock(&c0->lock); 03284 ast_mutex_unlock(&c1->lock); 03285 return AST_BRIDGE_FAILED_NOWARN; 03286 } 03287 03288 oi0 = dahdi_get_index(c0, p0, 0); 03289 oi1 = dahdi_get_index(c1, p1, 0); 03290 if ((oi0 < 0) || (oi1 < 0)) { 03291 ast_mutex_unlock(&c0->lock); 03292 ast_mutex_unlock(&c1->lock); 03293 return AST_BRIDGE_FAILED; 03294 } 03295 03296 op0 = p0 = c0->tech_pvt; 03297 op1 = p1 = c1->tech_pvt; 03298 ofd0 = c0->fds[0]; 03299 ofd1 = c1->fds[0]; 03300 oc0 = p0->owner; 03301 oc1 = p1->owner; 03302 03303 if (ast_mutex_trylock(&p0->lock)) { 03304 /* Don't block, due to potential for deadlock */ 03305 ast_mutex_unlock(&c0->lock); 03306 ast_mutex_unlock(&c1->lock); 03307 ast_log(LOG_NOTICE, "Avoiding deadlock...\n"); 03308 return AST_BRIDGE_RETRY; 03309 } 03310 if (ast_mutex_trylock(&p1->lock)) { 03311 /* Don't block, due to potential for deadlock */ 03312 ast_mutex_unlock(&p0->lock); 03313 ast_mutex_unlock(&c0->lock); 03314 ast_mutex_unlock(&c1->lock); 03315 ast_log(LOG_NOTICE, "Avoiding deadlock...\n"); 03316 return AST_BRIDGE_RETRY; 03317 } 03318 03319 if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) { 03320 if (p0->owner && p1->owner) { 03321 /* If we don't have a call-wait in a 3-way, and we aren't in a 3-way, we can be master */ 03322 if (!p0->subs[SUB_CALLWAIT].inthreeway && !p1->subs[SUB_REAL].inthreeway) { 03323 master = p0; 03324 slave = p1; 03325 inconf = 1; 03326 } else if (!p1->subs[SUB_CALLWAIT].inthreeway && !p0->subs[SUB_REAL].inthreeway) { 03327 master = p1; 03328 slave = p0; 03329 inconf = 1; 03330 } else { 03331 ast_log(LOG_WARNING, "Huh? Both calls are callwaits or 3-ways? That's clever...?\n"); 03332 ast_log(LOG_WARNING, "p0: chan %d/%d/CW%d/3W%d, p1: chan %d/%d/CW%d/3W%d\n", 03333 p0->channel, 03334 oi0, (p0->subs[SUB_CALLWAIT].dfd > -1) ? 1 : 0, 03335 p0->subs[SUB_REAL].inthreeway, p0->channel, 03336 oi0, (p1->subs[SUB_CALLWAIT].dfd > -1) ? 1 : 0, 03337 p1->subs[SUB_REAL].inthreeway); 03338 } 03339 nothingok = 0; 03340 } 03341 } else if ((oi0 == SUB_REAL) && (oi1 == SUB_THREEWAY)) { 03342 if (p1->subs[SUB_THREEWAY].inthreeway) { 03343 master = p1; 03344 slave = p0; 03345 nothingok = 0; 03346 } 03347 } else if ((oi0 == SUB_THREEWAY) && (oi1 == SUB_REAL)) { 03348 if (p0->subs[SUB_THREEWAY].inthreeway) { 03349 master = p0; 03350 slave = p1; 03351 nothingok = 0; 03352 } 03353 } else if ((oi0 == SUB_REAL) && (oi1 == SUB_CALLWAIT)) { 03354 /* We have a real and a call wait. If we're in a three way call, put us in it, otherwise, 03355 don't put us in anything */ 03356 if (p1->subs[SUB_CALLWAIT].inthreeway) { 03357 master = p1; 03358 slave = p0; 03359 nothingok = 0; 03360 } 03361 } else if ((oi0 == SUB_CALLWAIT) && (oi1 == SUB_REAL)) { 03362 /* Same as previous */ 03363 if (p0->subs[SUB_CALLWAIT].inthreeway) { 03364 master = p0; 03365 slave = p1; 03366 nothingok = 0; 03367 } 03368 } 03369 ast_log(LOG_DEBUG, "master: %d, slave: %d, nothingok: %d\n", 03370 master ? master->channel : 0, slave ? slave->channel : 0, nothingok); 03371 if (master && slave) { 03372 /* Stop any tones, or play ringtone as appropriate. If they're bridged 03373 in an active threeway call with a channel that is ringing, we should 03374 indicate ringing. */ 03375 if ((oi1 == SUB_THREEWAY) && 03376 p1->subs[SUB_THREEWAY].inthreeway && 03377 p1->subs[SUB_REAL].owner && 03378 p1->subs[SUB_REAL].inthreeway && 03379 (p1->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) { 03380 ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name); 03381 tone_zone_play_tone(p0->subs[oi0].dfd, DAHDI_TONE_RINGTONE); 03382 os1 = p1->subs[SUB_REAL].owner->_state; 03383 } else { 03384 ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1); 03385 tone_zone_play_tone(p0->subs[oi0].dfd, -1); 03386 } 03387 if ((oi0 == SUB_THREEWAY) && 03388 p0->subs[SUB_THREEWAY].inthreeway && 03389 p0->subs[SUB_REAL].owner && 03390 p0->subs[SUB_REAL].inthreeway && 03391 (p0->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) { 03392 ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name); 03393 tone_zone_play_tone(p1->subs[oi1].dfd, DAHDI_TONE_RINGTONE); 03394 os0 = p0->subs[SUB_REAL].owner->_state; 03395 } else { 03396 ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0); 03397 tone_zone_play_tone(p1->subs[oi0].dfd, -1); 03398 } 03399 if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) { 03400 if (!p0->echocanbridged || !p1->echocanbridged) { 03401 /* Disable echo cancellation if appropriate */ 03402 dahdi_disable_ec(p0); 03403 dahdi_disable_ec(p1); 03404 } 03405 } 03406 dahdi_link(slave, master); 03407 master->inconference = inconf; 03408 } else if (!nothingok) 03409 ast_log(LOG_WARNING, "Can't link %d/%s with %d/%s\n", p0->channel, subnames[oi0], p1->channel, subnames[oi1]); 03410 03411 update_conf(p0); 03412 update_conf(p1); 03413 t0 = p0->subs[SUB_REAL].inthreeway; 03414 t1 = p1->subs[SUB_REAL].inthreeway; 03415 03416 ast_mutex_unlock(&p0->lock); 03417 ast_mutex_unlock(&p1->lock); 03418 03419 ast_mutex_unlock(&c0->lock); 03420 ast_mutex_unlock(&c1->lock); 03421 03422 /* Native bridge failed */ 03423 if ((!master || !slave) && !nothingok) { 03424 dahdi_enable_ec(p0); 03425 dahdi_enable_ec(p1); 03426 return AST_BRIDGE_FAILED; 03427 } 03428 03429 if (option_verbose > 2) 03430 ast_verbose(VERBOSE_PREFIX_3 "Native bridging %s and %s\n", c0->name, c1->name); 03431 03432 if (!(flags & AST_BRIDGE_DTMF_CHANNEL_0) && (oi0 == SUB_REAL)) 03433 disable_dtmf_detect(op0); 03434 03435 if (!(flags & AST_BRIDGE_DTMF_CHANNEL_1) && (oi1 == SUB_REAL)) 03436 disable_dtmf_detect(op1); 03437 03438 for (;;) { 03439 struct ast_channel *c0_priority[2] = {c0, c1}; 03440 struct ast_channel *c1_priority[2] = {c1, c0}; 03441 03442 /* Here's our main loop... Start by locking things, looking for private parts, 03443 and then balking if anything is wrong */ 03444 ast_mutex_lock(&c0->lock); 03445 while (ast_mutex_trylock(&c1->lock)) { 03446 DEADLOCK_AVOIDANCE(&c0->lock); 03447 } 03448 03449 p0 = c0->tech_pvt; 03450 p1 = c1->tech_pvt; 03451 03452 if (op0 == p0) 03453 i0 = dahdi_get_index(c0, p0, 1); 03454 if (op1 == p1) 03455 i1 = dahdi_get_index(c1, p1, 1); 03456 ast_mutex_unlock(&c0->lock); 03457 ast_mutex_unlock(&c1->lock); 03458 03459 if (!timeoutms || 03460 (op0 != p0) || 03461 (op1 != p1) || 03462 (ofd0 != c0->fds[0]) || 03463 (ofd1 != c1->fds[0]) || 03464 (p0->subs[SUB_REAL].owner && (os0 > -1) && (os0 != p0->subs[SUB_REAL].owner->_state)) || 03465 (p1->subs[SUB_REAL].owner && (os1 > -1) && (os1 != p1->subs[SUB_REAL].owner->_state)) || 03466 (oc0 != p0->owner) || 03467 (oc1 != p1->owner) || 03468 (t0 != p0->subs[SUB_REAL].inthreeway) || 03469 (t1 != p1->subs[SUB_REAL].inthreeway) || 03470 (oi0 != i0) || 03471 (oi1 != i1)) { 03472 ast_log(LOG_DEBUG, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n", 03473 op0->channel, oi0, op1->channel, oi1); 03474 res = AST_BRIDGE_RETRY; 03475 goto return_from_bridge; 03476 } 03477 03478 #ifdef PRI_2BCT 03479 q931c0 = p0->call; 03480 q931c1 = p1->call; 03481 if (p0->transfer && p1->transfer 03482 && q931c0 && q931c1 03483 && !triedtopribridge) { 03484 pri_channel_bridge(q931c0, q931c1); 03485 triedtopribridge = 1; 03486 } 03487 #endif 03488 03489 who = ast_waitfor_n(priority ? c0_priority : c1_priority, 2, &timeoutms); 03490 if (!who) { 03491 ast_log(LOG_DEBUG, "Ooh, empty read...\n"); 03492 continue; 03493 } 03494 f = ast_read(who); 03495 if (!f || (f->frametype == AST_FRAME_CONTROL)) { 03496 *fo = f; 03497 *rc = who; 03498 res = AST_BRIDGE_COMPLETE; 03499 goto return_from_bridge; 03500 } 03501 if (f->frametype == AST_FRAME_DTMF) { 03502 if ((who == c0) && p0->pulsedial) { 03503 ast_write(c1, f); 03504 } else if ((who == c1) && p1->pulsedial) { 03505 ast_write(c0, f); 03506 } else { 03507 *fo = f; 03508 *rc = who; 03509 res = AST_BRIDGE_COMPLETE; 03510 goto return_from_bridge; 03511 } 03512 } 03513 ast_frfree(f); 03514 03515 /* Swap who gets priority */ 03516 priority = !priority; 03517 } 03518 03519 return_from_bridge: 03520 if (op0 == p0) 03521 dahdi_enable_ec(p0); 03522 03523 if (op1 == p1) 03524 dahdi_enable_ec(p1); 03525 03526 if (!(flags & AST_BRIDGE_DTMF_CHANNEL_0) && (oi0 == SUB_REAL)) 03527 enable_dtmf_detect(op0); 03528 03529 if (!(flags & AST_BRIDGE_DTMF_CHANNEL_1) && (oi1 == SUB_REAL)) 03530 enable_dtmf_detect(op1); 03531 03532 dahdi_unlink(slave, master, 1); 03533 03534 return res; 03535 }
| static int dahdi_call | ( | struct ast_channel * | ast, | |
| char * | rdest, | |||
| int | timeout | |||
| ) | [static] |
Definition at line 1821 of file chan_dahdi.c.
References ast_channel::_state, ast_callerid_generate(), ast_copy_string(), AST_LAW, ast_log(), ast_malloc, ast_mutex_lock(), ast_mutex_unlock(), ast_setstate(), AST_STATE_BUSY, AST_STATE_DIALING, AST_STATE_DOWN, AST_STATE_RESERVED, AST_STATE_RINGING, AST_STATE_UP, ast_strlen_zero(), ast_transfercapability2str(), ast_verbose(), dahdi_pvt::callwait_name, dahdi_pvt::callwait_num, dahdi_pvt::callwaitcas, dahdi_pvt::callwaitrings, dahdi_pvt::channel, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_pres, ast_callerid::cid_rdnis, dahdi_pvt::cidlen, dahdi_pvt::cidpos, dahdi_pvt::cidrings, dahdi_pvt::cidspill, dahdi_callwait(), dahdi_get_index(), dahdi_subchannel::dfd, dahdi_pvt::dialdest, dahdi_pvt::dialednone, dahdi_pvt::dialing, dahdi_pvt::digital, dahdi_pvt::distinctivering, dahdi_pvt::dop, dahdi_pvt::echobreak, dahdi_pvt::echorest, dahdi_pvt::echotraining, errno, dahdi_pvt::finaldial, free, dahdi_pvt::hidecallerid, dahdi_pvt::hidecalleridname, IS_DIGITAL, dahdi_pvt::lastcid_name, dahdi_pvt::lastcid_num, dahdi_pvt::law, dahdi_pvt::lock, LOG_DEBUG, LOG_WARNING, MAX_CALLERID_SIZE, ast_channel::name, dahdi_subchannel::needbusy, dahdi_subchannel::needringing, dahdi_pvt::oprmode, option_verbose, dahdi_pvt::outgoing, dahdi_pvt::outsigmod, dahdi_pvt::owner, pbx_builtin_getvar_helper(), PRI_TRANS_CAP_DIGITAL, dahdi_pvt::priexclusive, dahdi_pvt::pulse, dahdi_pvt::radio, dahdi_pvt::rxgain, s, send_callerid(), dahdi_pvt::sendcalleridafter, set_actual_gain(), dahdi_pvt::sig, SIG_E911, SIG_EM, SIG_EM_E1, SIG_EMWINK, SIG_FEATB, SIG_FEATD, SIG_FEATDMF, SIG_FEATDMF_TA, SIG_FGC_CAMA, SIG_FGC_CAMAMF, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_PRI, SIG_SF, SIG_SF_FEATB, SIG_SF_FEATD, SIG_SF_FEATDMF, SIG_SFWINK, dahdi_pvt::stripmsd, SUB_CALLWAIT, SUB_REAL, dahdi_pvt::subs, ast_channel::tech_pvt, ast_channel::transfercapability, dahdi_pvt::txgain, dahdi_pvt::use_callerid, dahdi_pvt::use_callingpres, VERBOSE_PREFIX_3, and dahdi_pvt::whichwink.
01822 { 01823 struct dahdi_pvt *p = ast->tech_pvt; 01824 int x, res, index,mysig; 01825 char *c, *n, *l; 01826 #ifdef HAVE_PRI 01827 char *s = NULL; 01828 #endif 01829 char dest[256]; /* must be same length as p->dialdest */ 01830 ast_mutex_lock(&p->lock); 01831 ast_copy_string(dest, rdest, sizeof(dest)); 01832 ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest)); 01833 if ((ast->_state == AST_STATE_BUSY)) { 01834 p->subs[SUB_REAL].needbusy = 1; 01835 ast_mutex_unlock(&p->lock); 01836 return 0; 01837 } 01838 if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) { 01839 ast_log(LOG_WARNING, "dahdi_call called on %s, neither down nor reserved\n", ast->name); 01840 ast_mutex_unlock(&p->lock); 01841 return -1; 01842 } 01843 p->dialednone = 0; 01844 if ((p->radio || (p->oprmode < 0))) /* if a radio channel, up immediately */ 01845 { 01846 /* Special pseudo -- automatically up */ 01847 ast_setstate(ast, AST_STATE_UP); 01848 ast_mutex_unlock(&p->lock); 01849 return 0; 01850 } 01851 x = DAHDI_FLUSH_READ | DAHDI_FLUSH_WRITE; 01852 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_FLUSH, &x); 01853 if (res) 01854 ast_log(LOG_WARNING, "Unable to flush input on channel %d: %s\n", p->channel, strerror(errno)); 01855 p->outgoing = 1; 01856 01857 set_actual_gain(p->subs[SUB_REAL].dfd, 0, p->rxgain, p->txgain, p->law); 01858 01859 mysig = p->sig; 01860 if (p->outsigmod > -1) 01861 mysig = p->outsigmod; 01862 01863 switch (mysig) { 01864 case SIG_FXOLS: 01865 case SIG_FXOGS: 01866 case SIG_FXOKS: 01867 if (p->owner == ast) { 01868 /* Normal ring, on hook */ 01869 01870 /* Don't send audio while on hook, until the call is answered */ 01871 p->dialing = 1; 01872 if (p->use_callerid) { 01873 /* Generate the Caller-ID spill if desired */ 01874 if (p->cidspill) { 01875 ast_log(LOG_WARNING, "cidspill already exists??\n"); 01876 free(p->cidspill); 01877 } 01878 p->callwaitcas = 0; 01879 if ((p->cidspill = ast_malloc(MAX_CALLERID_SIZE))) { 01880 p->cidlen = ast_callerid_generate(p->cidspill, ast->cid.cid_name, ast->cid.cid_num, AST_LAW(p)); 01881 p->cidpos = 0; 01882 send_callerid(p); 01883 } 01884 } 01885 /* Choose proper cadence */ 01886 if ((p->distinctivering > 0) && (p->distinctivering <= num_cadence)) { 01887 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCADENCE, &cadences[p->distinctivering - 1])) 01888 ast_log(LOG_WARNING, "Unable to set distinctive ring cadence %d on '%s': %s\n", p->distinctivering, ast->name, strerror(errno)); 01889 p->cidrings = cidrings[p->distinctivering - 1]; 01890 } else { 01891 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCADENCE, NULL)) 01892 ast_log(LOG_WARNING, "Unable to reset default ring on '%s': %s\n", ast->name, strerror(errno)); 01893 p->cidrings = p->sendcalleridafter; 01894 } 01895 01896 /* nick@dccinc.com 4/3/03 mods to allow for deferred dialing */ 01897 c = strchr(dest, '/'); 01898 if (c) 01899 c++; 01900 if (c && (strlen(c) < p->stripmsd)) { 01901 ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd); 01902 c = NULL; 01903 } 01904 if (c) { 01905 p->dop.op = DAHDI_DIAL_OP_REPLACE; 01906 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c); 01907 ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c); 01908 } else { 01909 p->dop.dialstr[0] = '\0'; 01910 } 01911 x = DAHDI_RING; 01912 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_HOOK, &x) && (errno != EINPROGRESS)) { 01913 ast_log(LOG_WARNING, "Unable to ring phone: %s\n", strerror(errno)); 01914 ast_mutex_unlock(&p->lock); 01915 return -1; 01916 } 01917 p->dialing = 1; 01918 } else { 01919 /* Call waiting call */ 01920 p->callwaitrings = 0; 01921 if (ast->cid.cid_num) 01922 ast_copy_string(p->callwait_num, ast->cid.cid_num, sizeof(p->callwait_num)); 01923 else 01924 p->callwait_num[0] = '\0'; 01925 if (ast->cid.cid_name) 01926 ast_copy_string(p->callwait_name, ast->cid.cid_name, sizeof(p->callwait_name)); 01927 else 01928 p->callwait_name[0] = '\0'; 01929 /* Call waiting tone instead */ 01930 if (dahdi_callwait(ast)) { 01931 ast_mutex_unlock(&p->lock); 01932 return -1; 01933 } 01934 /* Make ring-back */ 01935 if (tone_zone_play_tone(p->subs[SUB_CALLWAIT].dfd, DAHDI_TONE_RINGTONE)) 01936 ast_log(LOG_WARNING, "Unable to generate call-wait ring-back on channel %s\n", ast->name); 01937 01938 } 01939 n = ast->cid.cid_name; 01940 l = ast->cid.cid_num; 01941 if (l) 01942 ast_copy_string(p->lastcid_num, l, sizeof(p->lastcid_num)); 01943 else 01944 p->lastcid_num[0] = '\0'; 01945 if (n) 01946 ast_copy_string(p->lastcid_name, n, sizeof(p->lastcid_name)); 01947 else 01948 p->lastcid_name[0] = '\0'; 01949 ast_setstate(ast, AST_STATE_RINGING); 01950 index = dahdi_get_index(ast, p, 0); 01951 if (index > -1) { 01952 p->subs[index].needringing = 1; 01953 } 01954 break; 01955 case SIG_FXSLS: 01956 case SIG_FXSGS: 01957 case SIG_FXSKS: 01958 case SIG_EMWINK: 01959 case SIG_EM: 01960 case SIG_EM_E1: 01961 case SIG_FEATD: 01962 case SIG_FEATDMF: 01963 case SIG_E911: 01964 case SIG_FGC_CAMA: 01965 case SIG_FGC_CAMAMF: 01966 case SIG_FEATB: 01967 case SIG_SFWINK: 01968 case SIG_SF: 01969 case SIG_SF_FEATD: 01970 case SIG_SF_FEATDMF: 01971 case SIG_FEATDMF_TA: 01972 case SIG_SF_FEATB: 01973 c = strchr(dest, '/'); 01974 if (c) 01975 c++; 01976 else 01977 c = ""; 01978 if (strlen(c) < p->stripmsd) { 01979 ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd); 01980 ast_mutex_unlock(&p->lock); 01981 return -1; 01982 } 01983 #ifdef HAVE_PRI 01984 /* Start the trunk, if not GR-303 */ 01985 if (!p->pri) { 01986 #endif 01987 x = DAHDI_START; 01988 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_HOOK, &x); 01989 if (res < 0) { 01990 if (errno != EINPROGRESS) { 01991 ast_log(LOG_WARNING, "Unable to start channel: %s\n", strerror(errno)); 01992 ast_mutex_unlock(&p->lock); 01993 return -1; 01994 } 01995 } 01996 #ifdef HAVE_PRI 01997 } 01998 #endif 01999 ast_log(LOG_DEBUG, "Dialing '%s'\n", c); 02000 p->dop.op = DAHDI_DIAL_OP_REPLACE; 02001 02002 c += p->stripmsd; 02003 02004 switch (mysig) { 02005 case SIG_FEATD: 02006 l = ast->cid.cid_num; 02007 if (l) 02008 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T*%s*%s*", l, c); 02009 else 02010 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T**%s*", c); 02011 break; 02012 case SIG_FEATDMF: 02013 l = ast->cid.cid_num; 02014 if (l) 02015 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*00%s#*%s#", l, c); 02016 else 02017 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*02#*%s#", c); 02018 break; 02019 case SIG_FEATDMF_TA: 02020 { 02021 const char *cic, *ozz; 02022 02023 /* If you have to go through a Tandem Access point you need to use this */ 02024 ozz = pbx_builtin_getvar_helper(p->owner, "FEATDMF_OZZ"); 02025 if (!ozz) 02026 ozz = defaultozz; 02027 cic = pbx_builtin_getvar_helper(p->owner, "FEATDMF_CIC"); 02028 if (!cic) 02029 cic = defaultcic; 02030 if (!ozz || !cic) { 02031 ast_log(LOG_WARNING, "Unable to dial channel of type feature group D MF tandem access without CIC or OZZ set\n"); 02032 ast_mutex_unlock(&p->lock); 02033 return -1; 02034 } 02035 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s%s#", ozz, cic); 02036 snprintf(p->finaldial, sizeof(p->finaldial), "M*%s#", c); 02037 p->whichwink = 0; 02038 } 02039 break; 02040 case SIG_E911: 02041 ast_copy_string(p->dop.dialstr, "M*911#", sizeof(p->dop.dialstr)); 02042 break; 02043 case SIG_FGC_CAMA: 02044 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%s", c); 02045 break; 02046 case SIG_FGC_CAMAMF: 02047 case SIG_FEATB: 02048 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s#", c); 02049 break; 02050 default: 02051 if (p->pulse) 02052 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%sw", c); 02053 else 02054 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T%sw", c); 02055 break; 02056 } 02057 02058 if (p->echotraining && (strlen(p->dop.dialstr) > 4)) { 02059 memset(p->echorest, 'w', sizeof(p->echorest) - 1); 02060 strcpy(p->echorest + (p->echotraining / 400) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2); 02061 p->echorest[sizeof(p->echorest) - 1] = '\0'; 02062 p->echobreak = 1; 02063 p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0'; 02064 } else 02065 p->echobreak = 0; 02066 if (!res) { 02067 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_DIAL, &p->dop)) { 02068 int saveerr = errno; 02069 02070 x = DAHDI_ONHOOK; 02071 ioctl(p->subs[SUB_REAL].dfd, DAHDI_HOOK, &x); 02072 ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(saveerr)); 02073 ast_mutex_unlock(&p->lock); 02074 return -1; 02075 } 02076 } else 02077 ast_log(LOG_DEBUG, "Deferring dialing...\n"); 02078 p->dialing = 1; 02079 if (ast_strlen_zero(c)) 02080 p->dialednone = 1; 02081 ast_setstate(ast, AST_STATE_DIALING); 02082 break; 02083 case 0: 02084 /* Special pseudo -- automatically up*/ 02085 ast_setstate(ast, AST_STATE_UP); 02086 break; 02087 case SIG_PRI: 02088 /* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */ 02089 p->dialdest[0] = '\0'; 02090 break; 02091 default: 02092 ast_log(LOG_DEBUG, "not yet implemented\n"); 02093 ast_mutex_unlock(&p->lock); 02094 return -1; 02095 } 02096 #ifdef HAVE_PRI 02097 if (p->pri) { 02098 struct pri_sr *sr; 02099 #ifdef SUPPORT_USERUSER 02100 const char *useruser; 02101 #endif 02102 int pridialplan; 02103 int dp_strip; 02104 int prilocaldialplan; 02105 int ldp_strip; 02106 int exclusive; 02107 const char *rr_str; 02108 int redirect_reason; 02109 02110 c = strchr(dest, '/'); 02111 if (c) 02112 c++; 02113 else 02114 c = dest; 02115 02116 l = NULL; 02117 n = NULL; 02118 02119 if (!p->hidecallerid) { 02120 l = ast->cid.cid_num; 02121 if (!p->hidecalleridname) { 02122 n = ast->cid.cid_name; 02123 } 02124 } 02125 02126 02127 if (strlen(c) < p->stripmsd) { 02128 ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd); 02129 ast_mutex_unlock(&p->lock); 02130 return -1; 02131 } 02132 if (mysig != SIG_FXSKS) { 02133 p->dop.op = DAHDI_DIAL_OP_REPLACE; 02134 s = strchr(c + p->stripmsd, 'w'); 02135 if (s) { 02136 if (strlen(s) > 1) 02137 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T%s", s); 02138 else 02139 p->dop.dialstr[0] = '\0'; 02140 *s = '\0'; 02141 } else { 02142 p->dop.dialstr[0] = '\0'; 02143 } 02144 } 02145 if (pri_grab(p, p->pri)) { 02146 ast_log(LOG_WARNING, "Failed to grab PRI!\n"); 02147 ast_mutex_unlock(&p->lock); 02148 return -1; 02149 } 02150 if (!(p->call = pri_new_call(p->pri->pri))) { 02151 ast_log(LOG_WARNING, "Unable to create call on channel %d\n", p->channel); 02152 pri_rel(p->pri); 02153 ast_mutex_unlock(&p->lock); 02154 return -1; 02155 } 02156 if (!(sr = pri_sr_new())) { 02157 ast_log(LOG_WARNING, "Failed to allocate setup request channel %d\n", p->channel); 02158 pri_destroycall(p->pri->pri, p->call); 02159 p->call = NULL; 02160 pri_rel(p->pri); 02161 ast_mutex_unlock(&p->lock); 02162 return -1; 02163 } 02164 if (p->bearer || (mysig == SIG_FXSKS)) { 02165 if (p->bearer) { 02166 ast_log(LOG_DEBUG, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel); 02167 p->bearer->call = p->call; 02168 } else 02169 ast_log(LOG_DEBUG, "I'm being setup with no bearer right now...\n"); 02170 pri_set_crv(p->pri->pri, p->call, p->channel, 0); 02171 } 02172 p->digital = IS_DIGITAL(ast->transfercapability); 02173 /* Add support for exclusive override */ 02174 if (p->priexclusive) 02175 exclusive = 1; 02176 else { 02177 /* otherwise, traditional behavior */ 02178 if (p->pri->nodetype == PRI_NETWORK) 02179 exclusive = 0; 02180 else 02181 exclusive = 1; 02182 } 02183 02184 pri_sr_set_channel(sr, p->bearer ? PVT_TO_CHANNEL(p->bearer) : PVT_TO_CHANNEL(p), exclusive, 1); 02185 pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability, 02186 (p->digital ? -1 : 02187 ((p->law == DAHDI_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW))); 02188 if (p->pri->facilityenable) 02189 pri_facility_enable(p->pri->pri); 02190 02191 if (option_verbose > 2) 02192 ast_verbose(VERBOSE_PREFIX_3 "Requested transfer capability: 0x%.2x - %s\n", ast->transfercapability, ast_transfercapability2str(ast->transfercapability)); 02193 dp_strip = 0; 02194 pridialplan = p->pri->dialplan - 1; 02195 if (pridialplan == -2) { /* compute dynamically */ 02196 if (strncmp(c + p->stripmsd, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) { 02197 dp_strip = strlen(p->pri->internationalprefix); 02198 pridialplan = PRI_INTERNATIONAL_ISDN; 02199 } else if (strncmp(c + p->stripmsd, p->pri->nationalprefix, strlen(p->pri->nationalprefix)) == 0) { 02200 dp_strip = strlen(p->pri->nationalprefix); 02201 pridialplan = PRI_NATIONAL_ISDN; 02202 } else { 02203 pridialplan = PRI_LOCAL_ISDN; 02204 } 02205 } 02206 pri_sr_set_called(sr, c + p->stripmsd + dp_strip, pridialplan, s ? 1 : 0); 02207 02208 ldp_strip = 0; 02209 prilocaldialplan = p->pri->localdialplan - 1; 02210 if ((l != NULL) && (prilocaldialplan == -2)) { /* compute dynamically */ 02211 if (strncmp(l, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) { 02212 ldp_strip = strlen(p->pri->internationalprefix); 02213 prilocaldialplan = PRI_INTERNATIONAL_ISDN; 02214 } else if (strncmp(l, p->pri->nationalprefix, strlen(p->pri->nationalprefix)) == 0) { 02215 ldp_strip = strlen(p->pri->nationalprefix); 02216 prilocaldialplan = PRI_NATIONAL_ISDN; 02217 } else { 02218 prilocaldialplan = PRI_LOCAL_ISDN; 02219 } 02220 } 02221 pri_sr_set_caller(sr, l ? (l + ldp_strip) : NULL, n, prilocaldialplan, 02222 p->use_callingpres ? ast->cid.cid_pres : (l ? PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN : PRES_NUMBER_NOT_AVAILABLE)); 02223 if ((rr_str = pbx_builtin_getvar_helper(ast, "PRIREDIRECTREASON"))) { 02224 if (!strcasecmp(rr_str, "UNKNOWN")) 02225 redirect_reason = 0; 02226 else if (!strcasecmp(rr_str, "BUSY")) 02227 redirect_reason = 1; 02228 else if (!strcasecmp(rr_str, "NO_REPLY")) 02229 redirect_reason = 2; 02230 else if (!strcasecmp(rr_str, "UNCONDITIONAL")) 02231 redirect_reason = 15; 02232 else 02233 redirect_reason = PRI_REDIR_UNCONDITIONAL; 02234 } else 02235 redirect_reason = PRI_REDIR_UNCONDITIONAL; 02236 pri_sr_set_redirecting(sr, ast->cid.cid_rdnis, p->pri->localdialplan - 1, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, redirect_reason); 02237 02238 #ifdef SUPPORT_USERUSER 02239 /* User-user info */ 02240 useruser = pbx_builtin_getvar_helper(p->owner, "USERUSERINFO"); 02241 02242 if (useruser) 02243 pri_sr_set_useruser(sr, useruser); 02244 #endif 02245 02246 if (pri_setup(p->pri->pri, p->call, sr)) { 02247 ast_log(LOG_WARNING, "Unable to setup call to %s (using %s)\n", 02248 c + p->stripmsd + dp_strip, dialplan2str(p->pri->dialplan)); 02249 pri_rel(p->pri); 02250 ast_mutex_unlock(&p->lock); 02251 pri_sr_free(sr); 02252 return -1; 02253 } 02254 pri_sr_free(sr); 02255 ast_setstate(ast, AST_STATE_DIALING); 02256 pri_rel(p->pri); 02257 } 02258 #endif 02259 ast_mutex_unlock(&p->lock); 02260 return 0; 02261 }
| static int dahdi_callwait | ( | struct ast_channel * | ast | ) | [static] |
Definition at line 1793 of file chan_dahdi.c.
References ast_gen_cas(), AST_LAW, ast_log(), ast_malloc, dahdi_pvt::callwaitcas, CALLWAITING_REPEAT_SAMPLES, dahdi_pvt::callwaitingcallerid, dahdi_pvt::callwaitingrepeat, dahdi_pvt::callwaitrings, dahdi_pvt::cidlen, dahdi_pvt::cidpos, dahdi_pvt::cidspill, free, LOG_WARNING, READ_SIZE, save_conference(), send_callerid(), and ast_channel::tech_pvt.
Referenced by dahdi_call(), and dahdi_read().
01794 { 01795 struct dahdi_pvt *p = ast->tech_pvt; 01796 p->callwaitingrepeat = CALLWAITING_REPEAT_SAMPLES; 01797 if (p->cidspill) { 01798 ast_log(LOG_WARNING, "Spill already exists?!?\n"); 01799 free(p->cidspill); 01800 } 01801 if (!(p->cidspill = ast_malloc(2400 /* SAS */ + 680 /* CAS */ + READ_SIZE * 4))) 01802 return -1; 01803 save_conference(p); 01804 /* Silence */ 01805 memset(p->cidspill, 0x7f, 2400 + 600 + READ_SIZE * 4); 01806 if (!p->callwaitrings && p->callwaitingcallerid) { 01807 ast_gen_cas(p->cidspill, 1, 2400 + 680, AST_LAW(p)); 01808 p->callwaitcas = 1; 01809 p->cidlen = 2400 + 680 + READ_SIZE * 4; 01810 } else { 01811 ast_gen_cas(p->cidspill, 1, 2400, AST_LAW(p)); 01812 p->callwaitcas = 0; 01813 p->cidlen = 2400 + READ_SIZE * 4; 01814 } 01815 p->cidpos = 0; 01816 send_callerid(p); 01817 01818 return 0; 01819 }
| static struct dahdi_chan_conf dahdi_chan_conf_default | ( | void | ) | [static, read] |
returns a new dahdi_chan_conf with default values (by-value)
Definition at line 606 of file chan_dahdi.c.
References dahdi_chan_conf::chan, CID_SIG_BELL, CID_START_RING, dahdi_pvt::context, and DEFAULT_CIDRINGS.
Referenced by process_dahdi(), and setup_dahdi().
00606 { 00607 /* recall that if a field is not included here it is initialized 00608 * to 0 or equivalent 00609 */ 00610 struct dahdi_chan_conf conf = { 00611 #ifdef HAVE_PRI 00612 .pri = { 00613 .nsf = PRI_NSF_NONE, 00614 .switchtype = PRI_SWITCH_NI2, 00615 .dialplan = PRI_NATIONAL_ISDN + 1, 00616 .localdialplan = PRI_NATIONAL_ISDN + 1, 00617 .nodetype = PRI_CPE, 00618 00619 .minunused = 2, 00620 .idleext = "", 00621 .idledial = "", 00622 .internationalprefix = "", 00623 .nationalprefix = "", 00624 .localprefix = "", 00625 .privateprefix = "", 00626 .unknownprefix = "", 00627 00628 .resetinterval = 3600 00629 }, 00630 #endif 00631 .chan = { 00632 .context = "default", 00633 .cid_num = "", 00634 .cid_name = "", 00635 .mohinterpret = "default", 00636 .mohsuggest = "", 00637 .transfertobusy = 1, 00638 00639 .cid_signalling = CID_SIG_BELL, 00640 .cid_start = CID_START_RING, 00641 .dahditrcallerid = 0, 00642 .use_callerid = 1, 00643 .sig = -1, 00644 .outsigmod = -1, 00645 00646 .tonezone = -1, 00647 00648 .echocancel = 1, 00649 00650 .busycount = 3, 00651 00652 .accountcode = "", 00653 00654 .mailbox = "", 00655 00656 00657 .polarityonanswerdelay = 600, 00658 00659 .sendcalleridafter = DEFAULT_CIDRINGS, 00660 00661 .buf_policy = DAHDI_POLICY_IMMEDIATE, 00662 .buf_no = numbufs 00663 }, 00664 .timing = { 00665 .prewinktime = -1, 00666 .preflashtime = -1, 00667 .winktime = -1, 00668 .flashtime = -1, 00669 .starttime = -1, 00670 .rxwinktime = -1, 00671 .rxflashtime = -1, 00672 .debouncetime = -1 00673 }, 00674 .smdi_port = "/dev/ttyS0", 00675 }; 00676 00677 return conf; 00678 }
| static void dahdi_close | ( | int | fd | ) | [static] |
| static void dahdi_close_sub | ( | struct dahdi_pvt * | chan_pvt, | |
| int | sub_num | |||
| ) | [static] |
Definition at line 955 of file chan_dahdi.c.
References dahdi_close(), dahdi_subchannel::dfd, and dahdi_pvt::subs.
Referenced by alloc_sub(), destroy_dahdi_pvt(), and unalloc_sub().
00956 { 00957 dahdi_close(chan_pvt->subs[sub_num].dfd); 00958 chan_pvt->subs[sub_num].dfd = -1; 00959 }
| static int dahdi_confmute | ( | struct dahdi_pvt * | p, | |
| int | muted | |||
| ) | [inline, static] |
Definition at line 1676 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, dahdi_subchannel::dfd, errno, LOG_WARNING, dahdi_pvt::sig, SIG_PRI, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_handle_dtmfup(), dahdi_handle_event(), dahdi_hangup(), and dahdi_new().
01677 { 01678 int x, y, res; 01679 x = muted; 01680 if (p->sig == SIG_PRI) { 01681 y = 1; 01682 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &y); 01683 if (res) 01684 ast_log(LOG_WARNING, "Unable to set audio mode on %d: %s\n", p->channel, strerror(errno)); 01685 } 01686 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_CONFMUTE, &x); 01687 if (res < 0) 01688 ast_log(LOG_WARNING, "dahdi confmute(%d) failed on channel %d: %s\n", muted, p->channel, strerror(errno)); 01689 return res; 01690 }
| static int dahdi_destroy_channel | ( | int | fd, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 10042 of file chan_dahdi.c.
References dahdi_destroy_channel_bynum(), and RESULT_SHOWUSAGE.
10043 { 10044 int channel; 10045 10046 if (argc != 4) 10047 return RESULT_SHOWUSAGE; 10048 10049 channel = atoi(argv[3]); 10050 10051 return dahdi_destroy_channel_bynum(channel); 10052 }
| static int dahdi_destroy_channel_bynum | ( | int | channel | ) | [static] |
Definition at line 6708 of file chan_dahdi.c.
References ast_module_unref(), dahdi_pvt::channel, destroy_channel(), dahdi_subchannel::dfd, iflist, dahdi_pvt::next, dahdi_pvt::prev, RESULT_FAILURE, RESULT_SUCCESS, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_destroy_channel(), and handle_init_event().
06709 { 06710 struct dahdi_pvt *tmp = NULL; 06711 struct dahdi_pvt *prev = NULL; 06712 06713 tmp = iflist; 06714 while (tmp) { 06715 if (tmp->channel == channel) { 06716 int x = DAHDI_FLASH; 06717 ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_HOOK, &x); /* important to create an event for dahdi_wait_event to register so that all ss_threads terminate */ 06718 destroy_channel(prev, tmp, 1); 06719 ast_module_unref(ast_module_info->self); 06720 return RESULT_SUCCESS; 06721 } 06722 prev = tmp; 06723 tmp = tmp->next; 06724 } 06725 return RESULT_FAILURE; 06726 }
| static int dahdi_digit_begin | ( | struct ast_channel * | ast, | |
| char | digit | |||
| ) | [static] |
Definition at line 1050 of file chan_dahdi.c.
References ast_channel::_state, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), AST_STATE_DIALING, dahdi_pvt::begindigit, dahdi_get_index(), dahdi_subchannel::dfd, dahdi_pvt::dialdest, dahdi_pvt::dialing, digit_to_dtmfindex(), errno, dahdi_pvt::lock, LOG_DEBUG, LOG_WARNING, dahdi_pvt::owner, dahdi_pvt::pulse, dahdi_pvt::sig, SIG_PRI, dahdi_pvt::span, SUB_REAL, dahdi_pvt::subs, and ast_channel::tech_pvt.
01051 { 01052 struct dahdi_pvt *pvt; 01053 int index; 01054 int dtmf = -1; 01055 01056 pvt = chan->tech_pvt; 01057 01058 ast_mutex_lock(&pvt->lock); 01059 01060 index = dahdi_get_index(chan, pvt, 0); 01061 01062 if ((index != SUB_REAL) || !pvt->owner) 01063 goto out; 01064 01065 #ifdef HAVE_PRI 01066 if ((pvt->sig == SIG_PRI) && (chan->_state == AST_STATE_DIALING) && !pvt->proceeding) { 01067 if (pvt->setup_ack) { 01068 if (!pri_grab(pvt, pvt->pri)) { 01069 pri_information(pvt->pri->pri, pvt->call, digit); 01070 pri_rel(pvt->pri); 01071 } else 01072 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->span); 01073 } else if (strlen(pvt->dialdest) < sizeof(pvt->dialdest) - 1) { 01074 int res; 01075 ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit); 01076 res = strlen(pvt->dialdest); 01077 pvt->dialdest[res++] = digit; 01078 pvt->dialdest[res] = '\0'; 01079 } 01080 goto out; 01081 } 01082 #endif 01083 if ((dtmf = digit_to_dtmfindex(digit)) == -1) 01084 goto out; 01085 01086 if (pvt->pulse || ioctl(pvt->subs[SUB_REAL].dfd, DAHDI_SENDTONE, &dtmf)) { 01087 int res; 01088 struct dahdi_dialoperation zo = { 01089 .op = DAHDI_DIAL_OP_APPEND, 01090 .dialstr[0] = 'T', 01091 .dialstr[1] = digit, 01092 .dialstr[2] = 0, 01093 }; 01094 if ((res = ioctl(pvt->subs[SUB_REAL].dfd, DAHDI_DIAL, &zo))) 01095 ast_log(LOG_WARNING, "Couldn't dial digit %c: %s\n", digit, strerror(errno)); 01096 else 01097 pvt->dialing = 1; 01098 } else { 01099 ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit); 01100 pvt->dialing = 1; 01101 pvt->begindigit = digit; 01102 } 01103 01104 out: 01105 ast_mutex_unlock(&pvt->lock); 01106 01107 return 0; 01108 }
| static int dahdi_digit_end | ( | struct ast_channel * | ast, | |
| char | digit, | |||
| unsigned int | duration | |||
| ) | [static] |
Definition at line 1110 of file chan_dahdi.c.
References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dahdi_pvt::begindigit, dahdi_get_index(), dahdi_subchannel::dfd, dahdi_pvt::dialing, dahdi_pvt::lock, LOG_DEBUG, dahdi_pvt::owner, dahdi_pvt::pulse, dahdi_pvt::sig, SIG_PRI, SUB_REAL, dahdi_pvt::subs, and ast_channel::tech_pvt.
01111 { 01112 struct dahdi_pvt *pvt; 01113 int res = 0; 01114 int index; 01115 int x; 01116 01117 pvt = chan->tech_pvt; 01118 01119 ast_mutex_lock(&pvt->lock); 01120 01121 index = dahdi_get_index(chan, pvt, 0); 01122 01123 if ((index != SUB_REAL) || !pvt->owner || pvt->pulse) 01124 goto out; 01125 01126 #ifdef HAVE_PRI 01127 /* This means that the digit was already sent via PRI signalling */ 01128 if (pvt->sig == SIG_PRI && !pvt->begindigit) 01129 goto out; 01130 #endif 01131 01132 if (pvt->begindigit) { 01133 x = -1; 01134 ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit); 01135 res = ioctl(pvt->subs[SUB_REAL].dfd, DAHDI_SENDTONE, &x); 01136 pvt->dialing = 0; 01137 pvt->begindigit = 0; 01138 } 01139 01140 out: 01141 ast_mutex_unlock(&pvt->lock); 01142 01143 return res; 01144 }
| static void dahdi_disable_ec | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1507 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, dahdi_subchannel::dfd, dahdi_pvt::echocancel, dahdi_pvt::echocanon, errno, LOG_DEBUG, LOG_WARNING, option_debug, SUB_REAL, and dahdi_pvt::subs.
Referenced by __dahdi_exception(), dahdi_bridge(), dahdi_handle_event(), dahdi_hangup(), dahdi_setoption(), and handle_init_event().
01508 { 01509 int x; 01510 int res; 01511 if (p->echocancel) { 01512 x = 0; 01513 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_ECHOCANCEL, &x); 01514 if (res) 01515 ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d: %s\n", p->channel, strerror(errno)); 01516 else if (option_debug) 01517 ast_log(LOG_DEBUG, "disabled echo cancellation on channel %d\n", p->channel); 01518 } 01519 p->echocanon = 0; 01520 }
| static void dahdi_enable_ec | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1457 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, dahdi_subchannel::dfd, dahdi_pvt::digital, dahdi_pvt::echocancel, dahdi_pvt::echocanon, errno, LOG_DEBUG, LOG_WARNING, option_debug, dahdi_pvt::sig, SIG_PRI, SUB_REAL, and dahdi_pvt::subs.
Referenced by __dahdi_exception(), dahdi_answer(), dahdi_bridge(), dahdi_handle_event(), dahdi_setoption(), handle_init_event(), and ss_thread().
01458 { 01459 int x; 01460 int res; 01461 if (!p) 01462 return; 01463 if (p->echocanon) { 01464 ast_log(LOG_DEBUG, "Echo cancellation already on\n"); 01465 return; 01466 } 01467 if (p->digital) { 01468 ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n"); 01469 return; 01470 } 01471 if (p->echocancel) { 01472 if (p->sig == SIG_PRI) { 01473 x = 1; 01474 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &x); 01475 if (res) 01476 ast_log(LOG_WARNING, "Unable to enable audio mode on channel %d (%s)\n", p->channel, strerror(errno)); 01477 } 01478 x = p->echocancel; 01479 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_ECHOCANCEL, &x); 01480 if (res) 01481 ast_log(LOG_WARNING, "Unable to enable echo cancellation on channel %d (%s)\n", p->channel, strerror(errno)); 01482 else { 01483 p->echocanon = 1; 01484 if (option_debug) 01485 ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel); 01486 } 01487 } else if (option_debug) 01488 ast_log(LOG_DEBUG, "No echo cancellation requested\n"); 01489 }
| static struct ast_frame * dahdi_exception | ( | struct ast_channel * | ast | ) | [static, read] |
Definition at line 4739 of file chan_dahdi.c.
References __dahdi_exception(), ast_mutex_lock(), ast_mutex_unlock(), dahdi_pvt::lock, and ast_channel::tech_pvt.
04740 { 04741 struct dahdi_pvt *p = ast->tech_pvt; 04742 struct ast_frame *f; 04743 ast_mutex_lock(&p->lock); 04744 f = __dahdi_exception(ast); 04745 ast_mutex_unlock(&p->lock); 04746 return f; 04747 }
| static int dahdi_fake_event | ( | struct dahdi_pvt * | p, | |
| int | mode | |||
| ) | [static] |
Definition at line 10559 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::fake_event, HANGUP, LOG_WARNING, ast_channel::name, dahdi_pvt::owner, and TRANSFER.
Referenced by __action_transfer(), and __action_transferhangup().
10560 { 10561 if (p) { 10562 switch (mode) { 10563 case TRANSFER: 10564 p->fake_event = DAHDI_EVENT_WINKFLASH; 10565 break; 10566 case HANGUP: 10567 p->fake_event = DAHDI_EVENT_ONHOOK; 10568 break; 10569 default: 10570 ast_log(LOG_WARNING, "I don't know how to handle transfer event with this: %d on channel %s\n",mode, p->owner->name); 10571 } 10572 } 10573 return 0; 10574 }
| static int dahdi_fixup | ( | struct ast_channel * | oldchan, | |
| struct ast_channel * | newchan | |||
| ) | [static] |
Definition at line 3537 of file chan_dahdi.c.
References ast_channel::_state, AST_CONTROL_RINGING, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), AST_STATE_RINGING, dahdi_pvt::channel, dahdi_indicate(), dahdi_unlink(), dahdi_pvt::lock, LOG_DEBUG, ast_channel::name, dahdi_subchannel::owner, dahdi_pvt::owner, dahdi_pvt::subs, ast_channel::tech_pvt, and update_conf().
03538 { 03539 struct dahdi_pvt *p = newchan->tech_pvt; 03540 int x; 03541 ast_mutex_lock(&p->lock); 03542 ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name); 03543 if (p->owner == oldchan) { 03544 p->owner = newchan; 03545 } 03546 for (x = 0; x < 3; x++) 03547 if (p->subs[x].owner == oldchan) { 03548 if (!x) 03549 dahdi_unlink(NULL, p, 0); 03550 p->subs[x].owner = newchan; 03551 } 03552 if (newchan->_state == AST_STATE_RINGING) 03553 dahdi_indicate(newchan, AST_CONTROL_RINGING, NULL, 0); 03554 update_conf(p); 03555 ast_mutex_unlock(&p->lock); 03556 return 0; 03557 }
| static int dahdi_func_read | ( | struct ast_channel * | chan, | |
| char * | function, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 3109 of file chan_dahdi.c.
References ast_copy_string(), ast_mutex_lock(), ast_mutex_unlock(), dahdi_pvt::lock, dahdi_pvt::rxgain, ast_channel::tech_pvt, and dahdi_pvt::txgain.
03110 { 03111 struct dahdi_pvt *p = chan->tech_pvt; 03112 03113 if (!strcasecmp(data, "rxgain")) { 03114 ast_mutex_lock(&p->lock); 03115 snprintf(buf, len, "%f", p->rxgain); 03116 ast_mutex_unlock(&p->lock); 03117 } else if (!strcasecmp(data, "txgain")) { 03118 ast_mutex_lock(&p->lock); 03119 snprintf(buf, len, "%f", p->txgain); 03120 ast_mutex_unlock(&p->lock); 03121 } else { 03122 ast_copy_string(buf, "", len); 03123 } 03124 return 0; 03125 }
| static int dahdi_get_event | ( | int | fd | ) | [inline, static] |
Avoid the silly dahdi_getevent which ignores a bunch of events.
Definition at line 256 of file chan_dahdi.c.
Referenced by __dahdi_exception(), dahdi_handle_event(), do_monitor(), and ss_thread().
00257 { 00258 int j; 00259 if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) 00260 return -1; 00261 return j; 00262 }
| static int dahdi_get_index | ( | struct ast_channel * | ast, | |
| struct dahdi_pvt * | p, | |||
| int | nullok | |||
| ) | [static] |
Definition at line 794 of file chan_dahdi.c.
References ast_log(), LOG_WARNING, dahdi_subchannel::owner, SUB_CALLWAIT, SUB_REAL, SUB_THREEWAY, and dahdi_pvt::subs.
Referenced by __dahdi_exception(), dahdi_answer(), dahdi_bridge(), dahdi_call(), dahdi_digit_begin(), dahdi_digit_end(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_read(), dahdi_sendtext(), dahdi_setoption(), dahdi_write(), and ss_thread().
00795 { 00796 int res; 00797 if (p->subs[SUB_REAL].owner == ast) 00798 res = 0; 00799 else if (p->subs[SUB_CALLWAIT].owner == ast) 00800 res = 1; 00801 else if (p->subs[SUB_THREEWAY].owner == ast) 00802 res = 2; 00803 else { 00804 res = -1; 00805 if (!nullok) 00806 ast_log(LOG_WARNING, "Unable to get index, and nullok is not asserted\n"); 00807 } 00808 return res; 00809 }
| static void dahdi_handle_dtmfup | ( | struct ast_channel * | ast, | |
| int | index, | |||
| struct ast_frame ** | dest | |||
| ) | [static] |
Definition at line 3700 of file chan_dahdi.c.
References ast_async_goto(), AST_CONTROL_ANSWER, ast_exists_extension(), AST_FRAME_CONTROL, AST_FRAME_NULL, ast_log(), ast_verbose(), dahdi_pvt::callprogress, dahdi_pvt::callwaitcas, ast_channel::cid, ast_callerid::cid_num, dahdi_pvt::cidspill, dahdi_pvt::confirmanswer, ast_channel::context, dahdi_confmute(), ast_channel::exten, dahdi_subchannel::f, dahdi_pvt::faxhandled, ast_frame::frametype, free, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, ast_channel::macrocontext, ast_channel::name, option_debug, option_verbose, pbx_builtin_setvar_helper(), S_OR, send_cwcidspill(), ast_frame::subclass, dahdi_pvt::subs, ast_channel::tech_pvt, and VERBOSE_PREFIX_3.
Referenced by dahdi_handle_event(), and dahdi_read().
03701 { 03702 struct dahdi_pvt *p = ast->tech_pvt; 03703 struct ast_frame *f = *dest; 03704 03705 if (option_debug) 03706 ast_log(LOG_DEBUG, "DTMF digit: %c on %s\n", f->subclass, ast->name); 03707 03708 if (p->confirmanswer) { 03709 if (option_debug) 03710 ast_log(LOG_DEBUG, "Confirm answer on %s!\n", ast->name); 03711 /* Upon receiving a DTMF digit, consider this an answer confirmation instead 03712 of a DTMF digit */ 03713 p->subs[index].f.frametype = AST_FRAME_CONTROL; 03714 p->subs[index].f.subclass = AST_CONTROL_ANSWER; 03715 *dest = &p->subs[index].f; 03716 /* Reset confirmanswer so DTMF's will behave properly for the duration of the call */ 03717 p->confirmanswer = 0; 03718 } else if (p->callwaitcas) { 03719 if ((f->subclass == 'A') || (f->subclass == 'D')) { 03720 if (option_debug) 03721 ast_log(LOG_DEBUG, "Got some DTMF, but it's for the CAS\n"); 03722 if (p->cidspill) 03723 free(p->cidspill); 03724 send_cwcidspill(p); 03725 } 03726 if ((f->subclass != 'm') && (f->subclass != 'u')) 03727 p->callwaitcas = 0; 03728 p->subs[index].f.frametype = AST_FRAME_NULL; 03729 p->subs[index].f.subclass = 0; 03730 *dest = &p->subs[index].f; 03731 } else if (f->subclass == 'f') { 03732 /* Fax tone -- Handle and return NULL */ 03733 if ((p->callprogress & 0x6) && !p->faxhandled) { 03734 p->faxhandled++; 03735 if (strcmp(ast->exten, "fax")) { 03736 const char *target_context = S_OR(ast->macrocontext, ast->context); 03737 03738 if (ast_exists_extension(ast, target_context, "fax", 1, ast->cid.cid_num)) { 03739 if (option_verbose > 2) 03740 ast_verbose(VERBOSE_PREFIX_3 "Redirecting %s to fax extension\n", ast->name); 03741 /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */ 03742 pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten); 03743 if (ast_async_goto(ast, target_context, "fax", 1)) 03744 ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context); 03745 } else 03746 ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n"); 03747 } else if (option_debug) 03748 ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n"); 03749 } else if (option_debug) 03750 ast_log(LOG_DEBUG, "Fax already handled\n"); 03751 dahdi_confmute(p, 0); 03752 p->subs[index].f.frametype = AST_FRAME_NULL; 03753 p->subs[index].f.subclass = 0; 03754 *dest = &p->subs[index].f; 03755 } else if (f->subclass == 'm') { 03756 /* Confmute request */ 03757 dahdi_confmute(p, 1); 03758 p->subs[index].f.frametype = AST_FRAME_NULL; 03759 p->subs[index].f.subclass = 0; 03760 *dest = &p->subs[index].f; 03761 } else if (f->subclass == 'u') { 03762 /* Unmute */ 03763 dahdi_confmute(p, 0); 03764 p->subs[index].f.frametype = AST_FRAME_NULL; 03765 p->subs[index].f.subclass = 0; 03766 *dest = &p->subs[index].f; 03767 } else 03768 dahdi_confmute(p, 0); 03769 }
| static struct ast_frame* dahdi_handle_event | ( | struct ast_channel * | ast | ) | [static, read] |
Definition at line 3791 of file chan_dahdi.c.
References ast_channel::_softhangup, ast_channel::_state, alloc_sub(), dahdi_pvt::answeronpolarityswitch, ast_bridged_channel(), AST_CONTROL_ANSWER, AST_CONTROL_HOLD, AST_CONTROL_OFFHOOK, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, ast_copy_string(), AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_NULL, ast_hangup(), ast_log(), ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), ast_pthread_create, ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_setstate(), ast_softhangup(), AST_SOFTHANGUP_DEV, AST_SOFTHANGUP_EXPLICIT, AST_STATE_BUSY, AST_STATE_DIALING, AST_STATE_DIALING_OFFHOOK, AST_STATE_DOWN, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_strdup, ast_strlen_zero(), ast_tvdiff_ms(), ast_tvnow(), ast_verbose(), attempt_transfer(), dahdi_pvt::callprogress, dahdi_pvt::callwaitcas, dahdi_pvt::callwaitingrepeat, CANPROGRESSDETECT, ast_channel::cdr, dahdi_pvt::channel, check_for_conference(), ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_ani2, dahdi_pvt::cid_name, ast_callerid::cid_name, cid_name, dahdi_pvt::cid_num, ast_callerid::cid_num, cid_num, dahdi_pvt::cidcwexpire, dahdi_pvt::cidrings, dahdi_pvt::cidspill, dahdi_pvt::confirmanswer, dahdi_confmute(), dahdi_disable_ec(), dahdi_enable_ec(), DAHDI_EVENT_DTMFDOWN, DAHDI_EVENT_DTMFUP, dahdi_get_event(), dahdi_get_index(), dahdi_handle_dtmfup(), dahdi_new(), dahdi_ring_phone(), dahdi_set_hook(), dahdi_train_ec(), dahdi_pvt::dahditrcallerid, ast_frame::data, ast_frame::datalen, DEADLOCK_AVOIDANCE, dahdi_subchannel::dfd, dahdi_pvt::dialdest, dahdi_pvt::dialednone, dahdi_pvt::dialing, dahdi_pvt::dop, dahdi_pvt::dsp, dahdi_pvt::echobreak, dahdi_pvt::echocanon, dahdi_pvt::echorest, dahdi_pvt::echotraining, errno, event2str(), EVENT_FLAG_SYSTEM, dahdi_subchannel::f, dahdi_pvt::fake_event, dahdi_pvt::finaldial, dahdi_pvt::flashtime, ast_frame::frametype, free, get_alarms(), handle_alarms(), dahdi_pvt::hanguponpolarityswitch, has_voicemail(), dahdi_pvt::inalarm, dahdi_subchannel::inthreeway, dahdi_pvt::lock, ast_channel::lock, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, ast_frame::mallocd, manager_event(), MIN_MS_SINCE_FLASH, dahdi_pvt::mohsuggest, dahdi_pvt::msgstate, ast_channel::name, dahdi_subchannel::needanswer, dahdi_subchannel::needflash, dahdi_subchannel::needhold, dahdi_subchannel::needringing, dahdi_subchannel::needunhold, ast_frame::offset, dahdi_pvt::onhooktime, dahdi_pvt::oprmode, dahdi_pvt::oprpeer, option_debug, option_verbose, dahdi_pvt::origcid_name, dahdi_pvt::origcid_num, dahdi_pvt::outgoing, dahdi_pvt::outsigmod, dahdi_pvt::overlapdial, dahdi_subchannel::owner, dahdi_pvt::owner, ast_channel::pbx, dahdi_pvt::polarity, POLARITY_IDLE, POLARITY_REV, dahdi_pvt::polaritydelaytv, dahdi_pvt::polarityonanswerdelay, dahdi_pvt::pulsedial, dahdi_pvt::radio, restore_conference(), ast_channel::rings, dahdi_pvt::ringt, dahdi_pvt::ringt_base, S_OR, ast_frame::samples, save_conference(), dahdi_pvt::sig, sig2str, SIG_E911, SIG_EM, SIG_EM_E1, SIG_EMWINK, SIG_FEATB, SIG_FEATD, SIG_FEATDMF, SIG_FEATDMF_TA, SIG_FGC_CAMA, SIG_FGC_CAMAMF, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_PRI, SIG_SF, SIG_SF_FEATB, SIG_SF_FEATD, SIG_SF_FEATDMF, SIG_SFWINK, ast_frame::src, ss_thread(), SUB_CALLWAIT, SUB_REAL, SUB_THREEWAY, ast_frame::subclass, dahdi_pvt::subs, swap_subs(), ast_channel::tech_pvt, dahdi_pvt::threewaycalling, dahdi_pvt::transfer, dahdi_pvt::transfertobusy, unalloc_sub(), dahdi_pvt::unknown_alarm, update_conf(), VERBOSE_PREFIX_3, and dahdi_pvt::whichwink.
Referenced by __dahdi_exception().
03792 { 03793 int res, x; 03794 int index, mysig; 03795 char *c; 03796 struct dahdi_pvt *p = ast->tech_pvt; 03797 pthread_t threadid; 03798 pthread_attr_t attr; 03799 struct ast_channel *chan; 03800 struct ast_frame *f; 03801 03802 index = dahdi_get_index(ast, p, 0); 03803 mysig = p->sig; 03804 if (p->outsigmod > -1) 03805 mysig = p->outsigmod; 03806 p->subs[index].f.frametype = AST_FRAME_NULL; 03807 p->subs[index].f.subclass = 0; 03808 p->subs[index].f.datalen = 0; 03809 p->subs[index].f.samples = 0; 03810 p->subs[index].f.mallocd = 0; 03811 p->subs[index].f.offset = 0; 03812 p->subs[index].f.src = "dahdi_handle_event"; 03813 p->subs[index].f.data = NULL; 03814 f = &p->subs[index].f; 03815 03816 if (index < 0) 03817 return &p->subs[index].f; 03818 if (p->fake_event) { 03819 res = p->fake_event; 03820 p->fake_event = 0; 03821 } else 03822 res = dahdi_get_event(p->subs[index].dfd); 03823 03824 if (option_debug) 03825 ast_log(LOG_DEBUG, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index); 03826 03827 if (res & (DAHDI_EVENT_PULSEDIGIT | DAHDI_EVENT_DTMFUP)) { 03828 p->pulsedial = (res & DAHDI_EVENT_PULSEDIGIT) ? 1 : 0; 03829 03830 ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff); 03831 #ifdef HAVE_PRI 03832 if (!p->proceeding && p->sig == SIG_PRI && p->pri && p->pri->overlapdial) { 03833 /* absorb event */ 03834 } else { 03835 #endif 03836 p->subs[index].f.frametype = AST_FRAME_DTMF_END; 03837 p->subs[index].f.subclass = res & 0xff; 03838 #ifdef HAVE_PRI 03839 } 03840 #endif 03841 dahdi_handle_dtmfup(ast, index, &f); 03842 return f; 03843 } 03844 03845 if (res & DAHDI_EVENT_DTMFDOWN) { 03846 if (option_debug) 03847 ast_log(LOG_DEBUG, "DTMF Down '%c'\n", res & 0xff); 03848 /* Mute conference */ 03849 dahdi_confmute(p, 1); 03850 p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN; 03851 p->subs[index].f.subclass = res & 0xff; 03852 return &p->subs[index].f; 03853 } 03854 03855 switch (res) { 03856 #ifdef DAHDI_EVENT_EC_DISABLED 03857 case DAHDI_EVENT_EC_DISABLED: 03858 if (option_verbose > 2) 03859 ast_verbose(VERBOSE_PREFIX_3 "Channel %d echo canceler disabled due to CED detection\n", p->channel); 03860 p->echocanon = 0; 03861 break; 03862 #endif 03863 case DAHDI_EVENT_BITSCHANGED: 03864 ast_log(LOG_WARNING, "Recieved bits changed on %s signalling?\n", sig2str(p->sig)); 03865 case DAHDI_EVENT_PULSE_START: 03866 /* Stop tone if there's a pulse start and the PBX isn't started */ 03867 if (!ast->pbx) 03868 tone_zone_play_tone(p->subs[index].dfd, -1); 03869 break; 03870 case DAHDI_EVENT_DIALCOMPLETE: 03871 if (p->inalarm) break; 03872 if ((p->radio || (p->oprmode < 0))) break; 03873 if (ioctl(p->subs[index].dfd,DAHDI_DIALING,&x) == -1) { 03874 ast_log(LOG_DEBUG, "DAHDI_DIALING ioctl failed on %s: %s\n",ast->name, strerror(errno)); 03875 return NULL; 03876 } 03877 if (!x) { /* if not still dialing in driver */ 03878 dahdi_enable_ec(p); 03879 if (p->echobreak) { 03880 dahdi_train_ec(p); 03881 ast_copy_string(p->dop.dialstr, p->echorest, sizeof(p->dop.dialstr)); 03882 p->dop.op = DAHDI_DIAL_OP_REPLACE; 03883 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_DIAL, &p->dop); 03884 p->echobreak = 0; 03885 } else { 03886 p->dialing = 0; 03887 if ((mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF)) { 03888 /* if thru with dialing after offhook */ 03889 if (ast->_state == AST_STATE_DIALING_OFFHOOK) { 03890 ast_setstate(ast, AST_STATE_UP); 03891 p->subs[index].f.frametype = AST_FRAME_CONTROL; 03892 p->subs[index].f.subclass = AST_CONTROL_ANSWER; 03893 break; 03894 } else { /* if to state wait for offhook to dial rest */ 03895 /* we now wait for off hook */ 03896 ast_setstate(ast,AST_STATE_DIALING_OFFHOOK); 03897 } 03898 } 03899 if (ast->_state == AST_STATE_DIALING) { 03900 if ((p->callprogress & 1) && CANPROGRESSDETECT(p) && p->dsp && p->outgoing) { 03901 ast_log(LOG_DEBUG, "Done dialing, but waiting for progress detection before doing more...\n"); 03902 } else if (p->confirmanswer || (!p->dialednone && ((mysig == SIG_EM) || (mysig == SIG_EM_E1) || (mysig == SIG_EMWINK) || (mysig == SIG_FEATD) || (mysig == SIG_FEATDMF_TA) || (mysig == SIG_FEATDMF) || (mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF) || (mysig == SIG_FEATB) || (mysig == SIG_SF) || (mysig == SIG_SFWINK) || (mysig == SIG_SF_FEATD) || (mysig == SIG_SF_FEATDMF) || (mysig == SIG_SF_FEATB)))) { 03903 ast_setstate(ast, AST_STATE_RINGING); 03904 } else if (!p->answeronpolarityswitch) { 03905 ast_setstate(ast, AST_STATE_UP); 03906 p->subs[index].f.frametype = AST_FRAME_CONTROL; 03907 p->subs[index].f.subclass = AST_CONTROL_ANSWER; 03908 /* If aops=0 and hops=1, this is necessary */ 03909 p->polarity = POLARITY_REV; 03910 } else { 03911 /* Start clean, so we can catch the change to REV polarity when party answers */ 03912 p->polarity = POLARITY_IDLE; 03913 } 03914 } 03915 } 03916 } 03917 break; 03918 case DAHDI_EVENT_ALARM: 03919 #ifdef HAVE_PRI 03920 if (!p->pri || !p->pri->pri || (pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0)) { 03921 /* T309 is not enabled : hangup calls when alarm occurs */ 03922 if (p->call) { 03923 if (p->pri && p->pri->pri) { 03924 if (!pri_grab(p, p->pri)) { 03925 pri_hangup(p->pri->pri, p->call, -1); 03926 pri_destroycall(p->pri->pri, p->call); 03927 p->call = NULL; 03928 pri_rel(p->pri); 03929 } else 03930 ast_log(LOG_WARNING, "Failed to grab PRI!\n"); 03931 } else 03932 ast_log(LOG_WARNING, "The PRI Call has not been destroyed\n"); 03933 } 03934 if (p->owner) 03935 p->owner->_softhangup |= AST_SOFTHANGUP_DEV; 03936 } 03937 if (p->bearer) 03938 p->bearer->inalarm = 1; 03939 else 03940 #endif 03941 p->inalarm = 1; 03942 res = get_alarms(p); 03943 handle_alarms(p, res); 03944 #ifdef HAVE_LIBPRI 03945 if (!p->pri || !p->pri->pri || pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0) { 03946 /* fall through intentionally */ 03947 } else { 03948 break; 03949 } 03950 #endif 03951 case DAHDI_EVENT_ONHOOK: 03952 if (p->radio) { 03953 p->subs[index].f.frametype = AST_FRAME_CONTROL; 03954 p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY; 03955 break; 03956 } 03957 if (p->oprmode < 0) 03958 { 03959 if (p->oprmode != -1) break; 03960 if ((p->sig == SIG_FXOLS) || (p->sig == SIG_FXOKS) || (p->sig == SIG_FXOGS)) 03961 { 03962 /* Make sure it starts ringing */ 03963 dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_RINGOFF); 03964 dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_RING); 03965 save_conference(p->oprpeer); 03966 tone_zone_play_tone(p->oprpeer->subs[SUB_REAL].dfd, DAHDI_TONE_RINGTONE); 03967 } 03968 break; 03969 } 03970 switch (p->sig) { 03971 case SIG_FXOLS: 03972 case SIG_FXOGS: 03973 case SIG_FXOKS: 03974 p->onhooktime = time(NULL); 03975 p->msgstate = -1; 03976 /* Check for some special conditions regarding call waiting */ 03977 if (index == SUB_REAL) { 03978 /* The normal line was hung up */ 03979 if (p->subs[SUB_CALLWAIT].owner) { 03980 /* There's a call waiting call, so ring the phone, but make it unowned in the mean time */ 03981 swap_subs(p, SUB_CALLWAIT, SUB_REAL); 03982 if (option_verbose > 2) 03983 ast_verbose(VERBOSE_PREFIX_3 "Channel %d still has (callwait) call, ringing phone\n", p->channel); 03984 unalloc_sub(p, SUB_CALLWAIT); 03985 #if 0 03986 p->subs[index].needanswer = 0; 03987 p->subs[index].needringing = 0; 03988 #endif 03989 p->callwaitingrepeat = 0; 03990 p->cidcwexpire = 0; 03991 p->owner = NULL; 03992 /* Don't start streaming audio yet if the incoming call isn't up yet */ 03993 if (p->subs[SUB_REAL].owner->_state != AST_STATE_UP) 03994 p->dialing = 1; 03995 dahdi_ring_phone(p); 03996 } else if (p->subs[SUB_THREEWAY].owner) { 03997 unsigned int mssinceflash; 03998 /* Here we have to retain the lock on both the main channel, the 3-way channel, and 03999 the private structure -- not especially easy or clean */ 04000 while (p->subs[SUB_THREEWAY].owner && ast_mutex_trylock(&p->subs[SUB_THREEWAY].owner->lock)) { 04001 /* Yuck, didn't get the lock on the 3-way, gotta release everything and re-grab! */ 04002 ast_mutex_unlock(&p->lock); 04003 DEADLOCK_AVOIDANCE(&ast->lock); 04004 /* We can grab ast and p in that order, without worry. We should make sure 04005 nothing seriously bad has happened though like some sort of bizarre double 04006 masquerade! */ 04007 ast_mutex_lock(&p->lock); 04008 if (p->owner != ast) { 04009 ast_log(LOG_WARNING, "This isn't good...\n"); 04010 return NULL; 04011 } 04012 } 04013 if (!p->subs[SUB_THREEWAY].owner) { 04014 ast_log(LOG_NOTICE, "Whoa, threeway disappeared kinda randomly.\n"); 04015 return NULL; 04016 } 04017 mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime); 04018 ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash); 04019 if (mssinceflash < MIN_MS_SINCE_FLASH) { 04020 /* It hasn't been long enough since the last flashook. This is probably a bounce on 04021 hanging up. Hangup both channels now */ 04022 if (p->subs[SUB_THREEWAY].owner) 04023 ast_queue_hangup(p->subs[SUB_THREEWAY].owner); 04024 p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; 04025 ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel); 04026 ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); 04027 } else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) { 04028 if (p->transfer) { 04029 /* In any case this isn't a threeway call anymore */ 04030 p->subs[SUB_REAL].inthreeway = 0; 04031 p->subs[SUB_THREEWAY].inthreeway = 0; 04032 /* Only attempt transfer if the phone is ringing; why transfer to busy tone eh? */ 04033 if (!p->transfertobusy && ast->_state == AST_STATE_BUSY) { 04034 ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); 04035 /* Swap subs and dis-own channel */ 04036 swap_subs(p, SUB_THREEWAY, SUB_REAL); 04037 p->owner = NULL; 04038 /* Ring the phone */ 04039 dahdi_ring_phone(p); 04040 } else { 04041 if ((res = attempt_transfer(p)) < 0) { 04042 p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; 04043 if (p->subs[SUB_THREEWAY].owner) 04044 ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); 04045 } else if (res) { 04046 /* Don't actually hang up at this point */ 04047 if (p->subs[SUB_THREEWAY].owner) 04048 ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); 04049 break; 04050 } 04051 } 04052 } else { 04053 p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; 04054 if (p->subs[SUB_THREEWAY].owner) 04055 ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); 04056 } 04057 } else { 04058 ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock); 04059 /* Swap subs and dis-own channel */ 04060 swap_subs(p, SUB_THREEWAY, SUB_REAL); 04061 p->owner = NULL; 04062 /* Ring the phone */ 04063 dahdi_ring_phone(p); 04064 } 04065 } 04066 } else { 04067 ast_log(LOG_WARNING, "Got a hangup and my index is %d?\n", index); 04068 } 04069 /* Fall through */ 04070 default: 04071 dahdi_disable_ec(p); 04072 return NULL; 04073 } 04074 break; 04075 case DAHDI_EVENT_RINGOFFHOOK: 04076 if (p->inalarm) break; 04077 if (p->oprmode < 0) 04078 { 04079 if ((p->sig == SIG_FXOLS) || (p->sig == SIG_FXOKS) || (p->sig == SIG_FXOGS)) 04080 { 04081 /* Make sure it stops ringing */ 04082 dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_RINGOFF); 04083 tone_zone_play_tone(p->oprpeer->subs[SUB_REAL].dfd, -1); 04084 restore_conference(p->oprpeer); 04085 } 04086 break; 04087 } 04088 if (p->radio) 04089 { 04090 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04091 p->subs[index].f.subclass = AST_CONTROL_RADIO_KEY; 04092 break; 04093 } 04094 /* for E911, its supposed to wait for offhook then dial 04095 the second half of the dial string */ 04096 if (((mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF)) && (ast->_state == AST_STATE_DIALING_OFFHOOK)) { 04097 c = strchr(p->dialdest, '/'); 04098 if (c) 04099 c++; 04100 else 04101 c = p->dialdest; 04102 if (*c) snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*0%s#", c); 04103 else ast_copy_string(p->dop.dialstr,"M*2#", sizeof(p->dop.dialstr)); 04104 if (strlen(p->dop.dialstr) > 4) { 04105 memset(p->echorest, 'w', sizeof(p->echorest) - 1); 04106 strcpy(p->echorest + (p->echotraining / 401) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2); 04107 p->echorest[sizeof(p->echorest) - 1] = '\0'; 04108 p->echobreak = 1; 04109 p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0'; 04110 } else 04111 p->echobreak = 0; 04112 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_DIAL, &p->dop)) { 04113 int saveerr = errno; 04114 04115 x = DAHDI_ONHOOK; 04116 ioctl(p->subs[SUB_REAL].dfd, DAHDI_HOOK, &x); 04117 ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(saveerr)); 04118 return NULL; 04119 } 04120 p->dialing = 1; 04121 return &p->subs[index].f; 04122 } 04123 switch (p->sig) { 04124 case SIG_FXOLS: 04125 case SIG_FXOGS: 04126 case SIG_FXOKS: 04127 switch (ast->_state) { 04128 case AST_STATE_RINGING: 04129 dahdi_enable_ec(p); 04130 dahdi_train_ec(p); 04131 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04132 p->subs[index].f.subclass = AST_CONTROL_ANSWER; 04133 /* Make sure it stops ringing */ 04134 dahdi_set_hook(p->subs[index].dfd, DAHDI_OFFHOOK); 04135 ast_log(LOG_DEBUG, "channel %d answered\n", p->channel); 04136 if (p->cidspill) { 04137 /* Cancel any running CallerID spill */ 04138 free(p->cidspill); 04139 p->cidspill = NULL; 04140 } 04141 p->dialing = 0; 04142 p->callwaitcas = 0; 04143 if (p->confirmanswer) { 04144 /* Ignore answer if "confirm answer" is enabled */ 04145 p->subs[index].f.frametype = AST_FRAME_NULL; 04146 p->subs[index].f.subclass = 0; 04147 } else if (!ast_strlen_zero(p->dop.dialstr)) { 04148 /* nick@dccinc.com 4/3/03 - fxo should be able to do deferred dialing */ 04149 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_DIAL, &p->dop); 04150 if (res < 0) { 04151 ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d: %s\n", p->channel, strerror(errno)); 04152 p->dop.dialstr[0] = '\0'; 04153 return NULL; 04154 } else { 04155 ast_log(LOG_DEBUG, "Sent FXO deferred digit string: %s\n", p->dop.dialstr); 04156 p->subs[index].f.frametype = AST_FRAME_NULL; 04157 p->subs[index].f.subclass = 0; 04158 p->dialing = 1; 04159 } 04160 p->dop.dialstr[0] = '\0'; 04161 ast_setstate(ast, AST_STATE_DIALING); 04162 } else 04163 ast_setstate(ast, AST_STATE_UP); 04164 return &p->subs[index].f; 04165 case AST_STATE_DOWN: 04166 ast_setstate(ast, AST_STATE_RING); 04167 ast->rings = 1; 04168 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04169 p->subs[index].f.subclass = AST_CONTROL_OFFHOOK; 04170 ast_log(LOG_DEBUG, "channel %d picked up\n", p->channel); 04171 return &p->subs[index].f; 04172 case AST_STATE_UP: 04173 /* Make sure it stops ringing */ 04174 dahdi_set_hook(p->subs[index].dfd, DAHDI_OFFHOOK); 04175 /* Okay -- probably call waiting*/ 04176 if (ast_bridged_channel(p->owner)) 04177 ast_queue_control(p->owner, AST_CONTROL_UNHOLD); 04178 p->subs[index].needunhold = 1; 04179 break; 04180 case AST_STATE_RESERVED: 04181 /* Start up dialtone */ 04182 if (has_voicemail(p)) 04183 res = tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_STUTTER); 04184 else 04185 res = tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_DIALTONE); 04186 break; 04187 default: 04188 ast_log(LOG_WARNING, "FXO phone off hook in weird state %d??\n", ast->_state); 04189 } 04190 break; 04191 case SIG_FXSLS: 04192 case SIG_FXSGS: 04193 case SIG_FXSKS: 04194 if (ast->_state == AST_STATE_RING) { 04195 p->ringt = p->ringt_base; 04196 } 04197 04198 /* Fall through */ 04199 case SIG_EM: 04200 case SIG_EM_E1: 04201 case SIG_EMWINK: 04202 case SIG_FEATD: 04203 case SIG_FEATDMF: 04204 case SIG_FEATDMF_TA: 04205 case SIG_E911: 04206 case SIG_FGC_CAMA: 04207 case SIG_FGC_CAMAMF: 04208 case SIG_FEATB: 04209 case SIG_SF: 04210 case SIG_SFWINK: 04211 case SIG_SF_FEATD: 04212 case SIG_SF_FEATDMF: 04213 case SIG_SF_FEATB: 04214 if (ast->_state == AST_STATE_PRERING) 04215 ast_setstate(ast, AST_STATE_RING); 04216 if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) { 04217 if (option_debug) 04218 ast_log(LOG_DEBUG, "Ring detected\n"); 04219 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04220 p->subs[index].f.subclass = AST_CONTROL_RING; 04221 } else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) { 04222 if (option_debug) 04223 ast_log(LOG_DEBUG, "Line answered\n"); 04224 if (p->confirmanswer) { 04225 p->subs[index].f.frametype = AST_FRAME_NULL; 04226 p->subs[index].f.subclass = 0; 04227 } else { 04228 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04229 p->subs[index].f.subclass = AST_CONTROL_ANSWER; 04230 ast_setstate(ast, AST_STATE_UP); 04231 } 04232 } else if (ast->_state != AST_STATE_RING) 04233 ast_log(LOG_WARNING, "Ring/Off-hook in strange state %d on channel %d\n", ast->_state, p->channel); 04234 break; 04235 default: 04236 ast_log(LOG_WARNING, "Don't know how to handle ring/off hook for signalling %d\n", p->sig); 04237 } 04238 break; 04239 #ifdef DAHDI_EVENT_RINGBEGIN 04240 case DAHDI_EVENT_RINGBEGIN: 04241 switch (p->sig) { 04242 case SIG_FXSLS: 04243 case SIG_FXSGS: 04244 case SIG_FXSKS: 04245 if (ast->_state == AST_STATE_RING) { 04246 p->ringt = p->ringt_base; 04247 } 04248 break; 04249 } 04250 break; 04251 #endif 04252 case DAHDI_EVENT_RINGEROFF: 04253 if (p->inalarm) break; 04254 if ((p->radio || (p->oprmode < 0))) break; 04255 ast->rings++; 04256 if ((ast->rings > p->cidrings) && (p->cidspill)) { 04257 ast_log(LOG_WARNING, "Didn't finish Caller-ID spill. Cancelling.\n"); 04258 free(p->cidspill); 04259 p->cidspill = NULL; 04260 p->callwaitcas = 0; 04261 } 04262 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04263 p->subs[index].f.subclass = AST_CONTROL_RINGING; 04264 break; 04265 case DAHDI_EVENT_RINGERON: 04266 break; 04267 case DAHDI_EVENT_NOALARM: 04268 p->inalarm = 0; 04269 #ifdef HAVE_PRI 04270 /* Extremely unlikely but just in case */ 04271 if (p->bearer) 04272 p->bearer->inalarm = 0; 04273 #endif 04274 if (!p->unknown_alarm) { 04275 ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", p->channel); 04276 manager_event(EVENT_FLAG_SYSTEM, "AlarmClear", 04277 "Channel: %d\r\n", p->channel); 04278 } else { 04279 p->unknown_alarm = 0; 04280 } 04281 break; 04282 case DAHDI_EVENT_WINKFLASH: 04283 if (p->inalarm) break; 04284 if (p->radio) break; 04285 if (p->oprmode < 0) break; 04286 if (p->oprmode > 1) 04287 { 04288 struct dahdi_params par; 04289 04290 if (ioctl(p->oprpeer->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &par) != -1) 04291 { 04292 if (!par.rxisoffhook) 04293 { 04294 /* Make sure it stops ringing */ 04295 dahdi_set_hook(p->oprpeer->subs[SUB_REAL].dfd, DAHDI_RINGOFF); 04296 dahdi_set_hook(p->oprpeer->subs[SUB_REAL].dfd, DAHDI_RING); 04297 save_conference(p); 04298 tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_RINGTONE); 04299 } 04300 } 04301 break; 04302 } 04303 /* Remember last time we got a flash-hook */ 04304 gettimeofday(&p->flashtime, NULL); 04305 switch (mysig) { 04306 case SIG_FXOLS: 04307 case SIG_FXOGS: 04308 case SIG_FXOKS: 04309 ast_log(LOG_DEBUG, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n", 04310 index, p->subs[SUB_REAL].dfd, p->subs[SUB_CALLWAIT].dfd, p->subs[SUB_THREEWAY].dfd); 04311 p->callwaitcas = 0; 04312 04313 if (index != SUB_REAL) { 04314 ast_log(LOG_WARNING, "Got flash hook with index %d on channel %d?!?\n", index, p->channel); 04315 goto winkflashdone; 04316 } 04317 04318 if (p->subs[SUB_CALLWAIT].owner) { 04319 /* Swap to call-wait */ 04320 swap_subs(p, SUB_REAL, SUB_CALLWAIT); 04321 tone_zone_play_tone(p->subs[SUB_REAL].dfd, -1); 04322 p->owner = p->subs[SUB_REAL].owner; 04323 ast_log(LOG_DEBUG, "Making %s the new owner\n", p->owner->name); 04324 if (p->owner->_state == AST_STATE_RINGING) { 04325 ast_setstate(p->owner, AST_STATE_UP); 04326 p->subs[SUB_REAL].needanswer = 1; 04327 } 04328 p->callwaitingrepeat = 0; 04329 p->cidcwexpire = 0; 04330 /* Start music on hold if appropriate */ 04331 if (!p->subs[SUB_CALLWAIT].inthreeway && ast_bridged_channel(p->subs[SUB_CALLWAIT].owner)) { 04332 ast_queue_control_data(p->subs[SUB_CALLWAIT].owner, AST_CONTROL_HOLD, 04333 S_OR(p->mohsuggest, NULL), 04334 !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0); 04335 } 04336 p->subs[SUB_CALLWAIT].needhold = 1; 04337 if (ast_bridged_channel(p->subs[SUB_REAL].owner)) { 04338 ast_queue_control_data(p->subs[SUB_REAL].owner, AST_CONTROL_HOLD, 04339 S_OR(p->mohsuggest, NULL), 04340 !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0); 04341 } 04342 p->subs[SUB_REAL].needunhold = 1; 04343 } else if (!p->subs[SUB_THREEWAY].owner) { 04344 char cid_num[256]; 04345 char cid_name[256]; 04346 04347 if (!p->threewaycalling) { 04348 /* Just send a flash if no 3-way calling */ 04349 p->subs[SUB_REAL].needflash = 1; 04350 goto winkflashdone; 04351 } else if (!check_for_conference(p)) { 04352 if (p->dahditrcallerid && p->owner) { 04353 if (p->owner->cid.cid_num) 04354 ast_copy_string(cid_num, p->owner->cid.cid_num, sizeof(cid_num)); 04355 if (p->owner->cid.cid_name) 04356 ast_copy_string(cid_name, p->owner->cid.cid_name, sizeof(cid_name)); 04357 } 04358 /* XXX This section needs much more error checking!!! XXX */ 04359 /* Start a 3-way call if feasible */ 04360 if (!((ast->pbx) || 04361 (ast->_state == AST_STATE_UP) || 04362 (ast->_state == AST_STATE_RING))) { 04363 ast_log(LOG_DEBUG, "Flash when call not up or ringing\n"); 04364 goto winkflashdone; 04365 } 04366 if (alloc_sub(p, SUB_THREEWAY)) { 04367 ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n"); 04368 goto winkflashdone; 04369 } 04370 /* Make new channel */ 04371 chan = dahdi_new(p, AST_STATE_RESERVED, 0, SUB_THREEWAY, 0, 0); 04372 if (p->dahditrcallerid) { 04373 if (!p->origcid_num) 04374 p->origcid_num = ast_strdup(p->cid_num); 04375 if (!p->origcid_name) 04376 p->origcid_name = ast_strdup(p->cid_name); 04377 ast_copy_string(p->cid_num, cid_num, sizeof(p->cid_num)); 04378 ast_copy_string(p->cid_name, cid_name, sizeof(p->cid_name)); 04379 } 04380 /* Swap things around between the three-way and real call */ 04381 swap_subs(p, SUB_THREEWAY, SUB_REAL); 04382 /* Disable echo canceller for better dialing */ 04383 dahdi_disable_ec(p); 04384 res = tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_DIALRECALL); 04385 if (res) 04386 ast_log(LOG_WARNING, "Unable to start dial recall tone on channel %d\n", p->channel); 04387 p->owner = chan; 04388 pthread_attr_init(&attr); 04389 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 04390 if (!chan) { 04391 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", p->channel); 04392 } else if (ast_pthread_create(&threadid, &attr, ss_thread, chan)) { 04393 ast_log(LOG_WARNING, "Unable to start simple switch on channel %d\n", p->channel); 04394 res = tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_CONGESTION); 04395 dahdi_enable_ec(p); 04396 ast_hangup(chan); 04397 } else { 04398 struct ast_channel *other = ast_bridged_channel(p->subs[SUB_THREEWAY].owner); 04399 int way3bridge = 0, cdr3way = 0; 04400 04401 if (!other) { 04402 other = ast_bridged_channel(p->subs[SUB_REAL].owner); 04403 } else 04404 way3bridge = 1; 04405 04406 if (p->subs[SUB_THREEWAY].owner->cdr) 04407 cdr3way = 1; 04408 04409 if (option_verbose > 2) 04410 ast_verbose(VERBOSE_PREFIX_3 "Started three way call on channel %d\n", p->channel); 04411 /* Start music on hold if appropriate */ 04412 if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) { 04413 ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD, 04414 S_OR(p->mohsuggest, NULL), 04415 !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0); 04416 } 04417 p->subs[SUB_THREEWAY].needhold = 1; 04418 } 04419 pthread_attr_destroy(&attr); 04420 } 04421 } else { 04422 /* Already have a 3 way call */ 04423 if (p->subs[SUB_THREEWAY].inthreeway) { 04424 /* Call is already up, drop the last person */ 04425 if (option_debug) 04426 ast_log(LOG_DEBUG, "Got flash with three way call up, dropping last call on %d\n", p->channel); 04427 /* If the primary call isn't answered yet, use it */ 04428 if ((p->subs[SUB_REAL].owner->_state != AST_STATE_UP) && (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_UP)) { 04429 /* Swap back -- we're dropping the real 3-way that isn't finished yet*/ 04430 swap_subs(p, SUB_THREEWAY, SUB_REAL); 04431 p->owner = p->subs[SUB_REAL].owner; 04432 } 04433 /* Drop the last call and stop the conference */ 04434 if (option_verbose > 2) 04435 ast_verbose(VERBOSE_PREFIX_3 "Dropping three-way call on %s\n", p->subs[SUB_THREEWAY].owner->name); 04436 p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; 04437 p->subs[SUB_REAL].inthreeway = 0; 04438 p->subs[SUB_THREEWAY].inthreeway = 0; 04439 } else { 04440 /* Lets see what we're up to */ 04441 if (((ast->pbx) || (ast->_state == AST_STATE_UP)) && 04442 (p->transfertobusy || (ast->_state != AST_STATE_BUSY))) { 04443 int otherindex = SUB_THREEWAY; 04444 struct ast_channel *other = ast_bridged_channel(p->subs[SUB_THREEWAY].owner); 04445 int way3bridge = 0, cdr3way = 0; 04446 04447 if (!other) { 04448 other = ast_bridged_channel(p->subs[SUB_REAL].owner); 04449 } else 04450 way3bridge = 1; 04451 04452 if (p->subs[SUB_THREEWAY].owner->cdr) 04453 cdr3way = 1; 04454 04455 if (option_verbose > 2) 04456 ast_verbose(VERBOSE_PREFIX_3 "Building conference on call on %s and %s\n", p->subs[SUB_THREEWAY].owner->name, p->subs[SUB_REAL].owner->name); 04457 /* Put them in the threeway, and flip */ 04458 p->subs[SUB_THREEWAY].inthreeway = 1; 04459 p->subs[SUB_REAL].inthreeway = 1; 04460 if (ast->_state == AST_STATE_UP) { 04461 swap_subs(p, SUB_THREEWAY, SUB_REAL); 04462 otherindex = SUB_REAL; 04463 } 04464 if (p->subs[otherindex].owner && ast_bridged_channel(p->subs[otherindex].owner)) 04465 ast_queue_control(p->subs[otherindex].owner, AST_CONTROL_UNHOLD); 04466 p->subs[otherindex].needunhold = 1; 04467 p->owner = p->subs[SUB_REAL].owner; 04468 if (ast->_state == AST_STATE_RINGING) { 04469 ast_log(LOG_DEBUG, "Enabling ringtone on real and threeway\n"); 04470 res = tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_RINGTONE); 04471 res = tone_zone_play_tone(p->subs[SUB_THREEWAY].dfd, DAHDI_TONE_RINGTONE); 04472 } 04473 } else { 04474 if (option_verbose > 2) 04475 ast_verbose(VERBOSE_PREFIX_3 "Dumping incomplete call on on %s\n", p->subs[SUB_THREEWAY].owner->name); 04476 swap_subs(p, SUB_THREEWAY, SUB_REAL); 04477 p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; 04478 p->owner = p->subs[SUB_REAL].owner; 04479 if (p->subs[SUB_REAL].owner && ast_bridged_channel(p->subs[SUB_REAL].owner)) 04480 ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD); 04481 p->subs[SUB_REAL].needunhold = 1; 04482 dahdi_enable_ec(p); 04483 } 04484 04485 } 04486 } 04487 winkflashdone: 04488 update_conf(p); 04489 break; 04490 case SIG_EM: 04491 case SIG_EM_E1: 04492 case SIG_EMWINK: 04493 case SIG_FEATD: 04494 case SIG_SF: 04495 case SIG_SFWINK: 04496 case SIG_SF_FEATD: 04497 case SIG_FXSLS: 04498 case SIG_FXSGS: 04499 if (p->dialing) 04500 ast_log(LOG_DEBUG, "Ignoring wink on channel %d\n", p->channel); 04501 else 04502 ast_log(LOG_DEBUG, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel); 04503 break; 04504 case SIG_FEATDMF_TA: 04505 switch (p->whichwink) { 04506 case 0: 04507 ast_log(LOG_DEBUG, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani); 04508 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani); 04509 break; 04510 case 1: 04511 ast_copy_string(p->dop.dialstr, p->finaldial, sizeof(p->dop.dialstr)); 04512 break; 04513 case 2: 04514 ast_log(LOG_WARNING, "Received unexpected wink on channel of type SIG_FEATDMF_TA\n"); 04515 return NULL; 04516 } 04517 p->whichwink++; 04518 /* Fall through */ 04519 case SIG_FEATDMF: 04520 case SIG_E911: 04521 case SIG_FGC_CAMAMF: 04522 case SIG_FGC_CAMA: 04523 case SIG_FEATB: 04524 case SIG_SF_FEATDMF: 04525 case SIG_SF_FEATB: 04526 /* FGD MF *Must* wait for wink */ 04527 if (!ast_strlen_zero(p->dop.dialstr)) { 04528 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_DIAL, &p->dop); 04529 if (res < 0) { 04530 ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d: %s\n", p->channel, strerror(errno)); 04531 p->dop.dialstr[0] = '\0'; 04532 return NULL; 04533 } else 04534 ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr); 04535 } 04536 p->dop.dialstr[0] = '\0'; 04537 break; 04538 default: 04539 ast_log(LOG_WARNING, "Don't know how to handle ring/off hoook for signalling %d\n", p->sig); 04540 } 04541 break; 04542 case DAHDI_EVENT_HOOKCOMPLETE: 04543 if (p->inalarm) break; 04544 if ((p->radio || (p->oprmode < 0))) break; 04545 switch (mysig) { 04546 case SIG_FXSLS: /* only interesting for FXS */ 04547 case SIG_FXSGS: 04548 case SIG_FXSKS: 04549 case SIG_EM: 04550 case SIG_EM_E1: 04551 case SIG_EMWINK: 04552 case SIG_FEATD: 04553 case SIG_SF: 04554 case SIG_SFWINK: 04555 case SIG_SF_FEATD: 04556 if (!ast_strlen_zero(p->dop.dialstr)) { 04557 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_DIAL, &p->dop); 04558 if (res < 0) { 04559 ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d: %s\n", p->channel, strerror(errno)); 04560 p->dop.dialstr[0] = '\0'; 04561 return NULL; 04562 } else 04563 ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr); 04564 } 04565 p->dop.dialstr[0] = '\0'; 04566 p->dop.op = DAHDI_DIAL_OP_REPLACE; 04567 break; 04568 case SIG_FEATDMF: 04569 case SIG_FEATDMF_TA: 04570 case SIG_E911: 04571 case SIG_FGC_CAMA: 04572 case SIG_FGC_CAMAMF: 04573 case SIG_FEATB: 04574 case SIG_SF_FEATDMF: 04575 case SIG_SF_FEATB: 04576 ast_log(LOG_DEBUG, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel); 04577 break; 04578 default: 04579 break; 04580 } 04581 break; 04582 case DAHDI_EVENT_POLARITY: 04583 /* 04584 * If we get a Polarity Switch event, check to see 04585 * if we should change the polarity state and 04586 * mark the channel as UP or if this is an indication 04587 * of remote end disconnect. 04588 */ 04589 if (p->polarity == POLARITY_IDLE) { 04590 p->polarity = POLARITY_REV; 04591 if (p->answeronpolarityswitch && 04592 ((ast->_state == AST_STATE_DIALING) || 04593 (ast->_state == AST_STATE_RINGING))) { 04594 ast_log(LOG_DEBUG, "Answering on polarity switch!\n"); 04595 ast_setstate(p->owner, AST_STATE_UP); 04596 if (p->hanguponpolarityswitch) { 04597 gettimeofday(&p->polaritydelaytv, NULL); 04598 } 04599 } else 04600 ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state); 04601 } 04602 /* Removed else statement from here as it was preventing hangups from ever happening*/ 04603 /* Added AST_STATE_RING in if statement below to deal with calling party hangups that take place when ringing */ 04604 if (p->hanguponpolarityswitch && 04605 (p->polarityonanswerdelay > 0) && 04606 (p->polarity == POLARITY_REV) && 04607 ((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) { 04608 /* Added log_debug information below to provide a better indication of what is going on */ 04609 ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) ); 04610 04611 if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) { 04612 ast_log(LOG_DEBUG, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel); 04613 ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT); 04614 p->polarity = POLARITY_IDLE; 04615 } else { 04616 ast_log(LOG_DEBUG, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state); 04617 } 04618 } else { 04619 p->polarity = POLARITY_IDLE; 04620 ast_log(LOG_DEBUG, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state); 04621 } 04622 /* Added more log_debug information below to provide a better indication of what is going on */ 04623 ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) ); 04624 break; 04625 default: 04626 ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel); 04627 } 04628 return &p->subs[index].f; 04629 }
| static int dahdi_hangup | ( | struct ast_channel * | ast | ) | [static] |
Definition at line 2505 of file chan_dahdi.c.
References ast_channel::_state, ast_bridged_channel(), ast_channel_setoption(), AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, ast_copy_string(), ast_dsp_digitmode(), ast_dsp_free(), ast_log(), ast_module_unref(), ast_mutex_lock(), ast_mutex_unlock(), AST_OPTION_AUDIO_MODE, AST_OPTION_TDD, AST_OPTION_TONE_VERIFY, ast_queue_control(), ast_queue_control_data(), AST_STATE_RESERVED, AST_STATE_UP, ast_strlen_zero(), ast_verbose(), dahdi_pvt::callwaitcas, dahdi_pvt::callwaiting, dahdi_pvt::callwaitingrepeat, dahdi_pvt::channel, dahdi_pvt::cid_name, dahdi_pvt::cid_num, dahdi_pvt::cidcwexpire, dahdi_pvt::cidrings, dahdi_pvt::cidspill, dahdi_pvt::confirmanswer, dahdi_confmute(), dahdi_disable_ec(), dahdi_get_index(), dahdi_set_hook(), dahdi_setlinear(), dahdi_pvt::destroy, destroy_channel(), dahdi_subchannel::dfd, dahdi_pvt::dialing, dahdi_pvt::didtdd, dahdi_pvt::digital, dahdi_pvt::distinctivering, dahdi_pvt::dsp, DSP_DIGITMODE_DTMF, dahdi_pvt::dtmfrelax, errno, dahdi_pvt::exten, dahdi_pvt::faxhandled, free, dahdi_pvt::guardtime, ast_channel::hangupcause, dahdi_pvt::hidecallerid, iflist, iflock, dahdi_pvt::ignoredtmf, dahdi_subchannel::inthreeway, dahdi_subchannel::linear, dahdi_pvt::lock, LOG_DEBUG, LOG_WARNING, dahdi_pvt::mohsuggest, ast_channel::name, dahdi_subchannel::needanswer, dahdi_subchannel::needbusy, dahdi_subchannel::needcallerid, dahdi_subchannel::needcongestion, dahdi_subchannel::needflash, dahdi_subchannel::needringing, dahdi_pvt::next, dahdi_pvt::onhooktime, dahdi_pvt::oprmode, option_debug, option_verbose, dahdi_pvt::origcid_name, dahdi_pvt::origcid_num, dahdi_pvt::outgoing, dahdi_pvt::owner, dahdi_subchannel::owner, pbx_builtin_getvar_helper(), dahdi_pvt::permcallwaiting, dahdi_pvt::permhidecallerid, dahdi_pvt::polarity, POLARITY_IDLE, dahdi_pvt::prev, dahdi_pvt::pulsedial, dahdi_pvt::radio, dahdi_pvt::rdnis, reset_conf(), restart_monitor(), dahdi_pvt::restartpending, restore_gains(), dahdi_pvt::ringt, S_OR, dahdi_pvt::sig, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_PRI, dahdi_pvt::span, SUB_CALLWAIT, SUB_REAL, SUB_THREEWAY, dahdi_pvt::subs, swap_subs(), ast_channel::tech_pvt, unalloc_sub(), update_conf(), and VERBOSE_PREFIX_3.
02506 { 02507 int res; 02508 int index,x, law; 02509 /*static int restore_gains(struct dahdi_pvt *p);*/ 02510 struct dahdi_pvt *p = ast->tech_pvt; 02511 struct dahdi_pvt *tmp = NULL; 02512 struct dahdi_pvt *prev = NULL; 02513 struct dahdi_params par; 02514 02515 if (option_debug) 02516 ast_log(LOG_DEBUG, "dahdi_hangup(%s)\n", ast->name); 02517 if (!ast->tech_pvt) { 02518 ast_log(LOG_WARNING, "Asked to hangup channel not connected\n"); 02519 return 0; 02520 } 02521 02522 ast_mutex_lock(&p->lock); 02523 02524 index = dahdi_get_index(ast, p, 1); 02525 02526 if (p->sig == SIG_PRI) { 02527 x = 1; 02528 ast_channel_setoption(ast,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0); 02529 } 02530 02531 x = 0; 02532 dahdi_confmute(p, 0); 02533 restore_gains(p); 02534 if (p->origcid_num) { 02535 ast_copy_string(p->cid_num, p->origcid_num, sizeof(p->cid_num)); 02536 free(p->origcid_num); 02537 p->origcid_num = NULL; 02538 } 02539 if (p->origcid_name) { 02540 ast_copy_string(p->cid_name, p->origcid_name, sizeof(p->cid_name)); 02541 free(p->origcid_name); 02542 p->origcid_name = NULL; 02543 } 02544 if (p->dsp) 02545 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); 02546 if (p->exten) 02547 p->exten[0] = '\0'; 02548 02549 if (option_debug) 02550 ast_log(LOG_DEBUG, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n", 02551 p->channel, index, p->subs[SUB_REAL].dfd, p->subs[SUB_CALLWAIT].dfd, p->subs[SUB_THREEWAY].dfd); 02552 p->ignoredtmf = 0; 02553 02554 if (index > -1) { 02555 /* Real channel, do some fixup */ 02556 p->subs[index].owner = NULL; 02557 p->subs[index].needanswer = 0; 02558 p->subs[index].needflash = 0; 02559 p->subs[index].needringing = 0; 02560 p->subs[index].needbusy = 0; 02561 p->subs[index].needcongestion = 0; 02562 p->subs[index].linear = 0; 02563 p->subs[index].needcallerid = 0; 02564 p->polarity = POLARITY_IDLE; 02565 dahdi_setlinear(p->subs[index].dfd, 0); 02566 if (index == SUB_REAL) { 02567 if ((p->subs[SUB_CALLWAIT].dfd > -1) && (p->subs[SUB_THREEWAY].dfd > -1)) { 02568 ast_log(LOG_DEBUG, "Normal call hung up with both three way call and a call waiting call in place?\n"); 02569 if (p->subs[SUB_CALLWAIT].inthreeway) { 02570 /* We had flipped over to answer a callwait and now it's gone */ 02571 ast_log(LOG_DEBUG, "We were flipped over to the callwait, moving back and unowning.\n"); 02572 /* Move to the call-wait, but un-own us until they flip back. */ 02573 swap_subs(p, SUB_CALLWAIT, SUB_REAL); 02574 unalloc_sub(p, SUB_CALLWAIT); 02575 p->owner = NULL; 02576 } else { 02577 /* The three way hung up, but we still have a call wait */ 02578 ast_log(LOG_DEBUG, "We were in the threeway and have a callwait still. Ditching the threeway.\n"); 02579 swap_subs(p, SUB_THREEWAY, SUB_REAL); 02580 unalloc_sub(p, SUB_THREEWAY); 02581 if (p->subs[SUB_REAL].inthreeway) { 02582 /* This was part of a three way call. Immediately make way for 02583 another call */ 02584 ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n"); 02585 p->owner = p->subs[SUB_REAL].owner; 02586 } else { 02587 /* This call hasn't been completed yet... Set owner to NULL */ 02588 ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n"); 02589 p->owner = NULL; 02590 } 02591 p->subs[SUB_REAL].inthreeway = 0; 02592 } 02593 } else if (p->subs[SUB_CALLWAIT].dfd > -1) { 02594 /* Move to the call-wait and switch back to them. */ 02595 swap_subs(p, SUB_CALLWAIT, SUB_REAL); 02596 unalloc_sub(p, SUB_CALLWAIT); 02597 p->owner = p->subs[SUB_REAL].owner; 02598 if (p->owner->_state != AST_STATE_UP) 02599 p->subs[SUB_REAL].needanswer = 1; 02600 if (ast_bridged_channel(p->subs[SUB_REAL].owner)) 02601 ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD); 02602 } else if (p->subs[SUB_THREEWAY].dfd > -1) { 02603 swap_subs(p, SUB_THREEWAY, SUB_REAL); 02604 unalloc_sub(p, SUB_THREEWAY); 02605 if (p->subs[SUB_REAL].inthreeway) { 02606 /* This was part of a three way call. Immediately make way for 02607 another call */ 02608 ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n"); 02609 p->owner = p->subs[SUB_REAL].owner; 02610 } else { 02611 /* This call hasn't been completed yet... Set owner to NULL */ 02612 ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n"); 02613 p->owner = NULL; 02614 } 02615 p->subs[SUB_REAL].inthreeway = 0; 02616 } 02617 } else if (index == SUB_CALLWAIT) { 02618 /* Ditch the holding callwait call, and immediately make it availabe */ 02619 if (p->subs[SUB_CALLWAIT].inthreeway) { 02620 /* This is actually part of a three way, placed on hold. Place the third part 02621 on music on hold now */ 02622 if (p->subs[SUB_THREEWAY].owner && ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) { 02623 ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD, 02624 S_OR(p->mohsuggest, NULL), 02625 !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0); 02626 } 02627 p->subs[SUB_THREEWAY].inthreeway = 0; 02628 /* Make it the call wait now */ 02629 swap_subs(p, SUB_CALLWAIT, SUB_THREEWAY); 02630 unalloc_sub(p, SUB_THREEWAY); 02631 } else 02632 unalloc_sub(p, SUB_CALLWAIT); 02633 } else if (index == SUB_THREEWAY) { 02634 if (p->subs[SUB_CALLWAIT].inthreeway) { 02635 /* The other party of the three way call is currently in a call-wait state. 02636 Start music on hold for them, and take the main guy out of the third call */ 02637 if (p->subs[SUB_CALLWAIT].owner && ast_bridged_channel(p->subs[SUB_CALLWAIT].owner)) { 02638 ast_queue_control_data(p->subs[SUB_CALLWAIT].owner, AST_CONTROL_HOLD, 02639 S_OR(p->mohsuggest, NULL), 02640 !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0); 02641 } 02642 p->subs[SUB_CALLWAIT].inthreeway = 0; 02643 } 02644 p->subs[SUB_REAL].inthreeway = 0; 02645 /* If this was part of a three way call index, let us make 02646 another three way call */ 02647 unalloc_sub(p, SUB_THREEWAY); 02648 } else { 02649 /* This wasn't any sort of call, but how are we an index? */ 02650 ast_log(LOG_WARNING, "Index found but not any type of call?\n"); 02651 } 02652 } 02653 02654 if (!p->subs[SUB_REAL].owner && !p->subs[SUB_CALLWAIT].owner && !p->subs[SUB_THREEWAY].owner) { 02655 p->owner = NULL; 02656 p->ringt = 0; 02657 p->distinctivering = 0; 02658 p->confirmanswer = 0; 02659 p->cidrings = 1; 02660 p->outgoing = 0; 02661 p->digital = 0; 02662 p->faxhandled = 0; 02663 p->pulsedial = 0; 02664 p->onhooktime = time(NULL); 02665 #ifdef HAVE_PRI 02666 p->proceeding = 0; 02667 p->progress = 0; 02668 p->alerting = 0; 02669 p->setup_ack = 0; 02670 #endif 02671 if (p->dsp) { 02672 ast_dsp_free(p->dsp); 02673 p->dsp = NULL; 02674 } 02675 02676 law = DAHDI_LAW_DEFAULT; 02677 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETLAW, &law); 02678 if (res < 0) 02679 ast_log(LOG_WARNING, "Unable to set law on channel %d to default: %s\n", p->channel, strerror(errno)); 02680 /* Perform low level hangup if no owner left */ 02681 #ifdef HAVE_PRI 02682 if (p->pri) { 02683 #ifdef SUPPORT_USERUSER 02684 const char *useruser = pbx_builtin_getvar_helper(ast,"USERUSERINFO"); 02685 #endif 02686 02687 /* Make sure we have a call (or REALLY have a call in the case of a PRI) */ 02688 if (p->call && (!p->bearer || (p->bearer->call == p->call))) { 02689 if (!pri_grab(p, p->pri)) { 02690 if (p->alreadyhungup) { 02691 ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n"); 02692 02693 #ifdef SUPPORT_USERUSER 02694 pri_call_set_useruser(p->call, useruser); 02695 #endif 02696 02697 pri_hangup(p->pri->pri, p->call, -1); 02698 p->call = NULL; 02699 if (p->bearer) 02700 p->bearer->call = NULL; 02701 } else { 02702 const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE"); 02703 int icause = ast->hangupcause ? ast->hangupcause : -1; 02704 ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n"); 02705 02706 #ifdef SUPPORT_USERUSER 02707 pri_call_set_useruser(p->call, useruser); 02708 #endif 02709 02710 p->alreadyhungup = 1; 02711 if (p->bearer) 02712 p->bearer->alreadyhungup = 1; 02713 if (cause) { 02714 if (atoi(cause)) 02715 icause = atoi(cause); 02716 } 02717 pri_hangup(p->pri->pri, p->call, icause); 02718 } 02719 if (res < 0) 02720 ast_log(LOG_WARNING, "pri_disconnect failed\n"); 02721 pri_rel(p->pri); 02722 } else { 02723 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 02724 res = -1; 02725 } 02726 } else { 02727 if (p->bearer) 02728 ast_log(LOG_DEBUG, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call); 02729 p->call = NULL; 02730 res = 0; 02731 } 02732 } 02733 #endif 02734 if (p->sig && (p->sig != SIG_PRI)) 02735 res = dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_ONHOOK); 02736 if (res < 0) { 02737 ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name); 02738 } 02739 switch (p->sig) { 02740 case SIG_FXOGS: 02741 case SIG_FXOLS: 02742 case SIG_FXOKS: 02743 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &par); 02744 if (!res) { 02745 #if 0 02746 ast_log(LOG_DEBUG, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook); 02747 #endif 02748 /* If they're off hook, try playing congestion */ 02749 if ((par.rxisoffhook) && (!(p->radio || (p->oprmode < 0)))) 02750 tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_CONGESTION); 02751 else 02752 tone_zone_play_tone(p->subs[SUB_REAL].dfd, -1); 02753 } 02754 break; 02755 case SIG_FXSGS: 02756 case SIG_FXSLS: 02757 case SIG_FXSKS: 02758 /* Make sure we're not made available for at least two seconds assuming 02759 we were actually used for an inbound or outbound call. */ 02760 if (ast->_state != AST_STATE_RESERVED) { 02761 time(&p->guardtime); 02762 p->guardtime += 2; 02763 } 02764 break; 02765 default: 02766 tone_zone_play_tone(p->subs[SUB_REAL].dfd, -1); 02767 } 02768 if (p->cidspill) 02769 free(p->cidspill); 02770 if (p->sig) 02771 dahdi_disable_ec(p); 02772 x = 0; 02773 ast_channel_setoption(ast,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0); 02774 ast_channel_setoption(ast,AST_OPTION_TDD,&x,sizeof(char),0); 02775 p->didtdd = 0; 02776 p->cidspill = NULL; 02777 p->callwaitcas = 0; 02778 p->callwaiting = p->permcallwaiting; 02779 p->hidecallerid = p->permhidecallerid; 02780 p->dialing = 0; 02781 p->rdnis[0] = '\0'; 02782 update_conf(p); 02783 reset_conf(p); 02784 /* Restore data mode */ 02785 if (p->sig == SIG_PRI) { 02786 x = 0; 02787 ast_channel_setoption(ast,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0); 02788 } 02789 #ifdef HAVE_PRI 02790 if (p->bearer) { 02791 ast_log(LOG_DEBUG, "Freeing up bearer channel %d\n", p->bearer->channel); 02792 /* Free up the bearer channel as well, and 02793 don't use its file descriptor anymore */ 02794 update_conf(p->bearer); 02795 reset_conf(p->bearer); 02796 p->bearer->owner = NULL; 02797 p->bearer->realcall = NULL; 02798 p->bearer = NULL; 02799 p->subs[SUB_REAL].dfd = -1; 02800 p->pri = NULL; 02801 } 02802 #endif 02803 if (num_restart_pending == 0) 02804 restart_monitor(); 02805 } 02806 02807 p->callwaitingrepeat = 0; 02808 p->cidcwexpire = 0; 02809 p->oprmode = 0; 02810 ast->tech_pvt = NULL; 02811 ast_mutex_unlock(&p->lock); 02812 ast_module_unref(ast_module_info->self); 02813 if (option_verbose > 2) 02814 ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name); 02815 02816 ast_mutex_lock(&iflock); 02817 02818 if (p->restartpending) { 02819 num_restart_pending--; 02820 } 02821 02822 tmp = iflist; 02823 prev = NULL; 02824 if (p->destroy) { 02825 while (tmp) { 02826 if (tmp == p) { 02827 destroy_channel(prev, tmp, 0); 02828 break; 02829 } else { 02830 prev = tmp; 02831 tmp = tmp->next; 02832 } 02833 } 02834 } 02835 ast_mutex_unlock(&iflock); 02836 return 0; 02837 }
| static int dahdi_indicate | ( | struct ast_channel * | chan, | |
| int | condition, | |||
| const void * | data, | |||
| size_t | datalen | |||
| ) | [static] |
Definition at line 5145 of file chan_dahdi.c.
References ast_channel::_softhangup, ast_channel::_state, AST_CAUSE_CONGESTION, AST_CAUSE_SWITCH_CONGESTION, AST_CAUSE_USER_BUSY, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_FLASH, AST_CONTROL_HOLD, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RINGING, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, ast_log(), ast_moh_start(), ast_moh_stop(), ast_mutex_lock(), ast_mutex_unlock(), ast_setstate(), AST_SOFTHANGUP_DEV, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, dahdi_get_index(), dahdi_set_hook(), dahdi_subchannel::dfd, dahdi_pvt::digital, dahdi_pvt::dop, errno, ast_channel::hangupcause, ISTRUNK, dahdi_pvt::lock, LOG_DEBUG, LOG_WARNING, dahdi_pvt::mohinterpret, ast_channel::name, option_debug, dahdi_pvt::outgoing, dahdi_pvt::priindication_oob, dahdi_pvt::radio, dahdi_pvt::sig, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_PRI, dahdi_pvt::span, SUB_REAL, dahdi_pvt::subs, and ast_channel::tech_pvt.
Referenced by dahdi_fixup().
05146 { 05147 struct dahdi_pvt *p = chan->tech_pvt; 05148 int res=-1; 05149 int index; 05150 int func = DAHDI_FLASH; 05151 ast_mutex_lock(&p->lock); 05152 index = dahdi_get_index(chan, p, 0); 05153 if (option_debug) 05154 ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name); 05155 if (index == SUB_REAL) { 05156 switch (condition) { 05157 case AST_CONTROL_BUSY: 05158 #ifdef HAVE_PRI 05159 if (p->priindication_oob && p->sig == SIG_PRI) { 05160 chan->hangupcause = AST_CAUSE_USER_BUSY; 05161 chan->_softhangup |= AST_SOFTHANGUP_DEV; 05162 res = 0; 05163 } else if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing) { 05164 if (p->pri->pri) { 05165 if (!pri_grab(p, p->pri)) { 05166 pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); 05167 pri_rel(p->pri); 05168 } 05169 else 05170 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 05171 } 05172 p->progress = 1; 05173 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_BUSY); 05174 } else 05175 #endif 05176 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_BUSY); 05177 break; 05178 case AST_CONTROL_RINGING: 05179 #ifdef HAVE_PRI 05180 if ((!p->alerting) && p->sig==SIG_PRI && p->pri && !p->outgoing && (chan->_state != AST_STATE_UP)) { 05181 if (p->pri->pri) { 05182 if (!pri_grab(p, p->pri)) { 05183 pri_acknowledge(p->pri->pri,p->call, PVT_TO_CHANNEL(p), !p->digital); 05184 pri_rel(p->pri); 05185 } 05186 else 05187 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 05188 } 05189 p->alerting = 1; 05190 } 05191 #endif 05192 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_RINGTONE); 05193 if (chan->_state != AST_STATE_UP) { 05194 if ((chan->_state != AST_STATE_RING) || 05195 ((p->sig != SIG_FXSKS) && 05196 (p->sig != SIG_FXSLS) && 05197 (p->sig != SIG_FXSGS))) 05198 ast_setstate(chan, AST_STATE_RINGING); 05199 } 05200 break; 05201 case AST_CONTROL_PROCEEDING: 05202 ast_log(LOG_DEBUG,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name); 05203 #ifdef HAVE_PRI 05204 if (!p->proceeding && p->sig==SIG_PRI && p->pri && !p->outgoing) { 05205 if (p->pri->pri) { 05206 if (!pri_grab(p, p->pri)) { 05207 pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p), !p->digital); 05208 pri_rel(p->pri); 05209 } 05210 else 05211 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 05212 } 05213 p->proceeding = 1; 05214 } 05215 #endif 05216 /* don't continue in ast_indicate */ 05217 res = 0; 05218 break; 05219 case AST_CONTROL_PROGRESS: 05220 ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name); 05221 #ifdef HAVE_PRI 05222 p->digital = 0; /* Digital-only calls isn't allows any inband progress messages */ 05223 if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing) { 05224 if (p->pri->pri) { 05225 if (!pri_grab(p, p->pri)) { 05226 pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); 05227 pri_rel(p->pri); 05228 } 05229 else 05230 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 05231 } 05232 p->progress = 1; 05233 } 05234 #endif 05235 /* don't continue in ast_indicate */ 05236 res = 0; 05237 break; 05238 case AST_CONTROL_CONGESTION: 05239 chan->hangupcause = AST_CAUSE_CONGESTION; 05240 #ifdef HAVE_PRI 05241 if (p->priindication_oob && p->sig == SIG_PRI) { 05242 chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION; 05243 chan->_softhangup |= AST_SOFTHANGUP_DEV; 05244 res = 0; 05245 } else if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing) { 05246 if (p->pri) { 05247 if (!pri_grab(p, p->pri)) { 05248 pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); 05249 pri_rel(p->pri); 05250 } else 05251 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 05252 } 05253 p->progress = 1; 05254 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 05255 } else 05256 #endif 05257 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 05258 break; 05259 case AST_CONTROL_HOLD: 05260 #ifdef HAVE_PRI 05261 if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) { 05262 if (!pri_grab(p, p->pri)) { 05263 res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_HOLD); 05264 pri_rel(p->pri); 05265 } else 05266 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 05267 } else 05268 #endif 05269 ast_moh_start(chan, data, p->mohinterpret); 05270 break; 05271 case AST_CONTROL_UNHOLD: 05272 #ifdef HAVE_PRI 05273 if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) { 05274 if (!pri_grab(p, p->pri)) { 05275 res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_RETRIEVAL); 05276 pri_rel(p->pri); 05277 } else 05278 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 05279 } else 05280 #endif 05281 ast_moh_stop(chan); 05282 break; 05283 case AST_CONTROL_RADIO_KEY: 05284 if (p->radio) 05285 res = dahdi_set_hook(p->subs[index].dfd, DAHDI_OFFHOOK); 05286 res = 0; 05287 break; 05288 case AST_CONTROL_RADIO_UNKEY: 05289 if (p->radio) 05290 res = dahdi_set_hook(p->subs[index].dfd, DAHDI_RINGOFF); 05291 res = 0; 05292 break; 05293 case AST_CONTROL_FLASH: 05294 /* flash hookswitch */ 05295 if (ISTRUNK(p) && (p->sig != SIG_PRI)) { 05296 /* Clear out the dial buffer */ 05297 p->dop.dialstr[0] = '\0'; 05298 if ((ioctl(p->subs[SUB_REAL].dfd,DAHDI_HOOK,&func) == -1) && (errno != EINPROGRESS)) { 05299 ast_log(LOG_WARNING, "Unable to flash external trunk on channel %s: %s\n", 05300 chan->name, strerror(errno)); 05301 } else 05302 res = 0; 05303 } else 05304 res = 0; 05305 break; 05306 case AST_CONTROL_SRCUPDATE: 05307 res = 0; 05308 break; 05309 case -1: 05310 res = tone_zone_play_tone(p->subs[index].dfd, -1); 05311 break; 05312 } 05313 } else 05314 res = 0; 05315 ast_mutex_unlock(&p->lock); 05316 return res; 05317 }
Definition at line 3184 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, LOG_DEBUG, LOG_WARNING, dahdi_pvt::master, MAX_SLAVES, and dahdi_pvt::slaves.
Referenced by dahdi_bridge().
03184 { 03185 int x; 03186 if (!slave || !master) { 03187 ast_log(LOG_WARNING, "Tried to link to/from NULL??\n"); 03188 return; 03189 } 03190 for (x = 0; x < MAX_SLAVES; x++) { 03191 if (!master->slaves[x]) { 03192 master->slaves[x] = slave; 03193 break; 03194 } 03195 } 03196 if (x >= MAX_SLAVES) { 03197 ast_log(LOG_WARNING, "Replacing slave %d with new slave, %d\n", master->slaves[MAX_SLAVES - 1]->channel, slave->channel); 03198 master->slaves[MAX_SLAVES - 1] = slave; 03199 } 03200 if (slave->master) 03201 ast_log(LOG_WARNING, "Replacing master %d with new master, %d\n", slave->master->channel, master->channel); 03202 slave->master = master; 03203 03204 ast_log(LOG_DEBUG, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x); 03205 }
| static struct ast_channel * dahdi_new | ( | struct dahdi_pvt * | i, | |
| int | state, | |||
| int | startpbx, | |||
| int | index, | |||
| int | law, | |||
| int | transfercapability | |||
| ) | [static, read] |
> b2 can be freed now, it's been copied into the channel structure
Definition at line 5319 of file chan_dahdi.c.
References accountcode, dahdi_pvt::accountcode, dahdi_pvt::adsi, ast_channel::adsicpe, ast_channel::amaflags, dahdi_pvt::amaflags, AST_ADSI_UNAVAILABLE, ast_channel_alloc(), ast_copy_string(), ast_dsp_digitmode(), ast_dsp_new(), ast_dsp_set_busy_count(), ast_dsp_set_busy_pattern(), ast_dsp_set_call_progress_zone(), ast_dsp_set_features(), AST_FORMAT_ALAW, AST_FORMAT_SLINEAR, AST_FORMAT_ULAW, ast_hangup(), ast_jb_configure(), ast_log(), ast_module_ref(), ast_pbx_start(), ast_random(), ast_safe_string_alloc(), AST_STATE_RING, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_transfercapability2str(), dahdi_pvt::busy_quietlength, dahdi_pvt::busy_tonelength, dahdi_pvt::busycount, dahdi_pvt::busydetect, dahdi_pvt::call_forward, dahdi_pvt::callgroup, ast_channel::callgroup, dahdi_pvt::callingpres, dahdi_pvt::callprogress, CANBUSYDETECT, CANPROGRESSDETECT, CHAN_PSEUDO, dahdi_pvt::channel, ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_dnid, dahdi_pvt::cid_name, dahdi_pvt::cid_num, ast_callerid::cid_pres, ast_callerid::cid_rdnis, dahdi_pvt::cid_ton, ast_callerid::cid_ton, ast_channel::context, dahdi_pvt::context, dahdi_chan_name, dahdi_chan_name_len, dahdi_confmute(), dahdi_setlinear(), dahdi_subchannel::dfd, dahdi_pvt::digital, dahdi_pvt::dnid, dahdi_pvt::dsp, DSP_DIGITMODE_DTMF, DSP_FEATURE_BUSY_DETECT, DSP_FEATURE_CALL_PROGRESS, DSP_FEATURE_DTMF_DETECT, DSP_FEATURE_FAX_DETECT, dahdi_pvt::dsp_features, DSP_PROGRESS_TALK, dahdi_pvt::dtmfrelax, errno, ast_channel::exten, dahdi_pvt::exten, dahdi_pvt::fake_event, ast_channel::fds, free, global_jbconf, dahdi_pvt::hardwaredtmf, language, dahdi_pvt::language, dahdi_subchannel::linear, LOG_DEBUG, LOG_WARNING, ast_channel::name, ast_channel::nativeformats, NEED_MFDETECT, dahdi_pvt::outgoing, dahdi_pvt::owner, dahdi_subchannel::owner, pbx_builtin_setvar_helper(), dahdi_pvt::pickupgroup, ast_channel::pickupgroup, PRI_TRANS_CAP_DIGITAL, ast_channel::rawreadformat, ast_channel::rawwriteformat, dahdi_pvt::rdnis, ast_channel::readformat, ast_channel::rings, dahdi_pvt::sig, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSKS, SIG_PRI, SUB_REAL, dahdi_pvt::subs, ast_channel::tech, ast_channel::tech_pvt, ast_channel::transfercapability, and ast_channel::writeformat.
Referenced by dahdi_handle_event(), dahdi_request(), and handle_init_event().
05320 { 05321 struct ast_channel *tmp; 05322 int deflaw; 05323 int res; 05324 int x,y; 05325 int features; 05326 char *b2 = NULL; 05327 struct dahdi_params ps; 05328 char chanprefix[*dahdi_chan_name_len + 4]; 05329 05330 if (i->subs[index].owner) { 05331 ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[index]); 05332 return NULL; 05333 } 05334 y = 1; 05335 do { 05336 if (b2) 05337 free(b2); 05338 #ifdef HAVE_PRI 05339 if (i->bearer || (i->pri && (i->sig == SIG_FXSKS))) 05340 b2 = ast_safe_string_alloc("%d:%d-%d", i->pri->trunkgroup, i->channel, y); 05341 else 05342 #endif 05343 if (i->channel == CHAN_PSEUDO) 05344 b2 = ast_safe_string_alloc("pseudo-%ld", ast_random()); 05345 else 05346 b2 = ast_safe_string_alloc("%d-%d", i->channel, y); 05347 for (x = 0; x < 3; x++) { 05348 if ((index != x) && i->subs[x].owner && !strcasecmp(b2, i->subs[x].owner->name + (!strncmp(i->subs[x].owner->name, "Zap", 3) ? 4 : 6))) 05349 break; 05350 } 05351 y++; 05352 } while (x < 3); 05353 strcpy(chanprefix, dahdi_chan_name); 05354 strcat(chanprefix, "/%s"); 05355 tmp = ast_channel_alloc(0, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, chanprefix, b2); 05356 if (b2) /*!> b2 can be freed now, it's been copied into the channel structure */ 05357 free(b2); 05358 if (!tmp) 05359 return NULL; 05360 tmp->tech = chan_tech; 05361 ps.channo = i->channel; 05362 res = ioctl(i->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps); 05363 if (res) { 05364 ast_log(LOG_WARNING, "Unable to get parameters, assuming MULAW: %s\n", strerror(errno)); 05365 ps.curlaw = DAHDI_LAW_MULAW; 05366 } 05367 if (ps.curlaw == DAHDI_LAW_ALAW) 05368 deflaw = AST_FORMAT_ALAW; 05369 else 05370 deflaw = AST_FORMAT_ULAW; 05371 if (law) { 05372 if (law == DAHDI_LAW_ALAW) 05373 deflaw = AST_FORMAT_ALAW; 05374 else 05375 deflaw = AST_FORMAT_ULAW; 05376 } 05377 tmp->fds[0] = i->subs[index].dfd; 05378 tmp->nativeformats = AST_FORMAT_SLINEAR | deflaw; 05379 /* Start out assuming ulaw since it's smaller :) */ 05380 tmp->rawreadformat = deflaw; 05381 tmp->readformat = deflaw; 05382 tmp->rawwriteformat = deflaw; 05383 tmp->writeformat = deflaw; 05384 i->subs[index].linear = 0; 05385 dahdi_setlinear(i->subs[index].dfd, i->subs[index].linear); 05386 features = 0; 05387 if (index == SUB_REAL) { 05388 if (i->busydetect && CANBUSYDETECT(i)) 05389 features |= DSP_FEATURE_BUSY_DETECT; 05390 if ((i->callprogress & 1) && CANPROGRESSDETECT(i)) 05391 features |= DSP_FEATURE_CALL_PROGRESS; 05392 if ((!i->outgoing && (i->callprogress & 4)) || 05393 (i->outgoing && (i->callprogress & 2))) { 05394 features |= DSP_FEATURE_FAX_DETECT; 05395 } 05396 #ifdef DAHDI_TONEDETECT 05397 x = DAHDI_TONEDETECT_ON | DAHDI_TONEDETECT_MUTE; 05398 if (ioctl(i->subs[index].dfd, DAHDI_TONEDETECT, &x)) { 05399 #endif 05400 i->hardwaredtmf = 0; 05401 features |= DSP_FEATURE_DTMF_DETECT; 05402 #ifdef DAHDI_TONEDETECT 05403 } else if (NEED_MFDETECT(i)) { 05404 i->hardwaredtmf = 1; 05405 features |= DSP_FEATURE_DTMF_DETECT; 05406 } 05407 #endif 05408 } 05409 if (features) { 05410 if (i->dsp) { 05411 ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name); 05412 } else { 05413 if (i->channel != CHAN_PSEUDO) 05414 i->dsp = ast_dsp_new(); 05415 else 05416 i->dsp = NULL; 05417 if (i->dsp) { 05418 i->dsp_features = features; 05419 #ifdef HAVE_PRI 05420 /* We cannot do progress detection until receives PROGRESS message */ 05421 if (i->outgoing && (i->sig == SIG_PRI)) { 05422 /* Remember requested DSP features, don't treat 05423 talking as ANSWER */ 05424 i->dsp_features = features & ~DSP_PROGRESS_TALK; 05425 features = 0; 05426 } 05427 #endif 05428 ast_dsp_set_features(i->dsp, features); 05429 ast_dsp_digitmode(i->dsp, DSP_DIGITMODE_DTMF | i->dtmfrelax); 05430 if (!ast_strlen_zero(progzone)) 05431 ast_dsp_set_call_progress_zone(i->dsp, progzone); 05432 if (i->busydetect && CANBUSYDETECT(i)) { 05433 ast_dsp_set_busy_count(i->dsp, i->busycount); 05434 ast_dsp_set_busy_pattern(i->dsp, i->busy_tonelength, i->busy_quietlength); 05435 } 05436 } 05437 } 05438 } 05439 05440 if (state == AST_STATE_RING) 05441 tmp->rings = 1; 05442 tmp->tech_pvt = i; 05443 if ((i->sig == SIG_FXOKS) || (i->sig == SIG_FXOGS) || (i->sig == SIG_FXOLS)) { 05444 /* Only FXO signalled stuff can be picked up */ 05445 tmp->callgroup = i->callgroup; 05446 tmp->pickupgroup = i->pickupgroup; 05447 } 05448 if (!ast_strlen_zero(i->language)) 05449 ast_string_field_set(tmp, language, i->language); 05450 if (!i->owner) 05451 i->owner = tmp; 05452 if (!ast_strlen_zero(i->accountcode)) 05453 ast_string_field_set(tmp, accountcode, i->accountcode); 05454 if (i->amaflags) 05455 tmp->amaflags = i->amaflags; 05456 i->subs[index].owner = tmp; 05457 ast_copy_string(tmp->context, i->context, sizeof(tmp->context)); 05458 ast_string_field_set(tmp, call_forward, i->call_forward); 05459 /* If we've been told "no ADSI" then enforce it */ 05460 if (!i->adsi) 05461 tmp->adsicpe = AST_ADSI_UNAVAILABLE; 05462 if (!ast_strlen_zero(i->exten)) 05463 ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten)); 05464 if (!ast_strlen_zero(i->rdnis)) 05465 tmp->cid.cid_rdnis = ast_strdup(i->rdnis); 05466 if (!ast_strlen_zero(i->dnid)) 05467 tmp->cid.cid_dnid = ast_strdup(i->dnid); 05468 05469 /* Don't use ast_set_callerid() here because it will 05470 * generate a needless NewCallerID event */ 05471 #ifdef PRI_ANI 05472 if (!ast_strlen_zero(i->cid_ani)) 05473 tmp->cid.cid_ani = ast_strdup(i->cid_ani); 05474 else 05475 tmp->cid.cid_ani = ast_strdup(i->cid_num); 05476 #else 05477 tmp->cid.cid_ani = ast_strdup(i->cid_num); 05478 #endif 05479 tmp->cid.cid_pres = i->callingpres; 05480 tmp->cid.cid_ton = i->cid_ton; 05481 #ifdef HAVE_PRI 05482 tmp->transfercapability = transfercapability; 05483 pbx_builtin_setvar_helper(tmp, "TRANSFERCAPABILITY", ast_transfercapability2str(transfercapability)); 05484 if (transfercapability & PRI_TRANS_CAP_DIGITAL) 05485 i->digital = 1; 05486 /* Assume calls are not idle calls unless we're told differently */ 05487 i->isidlecall = 0; 05488 i->alreadyhungup = 0; 05489 #endif 05490 /* clear the fake event in case we posted one before we had ast_channel */ 05491 i->fake_event = 0; 05492 /* Assure there is no confmute on this channel */ 05493 dahdi_confmute(i, 0); 05494 /* Configure the new channel jb */ 05495 ast_jb_configure(tmp, &global_jbconf); 05496 if (startpbx) { 05497 if (ast_pbx_start(tmp)) { 05498 ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name); 05499 ast_hangup(tmp); 05500 i->owner = NULL; 05501 return NULL; 05502 } 05503 } 05504 05505 ast_module_ref(ast_module_info->self); 05506 05507 return tmp; 05508 }
| static int dahdi_open | ( | char * | fn | ) | [static] |
Definition at line 898 of file chan_dahdi.c.
References ast_log(), errno, LOG_WARNING, and READ_SIZE.
Referenced by alloc_sub(), chandup(), and mkintf().
00899 { 00900 int fd; 00901 int isnum; 00902 int chan = 0; 00903 int bs; 00904 int x; 00905 isnum = 1; 00906 for (x = 0; x < strlen(fn); x++) { 00907 if (!isdigit(fn[x])) { 00908 isnum = 0; 00909 break; 00910 } 00911 } 00912 if (isnum) { 00913 chan = atoi(fn); 00914 if (chan < 1) { 00915 ast_log(LOG_WARNING, "Invalid channel number '%s'\n", fn); 00916 return -1; 00917 } 00918 #ifdef HAVE_ZAPTEL 00919 fn = "/dev/zap/channel"; 00920 #else 00921 fn = "/dev/dahdi/channel"; 00922 #endif 00923 } 00924 fd = open(fn, O_RDWR | O_NONBLOCK); 00925 if (fd < 0) { 00926 ast_log(LOG_WARNING, "Unable to open '%s': %s\n", fn, strerror(errno)); 00927 return -1; 00928 } 00929 if (chan) { 00930 if (ioctl(fd, DAHDI_SPECIFY, &chan)) { 00931 x = errno; 00932 close(fd); 00933 errno = x; 00934 ast_log(LOG_WARNING, "Unable to specify channel %d: %s\n", chan, strerror(errno)); 00935 return -1; 00936 } 00937 } 00938 bs = READ_SIZE; 00939 if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &bs) == -1) { 00940 ast_log(LOG_WARNING, "Unable to set blocksize '%d': %s\n", bs, strerror(errno)); 00941 x = errno; 00942 close(fd); 00943 errno = x; 00944 return -1; 00945 } 00946 return fd; 00947 }
Definition at line 842 of file chan_dahdi.c.
References ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), ast_queue_frame(), DEADLOCK_AVOIDANCE, dahdi_pvt::lock, ast_channel::lock, and dahdi_pvt::owner.
Referenced by __action_dialoffhook().
00844 { 00845 /* We must unlock the PRI to avoid the possibility of a deadlock */ 00846 #ifdef HAVE_PRI 00847 if (pri) 00848 ast_mutex_unlock(&pri->lock); 00849 #endif 00850 for (;;) { 00851 if (p->owner) { 00852 if (ast_mutex_trylock(&p->owner->lock)) { 00853 DEADLOCK_AVOIDANCE(&p->lock); 00854 } else { 00855 ast_queue_frame(p->owner, f); 00856 ast_mutex_unlock(&p->owner->lock); 00857 break; 00858 } 00859 } else 00860 break; 00861 } 00862 #ifdef HAVE_PRI 00863 if (pri) 00864 ast_mutex_lock(&pri->lock); 00865 #endif 00866 }
| static struct ast_frame * dahdi_read | ( | struct ast_channel * | ast | ) | [static, read] |
Definition at line 4749 of file chan_dahdi.c.
References __dahdi_exception(), ast_channel::_state, ast_clear_flag, AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_FLASH, AST_CONTROL_HOLD, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, ast_dsp_process(), AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, AST_FORMAT_ALAW, AST_FORMAT_SLINEAR, AST_FORMAT_ULAW, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_getformatname(), ast_log(), ast_mutex_trylock(), ast_mutex_unlock(), ast_set_callerid(), ast_set_flag, ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, ast_tv(), ast_verbose(), dahdi_subchannel::buffer, dahdi_pvt::busydetect, dahdi_pvt::callprogress, dahdi_pvt::callwaitcas, dahdi_pvt::callwaitingrepeat, dahdi_pvt::callwaitrings, dahdi_pvt::channel, CHECK_BLOCKING, dahdi_pvt::cidcwexpire, dahdi_pvt::cidrings, dahdi_pvt::cidspill, dahdi_callwait(), dahdi_get_index(), dahdi_handle_dtmfup(), dahdi_setlinear(), ast_frame::data, ast_frame::datalen, DEADLOCK_AVOIDANCE, ast_frame::delivery, dahdi_subchannel::dfd, dahdi_pvt::dialing, dahdi_pvt::dsp, errno, dahdi_subchannel::f, dahdi_pvt::fake_event, dahdi_pvt::firstradio, ast_frame::frametype, dahdi_pvt::ignoredtmf, dahdi_pvt::inalarm, dahdi_subchannel::inthreeway, dahdi_pvt::lastcid_name, dahdi_pvt::lastcid_num, dahdi_subchannel::linear, ast_channel::lock, dahdi_pvt::lock, LOG_DEBUG, LOG_WARNING, ast_frame::mallocd, ast_channel::name, dahdi_subchannel::needanswer, dahdi_subchannel::needbusy, dahdi_subchannel::needcallerid, dahdi_subchannel::needcongestion, dahdi_subchannel::needflash, dahdi_subchannel::needhold, dahdi_subchannel::needringing, dahdi_subchannel::needunhold, ast_frame::offset, dahdi_pvt::oprmode, option_verbose, dahdi_pvt::outgoing, dahdi_pvt::overlapdial, dahdi_pvt::owner, dahdi_pvt::pulsedial, dahdi_pvt::radio, ast_channel::rawreadformat, READ_SIZE, restore_conference(), ast_channel::rings, dahdi_pvt::ringt, S_OR, ast_frame::samples, send_callerid(), dahdi_pvt::sig, SIG_PRI, ast_frame::src, SUB_CALLWAIT, SUB_REAL, ast_frame::subclass, dahdi_pvt::subs, dahdi_pvt::tdd, tdd_feed(), ast_channel::tech_pvt, and VERBOSE_PREFIX_3.
04750 { 04751 struct dahdi_pvt *p = ast->tech_pvt; 04752 int res; 04753 int index; 04754 void *readbuf; 04755 struct ast_frame *f; 04756 04757 while (ast_mutex_trylock(&p->lock)) { 04758 DEADLOCK_AVOIDANCE(&ast->lock); 04759 } 04760 04761 index = dahdi_get_index(ast, p, 0); 04762 04763 /* Hang up if we don't really exist */ 04764 if (index < 0) { 04765 ast_log(LOG_WARNING, "We dont exist?\n"); 04766 ast_mutex_unlock(&p->lock); 04767 return NULL; 04768 } 04769 04770 if ((p->radio || (p->oprmode < 0)) && p->inalarm) return NULL; 04771 04772 p->subs[index].f.frametype = AST_FRAME_NULL; 04773 p->subs[index].f.datalen = 0; 04774 p->subs[index].f.samples = 0; 04775 p->subs[index].f.mallocd = 0; 04776 p->subs[index].f.offset = 0; 04777 p->subs[index].f.subclass = 0; 04778 p->subs[index].f.delivery = ast_tv(0,0); 04779 p->subs[index].f.src = "dahdi_read"; 04780 p->subs[index].f.data = NULL; 04781 04782 /* make sure it sends initial key state as first frame */ 04783 if ((p->radio || (p->oprmode < 0)) && (!p->firstradio)) 04784 { 04785 struct dahdi_params ps; 04786 04787 ps.channo = p->channel; 04788 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps) < 0) { 04789 ast_mutex_unlock(&p->lock); 04790 return NULL; 04791 } 04792 p->firstradio = 1; 04793 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04794 if (ps.rxisoffhook) 04795 { 04796 p->subs[index].f.subclass = AST_CONTROL_RADIO_KEY; 04797 } 04798 else 04799 { 04800 p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY; 04801 } 04802 ast_mutex_unlock(&p->lock); 04803 return &p->subs[index].f; 04804 } 04805 if (p->ringt == 1) { 04806 ast_mutex_unlock(&p->lock); 04807 return NULL; 04808 } 04809 else if (p->ringt > 0) 04810 p->ringt--; 04811 04812 if (p->subs[index].needringing) { 04813 /* Send ringing frame if requested */ 04814 p->subs[index].needringing = 0; 04815 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04816 p->subs[index].f.subclass = AST_CONTROL_RINGING; 04817 ast_setstate(ast, AST_STATE_RINGING); 04818 ast_mutex_unlock(&p->lock); 04819 return &p->subs[index].f; 04820 } 04821 04822 if (p->subs[index].needbusy) { 04823 /* Send busy frame if requested */ 04824 p->subs[index].needbusy = 0; 04825 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04826 p->subs[index].f.subclass = AST_CONTROL_BUSY; 04827 ast_mutex_unlock(&p->lock); 04828 return &p->subs[index].f; 04829 } 04830 04831 if (p->subs[index].needcongestion) { 04832 /* Send congestion frame if requested */ 04833 p->subs[index].needcongestion = 0; 04834 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04835 p->subs[index].f.subclass = AST_CONTROL_CONGESTION; 04836 ast_mutex_unlock(&p->lock); 04837 return &p->subs[index].f; 04838 } 04839 04840 if (p->subs[index].needcallerid) { 04841 ast_set_callerid(ast, S_OR(p->lastcid_num, NULL), 04842 S_OR(p->lastcid_name, NULL), 04843 S_OR(p->lastcid_num, NULL) 04844 ); 04845 p->subs[index].needcallerid = 0; 04846 } 04847 04848 if (p->subs[index].needanswer) { 04849 /* Send answer frame if requested */ 04850 p->subs[index].needanswer = 0; 04851 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04852 p->subs[index].f.subclass = AST_CONTROL_ANSWER; 04853 ast_mutex_unlock(&p->lock); 04854 return &p->subs[index].f; 04855 } 04856 04857 if (p->subs[index].needflash) { 04858 /* Send answer frame if requested */ 04859 p->subs[index].needflash = 0; 04860 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04861 p->subs[index].f.subclass = AST_CONTROL_FLASH; 04862 ast_mutex_unlock(&p->lock); 04863 return &p->subs[index].f; 04864 } 04865 04866 if (p->subs[index].needhold) { 04867 /* Send answer frame if requested */ 04868 p->subs[index].needhold = 0; 04869 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04870 p->subs[index].f.subclass = AST_CONTROL_HOLD; 04871 ast_mutex_unlock(&p->lock); 04872 ast_log(LOG_DEBUG, "Sending hold on '%s'\n", ast->name); 04873 return &p->subs[index].f; 04874 } 04875 04876 if (p->subs[index].needunhold) { 04877 /* Send answer frame if requested */ 04878 p->subs[index].needunhold = 0; 04879 p->subs[index].f.frametype = AST_FRAME_CONTROL; 04880 p->subs[index].f.subclass = AST_CONTROL_UNHOLD; 04881 ast_mutex_unlock(&p->lock); 04882 ast_log(LOG_DEBUG, "Sending unhold on '%s'\n", ast->name); 04883 return &p->subs[index].f; 04884 } 04885 04886 if (ast->rawreadformat == AST_FORMAT_SLINEAR) { 04887 if (!p->subs[index].linear) { 04888 p->subs[index].linear = 1; 04889 res = dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear); 04890 if (res) 04891 ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to linear mode.\n", p->channel, index); 04892 } 04893 } else if ((ast->rawreadformat == AST_FORMAT_ULAW) || 04894 (ast->rawreadformat == AST_FORMAT_ALAW)) { 04895 if (p->subs[index].linear) { 04896 p->subs[index].linear = 0; 04897 res = dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear); 04898 if (res) 04899 ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to companded mode.\n", p->channel, index); 04900 } 04901 } else { 04902 ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(ast->rawreadformat)); 04903 ast_mutex_unlock(&p->lock); 04904 return NULL; 04905 } 04906 readbuf = ((unsigned char *)p->subs[index].buffer) + AST_FRIENDLY_OFFSET; 04907 CHECK_BLOCKING(ast); 04908 res = read(p->subs[index].dfd, readbuf, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE); 04909 ast_clear_flag(ast, AST_FLAG_BLOCKING); 04910 /* Check for hangup */ 04911 if (res < 0) { 04912 f = NULL; 04913 if (res == -1) { 04914 if (errno == EAGAIN) { 04915 /* Return "NULL" frame if there is nobody there */ 04916 ast_mutex_unlock(&p->lock); 04917 return &p->subs[index].f; 04918 } else if (errno == ELAST) { 04919 f = __dahdi_exception(ast); 04920 } else 04921 ast_log(LOG_WARNING, "dahdi_rec: %s\n", strerror(errno)); 04922 } 04923 ast_mutex_unlock(&p->lock); 04924 return f; 04925 } 04926 if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) { 04927 ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE); 04928 f = __dahdi_exception(ast); 04929 ast_mutex_unlock(&p->lock); 04930 return f; 04931 } 04932 if (p->tdd) { /* if in TDD mode, see if we receive that */ 04933 int c; 04934 04935 c = tdd_feed(p->tdd,readbuf,READ_SIZE); 04936 if (c < 0) { 04937 ast_log(LOG_DEBUG,"tdd_feed failed\n"); 04938 ast_mutex_unlock(&p->lock); 04939 return NULL; 04940 } 04941 if (c) { /* if a char to return */ 04942 p->subs[index].f.subclass = 0; 04943 p->subs[index].f.frametype = AST_FRAME_TEXT; 04944 p->subs[index].f.mallocd = 0; 04945 p->subs[index].f.offset = AST_FRIENDLY_OFFSET; 04946 p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET; 04947 p->subs[index].f.datalen = 1; 04948 *((char *) p->subs[index].f.data) = c; 04949 ast_mutex_unlock(&p->lock); 04950 return &p->subs[index].f; 04951 } 04952 } 04953 /* Ensure the CW timer decrements only on a single subchannel */ 04954 if (p->callwaitingrepeat && dahdi_get_index(ast, p, 1) == SUB_REAL) { 04955 p->callwaitingrepeat--; 04956 } 04957 if (p->cidcwexpire) 04958 p->cidcwexpire--; 04959 /* Repeat callwaiting */ 04960 if (p->callwaitingrepeat == 1) { 04961 p->callwaitrings++; 04962 dahdi_callwait(ast); 04963 } 04964 /* Expire CID/CW */ 04965 if (p->cidcwexpire == 1) { 04966 if (option_verbose > 2) 04967 ast_verbose(VERBOSE_PREFIX_3 "CPE does not support Call Waiting Caller*ID.\n"); 04968 restore_conference(p); 04969 } 04970 if (p->subs[index].linear) { 04971 p->subs[index].f.datalen = READ_SIZE * 2; 04972 } else 04973 p->subs[index].f.datalen = READ_SIZE; 04974 04975 /* Handle CallerID Transmission */ 04976 if ((p->owner == ast) && p->cidspill &&((ast->_state == AST_STATE_UP) || (ast->rings == p->cidrings))) { 04977 send_callerid(p); 04978 } 04979 04980 p->subs[index].f.frametype = AST_FRAME_VOICE; 04981 p->subs[index].f.subclass = ast->rawreadformat; 04982 p->subs[index].f.samples = READ_SIZE; 04983 p->subs[index].f.mallocd = 0; 04984 p->subs[index].f.offset = AST_FRIENDLY_OFFSET; 04985 p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[index].buffer[0]); 04986 #if 0 04987 ast_log(LOG_DEBUG, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name); 04988 #endif 04989 if (p->dialing || /* Transmitting something */ 04990 (index && (ast->_state != AST_STATE_UP)) || /* Three-way or callwait that isn't up */ 04991 ((index == SUB_CALLWAIT) && !p->subs[SUB_CALLWAIT].inthreeway) /* Inactive and non-confed call-wait */ 04992 ) { 04993 /* Whoops, we're still dialing, or in a state where we shouldn't transmit.... 04994 don't send anything */ 04995 p->subs[index].f.frametype = AST_FRAME_NULL; 04996 p->subs[index].f.subclass = 0; 04997 p->subs[index].f.samples = 0; 04998 p->subs[index].f.mallocd = 0; 04999 p->subs[index].f.offset = 0; 05000 p->subs[index].f.data = NULL; 05001 p->subs[index].f.datalen= 0; 05002 } 05003 if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect || p->callprogress) && !index) { 05004 /* Perform busy detection. etc on the dahdi line */ 05005 f = ast_dsp_process(ast, p->dsp, &p->subs[index].f); 05006 if (f) { 05007 if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_BUSY)) { 05008 if ((ast->_state == AST_STATE_UP) && !p->outgoing) { 05009 /* Treat this as a "hangup" instead of a "busy" on the assumption that 05010 a busy */ 05011 f = NULL; 05012 } 05013 } else if (f->frametype == AST_FRAME_DTMF) { 05014 #ifdef HAVE_PRI 05015 if (!p->proceeding && p->sig==SIG_PRI && p->pri && p->pri->overlapdial) { 05016 /* Don't accept in-band DTMF when in overlap dial mode */ 05017 f->frametype = AST_FRAME_NULL; 05018 f->subclass = 0; 05019 } 05020 #endif 05021 /* DSP clears us of being pulse */ 05022 p->pulsedial = 0; 05023 } 05024 } 05025 } else 05026 f = &p->subs[index].f; 05027 05028 if (f && (f->frametype == AST_FRAME_DTMF)) 05029 dahdi_handle_dtmfup(ast, index, &f); 05030 05031 /* If we have a fake_event, trigger exception to handle it */ 05032 if (p->fake_event) 05033 ast_set_flag(ast, AST_FLAG_EXCEPTION); 05034 05035 ast_mutex_unlock(&p->lock); 05036 return f; 05037 }
| static struct ast_channel * dahdi_request | ( | const char * | type, | |
| int | format, | |||
| void * | data, | |||
| int * | cause | |||
| ) | [static, read] |
Definition at line 7949 of file chan_dahdi.c.
References alloc_sub(), AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CDR_CALLWAIT, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), AST_STATE_RESERVED, ast_strdupa, AST_TRANS_CAP_DIGITAL, ast_verbose(), available(), busy, ast_channel::cdrflags, CHAN_PSEUDO, chandup(), dahdi_pvt::channel, dahdi_pvt::confirmanswer, dahdi_new(), dahdi_subchannel::dfd, dahdi_pvt::digital, dahdi_pvt::distinctivering, iflist, iflock, dahdi_pvt::inalarm, lock, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, ast_channel::name, dahdi_pvt::next, option_debug, dahdi_pvt::outgoing, dahdi_pvt::owner, dahdi_pvt::prev, restart_monitor(), s, dahdi_pvt::sig, SIG_FXSKS, SUB_CALLWAIT, SUB_REAL, dahdi_pvt::subs, and ast_channel::transfercapability.
07950 { 07951 ast_group_t groupmatch = 0; 07952 int channelmatch = -1; 07953 int roundrobin = 0; 07954 int callwait = 0; 07955 int busy = 0; 07956 struct dahdi_pvt *p; 07957 struct ast_channel *tmp = NULL; 07958 char *dest=NULL; 07959 int x; 07960 char *s; 07961 char opt=0; 07962 int res=0, y=0; 07963 int backwards = 0; 07964 #ifdef HAVE_PRI 07965 int crv; 07966 int bearer = -1; 07967 int trunkgroup; 07968 struct dahdi_pri *pri=NULL; 07969 #endif 07970 struct dahdi_pvt *exit, *start, *end; 07971 ast_mutex_t *lock; 07972 int channelmatched = 0; 07973 int groupmatched = 0; 07974 07975 /* Assume we're locking the iflock */ 07976 lock = &iflock; 07977 start = iflist; 07978 end = ifend; 07979 if (data) { 07980 dest = ast_strdupa((char *)data); 07981 } else { 07982 ast_log(LOG_WARNING, "Channel requested with no data\n"); 07983 return NULL; 07984 } 07985 if (toupper(dest[0]) == 'G' || toupper(dest[0])=='R') { 07986 /* Retrieve the group number */ 07987 char *stringp=NULL; 07988 stringp=dest + 1; 07989 s = strsep(&stringp, "/"); 07990 if ((res = sscanf(s, "%d%c%d", &x, &opt, &y)) < 1) { 07991 ast_log(LOG_WARNING, "Unable to determine group for data %s\n", (char *)data); 07992 return NULL; 07993 } 07994 groupmatch = ((ast_group_t) 1 << x); 07995 if (toupper(dest[0]) == 'G') { 07996 if (dest[0] == 'G') { 07997 backwards = 1; 07998 p = ifend; 07999 } else 08000 p = iflist; 08001 } else { 08002 if (dest[0] == 'R') { 08003 backwards = 1; 08004 p = round_robin[x]?round_robin[x]->prev:ifend; 08005 if (!p) 08006 p = ifend; 08007 } else { 08008 p = round_robin[x]?round_robin[x]->next:iflist; 08009 if (!p) 08010 p = iflist; 08011 } 08012 roundrobin = 1; 08013 } 08014 } else { 08015 char *stringp=NULL; 08016 stringp=dest; 08017 s = strsep(&stringp, "/"); 08018 p = iflist; 08019 if (!strcasecmp(s, "pseudo")) { 08020 /* Special case for pseudo */ 08021 x = CHAN_PSEUDO; 08022 channelmatch = x; 08023 } 08024 #ifdef HAVE_PRI 08025 else if ((res = sscanf(s, "%d:%d%c%d", &trunkgroup, &crv, &opt, &y)) > 1) { 08026 if ((trunkgroup < 1) || (crv < 1)) { 08027 ast_log(LOG_WARNING, "Unable to determine trunk group and CRV for data %s\n", (char *)data); 08028 return NULL; 08029 } 08030 res--; 08031 for (x = 0; x < NUM_SPANS; x++) { 08032 if (pris[x].trunkgroup == trunkgroup) { 08033 pri = pris + x; 08034 lock = &pri->lock; 08035 start = pri->crvs; 08036 end = pri->crvend; 08037 break; 08038 } 08039 } 08040 if (!pri) { 08041 ast_log(LOG_WARNING, "Unable to find trunk group %d\n", trunkgroup); 08042 return NULL; 08043 } 08044 channelmatch = crv; 08045 p = pris[x].crvs; 08046 } 08047 #endif 08048 else if ((res = sscanf(s, "%d%c%d", &x, &opt, &y)) < 1) { 08049 ast_log(LOG_WARNING, "Unable to determine channel for data %s\n", (char *)data); 08050 return NULL; 08051 } else { 08052 channelmatch = x; 08053 } 08054 } 08055 /* Search for an unowned channel */ 08056 ast_mutex_lock(lock); 08057 exit = p; 08058 while (p && !tmp) { 08059 if (roundrobin) 08060 round_robin[x] = p; 08061 #if 0 08062 ast_verbose("name = %s, %d, %d, %d\n",p->owner ? p->owner->name : "<none>", p->channel, channelmatch, groupmatch); 08063 #endif 08064 08065 if (p && available(p, channelmatch, groupmatch, &busy, &channelmatched, &groupmatched)) { 08066 if (option_debug) 08067 ast_log(LOG_DEBUG, "Using channel %d\n", p->channel); 08068 if (p->inalarm) 08069 goto next; 08070 08071 callwait = (p->owner != NULL); 08072 #ifdef HAVE_PRI 08073 if (pri && (p->subs[SUB_REAL].dfd < 0)) { 08074 if (p->sig != SIG_FXSKS) { 08075 /* Gotta find an actual channel to use for this 08076 CRV if this isn't a callwait */ 08077 bearer = pri_find_empty_chan(pri, 0); 08078 if (bearer < 0) { 08079 ast_log(LOG_NOTICE, "Out of bearer channels on span %d for call to CRV %d:%d\n", pri->span, trunkgroup, crv); 08080 p = NULL; 08081 break; 08082 } 08083 pri_assign_bearer(p, pri, pri->pvts[bearer]); 08084 } else { 08085 if (alloc_sub(p, 0)) { 08086 ast_log(LOG_NOTICE, "Failed to allocate place holder pseudo channel!\n"); 08087 p = NULL; 08088 break; 08089 } else 08090 ast_log(LOG_DEBUG, "Allocated placeholder pseudo channel\n"); 08091 p->pri = pri; 08092 } 08093 } 08094 #endif 08095 if (p->channel == CHAN_PSEUDO) { 08096 p = chandup(p); 08097 if (!p) { 08098 break; 08099 } 08100 } 08101 if (p->owner) { 08102 if (alloc_sub(p, SUB_CALLWAIT)) { 08103 p = NULL; 08104 break; 08105 } 08106 } 08107 p->outgoing = 1; 08108 tmp = dahdi_new(p, AST_STATE_RESERVED, 0, p->owner ? SUB_CALLWAIT : SUB_REAL, 0, 0); 08109 #ifdef HAVE_PRI 08110 if (p->bearer) { 08111 /* Log owner to bearer channel, too */ 08112 p->bearer->owner = tmp; 08113 } 08114 #endif 08115 /* Make special notes */ 08116 if (res > 1) { 08117 if (opt == 'c') { 08118 /* Confirm answer */ 08119 p->confirmanswer = 1; 08120 } else if (opt == 'r') { 08121 /* Distinctive ring */ 08122 if (res < 3) 08123 ast_log(LOG_WARNING, "Distinctive ring missing identifier in '%s'\n", (char *)data); 08124 else 08125 p->distinctivering = y; 08126 } else if (opt == 'd') { 08127 /* If this is an ISDN call, make it digital */ 08128 p->digital = 1; 08129 if (tmp) 08130 tmp->transfercapability = AST_TRANS_CAP_DIGITAL; 08131 } else { 08132 ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", opt, (char *)data); 08133 } 08134 } 08135 /* Note if the call is a call waiting call */ 08136 if (tmp && callwait) 08137 tmp->cdrflags |= AST_CDR_CALLWAIT; 08138 break; 08139 } 08140 next: 08141 if (backwards) { 08142 p = p->prev; 08143 if (!p) 08144 p = end; 08145 } else { 08146 p = p->next; 08147 if (!p) 08148 p = start; 08149 } 08150 /* stop when you roll to the one that we started from */ 08151 if (p == exit) 08152 break; 08153 } 08154 ast_mutex_unlock(lock); 08155 restart_monitor(); 08156 if (callwait) 08157 *cause = AST_CAUSE_BUSY; 08158 else if (!tmp) { 08159 if (channelmatched) { 08160 if (busy) 08161 *cause = AST_CAUSE_BUSY; 08162 } else if (groupmatched) { 08163 *cause = AST_CAUSE_CONGESTION; 08164 } 08165 } 08166 08167 return tmp; 08168 }
| static int dahdi_restart | ( | void | ) | [static] |
Definition at line 10083 of file chan_dahdi.c.
References ast_active_channels(), ast_cond_wait(), ast_log(), ast_mutex_init(), ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_NULL, AST_PTHREADT_STOP, ast_verbose(), dahdi_softhangup_all(), destroy_all_channels(), dahdi_subchannel::dfd, iflist, lock, LOG_WARNING, master, monlock, dahdi_pvt::next, option_debug, option_verbose, dahdi_pvt::owner, restart_lock, setup_dahdi(), ss_thread_lock, and dahdi_pvt::subs.
Referenced by __action_restart(), and dahdi_restart_cmd().
10084 { 10085 #if defined(HAVE_PRI) 10086 int i, j; 10087 #endif 10088 int cancel_code; 10089 struct dahdi_pvt *p; 10090 10091 ast_mutex_lock(&restart_lock); 10092 10093 if (option_verbose) 10094 ast_verbose("Destroying channels and reloading DAHDI configuration.\n"); 10095 dahdi_softhangup_all(); 10096 if (option_verbose > 3) 10097 ast_verbose("Initial softhangup of all DAHDI channels complete.\n"); 10098 10099 #if defined(HAVE_PRI) 10100 for (i = 0; i < NUM_SPANS; i++) { 10101 if (pris[i].master && (pris[i].master != AST_PTHREADT_NULL)) { 10102 cancel_code = pthread_cancel(pris[i].master); 10103 pthread_kill(pris[i].master, SIGURG); 10104 if (option_debug > 3) 10105 ast_verbose("Waiting to join thread of span %d with pid=%p, cancel_code=%d\n", i, (void *) pris[i].master, cancel_code); 10106 pthread_join(pris[i].master, NULL); 10107 if (option_debug > 3) 10108 ast_verbose("Joined thread of span %d\n", i); 10109 } 10110 } 10111 #endif 10112 10113 ast_mutex_lock(&monlock); 10114 if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) { 10115 cancel_code = pthread_cancel(monitor_thread); 10116 pthread_kill(monitor_thread, SIGURG); 10117 if (option_debug > 3) 10118 ast_verbose("Waiting to join monitor thread with pid=%p, cancel_code=%d\n", (void *) monitor_thread, cancel_code); 10119 pthread_join(monitor_thread, NULL); 10120 if (option_debug > 3) 10121 ast_verbose("Joined monitor thread\n"); 10122 } 10123 monitor_thread = AST_PTHREADT_NULL; /* prepare to restart thread in setup_dahdi once channels are reconfigured */ 10124 10125 ast_mutex_lock(&ss_thread_lock); 10126 while (ss_thread_count > 0) { /* let ss_threads finish and run dahdi_hangup before dahvi_pvts are destroyed */ 10127 int x = DAHDI_FLASH; 10128 if (option_debug > 2) 10129 ast_verbose("Waiting on %d ss_thread(s) to finish\n", ss_thread_count); 10130 10131 for (p = iflist; p; p = p->next) { 10132 if (p->owner) 10133 ioctl(p->subs[SUB_REAL].dfd, DAHDI_HOOK, &x); /* important to create an event for dahdi_wait_event to register so that all ss_threads terminate */ 10134 } 10135 ast_cond_wait(&ss_thread_complete, &ss_thread_lock); 10136 } 10137 10138 /* ensure any created channels before monitor threads were stopped are hungup */ 10139 dahdi_softhangup_all(); 10140 if (option_verbose > 3) 10141 ast_verbose("Final softhangup of all DAHDI channels complete.\n"); 10142 destroy_all_channels(); 10143 if (option_debug) 10144 ast_verbose("Channels destroyed. Now re-reading config. %d active channels remaining.\n", ast_active_channels()); 10145 10146 ast_mutex_unlock(&monlock); 10147 10148 #ifdef HAVE_PRI 10149 for (i = 0; i < NUM_SPANS; i++) { 10150 for (j = 0; j < NUM_DCHANS; j++) 10151 dahdi_close_pri_fd(&(pris[i]), j); 10152 } 10153 10154 memset(pris, 0, sizeof(pris)); 10155 for (i = 0; i < NUM_SPANS; i++) { 10156 ast_mutex_init(&pris[i].lock); 10157 pris[i].offset = -1; 10158 pris[i].master = AST_PTHREADT_NULL; 10159 for (j = 0; j < NUM_DCHANS; j++) 10160 pris[i].fds[j] = -1; 10161 } 10162 pri_set_error(dahdi_pri_error); 10163 pri_set_message(dahdi_pri_message); 10164 #endif 10165 10166 if (setup_dahdi(2) != 0) { 10167 ast_log(LOG_WARNING, "Reload channels from dahdi config failed!\n"); 10168 ast_mutex_unlock(&ss_thread_lock); 10169 return 1; 10170 } 10171 ast_mutex_unlock(&ss_thread_lock); 10172 ast_mutex_unlock(&restart_lock); 10173 return 0; 10174 }
| static int dahdi_restart_cmd | ( | int | fd, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 10176 of file chan_dahdi.c.
References dahdi_restart(), RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
10177 { 10178 if (argc != 2) { 10179 return RESULT_SHOWUSAGE; 10180 } 10181 10182 if (dahdi_restart() != 0) 10183 return RESULT_FAILURE; 10184 return RESULT_SUCCESS; 10185 }
| static int dahdi_ring_phone | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 3559 of file chan_dahdi.c.
References ast_log(), dahdi_subchannel::dfd, errno, LOG_WARNING, SUB_REAL, and dahdi_pvt::subs.
Referenced by __dahdi_exception(), and dahdi_handle_event().
03560 { 03561 int x; 03562 int res; 03563 /* Make sure our transmit state is on hook */ 03564 x = 0; 03565 x = DAHDI_ONHOOK; 03566 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_HOOK, &x); 03567 do { 03568 x = DAHDI_RING; 03569 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_HOOK, &x); 03570 if (res) { 03571 switch (errno) { 03572 case EBUSY: 03573 case EINTR: 03574 /* Wait just in case */ 03575 usleep(10000); 03576 continue; 03577 case EINPROGRESS: 03578 res = 0; 03579 break; 03580 default: 03581 ast_log(LOG_WARNING, "Couldn't ring the phone: %s\n", strerror(errno)); 03582 res = 0; 03583 } 03584 } 03585 } while (res); 03586 return res; 03587 }
| static int dahdi_sendtext | ( | struct ast_channel * | c, | |
| const char * | text | |||
| ) | [static] |
Definition at line 11884 of file chan_dahdi.c.
References ASCII_BYTES_PER_CHAR, ast_check_hangup(), ast_free, AST_LAW, ast_log(), ast_malloc, dahdi_pvt::channel, dahdi_get_index(), dahdi_subchannel::dfd, END_SILENCE_LEN, errno, pollfd::events, pollfd::fd, free, HEADER_LEN, HEADER_MS, LOG_DEBUG, LOG_ERROR, LOG_WARNING, dahdi_pvt::mate, option_debug, poll(), POLLOUT, PUT_CLID, PUT_CLID_MARKMS, READ_SIZE, pollfd::revents, dahdi_pvt::subs, dahdi_pvt::tdd, TDD_BYTES_PER_CHAR, tdd_generate(), ast_channel::tech_pvt, and TRAILER_MS.
11885 { 11886 #define END_SILENCE_LEN 400 11887 #define HEADER_MS 50 11888 #define TRAILER_MS 5 11889 #define HEADER_LEN ((HEADER_MS + TRAILER_MS) * 8) 11890 #define ASCII_BYTES_PER_CHAR 80 11891 11892 unsigned char *buf,*mybuf; 11893 struct dahdi_pvt *p = c->tech_pvt; 11894 struct pollfd fds[1]; 11895 int size,res,fd,len,x; 11896 int bytes=0; 11897 /* Initial carrier (imaginary) */ 11898 float cr = 1.0; 11899 float ci = 0.0; 11900 float scont = 0.0; 11901 int index; 11902 11903 index = dahdi_get_index(c, p, 0); 11904 if (index < 0) { 11905 ast_log(LOG_WARNING, "Huh? I don't exist?\n"); 11906 return -1; 11907 } 11908 if (!text[0]) return(0); /* if nothing to send, dont */ 11909 if ((!p->tdd) && (!p->mate)) return(0); /* if not in TDD mode, just return */ 11910 if (p->mate) 11911 buf = ast_malloc(((strlen(text) + 1) * ASCII_BYTES_PER_CHAR) + END_SILENCE_LEN + HEADER_LEN); 11912 else 11913 buf = ast_malloc(((strlen(text) + 1) * TDD_BYTES_PER_CHAR) + END_SILENCE_LEN); 11914 if (!buf) 11915 return -1; 11916 mybuf = buf; 11917 if (p->mate) { 11918 int codec = AST_LAW(p); 11919 for (x = 0; x < HEADER_MS; x++) { /* 50 ms of Mark */ 11920 PUT_CLID_MARKMS; 11921 } 11922 /* Put actual message */ 11923 for (x = 0; text[x]; x++) { 11924 PUT_CLID(text[x]); 11925 } 11926 for (x = 0; x < TRAILER_MS; x++) { /* 5 ms of Mark */ 11927 PUT_CLID_MARKMS; 11928 } 11929 len = bytes; 11930 buf = mybuf; 11931 } else { 11932 len = tdd_generate(p->tdd, buf, text); 11933 if (len < 1) { 11934 ast_log(LOG_ERROR, "TDD generate (len %d) failed!!\n", (int)strlen(text)); 11935 free(mybuf); 11936 return -1; 11937 } 11938 } 11939 memset(buf + len, 0x7f, END_SILENCE_LEN); 11940 len += END_SILENCE_LEN; 11941 fd = p->subs[index].dfd; 11942 while (len) { 11943 if (ast_check_hangup(c)) { 11944 free(mybuf); 11945 return -1; 11946 } 11947 size = len; 11948 if (size > READ_SIZE) 11949 size = READ_SIZE; 11950 fds[0].fd = fd; 11951 fds[0].events = POLLOUT | POLLPRI; 11952 fds[0].revents = 0; 11953 res = poll(fds, 1, -1); 11954 if (!res) { 11955 ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel); 11956 continue; 11957 } 11958 /* if got exception */ 11959 if (fds[0].revents & POLLPRI) { 11960 ast_free(mybuf); 11961 return -1; 11962 } 11963 if (!(fds[0].revents & POLLOUT)) { 11964 ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel); 11965 continue; 11966 } 11967 res = write(fd, buf, size); 11968 if (res != size) { 11969 if (res == -1) { 11970 free(mybuf); 11971 return -1; 11972 } 11973 if (option_debug) 11974 ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); 11975 break; 11976 } 11977 len -= size; 11978 buf += size; 11979 } 11980 free(mybuf); 11981 return(0); 11982 }
| static int dahdi_set_hook | ( | int | fd, | |
| int | hs | |||
| ) | [inline, static] |
Definition at line 1659 of file chan_dahdi.c.
References ast_log(), errno, and LOG_WARNING.
Referenced by __dahdi_exception(), dahdi_answer(), dahdi_handle_event(), dahdi_hangup(), dahdi_indicate(), dahdi_wink(), handle_init_event(), mkintf(), and ss_thread().
01660 { 01661 int x, res; 01662 01663 x = hs; 01664 res = ioctl(fd, DAHDI_HOOK, &x); 01665 01666 if (res < 0) { 01667 if (errno == EINPROGRESS) 01668 return 0; 01669 ast_log(LOG_WARNING, "DAHDI hook failed returned %d (trying %d): %s\n", res, hs, strerror(errno)); 01670 /* will expectedly fail if phone is off hook during operation, such as during a restart */ 01671 } 01672 01673 return res; 01674 }
| static int dahdi_setlinear | ( | int | dfd, | |
| int | linear | |||
| ) | [static] |
Definition at line 969 of file chan_dahdi.c.
Referenced by dahdi_hangup(), dahdi_new(), dahdi_read(), dahdi_write(), send_callerid(), and ss_thread().
00970 { 00971 int res; 00972 res = ioctl(dfd, DAHDI_SETLINEAR, &linear); 00973 if (res) 00974 return res; 00975 return 0; 00976 }
| static int dahdi_setoption | ( | struct ast_channel * | chan, | |
| int | option, | |||
| void * | data, | |||
| int | datalen | |||
| ) | [static] |
Definition at line 2924 of file chan_dahdi.c.
References ast_check_hangup(), ast_dsp_digitmode(), ast_log(), AST_OPTION_AUDIO_MODE, AST_OPTION_ECHOCAN, AST_OPTION_OPRMODE, AST_OPTION_RELAXDTMF, AST_OPTION_RXGAIN, AST_OPTION_TDD, AST_OPTION_TONE_VERIFY, AST_OPTION_TXGAIN, ast_tdd_gen_ecdisa(), dahdi_pvt::channel, dahdi_disable_ec(), dahdi_enable_ec(), dahdi_get_index(), dahdi_subchannel::dfd, dahdi_pvt::didtdd, dahdi_pvt::dsp, DSP_DIGITMODE_DTMF, DSP_DIGITMODE_MUTECONF, DSP_DIGITMODE_MUTEMAX, DSP_DIGITMODE_RELAXDTMF, dahdi_pvt::dtmfrelax, errno, pollfd::events, pollfd::fd, dahdi_pvt::law, len(), LOG_DEBUG, LOG_WARNING, dahdi_pvt::mate, oprmode::mode, ast_channel::name, dahdi_pvt::oprmode, dahdi_pvt::oprpeer, option_debug, oprmode::peer, poll(), POLLOUT, POLLPRI, READ_SIZE, pollfd::revents, dahdi_pvt::rxgain, set_actual_rxgain(), set_actual_txgain(), SUB_REAL, dahdi_pvt::subs, dahdi_pvt::tdd, tdd_free(), tdd_new(), ast_channel::tech_pvt, and dahdi_pvt::txgain.
02925 { 02926 char *cp; 02927 signed char *scp; 02928 int x; 02929 int index; 02930 struct dahdi_pvt *p = chan->tech_pvt, *pp; 02931 struct oprmode *oprmode; 02932 02933 02934 /* all supported options require data */ 02935 if (!data || (datalen < 1)) { 02936 errno = EINVAL; 02937 return -1; 02938 } 02939 02940 switch (option) { 02941 case AST_OPTION_TXGAIN: 02942 scp = (signed char *) data; 02943 index = dahdi_get_index(chan, p, 0); 02944 if (index < 0) { 02945 ast_log(LOG_WARNING, "No index in TXGAIN?\n"); 02946 return -1; 02947 } 02948 if (option_debug) 02949 ast_log(LOG_DEBUG, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp); 02950 return set_actual_txgain(p->subs[index].dfd, 0, p->txgain + (float) *scp, p->law); 02951 case AST_OPTION_RXGAIN: 02952 scp = (signed char *) data; 02953 index = dahdi_get_index(chan, p, 0); 02954 if (index < 0) { 02955 ast_log(LOG_WARNING, "No index in RXGAIN?\n"); 02956 return -1; 02957 } 02958 if (option_debug) 02959 ast_log(LOG_DEBUG, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp); 02960 return set_actual_rxgain(p->subs[index].dfd, 0, p->rxgain + (float) *scp, p->law); 02961 case AST_OPTION_TONE_VERIFY: 02962 if (!p->dsp) 02963 break; 02964 cp = (char *) data; 02965 switch (*cp) { 02966 case 1: 02967 ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name); 02968 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | p->dtmfrelax); /* set mute mode if desired */ 02969 break; 02970 case 2: 02971 ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name); 02972 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX | p->dtmfrelax); /* set mute mode if desired */ 02973 break; 02974 default: 02975 ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name); 02976 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); /* set mute mode if desired */ 02977 break; 02978 } 02979 break; 02980 case AST_OPTION_TDD: 02981 /* turn on or off TDD */ 02982 cp = (char *) data; 02983 p->mate = 0; 02984 if (!*cp) { /* turn it off */ 02985 if (option_debug) 02986 ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name); 02987 if (p->tdd) 02988 tdd_free(p->tdd); 02989 p->tdd = 0; 02990 break; 02991 } 02992 ast_log(LOG_DEBUG, "Set option TDD MODE, value: %s(%d) on %s\n", 02993 (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name); 02994 dahdi_disable_ec(p); 02995 /* otherwise, turn it on */ 02996 if (!p->didtdd) { /* if havent done it yet */ 02997 unsigned char mybuf[41000], *buf; 02998 int size, res, fd, len; 02999 struct pollfd fds[1]; 03000 03001 buf = mybuf; 03002 memset(buf, 0x7f, sizeof(mybuf)); /* set to silence */ 03003 ast_tdd_gen_ecdisa(buf + 16000, 16000); /* put in tone */ 03004 len = 40000; 03005 index = dahdi_get_index(chan, p, 0); 03006 if (index < 0) { 03007 ast_log(LOG_WARNING, "No index in TDD?\n"); 03008 return -1; 03009 } 03010 fd = p->subs[index].dfd; 03011 while (len) { 03012 if (ast_check_hangup(chan)) 03013 return -1; 03014 size = len; 03015 if (size > READ_SIZE) 03016 size = READ_SIZE; 03017 fds[0].fd = fd; 03018 fds[0].events = POLLPRI | POLLOUT; 03019 fds[0].revents = 0; 03020 res = poll(fds, 1, -1); 03021 if (!res) { 03022 ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel); 03023 continue; 03024 } 03025 /* if got exception */ 03026 if (fds[0].revents & POLLPRI) 03027 return -1; 03028 if (!(fds[0].revents & POLLOUT)) { 03029 ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel); 03030 continue; 03031 } 03032 res = write(fd, buf, size); 03033 if (res != size) { 03034 if (res == -1) return -1; 03035 ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); 03036 break; 03037 } 03038 len -= size; 03039 buf += size; 03040 } 03041 p->didtdd = 1; /* set to have done it now */ 03042 } 03043 if (*cp == 2) { /* Mate mode */ 03044 if (p->tdd) 03045 tdd_free(p->tdd); 03046 p->tdd = 0; 03047 p->mate = 1; 03048 break; 03049 } 03050 if (!p->tdd) { /* if we dont have one yet */ 03051 p->tdd = tdd_new(); /* allocate one */ 03052 } 03053 break; 03054 case AST_OPTION_RELAXDTMF: /* Relax DTMF decoding (or not) */ 03055 if (!p->dsp) 03056 break; 03057 cp = (char *) data; 03058 ast_log(LOG_DEBUG, "Set option RELAX DTMF, value: %s(%d) on %s\n", 03059 *cp ? "ON" : "OFF", (int) *cp, chan->name); 03060 p->dtmfrelax = 0; 03061 if (*cp) p->dtmfrelax = DSP_DIGITMODE_RELAXDTMF; 03062 ast_dsp_digitmode(p->dsp, DSP_DIGITMODE_DTMF | p->dtmfrelax); 03063 break; 03064 case AST_OPTION_AUDIO_MODE: /* Set AUDIO mode (or not) */ 03065 cp = (char *) data; 03066 if (!*cp) { 03067 ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name); 03068 x = 0; 03069 dahdi_disable_ec(p); 03070 } else { 03071 ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name); 03072 x = 1; 03073 } 03074 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &x) == -1) 03075 ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d: %s\n", p->channel, x, strerror(errno)); 03076 break; 03077 case AST_OPTION_OPRMODE: /* Operator services mode */ 03078 oprmode = (struct oprmode *) data; 03079 pp = oprmode->peer->tech_pvt; 03080 p->oprmode = pp->oprmode = 0; 03081 /* setup peers */ 03082 p->oprpeer = pp; 03083 pp->oprpeer = p; 03084 /* setup modes, if any */ 03085 if (oprmode->mode) 03086 { 03087 pp->oprmode = oprmode->mode; 03088 p->oprmode = -oprmode->mode; 03089 } 03090 ast_log(LOG_DEBUG, "Set Operator Services mode, value: %d on %s/%s\n", 03091 oprmode->mode, chan->name,oprmode->peer->name);; 03092 break; 03093 case AST_OPTION_ECHOCAN: 03094 cp = (char *) data; 03095 if (*cp) { 03096 ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name); 03097 dahdi_enable_ec(p); 03098 } else { 03099 ast_log(LOG_DEBUG, "Disabling echo cancelation on %s\n", chan->name); 03100 dahdi_disable_ec(p); 03101 } 03102 break; 03103 } 03104 errno = 0; 03105 03106 return 0; 03107 }
| static int dahdi_show_channel | ( | int | fd, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 10248 of file chan_dahdi.c.
References ast_cli(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dahdi_pvt::callwaitcas, dahdi_pvt::channel, dahdi_pvt::cid_name, dahdi_pvt::cid_num, dahdi_pvt::cid_ton, dahdi_pvt::confno, dahdi_pvt::context, dahdi_pvt::destroy, dahdi_subchannel::dfd, dahdi_pvt::dialing, dahdi_pvt::dsp, dahdi_pvt::dtmfrelax, dahdi_pvt::echocanbridged, dahdi_pvt::echocancel, dahdi_pvt::echocanon, errno, dahdi_pvt::exten, dahdi_pvt::faxhandled, iflist, iflock, dahdi_pvt::inalarm, dahdi_pvt::inconference, dahdi_subchannel::inthreeway, dahdi_pvt::law, dahdi_subchannel::linear, lock, LOG_WARNING, dahdi_pvt::master, MAX_SLAVES, ast_channel::name, dahdi_pvt::next, dahdi_subchannel::owner, dahdi_pvt::owner, dahdi_pvt::propconfno, dahdi_pvt::pulsedial, dahdi_pvt::radio, RESULT_FAILURE, RESULT_SHOWUSAGE, RESULT_SUCCESS, dahdi_pvt::sig, sig2str, dahdi_pvt::slaves, dahdi_pvt::span, SUB_CALLWAIT, SUB_THREEWAY, and dahdi_pvt::subs.
10249 { 10250 int channel; 10251 struct dahdi_pvt *tmp = NULL; 10252 struct dahdi_confinfo ci; 10253 struct dahdi_params ps; 10254 int x; 10255 ast_mutex_t *lock; 10256 struct dahdi_pvt *start; 10257 #ifdef HAVE_PRI 10258 char *c; 10259 int trunkgroup; 10260 struct dahdi_pri *pri=NULL; 10261 #endif 10262 10263 lock = &iflock; 10264 start = iflist; 10265 10266 if (argc != 4) 10267 return RESULT_SHOWUSAGE; 10268 #ifdef HAVE_PRI 10269 if ((c = strchr(argv[3], ':'))) { 10270 if (sscanf(argv[3], "%d:%d", &trunkgroup, &channel) != 2) 10271 return RESULT_SHOWUSAGE; 10272 if ((trunkgroup < 1) || (channel < 1)) 10273 return RESULT_SHOWUSAGE; 10274 for (x = 0; x < NUM_SPANS; x++) { 10275 if (pris[x].trunkgroup == trunkgroup) { 10276 pri = pris + x; 10277 break; 10278 } 10279 } 10280 if (pri) { 10281 start = pri->crvs; 10282 lock = &pri->lock; 10283 } else { 10284 ast_cli(fd, "No such trunk group %d\n", trunkgroup); 10285 return RESULT_FAILURE; 10286 } 10287 } else 10288 #endif 10289 channel = atoi(argv[3]); 10290 10291 ast_mutex_lock(lock); 10292 tmp = start; 10293 while (tmp) { 10294 if (tmp->channel == channel) { 10295 #ifdef HAVE_PRI 10296 if (pri) 10297 ast_cli(fd, "Trunk/CRV: %d/%d\n", trunkgroup, tmp->channel); 10298 else 10299 #endif 10300 ast_cli(fd, "Channel: %d\n", tmp->channel); 10301 ast_cli(fd, "File Descriptor: %d\n", tmp->subs[SUB_REAL].dfd); 10302 ast_cli(fd, "Span: %d\n", tmp->span); 10303 ast_cli(fd, "Extension: %s\n", tmp->exten); 10304 ast_cli(fd, "Dialing: %s\n", tmp->dialing ? "yes" : "no"); 10305 ast_cli(fd, "Context: %s\n", tmp->context); 10306 ast_cli(fd, "Caller ID: %s\n", tmp->cid_num); 10307 ast_cli(fd, "Calling TON: %d\n", tmp->cid_ton); 10308 ast_cli(fd, "Caller ID name: %s\n", tmp->cid_name); 10309 ast_cli(fd, "Destroy: %d\n", tmp->destroy); 10310 ast_cli(fd, "InAlarm: %d\n", tmp->inalarm); 10311 ast_cli(fd, "Signalling Type: %s\n", sig2str(tmp->sig)); 10312 ast_cli(fd, "Radio: %d\n", tmp->radio); 10313 ast_cli(fd, "Owner: %s\n", tmp->owner ? tmp->owner->name : "<None>"); 10314 ast_cli(fd, "Real: %s%s%s\n", tmp->subs[SUB_REAL].owner ? tmp->subs[SUB_REAL].owner->name : "<None>", tmp->subs[SUB_REAL].inthreeway ? " (Confed)" : "", tmp->subs[SUB_REAL].linear ? " (Linear)" : ""); 10315 ast_cli(fd, "Callwait: %s%s%s\n", tmp->subs[SUB_CALLWAIT].owner ? tmp->subs[SUB_CALLWAIT].owner->name : "<None>", tmp->subs[SUB_CALLWAIT].inthreeway ? " (Confed)" : "", tmp->subs[SUB_CALLWAIT].linear ? " (Linear)" : ""); 10316 ast_cli(fd, "Threeway: %s%s%s\n", tmp->subs[SUB_THREEWAY].owner ? tmp->subs[SUB_THREEWAY].owner->name : "<None>", tmp->subs[SUB_THREEWAY].inthreeway ? " (Confed)" : "", tmp->subs[SUB_THREEWAY].linear ? " (Linear)" : ""); 10317 ast_cli(fd, "Confno: %d\n", tmp->confno); 10318 ast_cli(fd, "Propagated Conference: %d\n", tmp->propconfno); 10319 ast_cli(fd, "Real in conference: %d\n", tmp->inconference); 10320 ast_cli(fd, "DSP: %s\n", tmp->dsp ? "yes" : "no"); 10321 ast_cli(fd, "Relax DTMF: %s\n", tmp->dtmfrelax ? "yes" : "no"); 10322 ast_cli(fd, "Dialing/CallwaitCAS: %d/%d\n", tmp->dialing, tmp->callwaitcas); 10323 ast_cli(fd, "Default law: %s\n", tmp->law == DAHDI_LAW_MULAW ? "ulaw" : tmp->law == DAHDI_LAW_ALAW ? "alaw" : "unknown"); 10324 ast_cli(fd, "Fax Handled: %s\n", tmp->faxhandled ? "yes" : "no"); 10325 ast_cli(fd, "Pulse phone: %s\n", tmp->pulsedial ? "yes" : "no"); 10326 ast_cli(fd, "Echo Cancellation: %d taps%s, currently %s\n", tmp->echocancel, tmp->echocanbridged ? "" : " unless TDM bridged", tmp->echocanon ? "ON" : "OFF"); 10327 if (tmp->master) 10328 ast_cli(fd, "Master Channel: %d\n", tmp->master->channel); 10329 for (x = 0; x < MAX_SLAVES; x++) { 10330 if (tmp->slaves[x]) 10331 ast_cli(fd, "Slave Channel: %d\n", tmp->slaves[x]->channel); 10332 } 10333 #ifdef HAVE_PRI 10334 if (tmp->pri) { 10335 ast_cli(fd, "PRI Flags: "); 10336 if (tmp->resetting) 10337 ast_cli(fd, "Resetting "); 10338 if (tmp->call) 10339 ast_cli(fd, "Call "); 10340 if (tmp->bearer) 10341 ast_cli(fd, "Bearer "); 10342 ast_cli(fd, "\n"); 10343 if (tmp->logicalspan) 10344 ast_cli(fd, "PRI Logical Span: %d\n", tmp->logicalspan); 10345 else 10346 ast_cli(fd, "PRI Logical Span: Implicit\n"); 10347 } 10348 10349 #endif 10350 memset(&ci, 0, sizeof(ci)); 10351 ps.channo = tmp->channel; 10352 if (tmp->subs[SUB_REAL].dfd > -1) { 10353 if (!ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GETCONF, &ci)) { 10354 ast_cli(fd, "Actual Confinfo: Num/%d, Mode/0x%04x\n", ci.confno, ci.confmode); 10355 } 10356 #ifdef DAHDI_GETCONFMUTE 10357 if (!ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GETCONFMUTE, &x)) { 10358 ast_cli(fd, "Actual Confmute: %s\n", x ? "Yes" : "No"); 10359 } 10360 #endif 10361 if (ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps) < 0) { 10362 ast_log(LOG_WARNING, "Failed to get parameters on channel %d: %s\n", tmp->channel, strerror(errno)); 10363 } else { 10364 ast_cli(fd, "Hookstate (FXS only): %s\n", ps.rxisoffhook ? "Offhook" : "Onhook"); 10365 } 10366 } 10367 ast_mutex_unlock(lock); 10368 return RESULT_SUCCESS; 10369 } 10370 tmp = tmp->next; 10371 } 10372 10373 ast_cli(fd, "Unable to find given channel %d\n", channel); 10374 ast_mutex_unlock(lock); 10375 return RESULT_FAILURE; 10376 }
| static int dahdi_show_channels | ( | int | fd, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 10187 of file chan_dahdi.c.
References ast_cli(), ast_copy_string(), ast_mutex_lock(), ast_mutex_unlock(), dahdi_pvt::channel, dahdi_pvt::context, dahdi_pvt::exten, FORMAT, FORMAT2, iflist, iflock, dahdi_pvt::language, lock, dahdi_pvt::mohinterpret, dahdi_pvt::next, RESULT_FAILURE, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
10188 { 10189 #define FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s\n" 10190 #define FORMAT2 "%7s %-10.10s %-15.15s %-10.10s %-20.20s\n" 10191 struct dahdi_pvt *tmp = NULL; 10192 char tmps[20] = ""; 10193 ast_mutex_t *lock; 10194 struct dahdi_pvt *start; 10195 #ifdef HAVE_PRI 10196 int trunkgroup; 10197 struct dahdi_pri *pri = NULL; 10198 int x; 10199 #endif 10200 10201 lock = &iflock; 10202 start = iflist; 10203 10204 #ifdef HAVE_PRI 10205 if (argc == 4) { 10206 if ((trunkgroup = atoi(argv[3])) < 1) 10207 return RESULT_SHOWUSAGE; 10208 for (x = 0; x < NUM_SPANS; x++) { 10209 if (pris[x].trunkgroup == trunkgroup) { 10210 pri = pris + x; 10211 break; 10212 } 10213 } 10214 if (pri) { 10215 start = pri->crvs; 10216 lock = &pri->lock; 10217 } else { 10218 ast_cli(fd, "No such trunk group %d\n", trunkgroup); 10219 return RESULT_FAILURE; 10220 } 10221 } else 10222 #endif 10223 if (argc != 3) 10224 return RESULT_SHOWUSAGE; 10225 10226 ast_mutex_lock(lock); 10227 #ifdef HAVE_PRI 10228 ast_cli(fd, FORMAT2, pri ? "CRV" : "Chan", "Extension", "Context", "Language", "MOH Interpret"); 10229 #else 10230 ast_cli(fd, FORMAT2, "Chan", "Extension", "Context", "Language", "MOH Interpret"); 10231 #endif 10232 10233 tmp = start; 10234 while (tmp) { 10235 if (tmp->channel > 0) { 10236 snprintf(tmps, sizeof(tmps), "%d", tmp->channel); 10237 } else 10238 ast_copy_string(tmps, "pseudo", sizeof(tmps)); 10239 ast_cli(fd, FORMAT, tmps, tmp->exten, tmp->context, tmp->language, tmp->mohinterpret); 10240 tmp = tmp->next; 10241 } 10242 ast_mutex_unlock(lock); 10243 return RESULT_SUCCESS; 10244 #undef FORMAT 10245 #undef FORMAT2 10246 }
| static int dahdi_show_status | ( | int | fd, | |
| int | argc, | |||
| char * | argv[] | |||
| ) | [static] |
Definition at line 10409 of file chan_dahdi.c.
References alarms, ast_cli(), ast_log(), errno, FORMAT, FORMAT2, LOG_WARNING, RESULT_FAILURE, and RESULT_SUCCESS.
10409 { 10410 #define FORMAT "%-40.40s %-10.10s %-10d %-10d %-10d\n" 10411 #define FORMAT2 "%-40.40s %-10.10s %-10.10s %-10.10s %-10.10s\n" 10412 10413 int span; 10414 int res; 10415 char alarms[50]; 10416 10417 int ctl; 10418 struct dahdi_spaninfo s; 10419 10420 #ifdef HAVE_ZAPTEL 10421 if ((ctl = open("/dev/zap/ctl", O_RDWR)) < 0) { 10422 ast_log(LOG_WARNING, "Unable to open /dev/zap/ctl: %s\n", strerror(errno)); 10423 ast_cli(fd, "No Zaptel interface found.\n"); 10424 return RESULT_FAILURE; 10425 } 10426 #else 10427 if ((ctl = open("/dev/dahdi/ctl", O_RDWR)) < 0) { 10428 ast_log(LOG_WARNING, "Unable to open /dev/dahdi/ctl: %s\n", strerror(errno)); 10429 ast_cli(fd, "No DAHDI interface found.\n"); 10430 return RESULT_FAILURE; 10431 } 10432 #endif 10433 ast_cli(fd, FORMAT2, "Description", "Alarms", "IRQ", "bpviol", "CRC4"); 10434 10435 for (span = 1; span < DAHDI_MAX_SPANS; ++span) { 10436 s.spanno = span; 10437 res = ioctl(ctl, DAHDI_SPANSTAT, &s); 10438 if (res) { 10439 continue; 10440 } 10441 alarms[0] = '\0'; 10442 if (s.alarms > 0) { 10443 if (s.alarms & DAHDI_ALARM_BLUE) 10444 strcat(alarms, "BLU/"); 10445 if (s.alarms & DAHDI_ALARM_YELLOW) 10446 strcat(alarms, "YEL/"); 10447 if (s.alarms & DAHDI_ALARM_RED) 10448 strcat(alarms, "RED/"); 10449 if (s.alarms & DAHDI_ALARM_LOOPBACK) 10450 strcat(alarms, "LB/"); 10451 if (s.alarms & DAHDI_ALARM_RECOVER) 10452 strcat(alarms, "REC/"); 10453 if (s.alarms & DAHDI_ALARM_NOTOPEN) 10454 strcat(alarms, "NOP/"); 10455 if (!strlen(alarms)) 10456 strcat(alarms, "UUU/"); 10457 if (strlen(alarms)) { 10458 /* Strip trailing / */ 10459 alarms[strlen(alarms) - 1] = '\0'; 10460 } 10461 } else { 10462 if (s.numchans) 10463 strcpy(alarms, "OK"); 10464 else 10465 strcpy(alarms, "UNCONFIGURED"); 10466 } 10467 10468 ast_cli(fd, FORMAT, s.desc, alarms, s.irqmisses, s.bpvcount, s.crc4count); 10469 } 10470 close(ctl); 10471 10472 return RESULT_SUCCESS; 10473 #undef FORMAT 10474 #undef FORMAT2 10475 }
| static char* dahdi_sig2str | ( | int | sig | ) | [static] |
Definition at line 1210 of file chan_dahdi.c.
References SIG_E911, SIG_EM, SIG_EM_E1, SIG_EMWINK, SIG_FEATB, SIG_FEATD, SIG_FEATDMF, SIG_FEATDMF_TA, SIG_FGC_CAMA, SIG_FGC_CAMAMF, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_GR303FXOKS, SIG_GR303FXSKS, SIG_PRI, SIG_SF, SIG_SF_FEATB, SIG_SF_FEATD, SIG_SF_FEATDMF, and SIG_SFWINK.
01211 { 01212 static char buf[256]; 01213 switch (sig) { 01214 case SIG_EM: 01215 return "E & M Immediate"; 01216 case SIG_EMWINK: 01217 return "E & M Wink"; 01218 case SIG_EM_E1: 01219 return "E & M E1"; 01220 case SIG_FEATD: 01221 return "Feature Group D (DTMF)"; 01222 case SIG_FEATDMF: 01223 return "Feature Group D (MF)"; 01224 case SIG_FEATDMF_TA: 01225 return "Feature Groud D (MF) Tandem Access"; 01226 case SIG_FEATB: 01227 return "Feature Group B (MF)"; 01228 case SIG_E911: 01229 return "E911 (MF)"; 01230 case SIG_FGC_CAMA: 01231 return "FGC/CAMA (Dialpulse)"; 01232 case SIG_FGC_CAMAMF: 01233 return "FGC/CAMA (MF)"; 01234 case SIG_FXSLS: 01235 return "FXS Loopstart"; 01236 case SIG_FXSGS: 01237 return "FXS Groundstart"; 01238 case SIG_FXSKS: 01239 return "FXS Kewlstart"; 01240 case SIG_FXOLS: 01241 return "FXO Loopstart"; 01242 case SIG_FXOGS: 01243 return "FXO Groundstart"; 01244 case SIG_FXOKS: 01245 return "FXO Kewlstart"; 01246 case SIG_PRI: 01247 return "ISDN PRI"; 01248 case SIG_SF: 01249 return "SF (Tone) Immediate"; 01250 case SIG_SFWINK: 01251 return "SF (Tone) Wink"; 01252 case SIG_SF_FEATD: 01253 return "SF (Tone) with Feature Group D (DTMF)"; 01254 case SIG_SF_FEATDMF: 01255 return "SF (Tone) with Feature Group D (MF)"; 01256 case SIG_SF_FEATB: 01257 return "SF (Tone) with Feature Group B (MF)"; 01258 case SIG_GR303FXOKS: 01259 return "GR-303 with FXOKS"; 01260 case SIG_GR303FXSKS: 01261 return "GR-303 with FXSKS"; 01262 case 0: 01263 return "Pseudo"; 01264 default: 01265 snprintf(buf, sizeof(buf), "Unknown signalling %d", sig); 01266 return buf; 01267 } 01268 }
| static void dahdi_softhangup_all | ( | void | ) | [static] |
Definition at line 10054 of file chan_dahdi.c.
References ast_channel_trylock, ast_channel_unlock, ast_mutex_lock(), ast_mutex_unlock(), AST_SOFTHANGUP_EXPLICIT, ast_softhangup_nolock(), ast_verbose(), iflist, iflock, dahdi_pvt::lock, ast_channel::name, dahdi_pvt::next, option_debug, dahdi_pvt::owner, and dahdi_pvt::restartpending.
Referenced by dahdi_restart().
10055 { 10056 struct dahdi_pvt *p; 10057 retry: 10058 ast_mutex_lock(&iflock); 10059 for (p = iflist; p; p = p->next) { 10060 ast_mutex_lock(&p->lock); 10061 if (p->owner && !p->restartpending) { 10062 if (ast_channel_trylock(p->owner)) { 10063 if (option_debug > 2) 10064 ast_verbose("Avoiding deadlock\n"); 10065 /* Avoid deadlock since you're not supposed to lock iflock or pvt before a channel */ 10066 ast_mutex_unlock(&p->lock); 10067 ast_mutex_unlock(&iflock); 10068 goto retry; 10069 } 10070 if (option_debug > 2) 10071 ast_verbose("Softhanging up on %s\n", p->owner->name); 10072 ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_EXPLICIT); 10073 p->restartpending = 1; 10074 num_restart_pending++; 10075 ast_channel_unlock(p->owner); 10076 } 10077 ast_mutex_unlock(&p->lock); 10078 } 10079 ast_mutex_unlock(&iflock); 10080 }
| static void dahdi_train_ec | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1491 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, dahdi_subchannel::dfd, dahdi_pvt::echocancel, dahdi_pvt::echotraining, errno, LOG_DEBUG, LOG_WARNING, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_answer(), and dahdi_handle_event().
01492 { 01493 int x; 01494 int res; 01495 if (p && p->echocancel && p->echotraining) { 01496 x = p->echotraining; 01497 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_ECHOTRAIN, &x); 01498 if (res) 01499 ast_log(LOG_WARNING, "Unable to request echo training on channel %d: %s\n", p->channel, strerror(errno)); 01500 else { 01501 ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel); 01502 } 01503 } else 01504 ast_log(LOG_DEBUG, "No echo training requested\n"); 01505 }
| static void dahdi_unlink | ( | struct dahdi_pvt * | slave, | |
| struct dahdi_pvt * | master, | |||
| int | needlock | |||
| ) | [static] |
Definition at line 3128 of file chan_dahdi.c.
References ast_log(), ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), dahdi_pvt::channel, conf_del(), DEADLOCK_AVOIDANCE, dahdi_pvt::inconference, dahdi_pvt::lock, LOG_DEBUG, dahdi_pvt::master, MAX_SLAVES, dahdi_pvt::slaves, SUB_REAL, dahdi_pvt::subs, and update_conf().
Referenced by dahdi_bridge(), and dahdi_fixup().
03129 { 03130 /* Unlink a specific slave or all slaves/masters from a given master */ 03131 int x; 03132 int hasslaves; 03133 if (!master) 03134 return; 03135 if (needlock) { 03136 ast_mutex_lock(&master->lock); 03137 if (slave) { 03138 while (ast_mutex_trylock(&slave->lock)) { 03139 DEADLOCK_AVOIDANCE(&master->lock); 03140 } 03141 } 03142 } 03143 hasslaves = 0; 03144 for (x = 0; x < MAX_SLAVES; x++) { 03145 if (master->slaves[x]) { 03146 if (!slave || (master->slaves[x] == slave)) { 03147 /* Take slave out of the conference */ 03148 ast_log(LOG_DEBUG, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel); 03149 conf_del(master, &master->slaves[x]->subs[SUB_REAL], SUB_REAL); 03150 conf_del(master->slaves[x], &master->subs[SUB_REAL], SUB_REAL); 03151 master->slaves[x]->master = NULL; 03152 master->slaves[x] = NULL; 03153 } else 03154 hasslaves = 1; 03155 } 03156 if (!hasslaves) 03157 master->inconference = 0; 03158 } 03159 if (!slave) { 03160 if (master->master) { 03161 /* Take master out of the conference */ 03162 conf_del(master->master, &master->subs[SUB_REAL], SUB_REAL); 03163 conf_del(master, &master->master->subs[SUB_REAL], SUB_REAL); 03164 hasslaves = 0; 03165 for (x = 0; x < MAX_SLAVES; x++) { 03166 if (master->master->slaves[x] == master) 03167 master->master->slaves[x] = NULL; 03168 else if (master->master->slaves[x]) 03169 hasslaves = 1; 03170 } 03171 if (!hasslaves) 03172 master->master->inconference = 0; 03173 } 03174 master->master = NULL; 03175 } 03176 update_conf(master); 03177 if (needlock) { 03178 if (slave) 03179 ast_mutex_unlock(&slave->lock); 03180 ast_mutex_unlock(&master->lock); 03181 } 03182 }
| static int dahdi_wait_event | ( | int | fd | ) | [inline, static] |
Avoid the silly dahdi_waitevent which ignores a bunch of events.
Definition at line 265 of file chan_dahdi.c.
Referenced by ss_thread().
00266 { 00267 int i, j = 0; 00268 i = DAHDI_IOMUX_SIGEVENT; 00269 if (ioctl(fd, DAHDI_IOMUX, &i) == -1) 00270 return -1; 00271 if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) 00272 return -1; 00273 return j; 00274 }
| static int dahdi_wink | ( | struct dahdi_pvt * | p, | |
| int | index | |||
| ) | [static] |
Definition at line 5530 of file chan_dahdi.c.
References dahdi_set_hook(), dahdi_subchannel::dfd, and dahdi_pvt::subs.
Referenced by ss_thread().
05531 { 05532 int j; 05533 dahdi_set_hook(p->subs[index].dfd, DAHDI_WINK); 05534 for (;;) 05535 { 05536 /* set bits of interest */ 05537 j = DAHDI_IOMUX_SIGEVENT; 05538 /* wait for some happening */ 05539 if (ioctl(p->subs[index].dfd,DAHDI_IOMUX,&j) == -1) return(-1); 05540 /* exit loop if we have it */ 05541 if (j & DAHDI_IOMUX_SIGEVENT) break; 05542 } 05543 /* get the event info */ 05544 if (ioctl(p->subs[index].dfd,DAHDI_GETEVENT,&j) == -1) return(-1); 05545 return 0; 05546 }
| static int dahdi_write | ( | struct ast_channel * | ast, | |
| struct ast_frame * | frame | |||
| ) | [static] |
Definition at line 5062 of file chan_dahdi.c.
References AST_FORMAT_ALAW, AST_FORMAT_SLINEAR, AST_FORMAT_ULAW, AST_FRAME_IMAGE, AST_FRAME_VOICE, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), dahdi_pvt::channel, dahdi_pvt::cidspill, dahdi_get_index(), dahdi_setlinear(), ast_frame::data, ast_frame::datalen, dahdi_subchannel::dfd, dahdi_pvt::dialing, dahdi_pvt::digital, errno, ast_frame::frametype, dahdi_subchannel::linear, dahdi_pvt::lock, LOG_DEBUG, LOG_WARNING, my_dahdi_write(), ast_channel::name, option_debug, dahdi_pvt::outgoing, dahdi_pvt::owner, dahdi_pvt::sig, SIG_PRI, dahdi_pvt::span, ast_frame::subclass, dahdi_pvt::subs, and ast_channel::tech_pvt.
05063 { 05064 struct dahdi_pvt *p = ast->tech_pvt; 05065 int res; 05066 int index; 05067 index = dahdi_get_index(ast, p, 0); 05068 if (index < 0) { 05069 ast_log(LOG_WARNING, "%s doesn't really exist?\n", ast->name); 05070 return -1; 05071 } 05072 05073 #if 0 05074 #ifdef HAVE_PRI 05075 ast_mutex_lock(&p->lock); 05076 if (!p->proceeding && p->sig==SIG_PRI && p->pri && !p->outgoing) { 05077 if (p->pri->pri) { 05078 if (!pri_grab(p, p->pri)) { 05079 pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), !p->digital); 05080 pri_rel(p->pri); 05081 } else 05082 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span); 05083 } 05084 p->proceeding=1; 05085 } 05086 ast_mutex_unlock(&p->lock); 05087 #endif 05088 #endif 05089 /* Write a frame of (presumably voice) data */ 05090 if (frame->frametype != AST_FRAME_VOICE) { 05091 if (frame->frametype != AST_FRAME_IMAGE) 05092 ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype); 05093 return 0; 05094 } 05095 if ((frame->subclass != AST_FORMAT_SLINEAR) && 05096 (frame->subclass != AST_FORMAT_ULAW) && 05097 (frame->subclass != AST_FORMAT_ALAW)) { 05098 ast_log(LOG_WARNING, "Cannot handle frames in %d format\n", frame->subclass); 05099 return -1; 05100 } 05101 if (p->dialing) { 05102 if (option_debug) 05103 ast_log(LOG_DEBUG, "Dropping frame since I'm still dialing on %s...\n",ast->name); 05104 return 0; 05105 } 05106 if (!p->owner) { 05107 if (option_debug) 05108 ast_log(LOG_DEBUG, "Dropping frame since there is no active owner on %s...\n",ast->name); 05109 return 0; 05110 } 05111 if (p->cidspill) { 05112 if (option_debug) 05113 ast_log(LOG_DEBUG, "Dropping frame since I've still got a callerid spill\n"); 05114 return 0; 05115 } 05116 /* Return if it's not valid data */ 05117 if (!frame->data || !frame->datalen) 05118 return 0; 05119 05120 if (frame->subclass == AST_FORMAT_SLINEAR) { 05121 if (!p->subs[index].linear) { 05122 p->subs[index].linear = 1; 05123 res = dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear); 05124 if (res) 05125 ast_log(LOG_WARNING, "Unable to set linear mode on channel %d\n", p->channel); 05126 } 05127 res = my_dahdi_write(p, (unsigned char *)frame->data, frame->datalen, index, 1); 05128 } else { 05129 /* x-law already */ 05130 if (p->subs[index].linear) { 05131 p->subs[index].linear = 0; 05132 res = dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear); 05133 if (res) 05134 ast_log(LOG_WARNING, "Unable to set companded mode on channel %d\n", p->channel); 05135 } 05136 res = my_dahdi_write(p, (unsigned char *)frame->data, frame->datalen, index, 0); 05137 } 05138 if (res < 0) { 05139 ast_log(LOG_WARNING, "write failed: %s\n", strerror(errno)); 05140 return -1; 05141 } 05142 return 0; 05143 }
| static void destroy_all_channels | ( | void | ) | [static] |
Definition at line 2331 of file chan_dahdi.c.
References ast_free, ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), dahdi_pvt::channel, dahdi_pvt::cidspill, destroy_dahdi_pvt(), iflist, iflock, dahdi_pvt::next, option_verbose, and VERBOSE_PREFIX_2.
Referenced by __unload_module(), and dahdi_restart().
02332 { 02333 int x; 02334 struct dahdi_pvt *p, *pl; 02335 02336 while (num_restart_pending) { 02337 usleep(1); 02338 } 02339 02340 ast_mutex_lock(&iflock); 02341 /* Destroy all the interfaces and free their memory */ 02342 p = iflist; 02343 while (p) { 02344 /* Free any callerid */ 02345 if (p->cidspill) 02346 ast_free(p->cidspill); 02347 pl = p; 02348 p = p->next; 02349 x = pl->channel; 02350 /* Free associated memory */ 02351 if (pl) 02352 destroy_dahdi_pvt(&pl); 02353 if (option_verbose > 2) 02354 ast_verbose(VERBOSE_PREFIX_2 "Unregistered channel %d\n", x); 02355 } 02356 iflist = NULL; 02357 ifcount = 0; 02358 ast_mutex_unlock(&iflock); 02359 }
Definition at line 2281 of file chan_dahdi.c.
References destroy_dahdi_pvt(), iflist, dahdi_pvt::next, dahdi_subchannel::owner, dahdi_pvt::owner, dahdi_pvt::prev, and dahdi_pvt::subs.
Referenced by dahdi_destroy_channel_bynum(), and dahdi_hangup().
02282 { 02283 int owned = 0; 02284 int i = 0; 02285 02286 if (!now) { 02287 if (cur->owner) { 02288 owned = 1; 02289 } 02290 02291 for (i = 0; i < 3; i++) { 02292 if (cur->subs[i].owner) { 02293 owned = 1; 02294 } 02295 } 02296 if (!owned) { 02297 if (prev) { 02298 prev->next = cur->next; 02299 if (prev->next) 02300 prev->next->prev = prev; 02301 else 02302 ifend = prev; 02303 } else { 02304 iflist = cur->next; 02305 if (iflist) 02306 iflist->prev = NULL; 02307 else 02308 ifend = NULL; 02309 } 02310 destroy_dahdi_pvt(&cur); 02311 } 02312 } else { 02313 if (prev) { 02314 prev->next = cur->next; 02315 if (prev->next) 02316 prev->next->prev = prev; 02317 else 02318 ifend = prev; 02319 } else { 02320 iflist = cur->next; 02321 if (iflist) 02322 iflist->prev = NULL; 02323 else 02324 ifend = NULL; 02325 } 02326 destroy_dahdi_pvt(&cur); 02327 } 02328 return 0; 02329 }
| static void destroy_dahdi_pvt | ( | struct dahdi_pvt ** | pvt | ) | [static] |
Definition at line 2263 of file chan_dahdi.c.
References ast_mutex_destroy(), ast_smdi_interface_unref(), dahdi_close_sub(), free, dahdi_pvt::lock, dahdi_pvt::next, dahdi_pvt::owner, dahdi_pvt::prev, dahdi_pvt::smdi_iface, SUB_REAL, ast_channel::tech_pvt, and dahdi_pvt::use_smdi.
Referenced by chandup(), destroy_all_channels(), destroy_channel(), and mkintf().
02264 { 02265 struct dahdi_pvt *p = *pvt; 02266 /* Remove channel from the list */ 02267 if (p->prev) 02268 p->prev->next = p->next; 02269 if (p->next) 02270 p->next->prev = p->prev; 02271 if (p->use_smdi) 02272 ast_smdi_interface_unref(p->smdi_iface); 02273 ast_mutex_destroy(&p->lock); 02274 dahdi_close_sub(p, SUB_REAL); 02275 if (p->owner) 02276 p->owner->tech_pvt = NULL; 02277 free(p); 02278 *pvt = NULL; 02279 }
| static int digit_to_dtmfindex | ( | char | digit | ) | [static] |
Definition at line 1034 of file chan_dahdi.c.
Referenced by dahdi_digit_begin().
01035 { 01036 if (isdigit(digit)) 01037 return DAHDI_TONE_DTMF_BASE + (digit - '0'); 01038 else if (digit >= 'A' && digit <= 'D') 01039 return DAHDI_TONE_DTMF_A + (digit - 'A'); 01040 else if (digit >= 'a' && digit <= 'd') 01041 return DAHDI_TONE_DTMF_A + (digit - 'a'); 01042 else if (digit == '*') 01043 return DAHDI_TONE_DTMF_s; 01044 else if (digit == '#') 01045 return DAHDI_TONE_DTMF_p; 01046 else 01047 return -1; 01048 }
| static void disable_dtmf_detect | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 3207 of file chan_dahdi.c.
References ast_dsp_set_features(), dahdi_subchannel::dfd, dahdi_pvt::dsp, DSP_FEATURE_DTMF_DETECT, dahdi_pvt::dsp_features, dahdi_pvt::hardwaredtmf, dahdi_pvt::ignoredtmf, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_bridge().
03208 { 03209 #ifdef DAHDI_TONEDETECT 03210 int val; 03211 #endif 03212 03213 p->ignoredtmf = 1; 03214 03215 #ifdef DAHDI_TONEDETECT 03216 val = 0; 03217 ioctl(p->subs[SUB_REAL].dfd, DAHDI_TONEDETECT, &val); 03218 #endif 03219 if (!p->hardwaredtmf && p->dsp) { 03220 p->dsp_features &= ~DSP_FEATURE_DTMF_DETECT; 03221 ast_dsp_set_features(p->dsp, p->dsp_features); 03222 } 03223 }
| static void* do_monitor | ( | void * | data | ) | [static] |
Definition at line 6936 of file chan_dahdi.c.
References ast_app_has_voicemail(), ast_calloc, ast_fdisset(), AST_LAW, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), dahdi_pvt::channel, dahdi_pvt::cidlen, dahdi_pvt::cidpos, dahdi_pvt::cidspill, dahdi_get_event(), dahdi_subchannel::dfd, errno, event2str(), pollfd::events, pollfd::fd, free, handle_init_event(), iflist, iflock, last, LOG_DEBUG, LOG_WARNING, dahdi_pvt::mailbox, MAX_CALLERID_SIZE, dahdi_pvt::msgstate, dahdi_pvt::next, dahdi_pvt::onhooktime, option_debug, dahdi_subchannel::owner, dahdi_pvt::owner, poll(), POLLIN, POLLPRI, dahdi_pvt::radio, pollfd::revents, dahdi_pvt::sig, SUB_REAL, dahdi_pvt::subs, and vmwi_generate().
Referenced by restart_monitor().
06937 { 06938 int count, res, res2, spoint, pollres=0; 06939 struct dahdi_pvt *i; 06940 struct dahdi_pvt *last = NULL; 06941 time_t thispass = 0, lastpass = 0; 06942 int found; 06943 char buf[1024]; 06944 struct pollfd *pfds=NULL; 06945 int lastalloc = -1; 06946 /* This thread monitors all the frame relay interfaces which are not yet in use 06947 (and thus do not have a separate thread) indefinitely */ 06948 /* From here on out, we die whenever asked */ 06949 #if 0 06950 if (pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL)) { 06951 ast_log(LOG_WARNING, "Unable to set cancel type to asynchronous\n"); 06952 return NULL; 06953 } 06954 ast_log(LOG_DEBUG, "Monitor starting...\n"); 06955 #endif 06956 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 06957 06958 for (;;) { 06959 /* Lock the interface list */ 06960 ast_mutex_lock(&iflock); 06961 if (!pfds || (lastalloc != ifcount)) { 06962 if (pfds) { 06963 free(pfds); 06964 pfds = NULL; 06965 } 06966 if (ifcount) { 06967 if (!(pfds = ast_calloc(1, ifcount * sizeof(*pfds)))) { 06968 ast_mutex_unlock(&iflock); 06969 return NULL; 06970 } 06971 } 06972 lastalloc = ifcount; 06973 } 06974 /* Build the stuff we're going to poll on, that is the socket of every 06975 dahdi_pvt that does not have an associated owner channel */ 06976 count = 0; 06977 i = iflist; 06978 while (i) { 06979 if ((i->subs[SUB_REAL].dfd > -1) && i->sig && (!i->radio)) { 06980 if (!i->owner && !i->subs[SUB_REAL].owner) { 06981 /* This needs to be watched, as it lacks an owner */ 06982 pfds[count].fd = i->subs[SUB_REAL].dfd; 06983 pfds[count].events = POLLPRI; 06984 pfds[count].revents = 0; 06985 /* Message waiting or r2 channels also get watched for reading */ 06986 if (i->cidspill) 06987 pfds[count].events |= POLLIN; 06988 count++; 06989 } 06990 } 06991 i = i->next; 06992 } 06993 /* Okay, now that we know what to do, release the interface lock */ 06994 ast_mutex_unlock(&iflock); 06995 06996 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); 06997 pthread_testcancel(); 06998 /* Wait at least a second for something to happen */ 06999 res = poll(pfds, count, 1000); 07000 pthread_testcancel(); 07001 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 07002 07003 /* Okay, poll has finished. Let's see what happened. */ 07004 if (res < 0) { 07005 if ((errno != EAGAIN) && (errno != EINTR)) 07006 ast_log(LOG_WARNING, "poll return %d: %s\n", res, strerror(errno)); 07007 continue; 07008 } 07009 /* Alright, lock the interface list again, and let's look and see what has 07010 happened */ 07011 ast_mutex_lock(&iflock); 07012 found = 0; 07013 spoint = 0; 07014 lastpass = thispass; 07015 thispass = time(NULL); 07016 i = iflist; 07017 while (i) { 07018 if (thispass != lastpass) { 07019 if (!found && ((i == last) || ((i == iflist) && !last))) { 07020 last = i; 07021 if (last) { 07022 if (!last->cidspill && !last->owner && !ast_strlen_zero(last->mailbox) && (thispass - last->onhooktime > 3) && 07023 (last->sig & __DAHDI_SIG_FXO)) { 07024 res = ast_app_has_voicemail(last->mailbox, NULL); 07025 if (last->msgstate != res) { 07026 int x; 07027 ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel); 07028 x = DAHDI_FLUSH_BOTH; 07029 res2 = ioctl(last->subs[SUB_REAL].dfd, DAHDI_FLUSH, &x); 07030 if (res2) 07031 ast_log(LOG_WARNING, "Unable to flush input on channel %d: %s\n", last->channel, strerror(errno)); 07032 if ((last->cidspill = ast_calloc(1, MAX_CALLERID_SIZE))) { 07033 /* Turn on on hook transfer for 4 seconds */ 07034 x = 4000; 07035 ioctl(last->subs[SUB_REAL].dfd, DAHDI_ONHOOKTRANSFER, &x); 07036 last->cidlen = vmwi_generate(last->cidspill, res, 1, AST_LAW(last)); 07037 last->cidpos = 0; 07038 last->msgstate = res; 07039 last->onhooktime = thispass; 07040 } 07041 found ++; 07042 } 07043 } 07044 last = last->next; 07045 } 07046 } 07047 } 07048 if ((i->subs[SUB_REAL].dfd > -1) && i->sig) { 07049 if (i->radio && !i->owner) 07050 { 07051 res = dahdi_get_event(i->subs[SUB_REAL].dfd); 07052 if (res) 07053 { 07054 if (option_debug) 07055 ast_log(LOG_DEBUG, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel); 07056 /* Don't hold iflock while handling init events */ 07057 ast_mutex_unlock(&iflock); 07058 handle_init_event(i, res); 07059 ast_mutex_lock(&iflock); 07060 } 07061 i = i->next; 07062 continue; 07063 } 07064 pollres = ast_fdisset(pfds, i->subs[SUB_REAL].dfd, count, &spoint); 07065 if (pollres & POLLIN) { 07066 if (i->owner || i->subs[SUB_REAL].owner) { 07067 #ifdef HAVE_PRI 07068 if (!i->pri) 07069 #endif 07070 ast_log(LOG_WARNING, "Whoa.... I'm owned but found (%d) in read...\n", i->subs[SUB_REAL].dfd); 07071 i = i->next; 07072 continue; 07073 } 07074 if (!i->cidspill) { 07075 ast_log(LOG_WARNING, "Whoa.... I'm reading but have no cidspill (%d)...\n", i->subs[SUB_REAL].dfd); 07076 i = i->next; 07077 continue; 07078 } 07079 res = read(i->subs[SUB_REAL].dfd, buf, sizeof(buf)); 07080 if (res > 0) { 07081 /* We read some number of bytes. Write an equal amount of data */ 07082 if (res > i->cidlen - i->cidpos) 07083 res = i->cidlen - i->cidpos; 07084 res2 = write(i->subs[SUB_REAL].dfd, i->cidspill + i->cidpos, res); 07085 if (res2 > 0) { 07086 i->cidpos += res2; 07087 if (i->cidpos >= i->cidlen) { 07088 free(i->cidspill); 07089 i->cidspill = 0; 07090 i->cidpos = 0; 07091 i->cidlen = 0; 07092 } 07093 } else { 07094 ast_log(LOG_WARNING, "Write failed: %s\n", strerror(errno)); 07095 i->msgstate = -1; 07096 } 07097 } else { 07098 ast_log(LOG_WARNING, "Read failed with %d: %s\n", res, strerror(errno)); 07099 } 07100 } 07101 if (pollres & POLLPRI) { 07102 if (i->owner || i->subs[SUB_REAL].owner) { 07103 #ifdef HAVE_PRI 07104 if (!i->pri) 07105 #endif 07106 ast_log(LOG_WARNING, "Whoa.... I'm owned but found (%d)...\n", i->subs[SUB_REAL].dfd); 07107 i = i->next; 07108 continue; 07109 } 07110 res = dahdi_get_event(i->subs[SUB_REAL].dfd); 07111 if (option_debug) 07112 ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel); 07113 /* Don't hold iflock while handling init events */ 07114 ast_mutex_unlock(&iflock); 07115 handle_init_event(i, res); 07116 ast_mutex_lock(&iflock); 07117 } 07118 } 07119 i=i->next; 07120 } 07121 ast_mutex_unlock(&iflock); 07122 } 07123 /* Never reached */ 07124 return NULL; 07125 07126 }
| static void enable_dtmf_detect | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 3225 of file chan_dahdi.c.
References ast_dsp_set_features(), CHAN_PSEUDO, dahdi_pvt::channel, dahdi_subchannel::dfd, dahdi_pvt::dsp, DSP_FEATURE_DTMF_DETECT, dahdi_pvt::dsp_features, dahdi_pvt::hardwaredtmf, dahdi_pvt::ignoredtmf, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_bridge().
03226 { 03227 #ifdef DAHDI_TONEDETECT 03228 int val; 03229 #endif 03230 03231 if (p->channel == CHAN_PSEUDO) 03232 return; 03233 03234 p->ignoredtmf = 0; 03235 03236 #ifdef DAHDI_TONEDETECT 03237 val = DAHDI_TONEDETECT_ON | DAHDI_TONEDETECT_MUTE; 03238 ioctl(p->subs[SUB_REAL].dfd, DAHDI_TONEDETECT, &val); 03239 #endif 03240 if (!p->hardwaredtmf && p->dsp) { 03241 p->dsp_features |= DSP_FEATURE_DTMF_DETECT; 03242 ast_dsp_set_features(p->dsp, p->dsp_features); 03243 } 03244 }
| static char* event2str | ( | int | event | ) | [static] |
Definition at line 1191 of file chan_dahdi.c.
Referenced by __dahdi_exception(), dahdi_handle_event(), do_monitor(), and ss_thread().
01192 { 01193 static char buf[256]; 01194 if ((event < (sizeof(events) / sizeof(events[0]))) && (event > -1)) 01195 return events[event]; 01196 sprintf(buf, "Event %d", event); /* safe */ 01197 return buf; 01198 }
| static void fill_rxgain | ( | struct dahdi_gains * | g, | |
| float | gain, | |||
| int | law | |||
| ) | [static] |
Definition at line 1556 of file chan_dahdi.c.
References AST_ALAW, AST_LIN2A, AST_LIN2MU, and AST_MULAW.
Referenced by set_actual_rxgain().
01557 { 01558 int j; 01559 int k; 01560 float linear_gain = pow(10.0, gain / 20.0); 01561 01562 switch (law) { 01563 case DAHDI_LAW_ALAW: 01564 for (j = 0; j < (sizeof(g->rxgain) / sizeof(g->rxgain[0])); j++) { 01565 if (gain) { 01566 k = (int) (((float) AST_ALAW(j)) * linear_gain); 01567 if (k > 32767) k = 32767; 01568 if (k < -32767) k = -32767; 01569 g->rxgain[j] = AST_LIN2A(k); 01570 } else { 01571 g->rxgain[j] = j; 01572 } 01573 } 01574 break; 01575 case DAHDI_LAW_MULAW: 01576 for (j = 0; j < (sizeof(g->rxgain) / sizeof(g->rxgain[0])); j++) { 01577 if (gain) { 01578 k = (int) (((float) AST_MULAW(j)) * linear_gain); 01579 if (k > 32767) k = 32767; 01580 if (k < -32767) k = -32767; 01581 g->rxgain[j] = AST_LIN2MU(k); 01582 } else { 01583 g->rxgain[j] = j; 01584 } 01585 } 01586 break; 01587 } 01588 }
| static void fill_txgain | ( | struct dahdi_gains * | g, | |
| float | gain, | |||
| int | law | |||
| ) | [static] |
Definition at line 1522 of file chan_dahdi.c.
References AST_ALAW, AST_LIN2A, AST_LIN2MU, and AST_MULAW.
Referenced by set_actual_txgain().
01523 { 01524 int j; 01525 int k; 01526 float linear_gain = pow(10.0, gain / 20.0); 01527 01528 switch (law) { 01529 case DAHDI_LAW_ALAW: 01530 for (j = 0; j < (sizeof(g->txgain) / sizeof(g->txgain[0])); j++) { 01531 if (gain) { 01532 k = (int) (((float) AST_ALAW(j)) * linear_gain); 01533 if (k > 32767) k = 32767; 01534 if (k < -32767) k = -32767; 01535 g->txgain[j] = AST_LIN2A(k); 01536 } else { 01537 g->txgain[j] = j; 01538 } 01539 } 01540 break; 01541 case DAHDI_LAW_MULAW: 01542 for (j = 0; j < (sizeof(g->txgain) / sizeof(g->txgain[0])); j++) { 01543 if (gain) { 01544 k = (int) (((float) AST_MULAW(j)) * linear_gain); 01545 if (k > 32767) k = 32767; 01546 if (k < -32767) k = -32767; 01547 g->txgain[j] = AST_LIN2MU(k); 01548 } else { 01549 g->txgain[j] = j; 01550 } 01551 } 01552 break; 01553 } 01554 }
| static struct dahdi_pvt* find_channel | ( | int | channel | ) | [static, read] |
Definition at line 10575 of file chan_dahdi.c.
References dahdi_pvt::channel, iflist, and dahdi_pvt::next.
Referenced by __action_dialoffhook(), __action_dnd(), __action_transfer(), and __action_transferhangup().
10576 { 10577 struct dahdi_pvt *p = iflist; 10578 while (p) { 10579 if (p->channel == channel) { 10580 break; 10581 } 10582 p = p->next; 10583 } 10584 return p; 10585 }
| static int get_alarms | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 3667 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, dahdi_subchannel::dfd, errno, LOG_WARNING, dahdi_pvt::span, SUB_REAL, and dahdi_pvt::subs.
Referenced by __action_showchannels(), dahdi_handle_event(), handle_init_event(), and mkintf().
03668 { 03669 int res; 03670 struct dahdi_spaninfo zi; 03671 #if !defined(HAVE_ZAPTEL) || defined(HAVE_ZAPTEL_CHANALARMS) 03672 /* 03673 * The conditional compilation is needed only in asterisk-1.4 for 03674 * backward compatibility with old zaptel drivers that don't have 03675 * a DAHDI_PARAMS.chan_alarms field. 03676 */ 03677 struct dahdi_params params; 03678 #endif 03679 03680 memset(&zi, 0, sizeof(zi)); 03681 zi.spanno = p->span; 03682 03683 /* First check for span alarms */ 03684 if((res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SPANSTAT, &zi)) < 0) { 03685 ast_log(LOG_WARNING, "Unable to determine alarm on channel %d: %s\n", p->channel, strerror(errno)); 03686 return 0; 03687 } 03688 if (zi.alarms != DAHDI_ALARM_NONE) 03689 return zi.alarms; 03690 #if !defined(HAVE_ZAPTEL) || defined(HAVE_ZAPTEL_CHANALARMS) 03691 /* No alarms on the span. Check for channel alarms. */ 03692 if ((res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, ¶ms)) >= 0) 03693 return params.chan_alarms; 03694 /* ioctl failed */ 03695 ast_log(LOG_WARNING, "Unable to determine alarm on channel %d\n", p->channel); 03696 #endif 03697 return DAHDI_ALARM_NONE; 03698 }
| static void handle_alarms | ( | struct dahdi_pvt * | p, | |
| int | alarms | |||
| ) | [static] |
Definition at line 3771 of file chan_dahdi.c.
References alarm2str(), ast_log(), dahdi_pvt::channel, EVENT_FLAG_SYSTEM, LOG_WARNING, manager_event(), and dahdi_pvt::unknown_alarm.
Referenced by dahdi_handle_event(), handle_init_event(), and mkintf().
03772 { 03773 const char *alarm_str = alarm2str(alarms); 03774 03775 /* hack alert! Zaptel 1.4 and DAHDI expose FXO battery as an alarm, but this code 03776 * doesn't know what to do with it. Don't confuse users with log messages. */ 03777 if (!strcasecmp(alarm_str, "No Alarm") || !strcasecmp(alarm_str, "Unknown Alarm")) { 03778 p->unknown_alarm = 1; 03779 return; 03780 } else { 03781 p->unknown_alarm = 0; 03782 } 03783 03784 ast_log(LOG_WARNING, "Detected alarm on channel %d: %s\n", p->channel, alarm_str); 03785 manager_event(EVENT_FLAG_SYSTEM, "Alarm", 03786 "Alarm: %s\r\n" 03787 "Channel: %d\r\n", 03788 alarm_str, p->channel); 03789 }
| static int handle_dahdi_show_cadences | ( | int | fd, | |
| int | argc, | |||
| char * | argv[] | |||
| ) | [static] |
Definition at line 10382 of file chan_dahdi.c.
References ast_cli(), COLOR_BLACK, COLOR_GREEN, COLOR_MAGENTA, and term_color().
10383 { 10384 int i, j; 10385 for (i = 0; i < num_cadence; i++) { 10386 char output[1024]; 10387 char tmp[16], tmp2[64]; 10388 snprintf(tmp, sizeof(tmp), "r%d: ", i + 1); 10389 term_color(output, tmp, COLOR_GREEN, COLOR_BLACK, sizeof(output)); 10390 10391 for (j = 0; j < 16; j++) { 10392 if (cadences[i].ringcadence[j] == 0) 10393 break; 10394 snprintf(tmp, sizeof(tmp), "%d", cadences[i].ringcadence[j]); 10395 if (cidrings[i] * 2 - 1 == j) 10396 term_color(tmp2, tmp, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp2) - 1); 10397 else 10398 term_color(tmp2, tmp, COLOR_GREEN, COLOR_BLACK, sizeof(tmp2) - 1); 10399 if (j != 0) 10400 strncat(output, ",", sizeof(output) - strlen(output) - 1); 10401 strncat(output, tmp2, sizeof(output) - strlen(output) - 1); 10402 } 10403 ast_cli(fd,"%s\n",output); 10404 } 10405 return 0; 10406 }
| static int handle_init_event | ( | struct dahdi_pvt * | i, | |
| int | event | |||
| ) | [static] |
Definition at line 6728 of file chan_dahdi.c.
References ast_hangup(), ast_log(), ast_pthread_create, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, ast_verbose(), dahdi_pvt::channel, dahdi_pvt::cid_start, CID_START_POLARITY, dahdi_pvt::cidspill, dahdi_destroy_channel_bynum(), dahdi_disable_ec(), dahdi_enable_ec(), dahdi_new(), dahdi_set_hook(), dahdi_subchannel::dfd, errno, EVENT_FLAG_SYSTEM, free, get_alarms(), handle_alarms(), dahdi_pvt::hanguponpolarityswitch, has_voicemail(), dahdi_pvt::immediate, dahdi_pvt::inalarm, LOG_NOTICE, LOG_WARNING, manager_event(), dahdi_pvt::polarity, POLARITY_REV, dahdi_pvt::radio, dahdi_pvt::ringt, dahdi_pvt::ringt_base, dahdi_pvt::sig, sig2str, SIG_E911, SIG_EM, SIG_EM_E1, SIG_EMWINK, SIG_FEATB, SIG_FEATD, SIG_FEATDMF, SIG_FEATDMF_TA, SIG_FGC_CAMA, SIG_FGC_CAMAMF, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_GR303FXOKS, SIG_GR303FXSKS, SIG_PRI, SIG_SF, SIG_SF_FEATB, SIG_SF_FEATD, SIG_SF_FEATDMF, SIG_SFWINK, ss_thread(), SUB_REAL, dahdi_pvt::subs, dahdi_pvt::unknown_alarm, and VERBOSE_PREFIX_2.
Referenced by do_monitor().
06729 { 06730 int res; 06731 pthread_t threadid; 06732 pthread_attr_t attr; 06733 struct ast_channel *chan; 06734 pthread_attr_init(&attr); 06735 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 06736 /* Handle an event on a given channel for the monitor thread. */ 06737 switch (event) { 06738 case DAHDI_EVENT_NONE: 06739 case DAHDI_EVENT_BITSCHANGED: 06740 break; 06741 case DAHDI_EVENT_WINKFLASH: 06742 case DAHDI_EVENT_RINGOFFHOOK: 06743 if (i->inalarm) break; 06744 if (i->radio) break; 06745 /* Got a ring/answer. What kind of channel are we? */ 06746 switch (i->sig) { 06747 case SIG_FXOLS: 06748 case SIG_FXOGS: 06749 case SIG_FXOKS: 06750 res = dahdi_set_hook(i->subs[SUB_REAL].dfd, DAHDI_OFFHOOK); 06751 if (res && (errno == EBUSY)) 06752 break; 06753 if (i->cidspill) { 06754 /* Cancel VMWI spill */ 06755 free(i->cidspill); 06756 i->cidspill = NULL; 06757 } 06758 if (i->immediate) { 06759 dahdi_enable_ec(i); 06760 /* The channel is immediately up. Start right away */ 06761 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, DAHDI_TONE_RINGTONE); 06762 chan = dahdi_new(i, AST_STATE_RING, 1, SUB_REAL, 0, 0); 06763 if (!chan) { 06764 ast_log(LOG_WARNING, "Unable to start PBX on channel %d\n", i->channel); 06765 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, DAHDI_TONE_CONGESTION); 06766 if (res < 0) 06767 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel); 06768 } 06769 } else { 06770 /* Check for callerid, digits, etc */ 06771 chan = dahdi_new(i, AST_STATE_RESERVED, 0, SUB_REAL, 0, 0); 06772 if (chan) { 06773 if (has_voicemail(i)) 06774 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, DAHDI_TONE_STUTTER); 06775 else 06776 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, DAHDI_TONE_DIALTONE); 06777 if (res < 0) 06778 ast_log(LOG_WARNING, "Unable to play dialtone on channel %d, do you have defaultzone and loadzone defined?\n", i->channel); 06779 if (ast_pthread_create(&threadid, &attr, ss_thread, chan)) { 06780 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel); 06781 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, DAHDI_TONE_CONGESTION); 06782 if (res < 0) 06783 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel); 06784 ast_hangup(chan); 06785 } 06786 } else 06787 ast_log(LOG_WARNING, "Unable to create channel\n"); 06788 } 06789 break; 06790 case SIG_FXSLS: 06791 case SIG_FXSGS: 06792 case SIG_FXSKS: 06793 i->ringt = i->ringt_base; 06794 /* Fall through */ 06795 case SIG_EMWINK: 06796 case SIG_FEATD: 06797 case SIG_FEATDMF: 06798 case SIG_FEATDMF_TA: 06799 case SIG_E911: 06800 case SIG_FGC_CAMA: 06801 case SIG_FGC_CAMAMF: 06802 case SIG_FEATB: 06803 case SIG_EM: 06804 case SIG_EM_E1: 06805 case SIG_SFWINK: 06806 case SIG_SF_FEATD: 06807 case SIG_SF_FEATDMF: 06808 case SIG_SF_FEATB: 06809 case SIG_SF: 06810 /* Check for callerid, digits, etc */ 06811 chan = dahdi_new(i, AST_STATE_RING, 0, SUB_REAL, 0, 0); 06812 if (chan && ast_pthread_create(&threadid, &attr, ss_thread, chan)) { 06813 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel); 06814 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, DAHDI_TONE_CONGESTION); 06815 if (res < 0) 06816 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel); 06817 ast_hangup(chan); 06818 } else if (!chan) { 06819 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel); 06820 } 06821 break; 06822 default: 06823 ast_log(LOG_WARNING, "Don't know how to handle ring/answer with signalling %s on channel %d\n", sig2str(i->sig), i->channel); 06824 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, DAHDI_TONE_CONGESTION); 06825 if (res < 0) 06826 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel); 06827 return -1; 06828 } 06829 break; 06830 case DAHDI_EVENT_NOALARM: 06831 i->inalarm = 0; 06832 if (!i->unknown_alarm) { 06833 ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel); 06834 manager_event(EVENT_FLAG_SYSTEM, "AlarmClear", 06835 "Channel: %d\r\n", i->channel); 06836 } else { 06837 i->unknown_alarm = 0; 06838 } 06839 break; 06840 case DAHDI_EVENT_ALARM: 06841 i->inalarm = 1; 06842 res = get_alarms(i); 06843 handle_alarms(i, res); 06844 /* fall thru intentionally */ 06845 case DAHDI_EVENT_ONHOOK: 06846 if (i->radio) 06847 break; 06848 /* Back on hook. Hang up. */ 06849 switch (i->sig) { 06850 case SIG_FXOLS: 06851 case SIG_FXOGS: 06852 case SIG_FEATD: 06853 case SIG_FEATDMF: 06854 case SIG_FEATDMF_TA: 06855 case SIG_E911: 06856 case SIG_FGC_CAMA: 06857 case SIG_FGC_CAMAMF: 06858 case SIG_FEATB: 06859 case SIG_EM: 06860 case SIG_EM_E1: 06861 case SIG_EMWINK: 06862 case SIG_SF_FEATD: 06863 case SIG_SF_FEATDMF: 06864 case SIG_SF_FEATB: 06865 case SIG_SF: 06866 case SIG_SFWINK: 06867 case SIG_FXSLS: 06868 case SIG_FXSGS: 06869 case SIG_FXSKS: 06870 case SIG_GR303FXSKS: 06871 dahdi_disable_ec(i); 06872 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, -1); 06873 dahdi_set_hook(i->subs[SUB_REAL].dfd, DAHDI_ONHOOK); 06874 break; 06875 case SIG_GR303FXOKS: 06876 case SIG_FXOKS: 06877 dahdi_disable_ec(i); 06878 /* Diddle the battery for the zhone */ 06879 #ifdef ZHONE_HACK 06880 dahdi_set_hook(i->subs[SUB_REAL].dfd, DAHDI_OFFHOOK); 06881 usleep(1); 06882 #endif 06883 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, -1); 06884 dahdi_set_hook(i->subs[SUB_REAL].dfd, DAHDI_ONHOOK); 06885 break; 06886 case SIG_PRI: 06887 dahdi_disable_ec(i); 06888 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, -1); 06889 break; 06890 default: 06891 ast_log(LOG_WARNING, "Don't know how to handle on hook with signalling %s on channel %d\n", sig2str(i->sig), i->channel); 06892 res = tone_zone_play_tone(i->subs[SUB_REAL].dfd, -1); 06893 return -1; 06894 } 06895 break; 06896 case DAHDI_EVENT_POLARITY: 06897 switch (i->sig) { 06898 case SIG_FXSLS: 06899 case SIG_FXSKS: 06900 case SIG_FXSGS: 06901 /* We have already got a PR before the channel was 06902 created, but it wasn't handled. We need polarity 06903 to be REV for remote hangup detection to work. 06904 At least in Spain */ 06905 if (i->hanguponpolarityswitch) 06906 i->polarity = POLARITY_REV; 06907 06908 if (i->cid_start == CID_START_POLARITY) { 06909 i->polarity = POLARITY_REV; 06910 ast_verbose(VERBOSE_PREFIX_2 "Starting post polarity " 06911 "CID detection on channel %d\n", 06912 i->channel); 06913 chan = dahdi_new(i, AST_STATE_PRERING, 0, SUB_REAL, 0, 0); 06914 if (chan && ast_pthread_create(&threadid, &attr, ss_thread, chan)) { 06915 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel); 06916 } 06917 } 06918 break; 06919 default: 06920 ast_log(LOG_WARNING, "handle_init_event detected " 06921 "polarity reversal on non-FXO (SIG_FXS) " 06922 "interface %d\n", i->channel); 06923 } 06924 break; 06925 case DAHDI_EVENT_REMOVED: /* destroy channel */ 06926 ast_log(LOG_NOTICE, 06927 "Got DAHDI_EVENT_REMOVED. Destroying channel %d\n", 06928 i->channel); 06929 dahdi_destroy_channel_bynum(i->channel); 06930 break; 06931 } 06932 pthread_attr_destroy(&attr); 06933 return 0; 06934 }
| static int has_voicemail | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1754 of file chan_dahdi.c.
References ast_app_has_voicemail(), and dahdi_pvt::mailbox.
Referenced by dahdi_handle_event(), and handle_init_event().
01755 { 01756 01757 return ast_app_has_voicemail(p->mailbox, NULL); 01758 }
| static int isourconf | ( | struct dahdi_pvt * | p, | |
| struct dahdi_subchannel * | c | |||
| ) | [static] |
Definition at line 1310 of file chan_dahdi.c.
References dahdi_pvt::channel, dahdi_pvt::confno, and dahdi_subchannel::curconf.
Referenced by conf_del().
01311 { 01312 /* If they're listening to our channel, they're ours */ 01313 if ((p->channel == c->curconf.confno) && (c->curconf.confmode == DAHDI_CONF_DIGITALMON)) 01314 return 1; 01315 /* If they're a talker on our (allocated) conference, they're ours */ 01316 if ((p->confno > 0) && (p->confno == c->curconf.confno) && (c->curconf.confmode & DAHDI_CONF_TALKER)) 01317 return 1; 01318 return 0; 01319 }
Definition at line 1343 of file chan_dahdi.c.
References dahdi_subchannel::dfd, dahdi_subchannel::inthreeway, dahdi_pvt::law, MAX_SLAVES, dahdi_pvt::slaves, and dahdi_pvt::subs.
Referenced by update_conf().
01344 { 01345 int x; 01346 int useslavenative; 01347 struct dahdi_pvt *slave = NULL; 01348 /* Start out optimistic */ 01349 useslavenative = 1; 01350 /* Update conference state in a stateless fashion */ 01351 for (x = 0; x < 3; x++) { 01352 /* Any three-way calling makes slave native mode *definitely* out 01353 of the question */ 01354 if ((p->subs[x].dfd > -1) && p->subs[x].inthreeway) 01355 useslavenative = 0; 01356 } 01357 /* If we don't have any 3-way calls, check to see if we have 01358 precisely one slave */ 01359 if (useslavenative) { 01360 for (x = 0; x < MAX_SLAVES; x++) { 01361 if (p->slaves[x]) { 01362 if (slave) { 01363 /* Whoops already have a slave! No 01364 slave native and stop right away */ 01365 slave = NULL; 01366 useslavenative = 0; 01367 break; 01368 } else { 01369 /* We have one slave so far */ 01370 slave = p->slaves[x]; 01371 } 01372 } 01373 } 01374 } 01375 /* If no slave, slave native definitely out */ 01376 if (!slave) 01377 useslavenative = 0; 01378 else if (slave->law != p->law) { 01379 useslavenative = 0; 01380 slave = NULL; 01381 } 01382 if (out) 01383 *out = slave; 01384 return useslavenative; 01385 }
| static int load_module | ( | void | ) | [static] |
Definition at line 11827 of file chan_dahdi.c.
References __unload_module(), ast_channel_register(), ast_cli_register_multiple(), ast_cond_init(), ast_log(), AST_MODULE_LOAD_DECLINE, ast_mutex_init(), AST_PTHREADT_NULL, ast_register_application(), ast_string_field_init, ast_string_field_set, CHAN_DAHDI_PLUS_ZAP_MODE, dahdi_chan_mode, inuse, local_astman_register, lock, LOG_ERROR, name, setup_dahdi(), and ast_channel_tech::type.
11828 { 11829 int res; 11830 11831 #ifdef HAVE_PRI 11832 int y,i; 11833 memset(pris, 0, sizeof(pris)); 11834 for (y = 0; y < NUM_SPANS; y++) { 11835 ast_mutex_init(&pris[y].lock); 11836 pris[y].offset = -1; 11837 pris[y].master = AST_PTHREADT_NULL; 11838 for (i = 0; i < NUM_DCHANS; i++) 11839 pris[y].fds[i] = -1; 11840 } 11841 pri_set_error(dahdi_pri_error); 11842 pri_set_message(dahdi_pri_message); 11843 if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { 11844 ast_register_application(dahdi_send_keypad_facility_app, dahdi_send_keypad_facility_exec, 11845 dahdi_send_keypad_facility_synopsis, dahdi_send_keypad_facility_descrip); 11846 } 11847 ast_register_application(zap_send_keypad_facility_app, zap_send_keypad_facility_exec, 11848 zap_send_keypad_facility_synopsis, zap_send_keypad_facility_descrip); 11849 #endif 11850 if ((res = setup_dahdi(0))) { 11851 return AST_MODULE_LOAD_DECLINE; 11852 } 11853 if (*dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { 11854 chan_tech = &dahdi_tech; 11855 } else { 11856 chan_tech = &zap_tech; 11857 } 11858 if (ast_channel_register(chan_tech)) { 11859 ast_log(LOG_ERROR, "Unable to register channel class '%s'\n", chan_tech->type); 11860 __unload_module(); 11861 return -1; 11862 } 11863 #ifdef HAVE_PRI 11864 ast_string_field_init(&inuse, 16); 11865 ast_string_field_set(&inuse, name, "GR-303InUse"); 11866 ast_cli_register_multiple(dahdi_pri_cli, sizeof(dahdi_pri_cli) / sizeof(struct ast_cli_entry)); 11867 #endif 11868 ast_cli_register_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry)); 11869 11870 memset(round_robin, 0, sizeof(round_robin)); 11871 local_astman_register("Transfer", 0, action_transfer, "Transfer Channel"); 11872 local_astman_register("Hangup", 0, action_transferhangup, "Hangup Channel"); 11873 local_astman_register("DialOffHook", 0, action_dialoffhook, "Dial over channel while offhook"); 11874 local_astman_register("DNDon", 0, action_dndon, "Toggle channel Do Not Disturb status ON"); 11875 local_astman_register("DNDoff", 0, action_dndoff, "Toggle channel Do Not Disturb status OFF"); 11876 local_astman_register("ShowChannels", 0, action_showchannels, "Show status channels"); 11877 local_astman_register("Restart", 0, action_restart, "Fully Restart channels (terminates calls)"); 11878 11879 ast_cond_init(&ss_thread_complete, NULL); 11880 11881 return res; 11882 }
| static struct dahdi_pvt* mkintf | ( | int | channel, | |
| const struct dahdi_chan_conf * | conf, | |||
| struct dahdi_pri * | pri, | |||
| int | reloading | |||
| ) | [static, read] |
Definition at line 7286 of file chan_dahdi.c.
References dahdi_pvt::accountcode, dahdi_pvt::adsi, dahdi_pvt::amaflags, dahdi_pvt::answeronpolarityswitch, ast_calloc, ast_copy_string(), ast_dsp_digitmode(), ast_log(), ast_mutex_init(), ast_smdi_interface_find(), ast_strlen_zero(), dahdi_pvt::buf_no, dahdi_pvt::buf_policy, dahdi_pvt::busy_quietlength, dahdi_pvt::busy_tonelength, dahdi_pvt::busycount, dahdi_pvt::busydetect, dahdi_pvt::callgroup, dahdi_pvt::callprogress, dahdi_pvt::callreturn, dahdi_pvt::callwaiting, dahdi_pvt::callwaitingcallerid, dahdi_pvt::cancallforward, dahdi_pvt::canpark, dahdi_chan_conf::chan, CHAN_PSEUDO, dahdi_pvt::channel, dahdi_pvt::cid_name, dahdi_pvt::cid_num, CID_SIG_SMDI, dahdi_pvt::cid_signalling, dahdi_pvt::cid_start, dahdi_pvt::cid_ton, dahdi_pvt::confno, dahdi_pvt::context, dahdi_open(), dahdi_set_hook(), dahdi_pvt::dahditrcallerid, dahdi_pvt::defcontext, dahdi_pvt::destroy, destroy_dahdi_pvt(), dahdi_subchannel::dfd, drings, dahdi_pvt::drings, dahdi_pvt::dsp, DSP_DIGITMODE_DTMF, dahdi_pvt::dtmfrelax, dahdi_pvt::echocanbridged, dahdi_pvt::echocancel, dahdi_pvt::echotraining, errno, dahdi_pvt::firstradio, free, get_alarms(), dahdi_pvt::group, handle_alarms(), dahdi_pvt::hanguponpolarityswitch, dahdi_pvt::hidecallerid, iflist, dahdi_pvt::immediate, dahdi_pvt::inalarm, dahdi_pvt::language, dahdi_pvt::law, dahdi_pvt::lock, LOG_ERROR, LOG_NOTICE, LOG_WARNING, dahdi_pvt::mailbox, MAX_CHANNELS, dahdi_pvt::mohinterpret, dahdi_pvt::mohsuggest, dahdi_pvt::msgstate, dahdi_pvt::next, dahdi_pvt::onhooktime, dahdi_pvt::outsigmod, dahdi_pvt::permcallwaiting, dahdi_pvt::permhidecallerid, dahdi_pvt::pickupgroup, dahdi_pvt::polarityonanswerdelay, dahdi_pvt::prev, dahdi_pvt::priexclusive, dahdi_pvt::priindication_oob, dahdi_pvt::propconfno, dahdi_pvt::pulse, dahdi_pvt::radio, dahdi_pvt::restrictcid, dahdi_pvt::ringt_base, dahdi_pvt::rxgain, dahdi_pvt::sendcalleridafter, set_actual_gain(), dahdi_pvt::sig, sig2str, SIG_E911, SIG_EM, SIG_EM_E1, SIG_EMWINK, SIG_FEATB, SIG_FEATD, SIG_FEATDMF, SIG_FEATDMF_TA, SIG_FGC_CAMA, SIG_FGC_CAMAMF, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSKS, SIG_FXSLS, SIG_GR303FXOKS, SIG_GR303FXSKS, SIG_PRI, SIG_SF, SIG_SF_FEATB, SIG_SF_FEATD, SIG_SF_FEATDMF, SIG_SFWINK, dahdi_pvt::smdi_iface, dahdi_chan_conf::smdi_port, dahdi_pvt::span, dahdi_pvt::stripmsd, SUB_REAL, dahdi_pvt::subs, dahdi_pvt::threewaycalling, dahdi_chan_conf::timing, dahdi_pvt::tonezone, dahdi_pvt::transfer, dahdi_pvt::transfertobusy, dahdi_pvt::txgain, dahdi_pvt::unknown_alarm, update_conf(), dahdi_pvt::use_callerid, dahdi_pvt::use_callingpres, dahdi_pvt::use_smdi, and dahdi_pvt::usedistinctiveringdetection.
Referenced by build_channels(), and process_dahdi().
07287 { 07288 /* Make a dahdi_pvt structure for this interface (or CRV if "pri" is specified) */ 07289 struct dahdi_pvt *tmp = NULL, *tmp2, *prev = NULL; 07290 char fn[80]; 07291 #if 1 07292 struct dahdi_bufferinfo bi; 07293 #endif 07294 int res; 07295 int span=0; 07296 int here = 0; 07297 int x; 07298 struct dahdi_pvt **wlist; 07299 struct dahdi_pvt **wend; 07300 struct dahdi_params p; 07301 07302 wlist = &iflist; 07303 wend = &ifend; 07304 07305 #ifdef HAVE_PRI 07306 if (pri) { 07307 wlist = &pri->crvs; 07308 wend = &pri->crvend; 07309 } 07310 #endif 07311 07312 tmp2 = *wlist; 07313 prev = NULL; 07314 07315 while (tmp2) { 07316 if (!tmp2->destroy) { 07317 if (tmp2->channel == channel) { 07318 tmp = tmp2; 07319 here = 1; 07320 break; 07321 } 07322 if (tmp2->channel > channel) { 07323 break; 07324 } 07325 } 07326 prev = tmp2; 07327 tmp2 = tmp2->next; 07328 } 07329 07330 if (!here && reloading != 1) { 07331 if (!(tmp = ast_calloc(1, sizeof(*tmp)))) { 07332 if (tmp) 07333 free(tmp); 07334 return NULL; 07335 } 07336 ast_mutex_init(&tmp->lock); 07337 ifcount++; 07338 for (x = 0; x < 3; x++) 07339 tmp->subs[x].dfd = -1; 07340 tmp->channel = channel; 07341 } 07342 07343 if (tmp) { 07344 int chan_sig = conf->chan.sig; 07345 if (!here) { 07346 if ((channel != CHAN_PSEUDO) && !pri) { 07347 int count = 0; 07348 snprintf(fn, sizeof(fn), "%d", channel); 07349 /* Open non-blocking */ 07350 tmp->subs[SUB_REAL].dfd = dahdi_open(fn); 07351 while (tmp->subs[SUB_REAL].dfd < 0 && reloading == 2 && count < 1000) { /* the kernel may not call dahdi_release fast enough for the open flagbit to be cleared in time */ 07352 usleep(1); 07353 tmp->subs[SUB_REAL].dfd = dahdi_open(fn); 07354 count++; 07355 } 07356 /* Allocate a DAHDI structure */ 07357 if (tmp->subs[SUB_REAL].dfd < 0) { 07358 ast_log(LOG_ERROR, "Unable to open channel %d: %s\nhere = %d, tmp->channel = %d, channel = %d\n", channel, strerror(errno), here, tmp->channel, channel); 07359 destroy_dahdi_pvt(&tmp); 07360 return NULL; 07361 } 07362 memset(&p, 0, sizeof(p)); 07363 res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &p); 07364 if (res < 0) { 07365 ast_log(LOG_ERROR, "Unable to get parameters: %s\n", strerror(errno)); 07366 destroy_dahdi_pvt(&tmp); 07367 return NULL; 07368 } 07369 if (p.sigtype != (conf->chan.sig & 0x3ffff)) { 07370 ast_log(LOG_ERROR, "Signalling requested on channel %d is %s but line is in %s signalling\n", channel, sig2str(conf->chan.sig), sig2str(p.sigtype)); 07371 destroy_dahdi_pvt(&tmp); 07372 return NULL; 07373 } 07374 tmp->law = p.curlaw; 07375 tmp->span = p.spanno; 07376 span = p.spanno - 1; 07377 } else { 07378 if (channel == CHAN_PSEUDO) 07379 chan_sig = 0; 07380 else if ((chan_sig != SIG_FXOKS) && (chan_sig != SIG_FXSKS)) { 07381 ast_log(LOG_ERROR, "CRV's must use FXO/FXS Kewl Start (fxo_ks/fxs_ks) signalling only.\n"); 07382 return NULL; 07383 } 07384 } 07385 #ifdef HAVE_PRI 07386 if ((chan_sig == SIG_PRI) || (chan_sig == SIG_GR303FXOKS) || (chan_sig == SIG_GR303FXSKS)) { 07387 int offset; 07388 int myswitchtype; 07389 int matchesdchan; 07390 int x,y; 07391 offset = 0; 07392 if ((chan_sig == SIG_PRI) && ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &offset)) { 07393 ast_log(LOG_ERROR, "Unable to set clear mode on clear channel %d of span %d: %s\n", channel, p.spanno, strerror(errno)); 07394 destroy_dahdi_pvt(&tmp); 07395 return NULL; 07396 } 07397 if (span >= NUM_SPANS) { 07398 ast_log(LOG_ERROR, "Channel %d does not lie on a span I know of (%d)\n", channel, span); 07399 destroy_dahdi_pvt(&tmp); 07400 return NULL; 07401 } else { 07402 struct dahdi_spaninfo si; 07403 si.spanno = 0; 07404 if (ioctl(tmp->subs[SUB_REAL].dfd,DAHDI_SPANSTAT,&si) == -1) { 07405 ast_log(LOG_ERROR, "Unable to get span status: %s\n", strerror(errno)); 07406 destroy_dahdi_pvt(&tmp); 07407 return NULL; 07408 } 07409 /* Store the logical span first based upon the real span */ 07410 tmp->logicalspan = pris[span].prilogicalspan; 07411 pri_resolve_span(&span, channel, (channel - p.chanpos), &si); 07412 if (span < 0) { 07413 ast_log(LOG_WARNING, "Channel %d: Unable to find locate channel/trunk group!\n", channel); 07414 destroy_dahdi_pvt(&tmp); 07415 return NULL; 07416 } 07417 if (chan_sig == SIG_PRI) 07418 myswitchtype = conf->pri.switchtype; 07419 else 07420 myswitchtype = PRI_SWITCH_GR303_TMC; 07421 /* Make sure this isn't a d-channel */ 07422 matchesdchan=0; 07423 for (x = 0; x < NUM_SPANS; x++) { 07424 for (y = 0; y < NUM_DCHANS; y++) { 07425 if (pris[x].dchannels[y] == tmp->channel) { 07426 matchesdchan = 1; 07427 break; 07428 } 07429 } 07430 } 07431 offset = p.chanpos; 07432 if (!matchesdchan) { 07433 if (pris[span].nodetype && (pris[span].nodetype != conf->pri.nodetype)) { 07434 ast_log(LOG_ERROR, "Span %d is already a %s node\n", span + 1, pri_node2str(pris[span].nodetype)); 07435 destroy_dahdi_pvt(&tmp); 07436 return NULL; 07437 } 07438 if (pris[span].switchtype && (pris[span].switchtype != myswitchtype)) { 07439 ast_log(LOG_ERROR, "Span %d is already a %s switch\n", span + 1, pri_switch2str(pris[span].switchtype)); 07440 destroy_dahdi_pvt(&tmp); 07441 return NULL; 07442 } 07443 if ((pris[span].dialplan) && (pris[span].dialplan != conf->pri.dialplan)) { 07444 ast_log(LOG_ERROR, "Span %d is already a %s dialing plan\n", span + 1, dialplan2str(pris[span].dialplan)); 07445 destroy_dahdi_pvt(&tmp); 07446 return NULL; 07447 } 07448 if (!ast_strlen_zero(pris[span].idledial) && strcmp(pris[span].idledial, conf->pri.idledial)) { 07449 ast_log(LOG_ERROR, "Span %d already has idledial '%s'.\n", span + 1, conf->pri.idledial); 07450 destroy_dahdi_pvt(&tmp); 07451 return NULL; 07452 } 07453 if (!ast_strlen_zero(pris[span].idleext) && strcmp(pris[span].idleext, conf->pri.idleext)) { 07454 ast_log(LOG_ERROR, "Span %d already has idleext '%s'.\n", span + 1, conf->pri.idleext); 07455 destroy_dahdi_pvt(&tmp); 07456 return NULL; 07457 } 07458 if (pris[span].minunused && (pris[span].minunused != conf->pri.minunused)) { 07459 ast_log(LOG_ERROR, "Span %d already has minunused of %d.\n", span + 1, conf->pri.minunused); 07460 destroy_dahdi_pvt(&tmp); 07461 return NULL; 07462 } 07463 if (pris[span].minidle && (pris[span].minidle != conf->pri.minidle)) { 07464 ast_log(LOG_ERROR, "Span %d already has minidle of %d.\n", span + 1, conf->pri.minidle); 07465 destroy_dahdi_pvt(&tmp); 07466 return NULL; 07467 } 07468 if (pris[span].numchans >= MAX_CHANNELS) { 07469 ast_log(LOG_ERROR, "Unable to add channel %d: Too many channels in trunk group %d!\n", channel, 07470 pris[span].trunkgroup); 07471 destroy_dahdi_pvt(&tmp); 07472 return NULL; 07473 } 07474 pris[span].nodetype = conf->pri.nodetype; 07475 pris[span].switchtype = myswitchtype; 07476 pris[span].nsf = conf->pri.nsf; 07477 pris[span].dialplan = conf->pri.dialplan; 07478 pris[span].localdialplan = conf->pri.localdialplan; 07479 pris[span].pvts[pris[span].numchans++] = tmp; 07480 pris[span].minunused = conf->pri.minunused; 07481 pris[span].minidle = conf->pri.minidle; 07482 pris[span].overlapdial = conf->pri.overlapdial; 07483 #ifdef HAVE_PRI_INBANDDISCONNECT 07484 pris[span].inbanddisconnect = conf->pri.inbanddisconnect; 07485 #endif 07486 pris[span].facilityenable = conf->pri.facilityenable; 07487 ast_copy_string(pris[span].idledial, conf->pri.idledial, sizeof(pris[span].idledial)); 07488 ast_copy_string(pris[span].idleext, conf->pri.idleext, sizeof(pris[span].idleext)); 07489 ast_copy_string(pris[span].internationalprefix, conf->pri.internationalprefix, sizeof(pris[span].internationalprefix)); 07490 ast_copy_string(pris[span].nationalprefix, conf->pri.nationalprefix, sizeof(pris[span].nationalprefix)); 07491 ast_copy_string(pris[span].localprefix, conf->pri.localprefix, sizeof(pris[span].localprefix)); 07492 ast_copy_string(pris[span].privateprefix, conf->pri.privateprefix, sizeof(pris[span].privateprefix)); 07493 ast_copy_string(pris[span].unknownprefix, conf->pri.unknownprefix, sizeof(pris[span].unknownprefix)); 07494 pris[span].resetinterval = conf->pri.resetinterval; 07495 07496 tmp->pri = &pris[span]; 07497 tmp->prioffset = offset; 07498 tmp->call = NULL; 07499 } else { 07500 ast_log(LOG_ERROR, "Channel %d is reserved for D-channel.\n", offset); 07501 destroy_dahdi_pvt(&tmp); 07502 return NULL; 07503 } 07504 } 07505 } else { 07506 tmp->prioffset = 0; 07507 } 07508 #endif 07509 } else { 07510 chan_sig = tmp->sig; 07511 memset(&p, 0, sizeof(p)); 07512 if (tmp->subs[SUB_REAL].dfd > -1) 07513 res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &p); 07514 } 07515 /* Adjust starttime on loopstart and kewlstart trunks to reasonable values */ 07516 switch (chan_sig) { 07517 case SIG_FXSKS: 07518 case SIG_FXSLS: 07519 case SIG_EM: 07520 case SIG_EM_E1: 07521 case SIG_EMWINK: 07522 case SIG_FEATD: 07523 case SIG_FEATDMF: 07524 case SIG_FEATDMF_TA: 07525 case SIG_FEATB: 07526 case SIG_E911: 07527 case SIG_SF: 07528 case SIG_SFWINK: 07529 case SIG_FGC_CAMA: 07530 case SIG_FGC_CAMAMF: 07531 case SIG_SF_FEATD: 07532 case SIG_SF_FEATDMF: 07533 case SIG_SF_FEATB: 07534 p.starttime = 250; 07535 break; 07536 } 07537 07538 if (tmp->radio) { 07539 /* XXX Waiting to hear back from Jim if these should be adjustable XXX */ 07540 p.channo = channel; 07541 p.rxwinktime = 1; 07542 p.rxflashtime = 1; 07543 p.starttime = 1; 07544 p.debouncetime = 5; 07545 } 07546 if (!tmp->radio) { 07547 p.channo = channel; 07548 /* Override timing settings based on config file */ 07549 if (conf->timing.prewinktime >= 0) 07550 p.prewinktime = conf->timing.prewinktime; 07551 if (conf->timing.preflashtime >= 0) 07552 p.preflashtime = conf->timing.preflashtime; 07553 if (conf->timing.winktime >= 0) 07554 p.winktime = conf->timing.winktime; 07555 if (conf->timing.flashtime >= 0) 07556 p.flashtime = conf->timing.flashtime; 07557 if (conf->timing.starttime >= 0) 07558 p.starttime = conf->timing.starttime; 07559 if (conf->timing.rxwinktime >= 0) 07560 p.rxwinktime = conf->timing.rxwinktime; 07561 if (conf->timing.rxflashtime >= 0) 07562 p.rxflashtime = conf->timing.rxflashtime; 07563 if (conf->timing.debouncetime >= 0) 07564 p.debouncetime = conf->timing.debouncetime; 07565 } 07566 07567 /* dont set parms on a pseudo-channel (or CRV) */ 07568 if (tmp->subs[SUB_REAL].dfd >= 0) 07569 { 07570 res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_SET_PARAMS, &p); 07571 if (res < 0) { 07572 ast_log(LOG_ERROR, "Unable to set parameters: %s\n", strerror(errno)); 07573 destroy_dahdi_pvt(&tmp); 07574 return NULL; 07575 } 07576 } 07577 #if 1 07578 if (!here && (tmp->subs[SUB_REAL].dfd > -1)) { 07579 memset(&bi, 0, sizeof(bi)); 07580 res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_BUFINFO, &bi); 07581 if (!res) { 07582 bi.txbufpolicy = conf->chan.buf_policy; 07583 bi.rxbufpolicy = conf->chan.buf_policy; 07584 bi.numbufs = conf->chan.buf_no; 07585 res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_SET_BUFINFO, &bi); 07586 if (res < 0) { 07587 ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d: %s\n", channel, strerror(errno)); 07588 } 07589 } else 07590 ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d: %s\n", channel, strerror(errno)); 07591 } 07592 #endif 07593 tmp->immediate = conf->chan.immediate; 07594 tmp->transfertobusy = conf->chan.transfertobusy; 07595 tmp->sig = chan_sig; 07596 tmp->outsigmod = conf->chan.outsigmod; 07597 tmp->ringt_base = ringt_base; 07598 tmp->firstradio = 0; 07599 if ((chan_sig == SIG_FXOKS) || (chan_sig == SIG_FXOLS) || (chan_sig == SIG_FXOGS)) 07600 tmp->permcallwaiting = conf->chan.callwaiting; 07601 else 07602 tmp->permcallwaiting = 0; 07603 /* Flag to destroy the channel must be cleared on new mkif. Part of changes for reload to work */ 07604 tmp->destroy = 0; 07605 tmp->drings = drings; 07606 tmp->usedistinctiveringdetection = conf->chan.usedistinctiveringdetection; 07607 tmp->callwaitingcallerid = conf->chan.callwaitingcallerid; 07608 tmp->threewaycalling = conf->chan.threewaycalling; 07609 tmp->adsi = conf->chan.adsi; 07610 tmp->use_smdi = conf->chan.use_smdi; 07611 tmp->permhidecallerid = conf->chan.hidecallerid; 07612 tmp->callreturn = conf->chan.callreturn; 07613 tmp->echocancel = conf->chan.echocancel; 07614 tmp->echotraining = conf->chan.echotraining; 07615 tmp->pulse = conf->chan.pulse; 07616 if (tmp->echocancel) 07617 tmp->echocanbridged = conf->chan.echocanbridged; 07618 else { 07619 if (conf->chan.echocanbridged) 07620 ast_log(LOG_NOTICE, "echocancelwhenbridged requires echocancel to be enabled; ignoring\n"); 07621 tmp->echocanbridged = 0; 07622 } 07623 tmp->busydetect = conf->chan.busydetect; 07624 tmp->busycount = conf->chan.busycount; 07625 tmp->busy_tonelength = conf->chan.busy_tonelength; 07626 tmp->busy_quietlength = conf->chan.busy_quietlength; 07627 tmp->callprogress = conf->chan.callprogress; 07628 tmp->cancallforward = conf->chan.cancallforward; 07629 tmp->dtmfrelax = conf->chan.dtmfrelax; 07630 tmp->callwaiting = tmp->permcallwaiting; 07631 tmp->hidecallerid = tmp->permhidecallerid; 07632 tmp->channel = channel; 07633 tmp->stripmsd = conf->chan.stripmsd; 07634 tmp->use_callerid = conf->chan.use_callerid; 07635 tmp->cid_signalling = conf->chan.cid_signalling; 07636 tmp->cid_start = conf->chan.cid_start; 07637 tmp->dahditrcallerid = conf->chan.dahditrcallerid; 07638 tmp->restrictcid = conf->chan.restrictcid; 07639 tmp->use_callingpres = conf->chan.use_callingpres; 07640 tmp->priindication_oob = conf->chan.priindication_oob; 07641 tmp->priexclusive = conf->chan.priexclusive; 07642 if (tmp->usedistinctiveringdetection) { 07643 if (!tmp->use_callerid) { 07644 ast_log(LOG_NOTICE, "Distinctive Ring detect requires 'usecallerid' be on\n"); 07645 tmp->use_callerid = 1; 07646 } 07647 } 07648 07649 if (tmp->cid_signalling == CID_SIG_SMDI) { 07650 if (!tmp->use_smdi) { 07651 ast_log(LOG_WARNING, "SMDI callerid requires SMDI to be enabled, enabling...\n"); 07652 tmp->use_smdi = 1; 07653 } 07654 } 07655 if (tmp->use_smdi) { 07656 tmp->smdi_iface = ast_smdi_interface_find(conf->smdi_port); 07657 if (!(tmp->smdi_iface)) { 07658 ast_log(LOG_ERROR, "Invalid SMDI port specfied, disabling SMDI support\n"); 07659 tmp->use_smdi = 0; 07660 } 07661 } 07662 07663 ast_copy_string(tmp->accountcode, conf->chan.accountcode, sizeof(tmp->accountcode)); 07664 tmp->amaflags = conf->chan.amaflags; 07665 if (!here) { 07666 tmp->confno = -1; 07667 tmp->propconfno = -1; 07668 } 07669 tmp->canpark = conf->chan.canpark; 07670 tmp->transfer = conf->chan.transfer; 07671 ast_copy_string(tmp->defcontext,conf->chan.context,sizeof(tmp->defcontext)); 07672 ast_copy_string(tmp->language, conf->chan.language, sizeof(tmp->language)); 07673 ast_copy_string(tmp->mohinterpret, conf->chan.mohinterpret, sizeof(tmp->mohinterpret)); 07674 ast_copy_string(tmp->mohsuggest, conf->chan.mohsuggest, sizeof(tmp->mohsuggest)); 07675 ast_copy_string(tmp->context, conf->chan.context, sizeof(tmp->context)); 07676 ast_copy_string(tmp->cid_num, conf->chan.cid_num, sizeof(tmp->cid_num)); 07677 tmp->cid_ton = 0; 07678 ast_copy_string(tmp->cid_name, conf->chan.cid_name, sizeof(tmp->cid_name)); 07679 ast_copy_string(tmp->mailbox, conf->chan.mailbox, sizeof(tmp->mailbox)); 07680 tmp->msgstate = -1; 07681 tmp->group = conf->chan.group; 07682 tmp->callgroup = conf->chan.callgroup; 07683 tmp->pickupgroup= conf->chan.pickupgroup; 07684 tmp->rxgain = conf->chan.rxgain; 07685 tmp->txgain = conf->chan.txgain; 07686 tmp->tonezone = conf->chan.tonezone; 07687 tmp->onhooktime = time(NULL); 07688 if (tmp->subs[SUB_REAL].dfd > -1) { 07689 set_actual_gain(tmp->subs[SUB_REAL].dfd, 0, tmp->rxgain, tmp->txgain, tmp->law); 07690 if (tmp->dsp) 07691 ast_dsp_digitmode(tmp->dsp, DSP_DIGITMODE_DTMF | tmp->dtmfrelax); 07692 update_conf(tmp); 07693 if (!here) { 07694 if (chan_sig != SIG_PRI) 07695 /* Hang it up to be sure it's good */ 07696 dahdi_set_hook(tmp->subs[SUB_REAL].dfd, DAHDI_ONHOOK); 07697 } 07698 ioctl(tmp->subs[SUB_REAL].dfd,DAHDI_SETTONEZONE,&tmp->tonezone); 07699 #ifdef HAVE_PRI 07700 /* the dchannel is down so put the channel in alarm */ 07701 if (tmp->pri && !pri_is_up(tmp->pri)) { 07702 tmp->inalarm = 1; 07703 } 07704 #endif 07705 if ((res = get_alarms(tmp)) != DAHDI_ALARM_NONE) { 07706 tmp->inalarm = 1; 07707 handle_alarms(tmp, res); 07708 } else { 07709 /* yes, this looks strange... the unknown_alarm flag is only used to 07710 control whether an 'alarm cleared' message gets generated when we 07711 get an indication that the channel is no longer in alarm status. 07712 however, the channel *could* be in an alarm status that we aren't 07713 aware of (since get_alarms() only reports span alarms, not channel 07714 alarms). setting this flag will cause any potential 'alarm cleared' 07715 message to be suppressed, but if a real alarm occurs before that 07716 happens, this flag will get cleared by it and the situation will 07717 be normal. 07718 */ 07719 tmp->unknown_alarm = 1; 07720 } 07721 } 07722 07723 tmp->polarityonanswerdelay = conf->chan.polarityonanswerdelay; 07724 tmp->answeronpolarityswitch = conf->chan.answeronpolarityswitch; 07725 tmp->hanguponpolarityswitch = conf->chan.hanguponpolarityswitch; 07726 tmp->sendcalleridafter = conf->chan.sendcalleridafter; 07727 07728 } 07729 if (tmp && !here) { 07730 /* nothing on the iflist */ 07731 if (!*wlist) { 07732 *wlist = tmp; 07733 tmp->prev = NULL; 07734 tmp->next = NULL; 07735 *wend = tmp; 07736 } else { 07737 /* at least one member on the iflist */ 07738 struct dahdi_pvt *working = *wlist; 07739 07740 /* check if we maybe have to put it on the begining */ 07741 if (working->channel > tmp->channel) { 07742 tmp->next = *wlist; 07743 tmp->prev = NULL; 07744 (*wlist)->prev = tmp; 07745 *wlist = tmp; 07746 } else { 07747 /* go through all the members and put the member in the right place */ 07748 while (working) { 07749 /* in the middle */ 07750 if (working->next) { 07751 if (working->channel < tmp->channel && working->next->channel > tmp->channel) { 07752 tmp->next = working->next; 07753 tmp->prev = working; 07754 working->next->prev = tmp; 07755 working->next = tmp; 07756 break; 07757 } 07758 } else { 07759 /* the last */ 07760 if (working->channel < tmp->channel) { 07761 working->next = tmp; 07762 tmp->next = NULL; 07763 tmp->prev = working; 07764 *wend = tmp; 07765 break; 07766 } 07767 } 07768 working = working->next; 07769 } 07770 } 07771 } 07772 } 07773 return tmp; 07774 }
| static int my_dahdi_write | ( | struct dahdi_pvt * | p, | |
| unsigned char * | buf, | |||
| int | len, | |||
| int | index, | |||
| int | linear | |||
| ) | [static] |
Definition at line 5039 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, dahdi_subchannel::dfd, errno, LOG_DEBUG, option_debug, READ_SIZE, and dahdi_pvt::subs.
Referenced by dahdi_write().
05040 { 05041 int sent=0; 05042 int size; 05043 int res; 05044 int fd; 05045 fd = p->subs[index].dfd; 05046 while (len) { 05047 size = len; 05048 if (size > (linear ? READ_SIZE * 2 : READ_SIZE)) 05049 size = (linear ? READ_SIZE * 2 : READ_SIZE); 05050 res = write(fd, buf, size); 05051 if (res != size) { 05052 if (option_debug) 05053 ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel); 05054 return sent; 05055 } 05056 len -= size; 05057 buf += size; 05058 } 05059 return sent; 05060 }
| static int my_getsigstr | ( | struct ast_channel * | chan, | |
| char * | str, | |||
| const char * | term, | |||
| int | ms | |||
| ) | [static] |
Definition at line 5511 of file chan_dahdi.c.
References ast_waitfordigit().
Referenced by ss_thread().
05512 { 05513 char c; 05514 05515 *str = 0; /* start with empty output buffer */ 05516 for (;;) 05517 { 05518 /* Wait for the first digit (up to specified ms). */ 05519 c = ast_waitfordigit(chan, ms); 05520 /* if timeout, hangup or error, return as such */ 05521 if (c < 1) 05522 return c; 05523 *str++ = c; 05524 *str = 0; 05525 if (strchr(term, c)) 05526 return 1; 05527 } 05528 }
| static int process_dahdi | ( | struct dahdi_chan_conf * | confp, | |
| const char * | cat, | |||
| struct ast_variable * | v, | |||
| int | reload, | |||
| int | skipchannels | |||
| ) | [static] |
Definition at line 10976 of file chan_dahdi.c.
References dahdi_pvt::accountcode, dahdi_pvt::adsi, dahdi_pvt::amaflags, dahdi_pvt::answeronpolarityswitch, ast_callerid_split(), ast_cdr_amaflags2int(), ast_copy_string(), ast_get_group(), ast_jb_read_conf(), ast_log(), ast_strlen_zero(), ast_true(), ast_verbose(), dahdi_pvt::buf_no, dahdi_pvt::buf_policy, build_channels(), dahdi_pvt::busy_quietlength, dahdi_pvt::busy_tonelength, dahdi_pvt::busycount, dahdi_pvt::busydetect, dahdi_pvt::callgroup, dahdi_pvt::callprogress, dahdi_pvt::callreturn, dahdi_pvt::callwaiting, dahdi_pvt::callwaitingcallerid, dahdi_pvt::cancallforward, dahdi_pvt::canpark, dahdi_chan_conf::chan, CHAN_PSEUDO, dahdi_pvt::cid_name, dahdi_pvt::cid_num, CID_SIG_BELL, CID_SIG_DTMF, CID_SIG_SMDI, CID_SIG_V23, CID_SIG_V23_JP, dahdi_pvt::cid_signalling, dahdi_pvt::cid_start, CID_START_POLARITY, CID_START_RING, dahdi_pvt::context, ringContextData::contextData, dahdi_chan_conf_default(), dahdi_pvt::dahditrcallerid, drings, DSP_DIGITMODE_RELAXDTMF, dahdi_pvt::dtmfrelax, dahdi_pvt::echocanbridged, dahdi_pvt::echocancel, dahdi_pvt::echotraining, errno, global_jbconf, dahdi_pvt::group, dahdi_pvt::hanguponpolarityswitch, dahdi_pvt::hidecallerid, dahdi_pvt::hidecalleridname, dahdi_pvt::immediate, dahdi_pvt::language, ast_variable::lineno, LOG_ERROR, LOG_WARNING, dahdi_pvt::mailbox, MAX_CHANLIST_LEN, mkintf(), dahdi_pvt::mohinterpret, dahdi_pvt::mohsuggest, ast_variable::name, ast_variable::next, NUM_CADENCE_MAX, option_verbose, dahdi_pvt::outsigmod, dahdi_pvt::pickupgroup, dahdi_pvt::polarityonanswerdelay, dahdi_pvt::priexclusive, dahdi_pvt::priindication_oob, dahdi_pvt::pulse, dahdi_pvt::radio, READ_SIZE, dahdi_pvt::restrictcid, distRingData::ring, dahdi_distRings::ringContext, dahdi_distRings::ringnum, dahdi_pvt::rxgain, dahdi_pvt::sendcalleridafter, dahdi_pvt::sig, SIG_E911, SIG_EM, SIG_EM_E1, SIG_EMWINK, SIG_FEATB, SIG_FEATD, SIG_FEATDMF, SIG_FEATDMF_TA, SIG_FGC_CAMA, SIG_FGC_CAMAMF, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_GR303FXOKS, SIG_GR303FXSKS, SIG_PRI, SIG_SF, SIG_SF_FEATB, SIG_SFWINK, dahdi_chan_conf::smdi_port, dahdi_pvt::stripmsd, dahdi_pvt::threewaycalling, dahdi_chan_conf::timing, dahdi_pvt::tonezone, dahdi_pvt::transfer, dahdi_pvt::transfertobusy, dahdi_pvt::txgain, dahdi_pvt::use_callerid, dahdi_pvt::use_callingpres, dahdi_pvt::use_smdi, dahdi_pvt::usedistinctiveringdetection, ast_variable::value, and VERBOSE_PREFIX_3.
Referenced by setup_dahdi().
10977 { 10978 struct dahdi_pvt *tmp; 10979 int y; 10980 int found_pseudo = 0; 10981 char dahdichan[MAX_CHANLIST_LEN] = {}; 10982 10983 for (; v; v = v->next) { 10984 if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) 10985 continue; 10986 10987 /* Create the interface list */ 10988 if (!strcasecmp(v->name, "channel") 10989 #ifdef HAVE_PRI 10990 || !strcasecmp(v->name, "crv") 10991 #endif 10992 ) { 10993 int iscrv; 10994 if (skipchannels) 10995 continue; 10996 iscrv = !strcasecmp(v->name, "crv"); 10997 if (build_channels(confp, iscrv, v->value, reload, v->lineno, &found_pseudo)) 10998 return -1; 10999 } else if (!strcasecmp(v->name, "buffers")) { 11000 int res; 11001 char policy[21] = ""; 11002 11003 res = sscanf(v->value, "%d,%20s", &confp->chan.buf_no, policy); 11004 if (res != 2) { 11005 ast_log(LOG_WARNING, "Parsing buffers option data failed, using defaults.\n"); 11006 confp->chan.buf_no = numbufs; 11007 continue; 11008 } 11009 if (confp->chan.buf_no < 0) 11010 confp->chan.buf_no = numbufs; 11011 if (!strcasecmp(policy, "full")) { 11012 confp->chan.buf_policy = DAHDI_POLICY_WHEN_FULL; 11013 } else if (!strcasecmp(policy, "immediate")) { 11014 confp->chan.buf_policy = DAHDI_POLICY_IMMEDIATE; 11015 } else { 11016 ast_log(LOG_WARNING, "Invalid policy name given (%s).\n", policy); 11017 } 11018 } else if (!strcasecmp(v->name, "zapchan") || !strcasecmp(v->name, "dahdichan")) { 11019 ast_copy_string(dahdichan, v->value, sizeof(dahdichan)); 11020 if (v->name[0] == 'z' || v->name[0] == 'Z') { 11021 ast_log(LOG_WARNING, "Option zapchan has been deprecated in favor of dahdichan (found in [%s])\n", cat); 11022 } 11023 } else if (!strcasecmp(v->name, "usedistinctiveringdetection")) { 11024 if (ast_true(v->value)) 11025 confp->chan.usedistinctiveringdetection = 1; 11026 } else if (!strcasecmp(v->name, "distinctiveringaftercid")) { 11027 if (ast_true(v->value)) 11028 distinctiveringaftercid = 1; 11029 } else if (!strcasecmp(v->name, "dring1context")) { 11030 ast_copy_string(drings.ringContext[0].contextData, v->value, sizeof(drings.ringContext[0].contextData)); 11031 } else if (!strcasecmp(v->name, "dring2context")) { 11032 ast_copy_string(drings.ringContext[1].contextData, v->value, sizeof(drings.ringContext[1].contextData)); 11033 } else if (!strcasecmp(v->name, "dring3context")) { 11034 ast_copy_string(drings.ringContext[2].contextData, v->value, sizeof(drings.ringContext[2].contextData)); 11035 } else if (!strcasecmp(v->name, "dring1")) { 11036 sscanf(v->value, "%d,%d,%d", &drings.ringnum[0].ring[0], &drings.ringnum[0].ring[1], &drings.ringnum[0].ring[2]); 11037 } else if (!strcasecmp(v->name, "dring2")) { 11038 sscanf(v->value, "%d,%d,%d", &drings.ringnum[1].ring[0], &drings.ringnum[1].ring[1], &drings.ringnum[1].ring[2]); 11039 } else if (!strcasecmp(v->name, "dring3")) { 11040 sscanf(v->value, "%d,%d,%d", &drings.ringnum[2].ring[0], &drings.ringnum[2].ring[1], &drings.ringnum[2].ring[2]); 11041 } else if (!strcasecmp(v->name, "usecallerid")) { 11042 confp->chan.use_callerid = ast_true(v->value); 11043 } else if (!strcasecmp(v->name, "cidsignalling")) { 11044 if (!strcasecmp(v->value, "bell")) 11045 confp->chan.cid_signalling = CID_SIG_BELL; 11046 else if (!strcasecmp(v->value, "v23")) 11047 confp->chan.cid_signalling = CID_SIG_V23; 11048 else if (!strcasecmp(v->value, "dtmf")) 11049 confp->chan.cid_signalling = CID_SIG_DTMF; 11050 else if (!strcasecmp(v->value, "smdi")) 11051 confp->chan.cid_signalling = CID_SIG_SMDI; 11052 else if (!strcasecmp(v->value, "v23_jp")) 11053 confp->chan.cid_signalling = CID_SIG_V23_JP; 11054 else if (ast_true(v->value)) 11055 confp->chan.cid_signalling = CID_SIG_BELL; 11056 } else if (!strcasecmp(v->name, "cidstart")) { 11057 if (!strcasecmp(v->value, "ring")) 11058 confp->chan.cid_start = CID_START_RING; 11059 else if (!strcasecmp(v->value, "polarity")) 11060 confp->chan.cid_start = CID_START_POLARITY; 11061 else if (ast_true(v->value)) 11062 confp->chan.cid_start = CID_START_RING; 11063 } else if (!strcasecmp(v->name, "threewaycalling")) { 11064 confp->chan.threewaycalling = ast_true(v->value); 11065 } else if (!strcasecmp(v->name, "cancallforward")) { 11066 confp->chan.cancallforward = ast_true(v->value); 11067 } else if (!strcasecmp(v->name, "relaxdtmf")) { 11068 if (ast_true(v->value)) 11069 confp->chan.dtmfrelax = DSP_DIGITMODE_RELAXDTMF; 11070 else 11071 confp->chan.dtmfrelax = 0; 11072 } else if (!strcasecmp(v->name, "mailbox")) { 11073 ast_copy_string(confp->chan.mailbox, v->value, sizeof(confp->chan.mailbox)); 11074 } else if (!strcasecmp(v->name, "hasvoicemail")) { 11075 if (ast_true(v->value) && ast_strlen_zero(confp->chan.mailbox)) { 11076 ast_copy_string(confp->chan.mailbox, cat, sizeof(confp->chan.mailbox)); 11077 } 11078 } else if (!strcasecmp(v->name, "adsi")) { 11079 confp->chan.adsi = ast_true(v->value); 11080 } else if (!strcasecmp(v->name, "usesmdi")) { 11081 confp->chan.use_smdi = ast_true(v->value); 11082 } else if (!strcasecmp(v->name, "smdiport")) { 11083 ast_copy_string(confp->smdi_port, v->value, sizeof(confp->smdi_port)); 11084 } else if (!strcasecmp(v->name, "transfer")) { 11085 confp->chan.transfer = ast_true(v->value); 11086 } else if (!strcasecmp(v->name, "canpark")) { 11087 confp->chan.canpark = ast_true(v->value); 11088 } else if (!strcasecmp(v->name, "echocancelwhenbridged")) { 11089 confp->chan.echocanbridged = ast_true(v->value); 11090 } else if (!strcasecmp(v->name, "busydetect")) { 11091 confp->chan.busydetect = ast_true(v->value); 11092 } else if (!strcasecmp(v->name, "busycount")) { 11093 confp->chan.busycount = atoi(v->value); 11094 } else if (!strcasecmp(v->name, "busypattern")) { 11095 if (sscanf(v->value, "%d,%d", &confp->chan.busy_tonelength, &confp->chan.busy_quietlength) != 2) { 11096 ast_log(LOG_ERROR, "busypattern= expects busypattern=tonelength,quietlength\n"); 11097 } 11098 } else if (!strcasecmp(v->name, "callprogress")) { 11099 if (ast_true(v->value)) 11100 confp->chan.callprogress |= 1; 11101 else 11102 confp->chan.callprogress &= ~1; 11103 } else if (!strcasecmp(v->name, "faxdetect")) { 11104 if (!strcasecmp(v->value, "incoming")) { 11105 confp->chan.callprogress |= 4; 11106 confp->chan.callprogress &= ~2; 11107 } else if (!strcasecmp(v->value, "outgoing")) { 11108 confp->chan.callprogress &= ~4; 11109 confp->chan.callprogress |= 2; 11110 } else if (!strcasecmp(v->value, "both") || ast_true(v->value)) 11111 confp->chan.callprogress |= 6; 11112 else 11113 confp->chan.callprogress &= ~6; 11114 } else if (!strcasecmp(v->name, "echocancel")) { 11115 if (!ast_strlen_zero(v->value)) { 11116 y = atoi(v->value); 11117 } else 11118 y = 0; 11119 if ((y == 32) || (y == 64) || (y == 128) || (y == 256) || (y == 512) || (y == 1024)) 11120 confp->chan.echocancel = y; 11121 else { 11122 confp->chan.echocancel = ast_true(v->value); 11123 if (confp->chan.echocancel) 11124 confp->chan.echocancel=128; 11125 } 11126 } else if (!strcasecmp(v->name, "echotraining")) { 11127 if (sscanf(v->value, "%d", &y) == 1) { 11128 if ((y < 10) || (y > 4000)) { 11129 ast_log(LOG_WARNING, "Echo training time must be within the range of 10 to 4000 ms at line %d\n", v->lineno); 11130 } else { 11131 confp->chan.echotraining = y; 11132 } 11133 } else if (ast_true(v->value)) { 11134 confp->chan.echotraining = 400; 11135 } else 11136 confp->chan.echotraining = 0; 11137 } else if (!strcasecmp(v->name, "hidecallerid")) { 11138 confp->chan.hidecallerid = ast_true(v->value); 11139 } else if (!strcasecmp(v->name, "hidecalleridname")) { 11140 confp->chan.hidecalleridname = ast_true(v->value); 11141 } else if (!strcasecmp(v->name, "pulsedial")) { 11142 confp->chan.pulse = ast_true(v->value); 11143 } else if (!strcasecmp(v->name, "callreturn")) { 11144 confp->chan.callreturn = ast_true(v->value); 11145 } else if (!strcasecmp(v->name, "callwaiting")) { 11146 confp->chan.callwaiting = ast_true(v->value); 11147 } else if (!strcasecmp(v->name, "callwaitingcallerid")) { 11148 confp->chan.callwaitingcallerid = ast_true(v->value); 11149 } else if (!strcasecmp(v->name, "context")) { 11150 ast_copy_string(confp->chan.context, v->value, sizeof(confp->chan.context)); 11151 } else if (!strcasecmp(v->name, "language")) { 11152 ast_copy_string(confp->chan.language, v->value, sizeof(confp->chan.language)); 11153 } else if (!strcasecmp(v->name, "progzone")) { 11154 ast_copy_string(progzone, v->value, sizeof(progzone)); 11155 } else if (!strcasecmp(v->name, "mohinterpret") 11156 ||!strcasecmp(v->name, "musiconhold") || !strcasecmp(v->name, "musicclass")) { 11157 ast_copy_string(confp->chan.mohinterpret, v->value, sizeof(confp->chan.mohinterpret)); 11158 } else if (!strcasecmp(v->name, "mohsuggest")) { 11159 ast_copy_string(confp->chan.mohsuggest, v->value, sizeof(confp->chan.mohsuggest)); 11160 } else if (!strcasecmp(v->name, "stripmsd")) { 11161 confp->chan.stripmsd = atoi(v->value); 11162 } else if (!strcasecmp(v->name, "jitterbuffers")) { 11163 numbufs = atoi(v->value); 11164 } else if (!strcasecmp(v->name, "group")) { 11165 confp->chan.group = ast_get_group(v->value); 11166 } else if (!strcasecmp(v->name, "callgroup")) { 11167 confp->chan.callgroup = ast_get_group(v->value); 11168 } else if (!strcasecmp(v->name, "pickupgroup")) { 11169 confp->chan.pickupgroup = ast_get_group(v->value); 11170 } else if (!strcasecmp(v->name, "immediate")) { 11171 confp->chan.immediate = ast_true(v->value); 11172 } else if (!strcasecmp(v->name, "transfertobusy")) { 11173 confp->chan.transfertobusy = ast_true(v->value); 11174 } else if (!strcasecmp(v->name, "rxgain")) { 11175 if (sscanf(v->value, "%f", &confp->chan.rxgain) != 1) { 11176 ast_log(LOG_WARNING, "Invalid rxgain: %s\n", v->value); 11177 } 11178 } else if (!strcasecmp(v->name, "txgain")) { 11179 if (sscanf(v->value, "%f", &confp->chan.txgain) != 1) { 11180 ast_log(LOG_WARNING, "Invalid txgain: %s\n", v->value); 11181 } 11182 } else if (!strcasecmp(v->name, "tonezone")) { 11183 if (sscanf(v->value, "%d", &confp->chan.tonezone) != 1) { 11184 ast_log(LOG_WARNING, "Invalid tonezone: %s\n", v->value); 11185 } 11186 } else if (!strcasecmp(v->name, "callerid")) { 11187 if (!strcasecmp(v->value, "asreceived")) { 11188 confp->chan.cid_num[0] = '\0'; 11189 confp->chan.cid_name[0] = '\0'; 11190 } else { 11191 ast_callerid_split(v->value, confp->chan.cid_name, sizeof(confp->chan.cid_name), confp->chan.cid_num, sizeof(confp->chan.cid_num)); 11192 } 11193 } else if (!strcasecmp(v->name, "fullname")) { 11194 ast_copy_string(confp->chan.cid_name, v->value, sizeof(confp->chan.cid_name)); 11195 } else if (!strcasecmp(v->name, "cid_number")) { 11196 ast_copy_string(confp->chan.cid_num, v->value, sizeof(confp->chan.cid_num)); 11197 } else if (!strcasecmp(v->name, "useincomingcalleridondahditransfer") || !strcasecmp(v->name, "useincomingcalleridonzaptransfer")) { 11198 confp->chan.dahditrcallerid = ast_true(v->value); 11199 if (strstr(v->name, "zap")) { 11200 ast_log(LOG_WARNING, "Option useincomingcalleridonzaptransfer has been deprecated in favor of useincomingcalleridondahditransfer (in [%s]).\n", cat); 11201 } 11202 } else if (!strcasecmp(v->name, "restrictcid")) { 11203 confp->chan.restrictcid = ast_true(v->value); 11204 } else if (!strcasecmp(v->name, "usecallingpres")) { 11205 confp->chan.use_callingpres = ast_true(v->value); 11206 } else if (!strcasecmp(v->name, "accountcode")) { 11207 ast_copy_string(confp->chan.accountcode, v->value, sizeof(confp->chan.accountcode)); 11208 } else if (!strcasecmp(v->name, "amaflags")) { 11209 y = ast_cdr_amaflags2int(v->value); 11210 if (y < 0) 11211 ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n", v->value, v->lineno); 11212 else 11213 confp->chan.amaflags = y; 11214 } else if (!strcasecmp(v->name, "polarityonanswerdelay")) { 11215 confp->chan.polarityonanswerdelay = atoi(v->value); 11216 } else if (!strcasecmp(v->name, "answeronpolarityswitch")) { 11217 confp->chan.answeronpolarityswitch = ast_true(v->value); 11218 } else if (!strcasecmp(v->name, "hanguponpolarityswitch")) { 11219 confp->chan.hanguponpolarityswitch = ast_true(v->value); 11220 } else if (!strcasecmp(v->name, "sendcalleridafter")) { 11221 confp->chan.sendcalleridafter = atoi(v->value); 11222 } else if (reload != 1){ 11223 if (!strcasecmp(v->name, "signalling")) { 11224 confp->chan.outsigmod = -1; 11225 if (!strcasecmp(v->value, "em")) { 11226 confp->chan.sig = SIG_EM; 11227 } else if (!strcasecmp(v->value, "em_e1")) { 11228 confp->chan.sig = SIG_EM_E1; 11229 } else if (!strcasecmp(v->value, "em_w")) { 11230 confp->chan.sig = SIG_EMWINK; 11231 confp->chan.radio = 0; 11232 } else if (!strcasecmp(v->value, "fxs_ls")) { 11233 confp->chan.sig = SIG_FXSLS; 11234 confp->chan.radio = 0; 11235 } else if (!strcasecmp(v->value, "fxs_gs")) { 11236 confp->chan.sig = SIG_FXSGS; 11237 confp->chan.radio = 0; 11238 } else if (!strcasecmp(v->value, "fxs_ks")) { 11239 confp->chan.sig = SIG_FXSKS; 11240 confp->chan.radio = 0; 11241 } else if (!strcasecmp(v->value, "fxo_ls")) { 11242 confp->chan.sig = SIG_FXOLS; 11243 confp->chan.radio = 0; 11244 } else if (!strcasecmp(v->value, "fxo_gs")) { 11245 confp->chan.sig = SIG_FXOGS; 11246 confp->chan.radio = 0; 11247 } else if (!strcasecmp(v->value, "fxo_ks")) { 11248 confp->chan.sig = SIG_FXOKS; 11249 confp->chan.radio = 0; 11250 } else if (!strcasecmp(v->value, "fxs_rx")) { 11251 confp->chan.sig = SIG_FXSKS; 11252 confp->chan.radio = 1; 11253 } else if (!strcasecmp(v->value, "fxo_rx")) { 11254 confp->chan.sig = SIG_FXOLS; 11255 confp->chan.radio = 1; 11256 } else if (!strcasecmp(v->value, "fxs_tx")) { 11257 confp->chan.sig = SIG_FXSLS; 11258 confp->chan.radio = 1; 11259 } else if (!strcasecmp(v->value, "fxo_tx")) { 11260 confp->chan.sig = SIG_FXOGS; 11261 confp->chan.radio = 1; 11262 } else if (!strcasecmp(v->value, "em_rx")) { 11263 confp->chan.sig = SIG_EM; 11264 confp->chan.radio = 1; 11265 } else if (!strcasecmp(v->value, "em_tx")) { 11266 confp->chan.sig = SIG_EM; 11267 confp->chan.radio = 1; 11268 } else if (!strcasecmp(v->value, "em_rxtx")) { 11269 confp->chan.sig = SIG_EM; 11270 confp->chan.radio = 2; 11271 } else if (!strcasecmp(v->value, "em_txrx")) { 11272 confp->chan.sig = SIG_EM; 11273 confp->chan.radio = 2; 11274 } else if (!strcasecmp(v->value, "sf")) { 11275 confp->chan.sig = SIG_SF; 11276 confp->chan.radio = 0; 11277 } else if (!strcasecmp(v->value, "sf_w")) { 11278 confp->chan.sig = SIG_SFWINK; 11279 confp->chan.radio = 0; 11280 } else if (!strcasecmp(v->value, "sf_featd")) { 11281 confp->chan.sig = SIG_FEATD; 11282 confp->chan.radio = 0; 11283 } else if (!strcasecmp(v->value, "sf_featdmf")) { 11284 confp->chan.sig = SIG_FEATDMF; 11285 confp->chan.radio = 0; 11286 } else if (!strcasecmp(v->value, "sf_featb")) { 11287 confp->chan.sig = SIG_SF_FEATB; 11288 confp->chan.radio = 0; 11289 } else if (!strcasecmp(v->value, "sf")) { 11290 confp->chan.sig = SIG_SF; 11291 confp->chan.radio = 0; 11292 } else if (!strcasecmp(v->value, "sf_rx")) { 11293 confp->chan.sig = SIG_SF; 11294 confp->chan.radio = 1; 11295 } else if (!strcasecmp(v->value, "sf_tx")) { 11296 confp->chan.sig = SIG_SF; 11297 confp->chan.radio = 1; 11298 } else if (!strcasecmp(v->value, "sf_rxtx")) { 11299 confp->chan.sig = SIG_SF; 11300 confp->chan.radio = 2; 11301 } else if (!strcasecmp(v->value, "sf_txrx")) { 11302 confp->chan.sig = SIG_SF; 11303 confp->chan.radio = 2; 11304 } else if (!strcasecmp(v->value, "featd")) { 11305 confp->chan.sig = SIG_FEATD; 11306 confp->chan.radio = 0; 11307 } else if (!strcasecmp(v->value, "featdmf")) { 11308 confp->chan.sig = SIG_FEATDMF; 11309 confp->chan.radio = 0; 11310 } else if (!strcasecmp(v->value, "featdmf_ta")) { 11311 confp->chan.sig = SIG_FEATDMF_TA; 11312 confp->chan.radio = 0; 11313 } else if (!strcasecmp(v->value, "e911")) { 11314 confp->chan.sig = SIG_E911; 11315 confp->chan.radio = 0; 11316 } else if (!strcasecmp(v->value, "fgccama")) { 11317 confp->chan.sig = SIG_FGC_CAMA; 11318 confp->chan.radio = 0; 11319 } else if (!strcasecmp(v->value, "fgccamamf")) { 11320 confp->chan.sig = SIG_FGC_CAMAMF; 11321 confp->chan.radio = 0; 11322 } else if (!strcasecmp(v->value, "featb")) { 11323 confp->chan.sig = SIG_FEATB; 11324 confp->chan.radio = 0; 11325 #ifdef HAVE_PRI 11326 } else if (!strcasecmp(v->value, "pri_net")) { 11327 confp->chan.radio = 0; 11328 confp->chan.sig = SIG_PRI; 11329 confp->pri.nodetype = PRI_NETWORK; 11330 } else if (!strcasecmp(v->value, "pri_cpe")) { 11331 confp->chan.sig = SIG_PRI; 11332 confp->chan.radio = 0; 11333 confp->pri.nodetype = PRI_CPE; 11334 } else if (!strcasecmp(v->value, "gr303fxoks_net")) { 11335 confp->chan.sig = SIG_GR303FXOKS; 11336 confp->chan.radio = 0; 11337 confp->pri.nodetype = PRI_NETWORK; 11338 } else if (!strcasecmp(v->value, "gr303fxsks_cpe")) { 11339 confp->chan.sig = SIG_GR303FXSKS; 11340 confp->chan.radio = 0; 11341 confp->pri.nodetype = PRI_CPE; 11342 #endif 11343 } else { 11344 ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value); 11345 } 11346 } else if (!strcasecmp(v->name, "outsignalling")) { 11347 if (!strcasecmp(v->value, "em")) { 11348 confp->chan.outsigmod = SIG_EM; 11349 } else if (!strcasecmp(v->value, "em_e1")) { 11350 confp->chan.outsigmod = SIG_EM_E1; 11351 } else if (!strcasecmp(v->value, "em_w")) { 11352 confp->chan.outsigmod = SIG_EMWINK; 11353 } else if (!strcasecmp(v->value, "sf")) { 11354 confp->chan.outsigmod = SIG_SF; 11355 } else if (!strcasecmp(v->value, "sf_w")) { 11356 confp->chan.outsigmod = SIG_SFWINK; 11357 } else if (!strcasecmp(v->value, "sf_featd")) { 11358 confp->chan.outsigmod = SIG_FEATD; 11359 } else if (!strcasecmp(v->value, "sf_featdmf")) { 11360 confp->chan.outsigmod = SIG_FEATDMF; 11361 } else if (!strcasecmp(v->value, "sf_featb")) { 11362 confp->chan.outsigmod = SIG_SF_FEATB; 11363 } else if (!strcasecmp(v->value, "sf")) { 11364 confp->chan.outsigmod = SIG_SF; 11365 } else if (!strcasecmp(v->value, "featd")) { 11366 confp->chan.outsigmod = SIG_FEATD; 11367 } else if (!strcasecmp(v->value, "featdmf")) { 11368 confp->chan.outsigmod = SIG_FEATDMF; 11369 } else if (!strcasecmp(v->value, "featdmf_ta")) { 11370 confp->chan.outsigmod = SIG_FEATDMF_TA; 11371 } else if (!strcasecmp(v->value, "e911")) { 11372 confp->chan.outsigmod = SIG_E911; 11373 } else if (!strcasecmp(v->value, "fgccama")) { 11374 confp->chan.outsigmod = SIG_FGC_CAMA; 11375 } else if (!strcasecmp(v->value, "fgccamamf")) { 11376 confp->chan.outsigmod = SIG_FGC_CAMAMF; 11377 } else if (!strcasecmp(v->value, "featb")) { 11378 confp->chan.outsigmod = SIG_FEATB; 11379 } else { 11380 ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value); 11381 } 11382 #ifdef HAVE_PRI 11383 } else if (!strcasecmp(v->name, "pridialplan")) { 11384 if (!strcasecmp(v->value, "national")) { 11385 confp->pri.dialplan = PRI_NATIONAL_ISDN + 1; 11386 } else if (!strcasecmp(v->value, "unknown")) { 11387 confp->pri.dialplan = PRI_UNKNOWN + 1; 11388 } else if (!strcasecmp(v->value, "private")) { 11389 confp->pri.dialplan = PRI_PRIVATE + 1; 11390 } else if (!strcasecmp(v->value, "international")) { 11391 confp->pri.dialplan = PRI_INTERNATIONAL_ISDN + 1; 11392 } else if (!strcasecmp(v->value, "local")) { 11393 confp->pri.dialplan = PRI_LOCAL_ISDN + 1; 11394 } else if (!strcasecmp(v->value, "dynamic")) { 11395 confp->pri.dialplan = -1; 11396 } else { 11397 ast_log(LOG_WARNING, "Unknown PRI dialplan '%s' at line %d.\n", v->value, v->lineno); 11398 } 11399 } else if (!strcasecmp(v->name, "prilocaldialplan")) { 11400 if (!strcasecmp(v->value, "national")) { 11401 confp->pri.localdialplan = PRI_NATIONAL_ISDN + 1; 11402 } else if (!strcasecmp(v->value, "unknown")) { 11403 confp->pri.localdialplan = PRI_UNKNOWN + 1; 11404 } else if (!strcasecmp(v->value, "private")) { 11405 confp->pri.localdialplan = PRI_PRIVATE + 1; 11406 } else if (!strcasecmp(v->value, "international")) { 11407 confp->pri.localdialplan = PRI_INTERNATIONAL_ISDN + 1; 11408 } else if (!strcasecmp(v->value, "local")) { 11409 confp->pri.localdialplan = PRI_LOCAL_ISDN + 1; 11410 } else if (!strcasecmp(v->value, "dynamic")) { 11411 confp->pri.localdialplan = -1; 11412 } else { 11413 ast_log(LOG_WARNING, "Unknown PRI dialplan '%s' at line %d.\n", v->value, v->lineno); 11414 } 11415 } else if (!strcasecmp(v->name, "switchtype")) { 11416 if (!strcasecmp(v->value, "national")) 11417 confp->pri.switchtype = PRI_SWITCH_NI2; 11418 else if (!strcasecmp(v->value, "ni1")) 11419 confp->pri.switchtype = PRI_SWITCH_NI1; 11420 else if (!strcasecmp(v->value, "dms100")) 11421 confp->pri.switchtype = PRI_SWITCH_DMS100; 11422 else if (!strcasecmp(v->value, "4ess")) 11423 confp->pri.switchtype = PRI_SWITCH_ATT4ESS; 11424 else if (!strcasecmp(v->value, "5ess")) 11425 confp->pri.switchtype = PRI_SWITCH_LUCENT5E; 11426 else if (!strcasecmp(v->value, "euroisdn")) 11427 confp->pri.switchtype = PRI_SWITCH_EUROISDN_E1; 11428 else if (!strcasecmp(v->value, "qsig")) 11429 confp->pri.switchtype = PRI_SWITCH_QSIG; 11430 else { 11431 ast_log(LOG_ERROR, "Unknown switchtype '%s'\n", v->value); 11432 return -1; 11433 } 11434 } else if (!strcasecmp(v->name, "nsf")) { 11435 if (!strcasecmp(v->value, "sdn")) 11436 confp->pri.nsf = PRI_NSF_SDN; 11437 else if (!strcasecmp(v->value, "megacom")) 11438 confp->pri.nsf = PRI_NSF_MEGACOM; 11439 else if (!strcasecmp(v->value, "tollfreemegacom")) 11440 confp->pri.nsf = PRI_NSF_TOLL_FREE_MEGACOM; 11441 else if (!strcasecmp(v->value, "accunet")) 11442 confp->pri.nsf = PRI_NSF_ACCUNET; 11443 else if (!strcasecmp(v->value, "none")) 11444 confp->pri.nsf = PRI_NSF_NONE; 11445 else { 11446 ast_log(LOG_WARNING, "Unknown network-specific facility '%s'\n", v->value); 11447 confp->pri.nsf = PRI_NSF_NONE; 11448 } 11449 } else if (!strcasecmp(v->name, "priindication")) { 11450 if (!strcasecmp(v->value, "outofband")) 11451 confp->chan.priindication_oob = 1; 11452 else if (!strcasecmp(v->value, "inband")) 11453 confp->chan.priindication_oob = 0; 11454 else 11455 ast_log(LOG_WARNING, "'%s' is not a valid pri indication value, should be 'inband' or 'outofband' at line %d\n", 11456 v->value, v->lineno); 11457 } else if (!strcasecmp(v->name, "priexclusive")) { 11458 confp->chan.priexclusive = ast_true(v->value); 11459 } else if (!strcasecmp(v->name, "internationalprefix")) { 11460 ast_copy_string(confp->pri.internationalprefix, v->value, sizeof(confp->pri.internationalprefix)); 11461 } else if (!strcasecmp(v->name, "nationalprefix")) { 11462 ast_copy_string(confp->pri.nationalprefix, v->value, sizeof(confp->pri.nationalprefix)); 11463 } else if (!strcasecmp(v->name, "localprefix")) { 11464 ast_copy_string(confp->pri.localprefix, v->value, sizeof(confp->pri.localprefix)); 11465 } else if (!strcasecmp(v->name, "privateprefix")) { 11466 ast_copy_string(confp->pri.privateprefix, v->value, sizeof(confp->pri.privateprefix)); 11467 } else if (!strcasecmp(v->name, "unknownprefix")) { 11468 ast_copy_string(confp->pri.unknownprefix, v->value, sizeof(confp->pri.unknownprefix)); 11469 } else if (!strcasecmp(v->name, "resetinterval")) { 11470 if (!strcasecmp(v->value, "never")) 11471 confp->pri.resetinterval = -1; 11472 else if (atoi(v->value) >= 60) 11473 confp->pri.resetinterval = atoi(v->value); 11474 else 11475 ast_log(LOG_WARNING, "'%s' is not a valid reset interval, should be >= 60 seconds or 'never' at line %d\n", 11476 v->value, v->lineno); 11477 } else if (!strcasecmp(v->name, "minunused")) { 11478 confp->pri.minunused = atoi(v->value); 11479 } else if (!strcasecmp(v->name, "minidle")) { 11480 confp->pri.minidle = atoi(v->value); 11481 } else if (!strcasecmp(v->name, "idleext")) { 11482 ast_copy_string(confp->pri.idleext, v->value, sizeof(confp->pri.idleext)); 11483 } else if (!strcasecmp(v->name, "idledial")) { 11484 ast_copy_string(confp->pri.idledial, v->value, sizeof(confp->pri.idledial)); 11485 } else if (!strcasecmp(v->name, "overlapdial")) { 11486 confp->pri.overlapdial = ast_true(v->value); 11487 #ifdef HAVE_PRI_INBANDDISCONNECT 11488 } else if (!strcasecmp(v->name, "inbanddisconnect")) { 11489 confp->pri.inbanddisconnect = ast_true(v->value); 11490 #endif 11491 } else if (!strcasecmp(v->name, "pritimer")) { 11492 #ifdef PRI_GETSET_TIMERS 11493 char *timerc, *c; 11494 int timer, timeridx; 11495 c = v->value; 11496 timerc = strsep(&c, ","); 11497 if (timerc) { 11498 timer = atoi(c); 11499 if (!timer) 11500 ast_log(LOG_WARNING, "'%s' is not a valid value for an ISDN timer\n", timerc); 11501 else { 11502 if ((timeridx = pri_timer2idx(timerc)) >= 0) 11503 pritimers[timeridx] = timer; 11504 else 11505 ast_log(LOG_WARNING, "'%s' is not a valid ISDN timer\n", timerc); 11506 } 11507 } else 11508 ast_log(LOG_WARNING, "'%s' is not a valid ISDN timer configuration string\n", v->value); 11509 11510 } else if (!strcasecmp(v->name, "facilityenable")) { 11511 confp->pri.facilityenable = ast_true(v->value); 11512 #endif /* PRI_GETSET_TIMERS */ 11513 #endif /* HAVE_PRI */ 11514 } else if (!strcasecmp(v->name, "cadence")) { 11515 /* setup to scan our argument */ 11516 int element_count, c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 11517 int i; 11518 struct dahdi_ring_cadence new_cadence; 11519 int cid_location = -1; 11520 int firstcadencepos = 0; 11521 char original_args[80]; 11522 int cadence_is_ok = 1; 11523 11524 ast_copy_string(original_args, v->value, sizeof(original_args)); 11525 /* 16 cadences allowed (8 pairs) */ 11526 element_count = sscanf(v->value, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4], &c[5], &c[6], &c[7], &c[8], &c[9], &c[10], &c[11], &c[12], &c[13], &c[14], &c[15]); 11527 11528 /* Cadence must be even (on/off) */ 11529 if (element_count % 2 == 1) { 11530 ast_log(LOG_ERROR, "Must be a silence duration for each ring duration: %s\n",original_args); 11531 cadence_is_ok = 0; 11532 } 11533 11534 /* Ring cadences cannot be negative */ 11535 for (i = 0; i < element_count; i++) { 11536 if (c[i] == 0) { 11537 ast_log(LOG_ERROR, "Ring or silence duration cannot be zero: %s\n", original_args); 11538 cadence_is_ok = 0; 11539 break; 11540 } else if (c[i] < 0) { 11541 if (i % 2 == 1) { 11542 /* Silence duration, negative possibly okay */ 11543 if (cid_location == -1) { 11544 cid_location = i; 11545 c[i] *= -1; 11546 } else { 11547 ast_log(LOG_ERROR, "CID location specified twice: %s\n",original_args); 11548 cadence_is_ok = 0; 11549 break; 11550 } 11551 } else { 11552 if (firstcadencepos == 0) { 11553 firstcadencepos = i; /* only recorded to avoid duplicate specification */ 11554 /* duration will be passed negative to the DAHDI driver */ 11555 } else { 11556 ast_log(LOG_ERROR, "First cadence position specified twice: %s\n",original_args); 11557 cadence_is_ok = 0; 11558 break; 11559 } 11560 } 11561 } 11562 } 11563 11564 /* Substitute our scanned cadence */ 11565 for (i = 0; i < 16; i++) { 11566 new_cadence.ringcadence[i] = c[i]; 11567 } 11568 11569 if (cadence_is_ok) { 11570 /* ---we scanned it without getting annoyed; now some sanity checks--- */ 11571 if (element_count < 2) { 11572 ast_log(LOG_ERROR, "Minimum cadence is ring,pause: %s\n", original_args); 11573 } else { 11574 if (cid_location == -1) { 11575 /* user didn't say; default to first pause */ 11576 cid_location = 1; 11577 } else { 11578 /* convert element_index to cidrings value */ 11579 cid_location = (cid_location + 1) / 2; 11580 } 11581 /* ---we like their cadence; try to install it--- */ 11582 if (!user_has_defined_cadences++) 11583 /* this is the first user-defined cadence; clear the default user cadences */ 11584 num_cadence = 0; 11585 if ((num_cadence+1) >= NUM_CADENCE_MAX) 11586 ast_log(LOG_ERROR, "Already %d cadences; can't add another: %s\n", NUM_CADENCE_MAX, original_args); 11587 else { 11588 cadences[num_cadence] = new_cadence; 11589 cidrings[num_cadence++] = cid_location; 11590 if (option_verbose > 2) 11591 ast_verbose(VERBOSE_PREFIX_3 "cadence 'r%d' added: %s\n",num_cadence,original_args); 11592 } 11593 } 11594 } 11595 } else if (!strcasecmp(v->name, "ringtimeout")) { 11596 ringt_base = (atoi(v->value) * 8) / READ_SIZE; 11597 } else if (!strcasecmp(v->name, "prewink")) { 11598 confp->timing.prewinktime = atoi(v->value); 11599 } else if (!strcasecmp(v->name, "preflash")) { 11600 confp->timing.preflashtime = atoi(v->value); 11601 } else if (!strcasecmp(v->name, "wink")) { 11602 confp->timing.winktime = atoi(v->value); 11603 } else if (!strcasecmp(v->name, "flash")) { 11604 confp->timing.flashtime = atoi(v->value); 11605 } else if (!strcasecmp(v->name, "start")) { 11606 confp->timing.starttime = atoi(v->value); 11607 } else if (!strcasecmp(v->name, "rxwink")) { 11608 confp->timing.rxwinktime = atoi(v->value); 11609 } else if (!strcasecmp(v->name, "rxflash")) { 11610 confp->timing.rxflashtime = atoi(v->value); 11611 } else if (!strcasecmp(v->name, "debounce")) { 11612 confp->timing.debouncetime = atoi(v->value); 11613 } else if (!strcasecmp(v->name, "toneduration")) { 11614 int toneduration; 11615 int ctlfd; 11616 int res; 11617 struct dahdi_dialparams dps; 11618 11619 #ifdef HAVE_ZAPTEL 11620 ctlfd = open("/dev/zap/ctl", O_RDWR); 11621 #else 11622 ctlfd = open("/dev/dahdi/ctl", O_RDWR); 11623 #endif 11624 11625 if (ctlfd == -1) { 11626 ast_log(LOG_ERROR, "Unable to open /dev/dahdi/ctl to set toneduration\n"); 11627 return -1; 11628 } 11629 11630 toneduration = atoi(v->value); 11631 if (toneduration > -1) { 11632 memset(&dps, 0, sizeof(dps)); 11633 11634 dps.dtmf_tonelen = dps.mfv1_tonelen = toneduration; 11635 res = ioctl(ctlfd, DAHDI_SET_DIALPARAMS, &dps); 11636 if (res < 0) { 11637 ast_log(LOG_ERROR, "Invalid tone duration: %d ms: %s\n", toneduration, strerror(errno)); 11638 return -1; 11639 } 11640 } 11641 close(ctlfd); 11642 } else if (!strcasecmp(v->name, "defaultcic")) { 11643 ast_copy_string(defaultcic, v->value, sizeof(defaultcic)); 11644 } else if (!strcasecmp(v->name, "defaultozz")) { 11645 ast_copy_string(defaultozz, v->value, sizeof(defaultozz)); 11646 } 11647 } else if (!skipchannels) 11648 ast_log(LOG_WARNING, "Ignoring %s\n", v->name); 11649 } 11650 if (dahdichan[0]) { 11651 /* The user has set 'dahdichan' */ 11652 /*< \todo pass proper line number instead of 0 */ 11653 if (build_channels(confp, 0, dahdichan, reload, 0, &found_pseudo)) { 11654 return -1; 11655 } 11656 } 11657 /*< \todo why check for the pseudo in the per-channel section. 11658 * Any actual use for manual setup of the pseudo channel? */ 11659 if (!found_pseudo && reload == 0) { 11660 /* use the default configuration for a channel, so 11661 that any settings from real configured channels 11662 don't "leak" into the pseudo channel config 11663 */ 11664 struct dahdi_chan_conf conf = dahdi_chan_conf_default(); 11665 11666 tmp = mkintf(CHAN_PSEUDO, &conf, NULL, reload); 11667 11668 if (tmp) { 11669 if (option_verbose > 2) 11670 ast_verbose(VERBOSE_PREFIX_3 "Automatically generated pseudo channel\n"); 11671 } else { 11672 ast_log(LOG_WARNING, "Unable to register pseudo channel!\n"); 11673 } 11674 } 11675 return 0; 11676 }
| static int reload | ( | void | ) | [static] |
Definition at line 11985 of file chan_dahdi.c.
References ast_log(), LOG_WARNING, and setup_dahdi().
11986 { 11987 int res = 0; 11988 11989 res = setup_dahdi(1); 11990 if (res) { 11991 ast_log(LOG_WARNING, "Reload of chan_dahdi.so is unsuccessful!\n"); 11992 return -1; 11993 } 11994 return 0; 11995 }
| static int reset_conf | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1387 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, dahdi_pvt::confno, dahdi_subchannel::curconf, dahdi_subchannel::dfd, errno, LOG_WARNING, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_hangup().
01388 { 01389 struct dahdi_confinfo zi; 01390 memset(&zi, 0, sizeof(zi)); 01391 p->confno = -1; 01392 memset(&p->subs[SUB_REAL].curconf, 0, sizeof(p->subs[SUB_REAL].curconf)); 01393 if (p->subs[SUB_REAL].dfd > -1) { 01394 if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCONF, &zi)) 01395 ast_log(LOG_WARNING, "Failed to reset conferencing on channel %d: %s\n", p->channel, strerror(errno)); 01396 } 01397 return 0; 01398 }
| static int restart_monitor | ( | void | ) | [static] |
Start the channel monitor thread.
Definition at line 7128 of file chan_dahdi.c.
References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_pthread_create_background, AST_PTHREADT_NULL, AST_PTHREADT_STOP, do_monitor(), LOG_ERROR, LOG_WARNING, and monlock.
Referenced by dahdi_hangup(), dahdi_request(), h323_reload(), load_module(), mgcp_reload(), mgcp_request(), oh323_request(), ooh323_reload(), ooh323_request(), phone_hangup(), phone_request(), setup_dahdi(), sip_reload(), sip_request_call(), and skinny_request().
07129 { 07130 pthread_attr_t attr; 07131 pthread_attr_init(&attr); 07132 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 07133 /* If we're supposed to be stopped -- stay stopped */ 07134 if (monitor_thread == AST_PTHREADT_STOP) 07135 return 0; 07136 ast_mutex_lock(&monlock); 07137 if (monitor_thread == pthread_self()) { 07138 ast_mutex_unlock(&monlock); 07139 ast_log(LOG_WARNING, "Cannot kill myself\n"); 07140 return -1; 07141 } 07142 if (monitor_thread != AST_PTHREADT_NULL) { 07143 /* Wake up the thread */ 07144 pthread_kill(monitor_thread, SIGURG); 07145 } else { 07146 /* Start a new monitor */ 07147 if (ast_pthread_create_background(&monitor_thread, &attr, do_monitor, NULL) < 0) { 07148 ast_mutex_unlock(&monlock); 07149 ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); 07150 pthread_attr_destroy(&attr); 07151 return -1; 07152 } 07153 } 07154 ast_mutex_unlock(&monlock); 07155 pthread_attr_destroy(&attr); 07156 return 0; 07157 }
| static int restore_conference | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1720 of file chan_dahdi.c.
References ast_log(), dahdi_subchannel::dfd, errno, LOG_DEBUG, LOG_WARNING, option_debug, dahdi_pvt::saveconf, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_handle_event(), dahdi_read(), and send_callerid().
01721 { 01722 int res; 01723 if (p->saveconf.confmode) { 01724 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCONF, &p->saveconf); 01725 p->saveconf.confmode = 0; 01726 if (res) { 01727 ast_log(LOG_WARNING, "Unable to restore conference info: %s\n", strerror(errno)); 01728 return -1; 01729 } 01730 } 01731 if (option_debug) 01732 ast_log(LOG_DEBUG, "Restored conferencing\n"); 01733 return 0; 01734 }
| static int restore_gains | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1646 of file chan_dahdi.c.
References ast_log(), dahdi_subchannel::dfd, errno, dahdi_pvt::law, LOG_WARNING, dahdi_pvt::rxgain, set_actual_gain(), SUB_REAL, dahdi_pvt::subs, and dahdi_pvt::txgain.
Referenced by dahdi_hangup(), and ss_thread().
01647 { 01648 int res; 01649 01650 res = set_actual_gain(p->subs[SUB_REAL].dfd, 0, p->rxgain, p->txgain, p->law); 01651 if (res) { 01652 ast_log(LOG_WARNING, "Unable to restore gains: %s\n", strerror(errno)); 01653 return -1; 01654 } 01655 01656 return 0; 01657 }
| static int save_conference | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1692 of file chan_dahdi.c.
References ast_log(), dahdi_subchannel::dfd, errno, LOG_DEBUG, LOG_WARNING, option_debug, dahdi_pvt::saveconf, SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_callwait(), and dahdi_handle_event().
01693 { 01694 struct dahdi_confinfo c; 01695 int res; 01696 if (p->saveconf.confmode) { 01697 ast_log(LOG_WARNING, "Can't save conference -- already in use\n"); 01698 return -1; 01699 } 01700 p->saveconf.chan = 0; 01701 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GETCONF, &p->saveconf); 01702 if (res) { 01703 ast_log(LOG_WARNING, "Unable to get conference info: %s\n", strerror(errno)); 01704 p->saveconf.confmode = 0; 01705 return -1; 01706 } 01707 c.chan = 0; 01708 c.confno = 0; 01709 c.confmode = DAHDI_CONF_NORMAL; 01710 res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETCONF, &c); 01711 if (res) { 01712 ast_log(LOG_WARNING, "Unable to set conference info: %s\n", strerror(errno)); 01713 return -1; 01714 } 01715 if (option_debug) 01716 ast_log(LOG_DEBUG, "Disabled conferencing\n"); 01717 return 0; 01718 }
| static int send_callerid | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1760 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::callwaitcas, CIDCW_EXPIRE_SAMPLES, dahdi_pvt::cidcwexpire, dahdi_pvt::cidlen, dahdi_pvt::cidpos, dahdi_pvt::cidspill, dahdi_setlinear(), dahdi_subchannel::dfd, errno, free, dahdi_subchannel::linear, LOG_WARNING, restore_conference(), SUB_REAL, and dahdi_pvt::subs.
Referenced by dahdi_call(), dahdi_callwait(), dahdi_read(), and send_cwcidspill().
01761 { 01762 /* Assumes spill in p->cidspill, p->cidlen in length and we're p->cidpos into it */ 01763 int res; 01764 /* Take out of linear mode if necessary */ 01765 if (p->subs[SUB_REAL].linear) { 01766 p->subs[SUB_REAL].linear = 0; 01767 dahdi_setlinear(p->subs[SUB_REAL].dfd, 0); 01768 } 01769 while (p->cidpos < p->cidlen) { 01770 res = write(p->subs[SUB_REAL].dfd, p->cidspill + p->cidpos, p->cidlen - p->cidpos); 01771 if (res < 0) { 01772 if (errno == EAGAIN) 01773 return 0; 01774 else { 01775 ast_log(LOG_WARNING, "write failed: %s\n", strerror(errno)); 01776 return -1; 01777 } 01778 } 01779 if (!res) 01780 return 0; 01781 p->cidpos += res; 01782 } 01783 free(p->cidspill); 01784 p->cidspill = NULL; 01785 if (p->callwaitcas) { 01786 /* Wait for CID/CW to expire */ 01787 p->cidcwexpire = CIDCW_EXPIRE_SAMPLES; 01788 } else 01789 restore_conference(p); 01790 return 0; 01791 }
| static int send_cwcidspill | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1738 of file chan_dahdi.c.
References ast_callerid_callwaiting_generate(), AST_LAW, ast_malloc, ast_verbose(), dahdi_pvt::callwait_name, dahdi_pvt::callwait_num, dahdi_pvt::callwaitcas, dahdi_pvt::cidcwexpire, dahdi_pvt::cidlen, dahdi_pvt::cidpos, dahdi_pvt::cidspill, MAX_CALLERID_SIZE, option_verbose, READ_SIZE, send_callerid(), and VERBOSE_PREFIX_3.
Referenced by dahdi_handle_dtmfup().
01739 { 01740 p->callwaitcas = 0; 01741 p->cidcwexpire = 0; 01742 if (!(p->cidspill = ast_malloc(MAX_CALLERID_SIZE))) 01743 return -1; 01744 p->cidlen = ast_callerid_callwaiting_generate(p->cidspill, p->callwait_name, p->callwait_num, AST_LAW(p)); 01745 /* Make sure we account for the end */ 01746 p->cidlen += READ_SIZE * 4; 01747 p->cidpos = 0; 01748 send_callerid(p); 01749 if (option_verbose > 2) 01750 ast_verbose(VERBOSE_PREFIX_3 "CPE supports Call Waiting Caller*ID. Sending '%s/%s'\n", p->callwait_name, p->callwait_num); 01751 return 0; 01752 }
| static int set_actual_gain | ( | int | fd, | |
| int | chan, | |||
| float | rxgain, | |||
| float | txgain, | |||
| int | law | |||
| ) | [static] |
Definition at line 1627 of file chan_dahdi.c.
References set_actual_rxgain(), and set_actual_txgain().
Referenced by bump_gains(), dahdi_call(), mkintf(), and restore_gains().
01628 { 01629 return set_actual_txgain(fd, chan, txgain, law) | set_actual_rxgain(fd, chan, rxgain, law); 01630 }
| static int set_actual_rxgain | ( | int | fd, | |
| int | chan, | |||
| float | gain, | |||
| int | law | |||
| ) | [static] |
Definition at line 1609 of file chan_dahdi.c.
References ast_log(), errno, fill_rxgain(), and LOG_DEBUG.
Referenced by dahdi_setoption(), and set_actual_gain().
01610 { 01611 struct dahdi_gains g; 01612 int res; 01613 01614 memset(&g, 0, sizeof(g)); 01615 g.chan = chan; 01616 res = ioctl(fd, DAHDI_GETGAINS, &g); 01617 if (res) { 01618 ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno)); 01619 return res; 01620 } 01621 01622 fill_rxgain(&g, gain, law); 01623 01624 return ioctl(fd, DAHDI_SETGAINS, &g); 01625 }
| static int set_actual_txgain | ( | int | fd, | |
| int | chan, | |||
| float | gain, | |||
| int | law | |||
| ) | [static] |
Definition at line 1590 of file chan_dahdi.c.
References ast_log(), errno, fill_txgain(), LOG_DEBUG, and option_debug.
Referenced by dahdi_setoption(), and set_actual_gain().
01591 { 01592 struct dahdi_gains g; 01593 int res; 01594 01595 memset(&g, 0, sizeof(g)); 01596 g.chan = chan; 01597 res = ioctl(fd, DAHDI_GETGAINS, &g); 01598 if (res) { 01599 if (option_debug) 01600 ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno)); 01601 return res; 01602 } 01603 01604 fill_txgain(&g, gain, law); 01605 01606 return ioctl(fd, DAHDI_SETGAINS, &g); 01607 }
| static int setup_dahdi | ( | int | reload | ) | [static] |
Definition at line 11678 of file chan_dahdi.c.
References ast_category_browse(), ast_config_destroy(), ast_config_load(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), ast_variable_browse(), ast_variable_retrieve(), ast_verbose(), CHAN_ZAP_MODE, dahdi_chan_conf_default(), dahdi_chan_mode, global_jbconf, iflock, ast_variable::lineno, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_variable::name, ast_variable::next, option_verbose, process_dahdi(), restart_monitor(), ast_variable::value, and VERBOSE_PREFIX_2.
Referenced by dahdi_restart(), load_module(), and reload().
11679 { 11680 struct ast_config *cfg; 11681 struct ast_variable *v; 11682 struct dahdi_chan_conf conf = dahdi_chan_conf_default(); 11683 int res; 11684 11685 #ifdef HAVE_PRI 11686 char *c; 11687 int spanno; 11688 int i, x; 11689 int logicalspan; 11690 int trunkgroup; 11691 int dchannels[NUM_DCHANS]; 11692 #endif 11693 11694 #ifdef HAVE_ZAPTEL 11695 int load_from_zapata_conf = 1; 11696 #else 11697 int load_from_zapata_conf = (dahdi_chan_mode == CHAN_ZAP_MODE); 11698 #endif 11699 11700 if (load_from_zapata_conf) { 11701 if (!(cfg = ast_config_load("zapata.conf"))) { 11702 ast_log(LOG_ERROR, "Unable to load zapata.conf\n"); 11703 return 0; 11704 } 11705 } else { 11706 if (!(cfg = ast_config_load("chan_dahdi.conf"))) { 11707 ast_log(LOG_ERROR, "Unable to load chan_dahdi.conf\n"); 11708 return 0; 11709 } 11710 } 11711 11712 /* It's a little silly to lock it, but we mind as well just to be sure */ 11713 ast_mutex_lock(&iflock); 11714 #ifdef HAVE_PRI 11715 if (reload != 1) { 11716 /* Process trunkgroups first */ 11717 v = ast_variable_browse(cfg, "trunkgroups"); 11718 while (v) { 11719 if (!strcasecmp(v->name, "trunkgroup")) { 11720 trunkgroup = atoi(v->value); 11721 if (trunkgroup > 0) { 11722 if ((c = strchr(v->value, ','))) { 11723 i = 0; 11724 memset(dchannels, 0, sizeof(dchannels)); 11725 while (c && (i < NUM_DCHANS)) { 11726 dchannels[i] = atoi(c + 1); 11727 if (dchannels[i] < 0) { 11728 ast_log(LOG_WARNING, "D-channel for trunk group %d must be a postiive number at line %d of chan_dahdi.conf\n", trunkgroup, v->lineno); 11729 } else 11730 i++; 11731 c = strchr(c + 1, ','); 11732 } 11733 if (i) { 11734 if (pri_create_trunkgroup(trunkgroup, dchannels)) { 11735 ast_log(LOG_WARNING, "Unable to create trunk group %d with Primary D-channel %d at line %d of chan_dahdi.conf\n", trunkgroup, dchannels[0], v->lineno); 11736 } else if (option_verbose > 1) 11737 ast_verbose(VERBOSE_PREFIX_2 "Created trunk group %d with Primary D-channel %d and %d backup%s\n", trunkgroup, dchannels[0], i - 1, (i == 1) ? "" : "s"); 11738 } else 11739 ast_log(LOG_WARNING, "Trunk group %d lacks any valid D-channels at line %d of chan_dahdi.conf\n", trunkgroup, v->lineno); 11740 } else 11741 ast_log(LOG_WARNING, "Trunk group %d lacks a primary D-channel at line %d of chan_dahdi.conf\n", trunkgroup, v->lineno); 11742 } else 11743 ast_log(LOG_WARNING, "Trunk group identifier must be a positive integer at line %d of chan_dahdi.conf\n", v->lineno); 11744 } else if (!strcasecmp(v->name, "spanmap")) { 11745 spanno = atoi(v->value); 11746 if (spanno > 0) { 11747 if ((c = strchr(v->value, ','))) { 11748 trunkgroup = atoi(c + 1); 11749 if (trunkgroup > 0) { 11750 if ((c = strchr(c + 1, ','))) 11751 logicalspan = atoi(c + 1); 11752 else 11753 logicalspan = 0; 11754 if (logicalspan >= 0) { 11755 if (pri_create_spanmap(spanno - 1, trunkgroup, logicalspan)) { 11756 ast_log(LOG_WARNING, "Failed to map span %d to trunk group %d (logical span %d)\n", spanno, trunkgroup, logicalspan); 11757 } else if (option_verbose > 1) 11758 ast_verbose(VERBOSE_PREFIX_2 "Mapped span %d to trunk group %d (logical span %d)\n", spanno, trunkgroup, logicalspan); 11759 } else 11760 ast_log(LOG_WARNING, "Logical span must be a postive number, or '0' (for unspecified) at line %d of chan_dahdi.conf\n", v->lineno); 11761 } else 11762 ast_log(LOG_WARNING, "Trunk group must be a postive number at line %d of chan_dahdi.conf\n", v->lineno); 11763 } else 11764 ast_log(LOG_WARNING, "Missing trunk group for span map at line %d of chan_dahdi.conf\n", v->lineno); 11765 } else 11766 ast_log(LOG_WARNING, "Span number must be a postive integer at line %d of chan_dahdi.conf\n", v->lineno); 11767 } else { 11768 ast_log(LOG_NOTICE, "Ignoring unknown keyword '%s' in trunkgroups\n", v->name); 11769 } 11770 v = v->next; 11771 } 11772 } 11773 #endif 11774 11775 /* Copy the default jb config over global_jbconf */ 11776 memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); 11777 11778 v = ast_variable_browse(cfg, "channels"); 11779 res = process_dahdi(&conf, "", v, reload, 0); 11780 ast_mutex_unlock(&iflock); 11781 ast_config_destroy(cfg); 11782 if (res) 11783 return res; 11784 cfg = ast_config_load("users.conf"); 11785 if (cfg) { 11786 char *cat; 11787 const char *chans; 11788 process_dahdi(&conf, "", ast_variable_browse(cfg, "general"), 1, 1); 11789 for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) { 11790 if (!strcasecmp(cat, "general")) 11791 continue; 11792 chans = ast_variable_retrieve(cfg, cat, "dahdichan"); 11793 if (!ast_strlen_zero(chans)) { 11794 struct dahdi_chan_conf sect_conf; 11795 memcpy(§_conf, &conf, sizeof(sect_conf)); 11796 11797 process_dahdi(§_conf, cat, ast_variable_browse(cfg, cat), reload, 0); 11798 } 11799 } 11800 ast_config_destroy(cfg); 11801 } 11802 #ifdef HAVE_PRI 11803 if (reload != 1) { 11804 for (x = 0; x < NUM_SPANS; x++) { 11805 if (pris[x].pvts[0]) { 11806 if (start_pri(pris + x)) { 11807 ast_log(LOG_ERROR, "Unable to start D-channel on span %d\n", x + 1); 11808 return -1; 11809 } else if (option_verbose > 1) 11810 ast_verbose(VERBOSE_PREFIX_2 "Starting D-Channel on span %d\n", x + 1); 11811 } 11812 } 11813 } 11814 #endif 11815 /* And start the monitor for the first time */ 11816 restart_monitor(); 11817 return 0; 11818 }
| static void * ss_thread | ( | void * | data | ) | [static] |
Definition at line 5548 of file chan_dahdi.c.
References ast_channel::_state, alloc_sub(), ast_bridged_channel(), ast_canmatch_extension(), AST_CAUSE_UNALLOCATED, ast_cond_signal(), AST_CONTROL_RING, AST_CONTROL_UNHOLD, ast_copy_string(), ast_db_put(), ast_dsp_digitmode(), ast_dsp_digitreset(), ast_dsp_free(), ast_exists_extension(), AST_FRAME_CONTROL, AST_FRAME_DTMF, ast_frfree, ast_hangup(), ast_ignore_pattern(), AST_LAW, ast_log(), ast_masq_park_call(), ast_matchmore_extension(), AST_MAX_EXTENSION, ast_mutex_lock(), ast_mutex_unlock(), ast_parking_ext(), ast_pbx_run(), ast_pickup_call(), ast_pickup_ext(), ast_queue_control(), ast_read(), ast_safe_sleep(), ast_say_digit_str(), ast_set_callerid(), ast_setstate(), ast_shrink_phone_number(), ast_smdi_md_message_destroy(), ast_smdi_md_message_wait(), AST_STATE_PRERING, AST_STATE_RING, AST_STATE_RINGING, ast_streamfile(), ast_strlen_zero(), ast_verbose(), ast_waitfor(), ast_waitfordigit(), ast_waitstream(), ASTOBJ_UNREF, bump_gains(), dahdi_pvt::call_forward, callerid_feed(), callerid_feed_jp(), callerid_free(), callerid_get(), callerid_get_dtmf(), callerid_new(), ast_smdi_md_message::calling_st, dahdi_pvt::callreturn, dahdi_pvt::callwaiting, dahdi_pvt::cancallforward, dahdi_pvt::canpark, dahdi_pvt::channel, ast_channel::cid, ast_callerid::cid_name, dahdi_pvt::cid_name, ast_callerid::cid_num, dahdi_pvt::cid_num, CID_SIG_DTMF, CID_SIG_SMDI, CID_SIG_V23, CID_SIG_V23_JP, dahdi_pvt::cid_signalling, dahdi_pvt::cid_start, CID_START_POLARITY, CID_START_RING, dahdi_pvt::context, ast_channel::context, ringContextData::contextData, counter, dahdi_chan_name, dahdi_enable_ec(), dahdi_get_event(), dahdi_get_index(), dahdi_set_hook(), dahdi_setlinear(), dahdi_wait_event(), dahdi_wink(), dahdi_pvt::defcontext, dahdi_subchannel::dfd, dahdi_pvt::dnd, dahdi_pvt::dop, dahdi_pvt::drings, dahdi_pvt::dsp, DSP_DIGITMODE_DTMF, DSP_DIGITMODE_MF, dahdi_pvt::dtmfrelax, errno, event2str(), EVENT_FLAG_SYSTEM, ast_channel::exten, dahdi_pvt::exten, exten, ast_frame::frametype, free, ast_smdi_md_message::fwd_st, ast_channel::hangupcause, dahdi_pvt::hanguponpolarityswitch, dahdi_pvt::hardwaredtmf, dahdi_pvt::hidecallerid, dahdi_pvt::immediate, ISTRUNK, ast_channel::language, dahdi_pvt::lastcid_num, len(), dahdi_subchannel::linear, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, manager_event(), my_getsigstr(), ast_channel::name, name, NEED_MFDETECT, option_debug, option_verbose, dahdi_pvt::owner, dahdi_subchannel::owner, pbx_builtin_setvar_helper(), dahdi_pvt::polarity, POLARITY_IDLE, POLARITY_REV, quit, restore_gains(), distRingData::ring, dahdi_distRings::ringContext, dahdi_distRings::ringnum, ast_channel::rings, dahdi_pvt::ringt, dahdi_pvt::ringt_base, dahdi_pvt::sig, sig2str, SIG_E911, SIG_EM, SIG_EM_E1, SIG_EMWINK, SIG_FEATB, SIG_FEATD, SIG_FEATDMF, SIG_FEATDMF_TA, SIG_FGC_CAMA, SIG_FGC_CAMAMF, SIG_FXOGS, SIG_FXOKS, SIG_FXOLS, SIG_FXSGS, SIG_FXSKS, SIG_FXSLS, SIG_PRI, SIG_SF, SIG_SF_FEATB, SIG_SF_FEATD, SIG_SF_FEATDMF, SIG_SFWINK, dahdi_pvt::smdi_iface, SMDI_MD_WAIT_TIMEOUT, ss_thread_lock, SUB_CALLWAIT, SUB_REAL, SUB_THREEWAY, ast_frame::subclass, dahdi_pvt::subs, swap_subs(), ast_channel::tech, ast_channel::tech_pvt, timeout, dahdi_pvt::transfer, ast_smdi_md_message::type, unalloc_sub(), dahdi_pvt::use_callerid, dahdi_pvt::use_smdi, dahdi_pvt::usedistinctiveringdetection, VERBOSE_PREFIX_2, and VERBOSE_PREFIX_3.
Referenced by dahdi_handle_event(), and handle_init_event().
05549 { 05550 struct ast_channel *chan = data; 05551 struct dahdi_pvt *p = chan->tech_pvt; 05552 char exten[AST_MAX_EXTENSION] = ""; 05553 char exten2[AST_MAX_EXTENSION] = ""; 05554 unsigned char buf[256]; 05555 char dtmfcid[300]; 05556 char dtmfbuf[300]; 05557 struct callerid_state *cs = NULL; 05558 char *name = NULL, *number = NULL; 05559 int distMatches; 05560 int curRingData[3]; 05561 int receivedRingT; 05562 int counter1; 05563 int counter; 05564 int samples = 0; 05565 struct ast_smdi_md_message *smdi_msg = NULL; 05566 int flags; 05567 int i; 05568 int timeout; 05569 int getforward = 0; 05570 char *s1, *s2; 05571 int len = 0; 05572 int res; 05573 int index; 05574 05575 ast_mutex_lock(&ss_thread_lock); 05576 ss_thread_count++; 05577 ast_mutex_unlock(&ss_thread_lock); 05578 /* in the bizarre case where the channel has become a zombie before we 05579 even get started here, abort safely 05580 */ 05581 if (!p) { 05582 ast_log(LOG_WARNING, "Channel became a zombie before simple switch could be started (%s)\n", chan->name); 05583 ast_hangup(chan); 05584 goto quit; 05585 } 05586 if (option_verbose > 2) 05587 ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s'\n", chan->name); 05588 index = dahdi_get_index(chan, p, 1); 05589 if (index < 0) { 05590 ast_log(LOG_WARNING, "Huh?\n"); 05591 ast_hangup(chan); 05592 goto quit; 05593 } 05594 if (p->dsp) 05595 ast_dsp_digitreset(p->dsp); 05596 switch (p->sig) { 05597 #ifdef HAVE_PRI 05598 case SIG_PRI: 05599 /* Now loop looking for an extension */ 05600 ast_copy_string(exten, p->exten, sizeof(exten)); 05601 len = strlen(exten); 05602 res = 0; 05603 while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) { 05604 if (len && !ast_ignore_pattern(chan->context, exten)) 05605 tone_zone_play_tone(p->subs[index].dfd, -1); 05606 else 05607 tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALTONE); 05608 if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) 05609 timeout = matchdigittimeout; 05610 else 05611 timeout = gendigittimeout; 05612 res = ast_waitfordigit(chan, timeout); 05613 if (res < 0) { 05614 ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); 05615 ast_hangup(chan); 05616 goto quit; 05617 } else if (res) { 05618 exten[len++] = res; 05619 exten[len] = '\0'; 05620 } else 05621 break; 05622 } 05623 /* if no extension was received ('unspecified') on overlap call, use the 's' extension */ 05624 if (ast_strlen_zero(exten)) { 05625 if (option_verbose > 2) 05626 ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of empty extension received on overlap call\n"); 05627 exten[0] = 's'; 05628 exten[1] = '\0'; 05629 } 05630 tone_zone_play_tone(p->subs[index].dfd, -1); 05631 if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) { 05632 /* Start the real PBX */ 05633 ast_copy_string(chan->exten, exten, sizeof(chan->exten)); 05634 if (p->dsp) ast_dsp_digitreset(p->dsp); 05635 dahdi_enable_ec(p); 05636 ast_setstate(chan, AST_STATE_RING); 05637 res = ast_pbx_run(chan); 05638 if (res) { 05639 ast_log(LOG_WARNING, "PBX exited non-zero!\n"); 05640 } 05641 } else { 05642 ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context); 05643 chan->hangupcause = AST_CAUSE_UNALLOCATED; 05644 ast_hangup(chan); 05645 p->exten[0] = '\0'; 05646 /* Since we send release complete here, we won't get one */ 05647 p->call = NULL; 05648 } 05649 goto quit; 05650 break; 05651 #endif 05652 case SIG_FEATD: 05653 case SIG_FEATDMF: 05654 case SIG_FEATDMF_TA: 05655 case SIG_E911: 05656 case SIG_FGC_CAMAMF: 05657 case SIG_FEATB: 05658 case SIG_EMWINK: 05659 case SIG_SF_FEATD: 05660 case SIG_SF_FEATDMF: 05661 case SIG_SF_FEATB: 05662 case SIG_SFWINK: 05663 if (dahdi_wink(p, index)) 05664 goto quit; 05665 /* Fall through */ 05666 case SIG_EM: 05667 case SIG_EM_E1: 05668 case SIG_SF: 05669 case SIG_FGC_CAMA: 05670 res = tone_zone_play_tone(p->subs[index].dfd, -1); 05671 if (p->dsp) 05672 ast_dsp_digitreset(p->dsp); 05673 /* set digit mode appropriately */ 05674 if (p->dsp) { 05675 if (NEED_MFDETECT(p)) 05676 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MF | p->dtmfrelax); 05677 else 05678 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); 05679 } 05680 memset(dtmfbuf, 0, sizeof(dtmfbuf)); 05681 /* Wait for the first digit only if immediate=no */ 05682 if (!p->immediate) 05683 /* Wait for the first digit (up to 5 seconds). */ 05684 res = ast_waitfordigit(chan, 5000); 05685 else 05686 res = 0; 05687 if (res > 0) { 05688 /* save first char */ 05689 dtmfbuf[0] = res; 05690 switch (p->sig) { 05691 case SIG_FEATD: 05692 case SIG_SF_FEATD: 05693 res = my_getsigstr(chan, dtmfbuf + 1, "*", 3000); 05694 if (res > 0) 05695 res = my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf), "*", 3000); 05696 if ((res < 1) && (p->dsp)) ast_dsp_digitreset(p->dsp); 05697 break; 05698 case SIG_FEATDMF_TA: 05699 res = my_getsigstr(chan, dtmfbuf + 1, "#", 3000); 05700 if ((res < 1) && (p->dsp)) ast_dsp_digitreset(p->dsp); 05701 if (dahdi_wink(p, index)) goto quit; 05702 dtmfbuf[0] = 0; 05703 /* Wait for the first digit (up to 5 seconds). */ 05704 res = ast_waitfordigit(chan, 5000); 05705 if (res <= 0) break; 05706 dtmfbuf[0] = res; 05707 /* fall through intentionally */ 05708 case SIG_FEATDMF: 05709 case SIG_E911: 05710 case SIG_FGC_CAMAMF: 05711 case SIG_SF_FEATDMF: 05712 res = my_getsigstr(chan, dtmfbuf + 1, "#", 3000); 05713 /* if international caca, do it again to get real ANO */ 05714 if ((p->sig == SIG_FEATDMF) && (dtmfbuf[1] != '0') && (strlen(dtmfbuf) != 14)) 05715 { 05716 if (dahdi_wink(p, index)) goto quit; 05717 dtmfbuf[0] = 0; 05718 /* Wait for the first digit (up to 5 seconds). */ 05719 res = ast_waitfordigit(chan, 5000); 05720 if (res <= 0) break; 05721 dtmfbuf[0] = res; 05722 res = my_getsigstr(chan, dtmfbuf + 1, "#", 3000); 05723 } 05724 if (res > 0) { 05725 /* if E911, take off hook */ 05726 if (p->sig == SIG_E911) 05727 dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_OFFHOOK); 05728 res = my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf), "#", 3000); 05729 } 05730 if ((res < 1) && (p->dsp)) ast_dsp_digitreset(p->dsp); 05731 break; 05732 case SIG_FEATB: 05733 case SIG_SF_FEATB: 05734 res = my_getsigstr(chan, dtmfbuf + 1, "#", 3000); 05735 if ((res < 1) && (p->dsp)) ast_dsp_digitreset(p->dsp); 05736 break; 05737 case SIG_EMWINK: 05738 /* if we received a '*', we are actually receiving Feature Group D 05739 dial syntax, so use that mode; otherwise, fall through to normal 05740 mode 05741 */ 05742 if (res == '*') { 05743 res = my_getsigstr(chan, dtmfbuf + 1, "*", 3000); 05744 if (res > 0) 05745 res = my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf), "*", 3000); 05746 if ((res < 1) && (p->dsp)) ast_dsp_digitreset(p->dsp); 05747 break; 05748 } 05749 default: 05750 /* If we got the first digit, get the rest */ 05751 len = 1; 05752 dtmfbuf[len] = '\0'; 05753 while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, dtmfbuf, 1, p->cid_num)) { 05754 if (ast_exists_extension(chan, chan->context, dtmfbuf, 1, p->cid_num)) { 05755 timeout = matchdigittimeout; 05756 } else { 05757 timeout = gendigittimeout; 05758 } 05759 res = ast_waitfordigit(chan, timeout); 05760 if (res < 0) { 05761 ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); 05762 ast_hangup(chan); 05763 goto quit; 05764 } else if (res) { 05765 dtmfbuf[len++] = res; 05766 dtmfbuf[len] = '\0'; 05767 } else { 05768 break; 05769 } 05770 } 05771 break; 05772 } 05773 } 05774 if (res == -1) { 05775 ast_log(LOG_WARNING, "getdtmf on channel %d: %s\n", p->channel, strerror(errno)); 05776 ast_hangup(chan); 05777 goto quit; 05778 } else if (res < 0) { 05779 ast_log(LOG_DEBUG, "Got hung up before digits finished\n"); 05780 ast_hangup(chan); 05781 goto quit; 05782 } 05783 05784 if (p->sig == SIG_FGC_CAMA) { 05785 char anibuf[100]; 05786 05787 if (ast_safe_sleep(chan,1000) == -1) { 05788 ast_hangup(chan); 05789 goto quit; 05790 } 05791 dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_OFFHOOK); 05792 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MF | p->dtmfrelax); 05793 res = my_getsigstr(chan, anibuf, "#", 10000); 05794 if ((res > 0) && (strlen(anibuf) > 2)) { 05795 if (anibuf[strlen(anibuf) - 1] == '#') 05796 anibuf[strlen(anibuf) - 1] = 0; 05797 ast_set_callerid(chan, anibuf + 2, NULL, anibuf + 2); 05798 } 05799 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); 05800 } 05801 05802 ast_copy_string(exten, dtmfbuf, sizeof(exten)); 05803 if (ast_strlen_zero(exten)) 05804 ast_copy_string(exten, "s", sizeof(exten)); 05805 if (p->sig == SIG_FEATD || p->sig == SIG_EMWINK) { 05806 /* Look for Feature Group D on all E&M Wink and Feature Group D trunks */ 05807 if (exten[0] == '*') { 05808 char *stringp=NULL; 05809 ast_copy_string(exten2, exten, sizeof(exten2)); 05810 /* Parse out extension and callerid */ 05811 stringp=exten2 +1; 05812 s1 = strsep(&stringp, "*"); 05813 s2 = strsep(&stringp, "*"); 05814 if (s2) { 05815 if (!ast_strlen_zero(p->cid_num)) 05816 ast_set_callerid(chan, p->cid_num, NULL, p->cid_num); 05817 else 05818 ast_set_callerid(chan, s1, NULL, s1); 05819 ast_copy_string(exten, s2, sizeof(exten)); 05820 } else 05821 ast_copy_string(exten, s1, sizeof(exten)); 05822 } else if (p->sig == SIG_FEATD) 05823 ast_log(LOG_WARNING, "Got a non-Feature Group D input on channel %d. Assuming E&M Wink instead\n", p->channel); 05824 } 05825 if ((p->sig == SIG_FEATDMF) || (p->sig == SIG_FEATDMF_TA)) { 05826 if (exten[0] == '*') { 05827 char *stringp=NULL; 05828 ast_copy_string(exten2, exten, sizeof(exten2)); 05829 /* Parse out extension and callerid */ 05830 stringp=exten2 +1; 05831 s1 = strsep(&stringp, "#"); 05832 s2 = strsep(&stringp, "#"); 05833 if (s2) { 05834 if (!ast_strlen_zero(p->cid_num)) 05835 ast_set_callerid(chan, p->cid_num, NULL, p->cid_num); 05836 else 05837 if (*(s1 + 2)) 05838 ast_set_callerid(chan, s1 + 2, NULL, s1 + 2); 05839 ast_copy_string(exten, s2 + 1, sizeof(exten)); 05840 } else 05841 ast_copy_string(exten, s1 + 2, sizeof(exten)); 05842 } else 05843 ast_log(LOG_WARNING, "Got a non-Feature Group D input on channel %d. Assuming E&M Wink instead\n", p->channel); 05844 } 05845 if ((p->sig == SIG_E911) || (p->sig == SIG_FGC_CAMAMF)) { 05846 if (exten[0] == '*') { 05847 char *stringp=NULL; 05848 ast_copy_string(exten2, exten, sizeof(exten2)); 05849 /* Parse out extension and callerid */ 05850 stringp=exten2 +1; 05851 s1 = strsep(&stringp, "#"); 05852 s2 = strsep(&stringp, "#"); 05853 if (s2 && (*(s2 + 1) == '0')) { 05854 if (*(s2 + 2)) 05855 ast_set_callerid(chan, s2 + 2, NULL, s2 + 2); 05856 } 05857 if (s1) ast_copy_string(exten, s1, sizeof(exten)); 05858 else ast_copy_string(exten, "911", sizeof(exten)); 05859 } else 05860 ast_log(LOG_WARNING, "Got a non-E911/FGC CAMA input on channel %d. Assuming E&M Wink instead\n", p->channel); 05861 } 05862 if (p->sig == SIG_FEATB) { 05863 if (exten[0] == '*') { 05864 char *stringp=NULL; 05865 ast_copy_string(exten2, exten, sizeof(exten2)); 05866 /* Parse out extension and callerid */ 05867 stringp=exten2 +1; 05868 s1 = strsep(&stringp, "#"); 05869 ast_copy_string(exten, exten2 + 1, sizeof(exten)); 05870 } else 05871 ast_log(LOG_WARNING, "Got a non-Feature Group B input on channel %d. Assuming E&M Wink instead\n", p->channel); 05872 } 05873 if ((p->sig == SIG_FEATDMF) || (p->sig == SIG_FEATDMF_TA)) { 05874 dahdi_wink(p, index); 05875 /* some switches require a minimum guard time between 05876 the last FGD wink and something that answers 05877 immediately. This ensures it */ 05878 if (ast_safe_sleep(chan,100)) goto quit; 05879 } 05880 dahdi_enable_ec(p); 05881 if (NEED_MFDETECT(p)) { 05882 if (p->dsp) { 05883 if (!p->hardwaredtmf) 05884 ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); 05885 else { 05886 ast_dsp_free(p->dsp); 05887 p->dsp = NULL; 05888 } 05889 } 05890 } 05891 05892 if (ast_exists_extension(chan, chan->context, exten, 1, chan->cid.cid_num)) { 05893 ast_copy_string(chan->exten, exten, sizeof(chan->exten)); 05894 if (p->dsp) ast_dsp_digitreset(p->dsp); 05895 res = ast_pbx_run(chan); 05896 if (res) { 05897 ast_log(LOG_WARNING, "PBX exited non-zero\n"); 05898 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 05899 } 05900 goto quit; 05901 } else { 05902 if (option_verbose > 2) 05903 ast_verbose(VERBOSE_PREFIX_2 "Unknown extension '%s' in context '%s' requested\n", exten, chan->context); 05904 sleep(2); 05905 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_INFO); 05906 if (res < 0) 05907 ast_log(LOG_WARNING, "Unable to start special tone on %d\n", p->channel); 05908 else 05909 sleep(1); 05910 res = ast_streamfile(chan, "ss-noservice", chan->language); 05911 if (res >= 0) 05912 ast_waitstream(chan, ""); 05913 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 05914 ast_hangup(chan); 05915 goto quit; 05916 } 05917 break; 05918 case SIG_FXOLS: 05919 case SIG_FXOGS: 05920 case SIG_FXOKS: 05921 /* Read the first digit */ 05922 timeout = firstdigittimeout; 05923 /* If starting a threeway call, never timeout on the first digit so someone 05924 can use flash-hook as a "hold" feature */ 05925 if (p->subs[SUB_THREEWAY].owner) 05926 timeout = 999999; 05927 while (len < AST_MAX_EXTENSION-1) { 05928 /* Read digit unless it's supposed to be immediate, in which case the 05929 only answer is 's' */ 05930 if (p->immediate) 05931 res = 's'; 05932 else 05933 res = ast_waitfordigit(chan, timeout); 05934 timeout = 0; 05935 if (res < 0) { 05936 ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); 05937 res = tone_zone_play_tone(p->subs[index].dfd, -1); 05938 ast_hangup(chan); 05939 goto quit; 05940 } else if (res) { 05941 exten[len++]=res; 05942 exten[len] = '\0'; 05943 } 05944 if (!ast_ignore_pattern(chan->context, exten)) 05945 tone_zone_play_tone(p->subs[index].dfd, -1); 05946 else 05947 tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALTONE); 05948 if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num) && strcmp(exten, ast_parking_ext())) { 05949 if (!res || !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) { 05950 if (getforward) { 05951 /* Record this as the forwarding extension */ 05952 ast_copy_string(p->call_forward, exten, sizeof(p->call_forward)); 05953 if (option_verbose > 2) 05954 ast_verbose(VERBOSE_PREFIX_3 "Setting call forward to '%s' on channel %d\n", p->call_forward, p->channel); 05955 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 05956 if (res) 05957 break; 05958 usleep(500000); 05959 res = tone_zone_play_tone(p->subs[index].dfd, -1); 05960 sleep(1); 05961 memset(exten, 0, sizeof(exten)); 05962 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALTONE); 05963 len = 0; 05964 getforward = 0; 05965 } else { 05966 res = tone_zone_play_tone(p->subs[index].dfd, -1); 05967 ast_copy_string(chan->exten, exten, sizeof(chan->exten)); 05968 if (!ast_strlen_zero(p->cid_num)) { 05969 if (!p->hidecallerid) 05970 ast_set_callerid(chan, p->cid_num, NULL, p->cid_num); 05971 else 05972 ast_set_callerid(chan, NULL, NULL, p->cid_num); 05973 } 05974 if (!ast_strlen_zero(p->cid_name)) { 05975 if (!p->hidecallerid) 05976 ast_set_callerid(chan, NULL, p->cid_name, NULL); 05977 } 05978 ast_setstate(chan, AST_STATE_RING); 05979 dahdi_enable_ec(p); 05980 res = ast_pbx_run(chan); 05981 if (res) { 05982 ast_log(LOG_WARNING, "PBX exited non-zero\n"); 05983 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 05984 } 05985 goto quit; 05986 } 05987 } else { 05988 /* It's a match, but they just typed a digit, and there is an ambiguous match, 05989 so just set the timeout to matchdigittimeout and wait some more */ 05990 timeout = matchdigittimeout; 05991 } 05992 } else if (res == 0) { 05993 ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n"); 05994 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 05995 dahdi_wait_event(p->subs[index].dfd); 05996 ast_hangup(chan); 05997 goto quit; 05998 } else if (p->callwaiting && !strcmp(exten, "*70")) { 05999 if (option_verbose > 2) 06000 ast_verbose(VERBOSE_PREFIX_3 "Disabling call waiting on %s\n", chan->name); 06001 /* Disable call waiting if enabled */ 06002 p->callwaiting = 0; 06003 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06004 if (res) { 06005 ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n", 06006 chan->name, strerror(errno)); 06007 } 06008 len = 0; 06009 ioctl(p->subs[index].dfd,DAHDI_CONFDIAG,&len); 06010 memset(exten, 0, sizeof(exten)); 06011 timeout = firstdigittimeout; 06012 06013 } else if (!strcmp(exten,ast_pickup_ext())) { 06014 /* Scan all channels and see if there are any 06015 * ringing channels that have call groups 06016 * that equal this channels pickup group 06017 */ 06018 if (index == SUB_REAL) { 06019 /* Switch us from Third call to Call Wait */ 06020 if (p->subs[SUB_THREEWAY].owner) { 06021 /* If you make a threeway call and the *8# a call, it should actually 06022 look like a callwait */ 06023 alloc_sub(p, SUB_CALLWAIT); 06024 swap_subs(p, SUB_CALLWAIT, SUB_THREEWAY); 06025 unalloc_sub(p, SUB_THREEWAY); 06026 } 06027 dahdi_enable_ec(p); 06028 if (ast_pickup_call(chan)) { 06029 ast_log(LOG_DEBUG, "No call pickup possible...\n"); 06030 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 06031 dahdi_wait_event(p->subs[index].dfd); 06032 } 06033 ast_hangup(chan); 06034 goto quit; 06035 } else { 06036 ast_log(LOG_WARNING, "Huh? Got *8# on call not on real\n"); 06037 ast_hangup(chan); 06038 goto quit; 06039 } 06040 06041 } else if (!p->hidecallerid && !strcmp(exten, "*67")) { 06042 if (option_verbose > 2) 06043 ast_verbose(VERBOSE_PREFIX_3 "Disabling Caller*ID on %s\n", chan->name); 06044 /* Disable Caller*ID if enabled */ 06045 p->hidecallerid = 1; 06046 if (chan->cid.cid_num) 06047 free(chan->cid.cid_num); 06048 chan->cid.cid_num = NULL; 06049 if (chan->cid.cid_name) 06050 free(chan->cid.cid_name); 06051 chan->cid.cid_name = NULL; 06052 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06053 if (res) { 06054 ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n", 06055 chan->name, strerror(errno)); 06056 } 06057 len = 0; 06058 memset(exten, 0, sizeof(exten)); 06059 timeout = firstdigittimeout; 06060 } else if (p->callreturn && !strcmp(exten, "*69")) { 06061 res = 0; 06062 if (!ast_strlen_zero(p->lastcid_num)) { 06063 res = ast_say_digit_str(chan, p->lastcid_num, "", chan->language); 06064 } 06065 if (!res) 06066 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06067 break; 06068 } else if (!strcmp(exten, "*78")) { 06069 /* Do not disturb */ 06070 if (option_verbose > 2) 06071 ast_verbose(VERBOSE_PREFIX_3 "Enabled DND on channel %d\n", p->channel); 06072 manager_event(EVENT_FLAG_SYSTEM, "DNDState", 06073 "Channel: %s/%d\r\n" 06074 "Status: enabled\r\n", dahdi_chan_name, p->channel); 06075 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06076 p->dnd = 1; 06077 getforward = 0; 06078 memset(exten, 0, sizeof(exten)); 06079 len = 0; 06080 } else if (!strcmp(exten, "*79")) { 06081 /* Do not disturb */ 06082 if (option_verbose > 2) 06083 ast_verbose(VERBOSE_PREFIX_3 "Disabled DND on channel %d\n", p->channel); 06084 manager_event(EVENT_FLAG_SYSTEM, "DNDState", 06085 "Channel: %s/%d\r\n" 06086 "Status: disabled\r\n", dahdi_chan_name, p->channel); 06087 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06088 p->dnd = 0; 06089 getforward = 0; 06090 memset(exten, 0, sizeof(exten)); 06091 len = 0; 06092 } else if (p->cancallforward && !strcmp(exten, "*72")) { 06093 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06094 getforward = 1; 06095 memset(exten, 0, sizeof(exten)); 06096 len = 0; 06097 } else if (p->cancallforward && !strcmp(exten, "*73")) { 06098 if (option_verbose > 2) 06099 ast_verbose(VERBOSE_PREFIX_3 "Cancelling call forwarding on channel %d\n", p->channel); 06100 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06101 memset(p->call_forward, 0, sizeof(p->call_forward)); 06102 getforward = 0; 06103 memset(exten, 0, sizeof(exten)); 06104 len = 0; 06105 } else if ((p->transfer || p->canpark) && !strcmp(exten, ast_parking_ext()) && 06106 p->subs[SUB_THREEWAY].owner && 06107 ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) { 06108 /* This is a three way call, the main call being a real channel, 06109 and we're parking the first call. */ 06110 ast_masq_park_call(ast_bridged_channel(p->subs[SUB_THREEWAY].owner), chan, 0, NULL); 06111 if (option_verbose > 2) 06112 ast_verbose(VERBOSE_PREFIX_3 "Parking call to '%s'\n", chan->name); 06113 break; 06114 } else if (!ast_strlen_zero(p->lastcid_num) && !strcmp(exten, "*60")) { 06115 if (option_verbose > 2) 06116 ast_verbose(VERBOSE_PREFIX_3 "Blacklisting number %s\n", p->lastcid_num); 06117 res = ast_db_put("blacklist", p->lastcid_num, "1"); 06118 if (!res) { 06119 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06120 memset(exten, 0, sizeof(exten)); 06121 len = 0; 06122 } 06123 } else if (p->hidecallerid && !strcmp(exten, "*82")) { 06124 if (option_verbose > 2) 06125 ast_verbose(VERBOSE_PREFIX_3 "Enabling Caller*ID on %s\n", chan->name); 06126 /* Enable Caller*ID if enabled */ 06127 p->hidecallerid = 0; 06128 if (chan->cid.cid_num) 06129 free(chan->cid.cid_num); 06130 chan->cid.cid_num = NULL; 06131 if (chan->cid.cid_name) 06132 free(chan->cid.cid_name); 06133 chan->cid.cid_name = NULL; 06134 ast_set_callerid(chan, p->cid_num, p->cid_name, NULL); 06135 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL); 06136 if (res) { 06137 ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n", 06138 chan->name, strerror(errno)); 06139 } 06140 len = 0; 06141 memset(exten, 0, sizeof(exten)); 06142 timeout = firstdigittimeout; 06143 } else if (!strcmp(exten, "*0")) { 06144 struct ast_channel *nbridge = 06145 p->subs[SUB_THREEWAY].owner; 06146 struct dahdi_pvt *pbridge = NULL; 06147 /* set up the private struct of the bridged one, if any */ 06148 if (nbridge && ast_bridged_channel(nbridge)) 06149 pbridge = ast_bridged_channel(nbridge)->tech_pvt; 06150 if (nbridge && pbridge && 06151 (nbridge->tech == chan_tech) && 06152 (ast_bridged_channel(nbridge)->tech == chan_tech) && 06153 ISTRUNK(pbridge)) { 06154 int func = DAHDI_FLASH; 06155 /* Clear out the dial buffer */ 06156 p->dop.dialstr[0] = '\0'; 06157 /* flash hookswitch */ 06158 if ((ioctl(pbridge->subs[SUB_REAL].dfd,DAHDI_HOOK,&func) == -1) && (errno != EINPROGRESS)) { 06159 ast_log(LOG_WARNING, "Unable to flash external trunk on channel %s: %s\n", 06160 nbridge->name, strerror(errno)); 06161 } 06162 swap_subs(p, SUB_REAL, SUB_THREEWAY); 06163 unalloc_sub(p, SUB_THREEWAY); 06164 p->owner = p->subs[SUB_REAL].owner; 06165 if (ast_bridged_channel(p->subs[SUB_REAL].owner)) 06166 ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD); 06167 ast_hangup(chan); 06168 goto quit; 06169 } else { 06170 tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 06171 dahdi_wait_event(p->subs[index].dfd); 06172 tone_zone_play_tone(p->subs[index].dfd, -1); 06173 swap_subs(p, SUB_REAL, SUB_THREEWAY); 06174 unalloc_sub(p, SUB_THREEWAY); 06175 p->owner = p->subs[SUB_REAL].owner; 06176 ast_hangup(chan); 06177 goto quit; 06178 } 06179 } else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) && 06180 ((exten[0] != '*') || (strlen(exten) > 2))) { 06181 if (option_debug) 06182 ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context); 06183 break; 06184 } 06185 if (!timeout) 06186 timeout = gendigittimeout; 06187 if (len && !ast_ignore_pattern(chan->context, exten)) 06188 tone_zone_play_tone(p->subs[index].dfd, -1); 06189 } 06190 break; 06191 case SIG_FXSLS: 06192 case SIG_FXSGS: 06193 case SIG_FXSKS: 06194 #ifdef HAVE_PRI 06195 if (p->pri) { 06196 /* This is a GR-303 trunk actually. Wait for the first ring... */ 06197 struct ast_frame *f; 06198 int res; 06199 time_t start; 06200 06201 time(&start); 06202 ast_setstate(chan, AST_STATE_RING); 06203 while (time(NULL) < start + 3) { 06204 res = ast_waitfor(chan, 1000); 06205 if (res) { 06206 f = ast_read(chan); 06207 if (!f) { 06208 ast_log(LOG_WARNING, "Whoa, hangup while waiting for first ring!\n"); 06209 ast_hangup(chan); 06210 goto quit; 06211 } else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) { 06212 res = 1; 06213 } else 06214 res = 0; 06215 ast_frfree(f); 06216 if (res) { 06217 ast_log(LOG_DEBUG, "Got ring!\n"); 06218 res = 0; 06219 break; 06220 } 06221 } 06222 } 06223 } 06224 #endif 06225 /* check for SMDI messages */ 06226 if (p->use_smdi && p->smdi_iface) { 06227 smdi_msg = ast_smdi_md_message_wait(p->smdi_iface, SMDI_MD_WAIT_TIMEOUT); 06228 06229 if (smdi_msg != NULL) { 06230 ast_copy_string(chan->exten, smdi_msg->fwd_st, sizeof(chan->exten)); 06231 06232 if (smdi_msg->type == 'B') 06233 pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "b"); 06234 else if (smdi_msg->type == 'N') 06235 pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "u"); 06236 06237 ast_log(LOG_DEBUG, "Recieved SMDI message on %s\n", chan->name); 06238 } else { 06239 ast_log(LOG_WARNING, "SMDI enabled but no SMDI message present\n"); 06240 } 06241 } 06242 06243 if (p->use_callerid && (p->cid_signalling == CID_SIG_SMDI && smdi_msg)) { 06244 number = smdi_msg->calling_st; 06245 06246 /* If we want caller id, we're in a prering state due to a polarity reversal 06247 * and we're set to use a polarity reversal to trigger the start of caller id, 06248 * grab the caller id and wait for ringing to start... */ 06249 } else if (p->use_callerid && (chan->_state == AST_STATE_PRERING && p->cid_start == CID_START_POLARITY)) { 06250 /* If set to use DTMF CID signalling, listen for DTMF */ 06251 if (p->cid_signalling == CID_SIG_DTMF) { 06252 int i = 0; 06253 cs = NULL; 06254 ast_log(LOG_DEBUG, "Receiving DTMF cid on " 06255 "channel %s\n", chan->name); 06256 dahdi_setlinear(p->subs[index].dfd, 0); 06257 res = 2000; 06258 for (;;) { 06259 struct ast_frame *f; 06260 res = ast_waitfor(chan, res); 06261 if (res <= 0) { 06262 ast_log(LOG_WARNING, "DTMFCID timed out waiting for ring. " 06263 "Exiting simple switch\n"); 06264 ast_hangup(chan); 06265 goto quit; 06266 } 06267 f = ast_read(chan); 06268 if (!f) 06269 break; 06270 if (f->frametype == AST_FRAME_DTMF) { 06271 dtmfbuf[i++] = f->subclass; 06272 ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass); 06273 res = 2000; 06274 } 06275 ast_frfree(f); 06276 if (chan->_state == AST_STATE_RING || 06277 chan->_state == AST_STATE_RINGING) 06278 break; /* Got ring */ 06279 } 06280 dtmfbuf[i] = '\0'; 06281 dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear); 06282 /* Got cid and ring. */ 06283 ast_log(LOG_DEBUG, "CID got string '%s'\n", dtmfbuf); 06284 callerid_get_dtmf(dtmfbuf, dtmfcid, &flags); 06285 ast_log(LOG_DEBUG, "CID is '%s', flags %d\n", 06286 dtmfcid, flags); 06287 /* If first byte is NULL, we have no cid */ 06288 if (!ast_strlen_zero(dtmfcid)) 06289 number = dtmfcid; 06290 else 06291 number = NULL; 06292 /* If set to use V23 Signalling, launch our FSK gubbins and listen for it */ 06293 } else if ((p->cid_signalling == CID_SIG_V23) || (p->cid_signalling == CID_SIG_V23_JP)) { 06294 cs = callerid_new(p->cid_signalling); 06295 if (cs) { 06296 samples = 0; 06297 #if 1 06298 bump_gains(p); 06299 #endif 06300 /* Take out of linear mode for Caller*ID processing */ 06301 dahdi_setlinear(p->subs[index].dfd, 0); 06302 06303 /* First we wait and listen for the Caller*ID */ 06304 for (;;) { 06305 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT; 06306 if ((res = ioctl(p->subs[index].dfd, DAHDI_IOMUX, &i))) { 06307 ast_log(LOG_WARNING, "I/O MUX failed: %s\n", strerror(errno)); 06308 callerid_free(cs); 06309 ast_hangup(chan); 06310 goto quit; 06311 } 06312 if (i & DAHDI_IOMUX_SIGEVENT) { 06313 res = dahdi_get_event(p->subs[index].dfd); 06314 ast_log(LOG_NOTICE, "Got event %d (%s)...\n", res, event2str(res)); 06315 06316 if (p->cid_signalling == CID_SIG_V23_JP) { 06317 #ifdef DAHDI_EVENT_RINGBEGIN 06318 if (res == DAHDI_EVENT_RINGBEGIN) { 06319 res = dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_OFFHOOK); 06320 usleep(1); 06321 } 06322 #endif 06323 } else { 06324 res = 0; 06325 break; 06326 } 06327 } else if (i & DAHDI_IOMUX_READ) { 06328 res = read(p->subs[index].dfd, buf, sizeof(buf)); 06329 if (res < 0) { 06330 if (errno != ELAST) { 06331 ast_log(LOG_WARNING, "read returned error: %s\n", strerror(errno)); 06332 callerid_free(cs); 06333 ast_hangup(chan); 06334 goto quit; 06335 } 06336 break; 06337 } 06338 samples += res; 06339 06340 if (p->cid_signalling == CID_SIG_V23_JP) { 06341 res = callerid_feed_jp(cs, buf, res, AST_LAW(p)); 06342 } else { 06343 res = callerid_feed(cs, buf, res, AST_LAW(p)); 06344 } 06345 06346 if (res < 0) { 06347 ast_log(LOG_WARNING, "CallerID feed failed on channel '%s'\n", chan->name); 06348 break; 06349 } else if (res) 06350 break; 06351 else if (samples > (8000 * 10)) 06352 break; 06353 } 06354 } 06355 if (res == 1) { 06356 callerid_get(cs, &name, &number, &flags); 06357 ast_log(LOG_NOTICE, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags); 06358 } 06359 06360 if (p->cid_signalling == CID_SIG_V23_JP) { 06361 res = dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_ONHOOK); 06362 usleep(1); 06363 res = 4000; 06364 } else { 06365 06366 /* Finished with Caller*ID, now wait for a ring to make sure there really is a call coming */ 06367 res = 2000; 06368 } 06369 06370 for (;;) { 06371 struct ast_frame *f; 06372 res = ast_waitfor(chan, res); 06373 if (res <= 0) { 06374 ast_log(LOG_WARNING, "CID timed out waiting for ring. " 06375 "Exiting simple switch\n"); 06376 ast_hangup(chan); 06377 goto quit; 06378 } 06379 if (!(f = ast_read(chan))) { 06380 ast_log(LOG_WARNING, "Hangup received waiting for ring. Exiting simple switch\n"); 06381 ast_hangup(chan); 06382 goto quit; 06383 } 06384 ast_frfree(f); 06385 if (chan->_state == AST_STATE_RING || 06386 chan->_state == AST_STATE_RINGING) 06387 break; /* Got ring */ 06388 } 06389 06390 /* We must have a ring by now, so, if configured, lets try to listen for 06391 * distinctive ringing */ 06392 if (p->usedistinctiveringdetection == 1) { 06393 len = 0; 06394 distMatches = 0; 06395 /* Clear the current ring data array so we dont have old data in it. */ 06396 for (receivedRingT = 0; receivedRingT < (sizeof(curRingData) / sizeof(curRingData[0])); receivedRingT++) 06397 curRingData[receivedRingT] = 0; 06398 receivedRingT = 0; 06399 counter = 0; 06400 counter1 = 0; 06401 /* Check to see if context is what it should be, if not set to be. */ 06402 if (strcmp(p->context,p->defcontext) != 0) { 06403 ast_copy_string(p->context, p->defcontext, sizeof(p->context)); 06404 ast_copy_string(chan->context,p->defcontext,sizeof(chan->context)); 06405 } 06406 06407 for (;;) { 06408 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT; 06409 if ((res = ioctl(p->subs[index].dfd, DAHDI_IOMUX, &i))) { 06410 ast_log(LOG_WARNING, "I/O MUX failed: %s\n", strerror(errno)); 06411 callerid_free(cs); 06412 ast_hangup(chan); 06413 goto quit; 06414 } 06415 if (i & DAHDI_IOMUX_SIGEVENT) { 06416 res = dahdi_get_event(p->subs[index].dfd); 06417 ast_log(LOG_NOTICE, "Got event %d (%s)...\n", res, event2str(res)); 06418 res = 0; 06419 /* Let us detect distinctive ring */ 06420 06421 curRingData[receivedRingT] = p->ringt; 06422 06423 if (p->ringt < p->ringt_base/2) 06424 break; 06425 /* Increment the ringT counter so we can match it against 06426 values in chan_dahdi.conf for distinctive ring */ 06427 if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0]))) 06428 break; 06429 } else if (i & DAHDI_IOMUX_READ) { 06430 res = read(p->subs[index].dfd, buf, sizeof(buf)); 06431 if (res < 0) { 06432 if (errno != ELAST) { 06433 ast_log(LOG_WARNING, "read returned error: %s\n", strerror(errno)); 06434 callerid_free(cs); 06435 ast_hangup(chan); 06436 goto quit; 06437 } 06438 break; 06439 } 06440 if (p->ringt) 06441 p->ringt--; 06442 if (p->ringt == 1) { 06443 res = -1; 06444 break; 06445 } 06446 } 06447 } 06448 if (option_verbose > 2) 06449 /* this only shows up if you have n of the dring patterns filled in */ 06450 ast_verbose( VERBOSE_PREFIX_3 "Detected ring pattern: %d,%d,%d\n",curRingData[0],curRingData[1],curRingData[2]); 06451 06452 for (counter = 0; counter < 3; counter++) { 06453 /* Check to see if the rings we received match any of the ones in chan_dahdi.conf for this 06454 channel */ 06455 distMatches = 0; 06456 for (counter1 = 0; counter1 < 3; counter1++) { 06457 if (curRingData[counter1] <= (p->drings.ringnum[counter].ring[counter1]+10) && curRingData[counter1] >= 06458 (p->drings.ringnum[counter].ring[counter1]-10)) { 06459 distMatches++; 06460 } 06461 } 06462 if (distMatches == 3) { 06463 /* The ring matches, set the context to whatever is for distinctive ring.. */ 06464 ast_copy_string(p->context, p->drings.ringContext[counter].contextData, sizeof(p->context)); 06465 ast_copy_string(chan->context, p->drings.ringContext[counter].contextData, sizeof(chan->context)); 06466 if (option_verbose > 2) 06467 ast_verbose( VERBOSE_PREFIX_3 "Distinctive Ring matched context %s\n",p->context); 06468 break; 06469 } 06470 } 06471 } 06472 /* Restore linear mode (if appropriate) for Caller*ID processing */ 06473 dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear); 06474 #if 1 06475 restore_gains(p); 06476 #endif 06477 } else 06478 ast_log(LOG_WARNING, "Unable to get caller ID space\n"); 06479 } else { 06480 ast_log(LOG_WARNING, "Channel %s in prering " 06481 "state, but I have nothing to do. " 06482 "Terminating simple switch, should be " 06483 "restarted by the actual ring.\n", 06484 chan->name); 06485 ast_hangup(chan); 06486 goto quit; 06487 } 06488 } else if (p->use_callerid && p->cid_start == CID_START_RING) { 06489 /* FSK Bell202 callerID */ 06490 cs = callerid_new(p->cid_signalling); 06491 if (cs) { 06492 #if 1 06493 bump_gains(p); 06494 #endif 06495 samples = 0; 06496 len = 0; 06497 distMatches = 0; 06498 /* Clear the current ring data array so we dont have old data in it. */ 06499 for (receivedRingT = 0; receivedRingT < (sizeof(curRingData) / sizeof(curRingData[0])); receivedRingT++) 06500 curRingData[receivedRingT] = 0; 06501 receivedRingT = 0; 06502 counter = 0; 06503 counter1 = 0; 06504 /* Check to see if context is what it should be, if not set to be. */ 06505 if (strcmp(p->context,p->defcontext) != 0) { 06506 ast_copy_string(p->context, p->defcontext, sizeof(p->context)); 06507 ast_copy_string(chan->context,p->defcontext,sizeof(chan->context)); 06508 } 06509 06510 /* Take out of linear mode for Caller*ID processing */ 06511 dahdi_setlinear(p->subs[index].dfd, 0); 06512 for (;;) { 06513 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT; 06514 if ((res = ioctl(p->subs[index].dfd, DAHDI_IOMUX, &i))) { 06515 ast_log(LOG_WARNING, "I/O MUX failed: %s\n", strerror(errno)); 06516 callerid_free(cs); 06517 ast_hangup(chan); 06518 goto quit; 06519 } 06520 if (i & DAHDI_IOMUX_SIGEVENT) { 06521 res = dahdi_get_event(p->subs[index].dfd); 06522 ast_log(LOG_NOTICE, "Got event %d (%s)...\n", res, event2str(res)); 06523 /* If we get a PR event, they hung up while processing calerid */ 06524 if ( res == DAHDI_EVENT_POLARITY && p->hanguponpolarityswitch && p->polarity == POLARITY_REV) { 06525 ast_log(LOG_DEBUG, "Hanging up due to polarity reversal on channel %d while detecting callerid\n", p->channel); 06526 p->polarity = POLARITY_IDLE; 06527 callerid_free(cs); 06528 ast_hangup(chan); 06529 goto quit; 06530 } 06531 res = 0; 06532 /* Let us detect callerid when the telco uses distinctive ring */ 06533 06534 curRingData[receivedRingT] = p->ringt; 06535 06536 if (p->ringt < p->ringt_base/2) 06537 break; 06538 /* Increment the ringT counter so we can match it against 06539 values in chan_dahdi.conf for distinctive ring */ 06540 if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0]))) 06541 break; 06542 } else if (i & DAHDI_IOMUX_READ) { 06543 res = read(p->subs[index].dfd, buf, sizeof(buf)); 06544 if (res < 0) { 06545 if (errno != ELAST) { 06546 ast_log(LOG_WARNING, "read returned error: %s\n", strerror(errno)); 06547 callerid_free(cs); 06548 ast_hangup(chan); 06549 goto quit; 06550 } 06551 break; 06552 } 06553 if (p->ringt) 06554 p->ringt--; 06555 if (p->ringt == 1) { 06556 res = -1; 06557 break; 06558 } 06559 samples += res; 06560 res = callerid_feed(cs, buf, res, AST_LAW(p)); 06561 if (res < 0) { 06562 ast_log(LOG_WARNING, "CallerID feed failed: %s\n", strerror(errno)); 06563 break; 06564 } else if (res) 06565 break; 06566 else if (samples > (8000 * 10)) 06567 break; 06568 } 06569 } 06570 if (res == 1) { 06571 callerid_get(cs, &name, &number, &flags); 06572 if (option_debug) 06573 ast_log(LOG_DEBUG, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags); 06574 } 06575 if (distinctiveringaftercid == 1) { 06576 /* Clear the current ring data array so we dont have old data in it. */ 06577 for (receivedRingT = 0; receivedRingT < 3; receivedRingT++) { 06578 curRingData[receivedRingT] = 0; 06579 } 06580 receivedRingT = 0; 06581 if (option_verbose > 2) 06582 ast_verbose( VERBOSE_PREFIX_3 "Detecting post-CID distinctive ring\n"); 06583 for (;;) { 06584 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT; 06585 if ((res = ioctl(p->subs[index].dfd, DAHDI_IOMUX, &i))) { 06586 ast_log(LOG_WARNING, "I/O MUX failed: %s\n", strerror(errno)); 06587 callerid_free(cs); 06588 ast_hangup(chan); 06589 goto quit; 06590 } 06591 if (i & DAHDI_IOMUX_SIGEVENT) { 06592 res = dahdi_get_event(p->subs[index].dfd); 06593 ast_log(LOG_NOTICE, "Got event %d (%s)...\n", res, event2str(res)); 06594 res = 0; 06595 /* Let us detect callerid when the telco uses distinctive ring */ 06596 06597 curRingData[receivedRingT] = p->ringt; 06598 06599 if (p->ringt < p->ringt_base/2) 06600 break; 06601 /* Increment the ringT counter so we can match it against 06602 values in chan_dahdi.conf for distinctive ring */ 06603 if (++receivedRingT == (sizeof(curRingData) / sizeof(curRingData[0]))) 06604 break; 06605 } else if (i & DAHDI_IOMUX_READ) { 06606 res = read(p->subs[index].dfd, buf, sizeof(buf)); 06607 if (res < 0) { 06608 if (errno != ELAST) { 06609 ast_log(LOG_WARNING, "read returned error: %s\n", strerror(errno)); 06610 callerid_free(cs); 06611 ast_hangup(chan); 06612 goto quit; 06613 } 06614 break; 06615 } 06616 if (p->ringt) 06617 p->ringt--; 06618 if (p->ringt == 1) { 06619 res = -1; 06620 break; 06621 } 06622 } 06623 } 06624 } 06625 if (p->usedistinctiveringdetection == 1) { 06626 if (option_verbose > 2) 06627 /* this only shows up if you have n of the dring patterns filled in */ 06628 ast_verbose( VERBOSE_PREFIX_3 "Detected ring pattern: %d,%d,%d\n",curRingData[0],curRingData[1],curRingData[2]); 06629 06630 for (counter = 0; counter < 3; counter++) { 06631 /* Check to see if the rings we received match any of the ones in chan_dahdi.conf for this 06632 channel */ 06633 if (option_verbose > 2) 06634 /* this only shows up if you have n of the dring patterns filled in */ 06635 ast_verbose( VERBOSE_PREFIX_3 "Checking %d,%d,%d\n", 06636 p->drings.ringnum[counter].ring[0], 06637 p->drings.ringnum[counter].ring[1], 06638 p->drings.ringnum[counter].ring[2]); 06639 distMatches = 0; 06640 for (counter1 = 0; counter1 < 3; counter1++) { 06641 if (curRingData[counter1] <= (p->drings.ringnum[counter].ring[counter1]+10) && curRingData[counter1] >= 06642 (p->drings.ringnum[counter].ring[counter1]-10)) { 06643 distMatches++; 06644 } 06645 } 06646 if (distMatches == 3) { 06647 /* The ring matches, set the context to whatever is for distinctive ring.. */ 06648 ast_copy_string(p->context, p->drings.ringContext[counter].contextData, sizeof(p->context)); 06649 ast_copy_string(chan->context, p->drings.ringContext[counter].contextData, sizeof(chan->context)); 06650 if (option_verbose > 2) 06651 ast_verbose( VERBOSE_PREFIX_3 "Distinctive Ring matched context %s\n",p->context); 06652 break; 06653 } 06654 } 06655 } 06656 /* Restore linear mode (if appropriate) for Caller*ID processing */ 06657 dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear); 06658 #if 1 06659 restore_gains(p); 06660 #endif 06661 if (res < 0) { 06662 ast_log(LOG_WARNING, "CallerID returned with error on channel '%s'\n", chan->name); 06663 } 06664 } else 06665 ast_log(LOG_WARNING, "Unable to get caller ID space\n"); 06666 } 06667 else 06668 cs = NULL; 06669 06670 if (number) 06671 ast_shrink_phone_number(number); 06672 ast_set_callerid(chan, number, name, number); 06673 06674 if (smdi_msg) 06675 ASTOBJ_UNREF(smdi_msg, ast_smdi_md_message_destroy); 06676 06677 if (cs) 06678 callerid_free(cs); 06679 06680 ast_setstate(chan, AST_STATE_RING); 06681 chan->rings = 1; 06682 p->ringt = p->ringt_base; 06683 res = ast_pbx_run(chan); 06684 if (res) { 06685 ast_hangup(chan); 06686 ast_log(LOG_WARNING, "PBX exited non-zero\n"); 06687 } 06688 goto quit; 06689 default: 06690 ast_log(LOG_WARNING, "Don't know how to handle simple switch with signalling %s on channel %d\n", sig2str(p->sig), p->channel); 06691 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 06692 if (res < 0) 06693 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", p->channel); 06694 } 06695 res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_CONGESTION); 06696 if (res < 0) 06697 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", p->channel); 06698 ast_hangup(chan); 06699 quit: 06700 ast_mutex_lock(&ss_thread_lock); 06701 ss_thread_count--; 06702 ast_cond_signal(&ss_thread_complete); 06703 ast_mutex_unlock(&ss_thread_lock); 06704 return NULL; 06705 }
| static void swap_subs | ( | struct dahdi_pvt * | p, | |
| int | a, | |||
| int | b | |||
| ) | [static] |
Definition at line 870 of file chan_dahdi.c.
References ast_log(), dahdi_subchannel::chan, dahdi_subchannel::dfd, ast_channel::fds, dahdi_subchannel::inthreeway, LOG_DEBUG, dahdi_subchannel::owner, dahdi_pvt::subs, and wakeup_sub().
Referenced by attempt_transfer(), dahdi_answer(), dahdi_handle_event(), dahdi_hangup(), and ss_thread().
00871 { 00872 int tchan; 00873 int tinthreeway; 00874 struct ast_channel *towner; 00875 00876 ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b); 00877 00878 tchan = p->subs[a].chan; 00879 towner = p->subs[a].owner; 00880 tinthreeway = p->subs[a].inthreeway; 00881 00882 p->subs[a].chan = p->subs[b].chan; 00883 p->subs[a].owner = p->subs[b].owner; 00884 p->subs[a].inthreeway = p->subs[b].inthreeway; 00885 00886 p->subs[b].chan = tchan; 00887 p->subs[b].owner = towner; 00888 p->subs[b].inthreeway = tinthreeway; 00889 00890 if (p->subs[a].owner) 00891 p->subs[a].owner->fds[0] = p->subs[a].dfd; 00892 if (p->subs[b].owner) 00893 p->subs[b].owner->fds[0] = p->subs[b].dfd; 00894 wakeup_sub(p, a, NULL); 00895 wakeup_sub(p, b, NULL); 00896 }
| static int unalloc_sub | ( | struct dahdi_pvt * | p, | |
| int | x | |||
| ) | [static] |
Definition at line 1017 of file chan_dahdi.c.
References ast_log(), dahdi_subchannel::chan, dahdi_pvt::channel, dahdi_subchannel::curconf, dahdi_close_sub(), dahdi_subchannel::inthreeway, dahdi_subchannel::linear, LOG_DEBUG, LOG_WARNING, dahdi_subchannel::owner, dahdi_pvt::polarity, POLARITY_IDLE, and dahdi_pvt::subs.
Referenced by attempt_transfer(), dahdi_handle_event(), dahdi_hangup(), and ss_thread().
01018 { 01019 if (!x) { 01020 ast_log(LOG_WARNING, "Trying to unalloc the real channel %d?!?\n", p->channel); 01021 return -1; 01022 } 01023 ast_log(LOG_DEBUG, "Released sub %d of channel %d\n", x, p->channel); 01024 dahdi_close_sub(p, x); 01025 p->subs[x].linear = 0; 01026 p->subs[x].chan = 0; 01027 p->subs[x].owner = NULL; 01028 p->subs[x].inthreeway = 0; 01029 p->polarity = POLARITY_IDLE; 01030 memset(&p->subs[x].curconf, 0, sizeof(p->subs[x].curconf)); 01031 return 0; 01032 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 10873 of file chan_dahdi.c.
References __unload_module(), ast_mutex_destroy(), and lock.
10874 { 10875 #ifdef HAVE_PRI 10876 int y; 10877 for (y = 0; y < NUM_SPANS; y++) 10878 ast_mutex_destroy(&pris[y].lock); 10879 #endif 10880 return __unload_module(); 10881 }
| static int update_conf | ( | struct dahdi_pvt * | p | ) | [static] |
Definition at line 1400 of file chan_dahdi.c.
References ast_log(), dahdi_pvt::channel, conf_add(), conf_del(), dahdi_pvt::confno, dahdi_subchannel::dfd, GET_CHANNEL, dahdi_pvt::inconference, dahdi_subchannel::inthreeway, isslavenative(), LOG_DEBUG, dahdi_pvt::master, MAX_SLAVES, option_debug, dahdi_pvt::slaves, SUB_REAL, and dahdi_pvt::subs.
Referenced by __dahdi_exception(), dahdi_bridge(), dahdi_fixup(), dahdi_handle_event(), dahdi_hangup(), dahdi_unlink(), and mkintf().
01401 { 01402 int needconf = 0; 01403 int x; 01404 int useslavenative; 01405 struct dahdi_pvt *slave = NULL; 01406 01407 useslavenative = isslavenative(p, &slave); 01408 /* Start with the obvious, general stuff */ 01409 for (x = 0; x < 3; x++) { 01410 /* Look for three way calls */ 01411 if ((p->subs[x].dfd > -1) && p->subs[x].inthreeway) { 01412 conf_add(p, &p->subs[x], x, 0); 01413 needconf++; 01414 } else { 01415 conf_del(p, &p->subs[x], x); 01416 } 01417 } 01418 /* If we have a slave, add him to our conference now. or DAX 01419 if this is slave native */ 01420 for (x = 0; x < MAX_SLAVES; x++) { 01421 if (p->slaves[x]) { 01422 if (useslavenative) 01423 conf_add(p, &p->slaves[x]->subs[SUB_REAL], SUB_REAL, GET_CHANNEL(p)); 01424 else { 01425 conf_add(p, &p->slaves[x]->subs[SUB_REAL], SUB_REAL, 0); 01426 needconf++; 01427 } 01428 } 01429 } 01430 /* If we're supposed to be in there, do so now */ 01431 if (p->inconference && !p->subs[SUB_REAL].inthreeway) { 01432 if (useslavenative) 01433 conf_add(p, &p->subs[SUB_REAL], SUB_REAL, GET_CHANNEL(slave)); 01434 else { 01435 conf_add(p, &p->subs[SUB_REAL], SUB_REAL, 0); 01436 needconf++; 01437 } 01438 } 01439 /* If we have a master, add ourselves to his conference */ 01440 if (p->master) { 01441 if (isslavenative(p->master, NULL)) { 01442 conf_add(p->master, &p->subs[SUB_REAL], SUB_REAL, GET_CHANNEL(p->master)); 01443 } else { 01444 conf_add(p->master, &p->subs[SUB_REAL], SUB_REAL, 0); 01445 } 01446 } 01447 if (!needconf) { 01448 /* Nobody is left (or should be left) in our conference. 01449 Kill it. */ 01450 p->confno = -1; 01451 } 01452 if (option_debug) 01453 ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf); 01454 return 0; 01455 }
| static void wakeup_sub | ( | struct dahdi_pvt * | p, | |
| int | a, | |||
| void * | pri | |||
| ) | [static] |
Definition at line 814 of file chan_dahdi.c.
References ast_mutex_lock(), ast_mutex_trylock(), ast_mutex_unlock(), ast_null_frame, ast_queue_frame(), DEADLOCK_AVOIDANCE, dahdi_pvt::lock, ast_channel::lock, dahdi_subchannel::owner, and dahdi_pvt::subs.
Referenced by swap_subs().
00816 { 00817 #ifdef HAVE_PRI 00818 if (pri) 00819 ast_mutex_unlock(&pri->lock); 00820 #endif 00821 for (;;) { 00822 if (p->subs[a].owner) { 00823 if (ast_mutex_trylock(&p->subs[a].owner->lock)) { 00824 DEADLOCK_AVOIDANCE(&p->lock); 00825 } else { 00826 ast_queue_frame(p->subs[a].owner, &ast_null_frame); 00827 ast_mutex_unlock(&p->subs[a].owner->lock); 00828 break; 00829 } 00830 } else 00831 break; 00832 } 00833 #ifdef HAVE_PRI 00834 if (pri) 00835 ast_mutex_lock(&pri->lock); 00836 #endif 00837 }
| static int zap_action_dialoffhook | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10719 of file chan_dahdi.c.
References __action_dialoffhook().
10720 { 10721 return __action_dialoffhook(s, m, 1); 10722 }
| static int zap_action_dndoff | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10619 of file chan_dahdi.c.
References __action_dnd().
10620 { 10621 return __action_dnd(s, m, 1, 0); 10622 }
| static int zap_action_dndon | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10609 of file chan_dahdi.c.
References __action_dnd().
10610 { 10611 return __action_dnd(s, m, 1, 1); 10612 }
| static int zap_action_restart | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10798 of file chan_dahdi.c.
References __action_restart().
10799 { 10800 return __action_restart(s, m, 1); 10801 }
| static int zap_action_showchannels | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10774 of file chan_dahdi.c.
References __action_showchannels().
10775 { 10776 return __action_showchannels(s, m, 1); 10777 }
| static int zap_action_transfer | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10648 of file chan_dahdi.c.
References __action_transfer().
10649 { 10650 return __action_transfer(s, m, 1); 10651 }
| static int zap_action_transferhangup | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 10676 of file chan_dahdi.c.
References __action_transferhangup().
10677 { 10678 return __action_transferhangup(s, m, 1); 10679 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "DAHDI Telephony" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } [static] |
Definition at line 12011 of file chan_dahdi.c.
| int alarm |
struct { ... } alarms[] [static] |
Referenced by alarm2str(), and dahdi_show_status().
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 12011 of file chan_dahdi.c.
struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX] [static] |
Definition at line 770 of file chan_dahdi.c.
struct ast_channel_tech* chan_tech [static] |
int cidrings[NUM_CADENCE_MAX] [static] |
cidrings says in which pause to transmit the cid information, where the first pause is 1, the second pause is 2 and so on.
Definition at line 781 of file chan_dahdi.c.
struct ast_cli_entry cli_zap_destroy_channel_deprecated [static] |
Initial value:
{
{ "zap", "destroy", "channel", NULL },
dahdi_destroy_channel, NULL,
NULL }
Definition at line 10515 of file chan_dahdi.c.
struct ast_cli_entry cli_zap_restart_deprecated [static] |
Initial value:
{
{ "zap", "restart", NULL },
dahdi_restart_cmd, NULL,
NULL }
Definition at line 10520 of file chan_dahdi.c.
struct ast_cli_entry cli_zap_show_cadences_deprecated [static] |
Initial value:
{
{ "zap", "show", "cadences", NULL },
handle_dahdi_show_cadences, NULL,
NULL }
Definition at line 10500 of file chan_dahdi.c.
struct ast_cli_entry cli_zap_show_channel_deprecated [static] |
Initial value:
{
{ "zap", "show", "channel", NULL },
dahdi_show_channel, NULL,
NULL }
Definition at line 10510 of file chan_dahdi.c.
struct ast_cli_entry cli_zap_show_channels_deprecated [static] |
Initial value:
{
{ "zap", "show", "channels", NULL },
dahdi_show_channels, NULL,
NULL }
Definition at line 10505 of file chan_dahdi.c.
struct ast_cli_entry cli_zap_show_status_deprecated [static] |
Initial value:
{
{ "zap", "show", "status", NULL },
dahdi_show_status, NULL,
NULL }
Definition at line 10525 of file chan_dahdi.c.
struct ast_cli_entry dahdi_cli[] [static] |
Definition at line 10530 of file chan_dahdi.c.
char dahdi_restart_usage[] [static] |
Definition at line 10493 of file chan_dahdi.c.
char dahdi_show_cadences_usage[] [static] |
Initial value:
"Usage: dahdi show cadences\n" " Shows all cadences currently defined\n"
Definition at line 10378 of file chan_dahdi.c.
char dahdi_show_status_usage[] [static] |
Initial value:
"Usage: dahdi show status\n" " Shows a list of DAHDI cards with status\n"
Definition at line 10485 of file chan_dahdi.c.
struct ast_channel_tech dahdi_tech [static] |
Definition at line 696 of file chan_dahdi.c.
struct ast_jb_conf default_jbconf [static] |
Global jitterbuffer configuration - by default, jb is disabled
Definition at line 110 of file chan_dahdi.c.
char defaultcic[64] = "" [static] |
Definition at line 199 of file chan_dahdi.c.
char defaultozz[64] = "" [static] |
Definition at line 200 of file chan_dahdi.c.
char destroy_channel_usage[] [static] |
Initial value:
"Usage: dahdi destroy channel <chan num>\n" " DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING. Immediately removes a given channel, whether it is in use or not\n"
Definition at line 10489 of file chan_dahdi.c.
int distinctiveringaftercid = 0 [static] |
Definition at line 204 of file chan_dahdi.c.
struct dahdi_distRings drings [static] |
char* events[] [static] |
int firstdigittimeout = 16000 [static] |
Wait up to 16 seconds for first digit (FXO logic).
Definition at line 218 of file chan_dahdi.c.
Referenced by disa_exec().
int gendigittimeout = 8000 [static] |
struct ast_jb_conf global_jbconf [static] |
Definition at line 117 of file chan_dahdi.c.
Referenced by dahdi_new(), process_dahdi(), and setup_dahdi().
int ifcount = 0 [static] |
Definition at line 230 of file chan_dahdi.c.
Referenced by __action_showchannels(), __sip_destroy(), __sip_show_channels(), __unload_module(), chandup(), complete_sipch(), dahdi_destroy_channel_bynum(), dahdi_hangup(), dahdi_request(), dahdi_restart(), dahdi_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), destroy_all_channels(), destroy_channel(), do_monitor(), find_call(), find_channel(), get_sip_pvt_byid_locked(), handle_request_subscribe(), load_module(), mkintf(), ooh323_alloc(), ooh323_destroy(), phone_request(), sip_alloc(), sip_show_channel(), sip_show_history(), and unload_module().
ast_mutex_t iflock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static] |
Protect the interface list (of dahdi_pvt's).
Definition at line 227 of file chan_dahdi.c.
Referenced by __action_showchannels(), __unload_module(), dahdi_hangup(), dahdi_request(), dahdi_show_channel(), dahdi_show_channels(), dahdi_softhangup_all(), destroy_all_channels(), do_monitor(), and setup_dahdi().
int matchdigittimeout = 3000 [static] |
How long to wait for an extra digit, if there is an ambiguous match.
Definition at line 224 of file chan_dahdi.c.
pthread_t monitor_thread = AST_PTHREADT_NULL [static] |
This is the thread for the monitor which checks for input on the channels which are not currently in use.
Definition at line 242 of file chan_dahdi.c.
ast_mutex_t monlock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static] |
Protect the monitoring thread, so only one process can kill or start it, and not when it's doing something critical.
Definition at line 238 of file chan_dahdi.c.
Referenced by __unload_module(), dahdi_restart(), and restart_monitor().
| char* name |
Definition at line 1170 of file chan_dahdi.c.
int num_cadence = 4 [static] |
Definition at line 767 of file chan_dahdi.c.
int num_restart_pending = 0 [static] |
Definition at line 247 of file chan_dahdi.c.
int numbufs = 4 [static] |
Definition at line 206 of file chan_dahdi.c.
char progzone[10] = "" [static] |
Definition at line 202 of file chan_dahdi.c.
ast_mutex_t restart_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static] |
int ringt_base = DEFAULT_RINGT [static] |
Definition at line 290 of file chan_dahdi.c.
| struct dahdi_pvt* round_robin[32] |
Definition at line 746 of file chan_dahdi.c.
char show_channel_usage[] [static] |
Initial value:
"Usage: dahdi show channel <chan num>\n" " Detailed information about a given channel\n"
Definition at line 10481 of file chan_dahdi.c.
char show_channels_usage[] [static] |
Initial value:
"Usage: dahdi show channels\n" " Shows a list of available channels\n"
Definition at line 10477 of file chan_dahdi.c.
ast_cond_t ss_thread_complete [static] |
Definition at line 243 of file chan_dahdi.c.
int ss_thread_count = 0 [static] |
Definition at line 246 of file chan_dahdi.c.
ast_mutex_t ss_thread_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) [static] |
char* subnames[] [static] |
const char tdesc[] = "DAHDI Telephony Driver" [static] |
Definition at line 156 of file chan_dahdi.c.
int user_has_defined_cadences = 0 [static] |
Definition at line 768 of file chan_dahdi.c.
struct ast_channel_tech zap_tech [static] |
Definition at line 717 of file chan_dahdi.c.
1.5.9