Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Functions | Variables
chan_dahdi.c File Reference

DAHDI for Pseudo TDM. More...

#include "asterisk.h"
#include <sys/sysmacros.h>
#include <signal.h>
#include <sys/stat.h>
#include <math.h>
#include "sig_analog.h"
#include "sig_pri.h"
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/pbx.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/pickup.h"
#include "asterisk/features.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/tdd.h"
#include "asterisk/mwi.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/devicestate.h"
#include "asterisk/paths.h"
#include "asterisk/ccss.h"
#include "asterisk/features_config.h"
#include "asterisk/bridge.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/parking.h"
#include "asterisk/format_cache.h"
#include "chan_dahdi.h"
#include "dahdi/bridge_native_dahdi.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_parms_pseudo
 
struct  dahdi_pri
 
struct  dahdi_starting_point
 
struct  doomed_pri
 
struct  doomed_pris
 
struct  mwi_thread_data
 

Macros

#define ASCII_BYTES_PER_CHAR   80
 
#define AST_LAW(p)   (((p)->law == DAHDI_LAW_ALAW) ? ast_format_alaw : ast_format_ulaw)
 
#define CALLPROGRESS_FAX   (CALLPROGRESS_FAX_INCOMING | CALLPROGRESS_FAX_OUTGOING)
 
#define CALLPROGRESS_FAX_INCOMING   4
 
#define CALLPROGRESS_FAX_OUTGOING   2
 
#define CALLPROGRESS_PROGRESS   1
 
#define CALLWAITING_REPEAT_SAMPLES   ((10000 * 8) / READ_SIZE)
 
#define CALLWAITING_SILENT_SAMPLES   ((300 * 8) / READ_SIZE)
 
#define CALLWAITING_SUPPRESS_SAMPLES   ((100 * 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 CIDCW_EXPIRE_SAMPLES   ((500 * 8) / READ_SIZE)
 
#define container_of(ptr, type, member)   ((type *)((char *)(ptr) - offsetof(type, member)))
 
#define DEFAULT_CIDRINGS   1
 Typically, how many rings before we should send Caller*ID. More...
 
#define DEFAULT_DIALTONE_DETECT_TIMEOUT   ((10000 * 8) / READ_SIZE)
 
#define DEFAULT_RINGT   ((8000 * 8) / READ_SIZE)
 
#define END_SILENCE_LEN   400
 
#define FORMAT   "%7s %4d %-20.20s %-10.10s %-15.15s %-8.8s %-20.20s %-10.10s %-10.10s %-12.12s %-32.32s\n"
 
#define FORMAT   "%4d %-40.40s %-7.7s %-6d %-6d %-6d %-3.3s %-4.4s %-8.8s %s\n"
 
#define FORMAT2   "%7s %4s %-20.20s %-10.10s %-15.15s %-8.8s %-20.20s %-10.10s %-10.10s %-12.12s %-32.32s\n"
 
#define FORMAT2   "%4s %-40.40s %-7.7s %-6.6s %-6.6s %-6.6s %-3.3s %-4.4s %-8.8s %s\n"
 
#define gen_pvt_field_callback(type, field)
 
#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 MASK_AVAIL   (1 << 0)
 
#define MASK_INUSE   (1 << 1)
 
#define MAX_CHANLIST_LEN   80
 
#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_SPANS   32
 
#define POLARITY_IDLE   0
 
#define POLARITY_REV   1
 
#define PROC_DAHDI_OPT_NOCHAN   (1 << 0)
 
#define PROC_DAHDI_OPT_NOWARN   (1 << 1)
 
#define READ_SIZE   160
 
#define REPORT_CHANNEL_ALARMS   1
 
#define REPORT_SPAN_ALARMS   2
 
#define sig2str   dahdi_sig2str
 
#define SMDI_MD_WAIT_TIMEOUT   1500 /* 1.5 seconds */
 
#define TRAILER_MS   5
 
#define TRANSFER   0
 

Functions

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)
 
int _dahdi_get_index (struct ast_channel *ast, struct dahdi_pvt *p, int nullok, const char *fname, unsigned long line)
 
static int action_dahdidialoffhook (struct mansession *s, const struct message *m)
 
static int action_dahdidndoff (struct mansession *s, const struct message *m)
 
static int action_dahdidndon (struct mansession *s, const struct message *m)
 
static int action_dahdirestart (struct mansession *s, const struct message *m)
 
static int action_dahdishowchannels (struct mansession *s, const struct message *m)
 
static int action_dahdishowstatus (struct mansession *s, const struct message *m)
 
static int action_pri_debug_file_set (struct mansession *s, const struct message *m)
 
static int action_pri_debug_file_unset (struct mansession *s, const struct message *m)
 
static int action_pri_debug_set (struct mansession *s, const struct message *m)
 
static int action_prishowspans (struct mansession *s, const struct message *m)
 
static int action_transfer (struct mansession *s, const struct message *m)
 
static int action_transferhangup (struct mansession *s, const struct message *m)
 
static char * alarm2str (int alm)
 
static int alloc_sub (struct dahdi_pvt *p, int x)
 
static void * analog_ss_thread (void *data)
 
static int analog_tone_to_dahditone (enum analog_tone tone)
 
static int analogsub_to_dahdisub (enum analog_sub analogsub)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int attempt_transfer (struct dahdi_pvt *p)
 
static int available (struct dahdi_pvt **pvt, int is_specific_channel)
 
static void build_alarm_info (char *restrict alarmstr, struct dahdi_spaninfo *spaninfo)
 
static int build_channels (struct dahdi_chan_conf *conf, const char *value, int reload, int lineno)
 
static int bump_gains (struct dahdi_pvt *p)
 
static int calc_energy (const unsigned char *buf, int len, struct ast_format *law)
 
static int canmatch_featurecode (const char *pickupexten, const char *exten)
 
static int check_for_conference (struct dahdi_pvt *p)
 
static char * complete_span_4 (const char *line, const char *word, int pos, int state)
 
static char * complete_span_helper (const char *line, const char *word, int pos, int state, int rpos)
 
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 struct ast_strcreate_channel_name (struct dahdi_pvt *i, int is_outgoing, char *address)
 
static void dahdi_ami_channel_event (struct dahdi_pvt *p, struct ast_channel *chan)
 
static int dahdi_answer (struct ast_channel *ast)
 
static int dahdi_call (struct ast_channel *ast, const char *rdest, int timeout)
 
static int dahdi_callwait (struct ast_channel *ast)
 
static int dahdi_cc_callback (struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback)
 Callback made when dial failed to get a channel out of dahdi_request(). More...
 
static struct dahdi_chan_conf dahdi_chan_conf_default (void)
 
static void dahdi_close (int fd)
 
static void dahdi_close_pri_fd (struct dahdi_pri *pri, int fd_num)
 
static void dahdi_close_sub (struct dahdi_pvt *chan_pvt, int sub_num)
 
void dahdi_conf_update (struct dahdi_pvt *p)
 
static int dahdi_confmute (struct dahdi_pvt *p, int muted)
 
static int dahdi_create_channel_range (int start, int end)
 
static char * dahdi_create_channels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int dahdi_datetime_send_option (const char *value)
 
static void dahdi_destroy_channel_range (int start, int end)
 
static char * dahdi_destroy_channels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int dahdi_devicestate (const char *data)
 
static int dahdi_dial_str (struct dahdi_pvt *pvt, int operation, const char *dial_str)
 
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 unsigned long dahdi_display_text_option (const char *value)
 
static int dahdi_dnd (struct dahdi_pvt *dahdichan, int flag)
 enable or disable the chan_dahdi Do-Not-Disturb mode for a DAHDI channel More...
 
void dahdi_dtmf_detect_disable (struct dahdi_pvt *p)
 
void dahdi_dtmf_detect_enable (struct dahdi_pvt *p)
 
void dahdi_ec_disable (struct dahdi_pvt *p)
 
void dahdi_ec_enable (struct dahdi_pvt *p)
 
static struct ast_framedahdi_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, const char *function, char *data, char *buf, size_t len)
 
static int dahdi_func_write (struct ast_channel *chan, const char *function, char *data, const char *value)
 
static int dahdi_get_event (int fd)
 Avoid the silly dahdi_getevent which ignores a bunch of events.
 
static void dahdi_handle_dtmf (struct ast_channel *ast, int idx, struct ast_frame **dest)
 
static struct ast_framedahdi_handle_event (struct ast_channel *ast)
 
static int dahdi_hangup (struct ast_channel *ast)
 
static void dahdi_iflist_extract (struct dahdi_pvt *pvt)
 
static void dahdi_iflist_insert (struct dahdi_pvt *pvt)
 
static int dahdi_indicate (struct ast_channel *chan, int condition, const void *data, size_t datalen)
 
static void dahdi_lock_sub_owner (struct dahdi_pvt *pvt, int sub_idx)
 
void dahdi_master_slave_link (struct dahdi_pvt *slave, struct dahdi_pvt *master)
 
void dahdi_master_slave_unlink (struct dahdi_pvt *slave, struct dahdi_pvt *master, int needlock)
 
static struct ast_channeldahdi_new (struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid)
 
static struct ast_channeldahdi_new_callid_clean (struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid, int callid_created)
 
static int dahdi_new_pri_nobch_channel (struct sig_pri_span *pri)
 
static void dahdi_nobch_extract (struct sig_pri_span *pri, struct dahdi_pvt *pvt)
 
static void dahdi_nobch_insert (struct sig_pri_span *pri, struct dahdi_pvt *pvt)
 
static int dahdi_open (char *fn)
 
static void dahdi_pri_cc_agent_destructor (struct ast_cc_agent *agent)
 
static int dahdi_pri_cc_agent_init (struct ast_cc_agent *agent, struct ast_channel *chan)
 
static void dahdi_pri_error (struct pri *pri, char *s)
 
static void dahdi_pri_message (struct pri *pri, char *s)
 
static void dahdi_pri_update_span_devstate (struct sig_pri_span *pri)
 
static int dahdi_queryoption (struct ast_channel *chan, int option, void *data, int *datalen)
 
static void dahdi_queue_frame (struct dahdi_pvt *p, struct ast_frame *f)
 
static struct ast_framedahdi_read (struct ast_channel *ast)
 
static struct ast_channeldahdi_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
 
static int dahdi_restart (void)
 
static char * dahdi_restart_cmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int dahdi_ring_phone (struct dahdi_pvt *p)
 
static int dahdi_send_callrerouting_facility_exec (struct ast_channel *chan, const char *data)
 
static int dahdi_send_keypad_facility_exec (struct ast_channel *chan, const char *digits)
 
static int dahdi_sendtext (struct ast_channel *c, const char *text)
 
static char * dahdi_set_dnd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int dahdi_set_hook (int fd, int hs)
 
static char * dahdi_set_hwgain (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * dahdi_set_mwi (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * dahdi_set_swgain (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int dahdi_setlaw (int dfd, int law)
 
static int dahdi_setlinear (int dfd, int linear)
 
static int dahdi_setoption (struct ast_channel *chan, int option, void *data, int datalen)
 
static char * dahdi_show_channel (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * dahdi_show_channels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * dahdi_show_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * dahdi_show_version (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
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_pri_pvt (struct dahdi_pvt *pvt)
 
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 struct ast_manager_event_blobdahdichannel_to_ami (struct stasis_message *msg)
 
static enum analog_event dahdievent_to_analogevent (int event)
 
static enum analog_sigtype dahdisig_to_analogsig (int sig)
 
static void deep_copy_dahdi_chan_conf (struct dahdi_chan_conf *dest, const struct dahdi_chan_conf *src)
 
static void destroy_all_channels (void)
 
static void destroy_channel (struct dahdi_pvt *cur, int now)
 
static void destroy_dahdi_pvt (struct dahdi_pvt *pvt)
 
static struct dahdi_pvtdetermine_starting_point (const char *data, struct dahdi_starting_point *param)
 
static int digit_to_dtmfindex (char digit)
 
static void * do_monitor (void *data)
 
static int drc_sample (int sample, float drc)
 
static struct dahdi_pvtduplicate_pseudo (struct dahdi_pvt *src)
 
static const char * event2str (int event)
 
static void fill_rxgain (struct dahdi_gains *g, float gain, float drc, int law)
 
static void fill_txgain (struct dahdi_gains *g, float gain, float drc, int law)
 
static struct dahdi_pvtfind_channel (int channel)
 
static struct dahdi_pvtfind_channel_from_str (const char *channel)
 
static struct dahdi_pvtfind_next_iface_in_span (struct dahdi_pvt *cur)
 
static struct dahdi_pvtfxo_pvt (struct ast_channel *chan)
 Return DAHDI pivot if channel is FXO signalled.
 
 gen_pvt_field_callback (int, firstdigit_timeout)
 
 gen_pvt_field_callback (int, interdigit_timeout)
 
 gen_pvt_field_callback (int, matchdigit_timeout)
 
static int get_alarms (struct dahdi_pvt *p)
 
static void handle_alarms (struct dahdi_pvt *p, int alms)
 
static void handle_clear_alarms (struct dahdi_pvt *p)
 
static char * handle_dahdi_show_cadences (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static struct dahdi_pvthandle_init_event (struct dahdi_pvt *i, int event)
 
static char * handle_pri_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_destroy_span (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_service_disable_channel (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_service_enable_channel (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_service_generic (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a, int changestatus)
 
static char * handle_pri_set_debug_file (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_show_channels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_show_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_show_span (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_show_spans (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_pri_version (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int has_voicemail (struct dahdi_pvt *p)
 
static int is_group_or_channel_match (struct dahdi_pvt *p, int span, ast_group_t groupmatch, int *groupmatched, int channelmatch, int *channelmatched)
 
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)
 Load the module. More...
 
static struct dahdi_pvtmkintf (int channel, const struct dahdi_chan_conf *conf, int reloading)
 
static void monitor_pfds_clean (void *arg)
 
static int mwi_send_init (struct dahdi_pvt *pvt)
 
static int mwi_send_process_buffer (struct dahdi_pvt *pvt, int num_read)
 
static int mwi_send_process_event (struct dahdi_pvt *pvt, int event)
 
static void * mwi_thread (void *data)
 
static void my_all_subchannels_hungup (void *pvt)
 
static int my_allocate_sub (void *pvt, enum analog_sub analogsub)
 
static void my_ami_channel_event (void *pvt, struct ast_channel *chan)
 
static void my_answer_polarityswitch (void *pvt)
 
static int my_callwait (void *pvt)
 
static void my_cancel_cidspill (void *pvt)
 
static int my_check_confirmanswer (void *pvt)
 
static int my_check_for_conference (void *pvt)
 
static int my_check_waitingfordt (void *pvt)
 
static int my_complete_conference_update (void *pvt, int needconference)
 
static int my_conf_add (void *pvt, enum analog_sub sub)
 
static int my_conf_del (void *pvt, enum analog_sub sub)
 
static int my_confmute (void *pvt, int mute)
 
static int my_dahdi_write (struct dahdi_pvt *p, unsigned char *buf, int len, int idx, int linear)
 
static void my_deadlock_avoidance_private (void *pvt)
 
static void my_decrease_ss_count (void)
 
static int my_dial_digits (void *pvt, enum analog_sub sub, struct analog_dialoperation *dop)
 
static int my_distinctive_ring (struct ast_channel *chan, void *pvt, int idx, int *ringdata)
 
static int my_dsp_reset_and_flush_digits (void *pvt)
 
static int my_dsp_set_digitmode (void *pvt, enum analog_dsp_digitmode mode)
 
static int my_flash (void *pvt)
 
static void my_get_and_handle_alarms (void *pvt)
 
static int my_get_callerid (void *pvt, char *namebuf, char *numbuf, enum analog_event *ev, size_t timeout)
 
static int my_get_event (void *pvt)
 
static const char * my_get_orig_dialstring (void *pvt)
 
static void * my_get_sigpvt_bridged_channel (struct ast_channel *chan)
 
static int my_get_sub_fd (void *pvt, enum analog_sub sub)
 
static int my_getsigstr (struct ast_channel *chan, char *str, const char *term, int ms)
 
static void my_handle_dchan_exception (struct sig_pri_span *pri, int index)
 
static void my_handle_dtmf (void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest)
 
static void my_handle_notify_message (struct ast_channel *chan, void *pvt, int cid_flags, int neon_mwievent)
 
static void my_hangup_polarityswitch (void *pvt)
 
static int my_has_voicemail (void *pvt)
 
static int my_have_progressdetect (void *pvt)
 
static void my_increase_ss_count (void)
 
static int my_is_dialing (void *pvt, enum analog_sub sub)
 
static int my_is_off_hook (void *pvt)
 
static void my_lock_private (void *pvt)
 
static void my_module_ref (void)
 
static void my_module_unref (void)
 
static struct ast_channelmy_new_analog_ast_channel (void *pvt, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
 
static struct ast_channelmy_new_pri_ast_channel (void *pvt, int state, enum sig_pri_law law, char *exten, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
 
static int my_off_hook (void *pvt)
 
static int my_on_hook (void *pvt)
 
static int my_play_tone (void *pvt, enum analog_sub sub, enum analog_tone tone)
 
static void my_pri_dial_digits (void *p, const char *dial_string)
 
static void my_pri_fixup_chans (void *chan_old, void *chan_new)
 
static void my_pri_init_config (void *priv, struct sig_pri_span *pri)
 
static void my_pri_make_cc_dialstring (void *priv, char *buf, size_t buf_size)
 
static int my_pri_play_tone (void *pvt, enum sig_pri_tone tone)
 
static void my_pri_ss7_open_media (void *p)
 
static int my_ring (void *pvt)
 
static int my_send_callerid (void *pvt, int cwcid, struct ast_party_caller *caller)
 
static void my_set_alarm (void *pvt, int in_alarm)
 
static void my_set_cadence (void *pvt, int *cid_rings, struct ast_channel *ast)
 
static void my_set_callerid (void *pvt, const struct ast_party_caller *caller)
 
static void my_set_callwaiting (void *pvt, int callwaiting_enable)
 
static void my_set_confirmanswer (void *pvt, int flag)
 
static void my_set_dialing (void *pvt, int is_dialing)
 
static void my_set_digital (void *pvt, int is_digital)
 
static void my_set_dnid (void *pvt, const char *dnid)
 
static int my_set_echocanceller (void *pvt, int enable)
 
static void my_set_inthreeway (void *pvt, enum analog_sub sub, int inthreeway)
 
static int my_set_linear_mode (void *pvt, enum analog_sub sub, int linear_mode)
 
static void my_set_needringing (void *pvt, int value)
 
static void my_set_new_owner (void *pvt, struct ast_channel *new_owner)
 
static void my_set_outgoing (void *pvt, int is_outgoing)
 
static void my_set_polarity (void *pvt, int value)
 
static void my_set_pulsedial (void *pvt, int flag)
 
static void my_set_rdnis (void *pvt, const char *rdnis)
 
static void my_set_ringtimeout (void *pvt, int ringt)
 
static void my_set_waitingfordt (void *pvt, struct ast_channel *ast)
 
static int my_start (void *pvt)
 
static int my_start_cid_detect (void *pvt, int cid_signalling)
 
static void my_start_polarityswitch (void *pvt)
 
static int my_stop_callwait (void *pvt)
 
static int my_stop_cid_detect (void *pvt)
 
static void my_swap_subchannels (void *pvt, enum analog_sub a, struct ast_channel *ast_a, enum analog_sub b, struct ast_channel *ast_b)
 
static int my_train_echocanceller (void *pvt)
 
static int my_unallocate_sub (void *pvt, enum analog_sub analogsub)
 
static void my_unlock_private (void *pvt)
 
static int my_wait_event (void *pvt)
 
static int my_wink (void *pvt, enum analog_sub sub)
 
static void notify_message (char *mailbox, int thereornot)
 Send MWI state change. More...
 
static int parse_buffers_policy (const char *parse, int *num_buffers, int *policy)
 
static void parse_busy_pattern (struct ast_variable *v, struct ast_dsp_busy_pattern *busy_cadence)
 
static int polarity_read (struct ast_channel *chan, const char *cmd, char *data, char *buffer, size_t buflen)
 
static int polarity_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 
static int prepare_pri (struct dahdi_pri *pri)
 
static int pri_create_spanmap (int span, int trunkgroup, int logicalspan)
 
static int pri_create_trunkgroup (int trunkgroup, int *channels)
 
static void pri_destroy_span (struct sig_pri_span *pri)
 
static void pri_queue_for_destruction (struct sig_pri_span *pri)
 Queue a span for destruction. More...
 
static int pri_resolve_span (int *span, int channel, int offset, struct dahdi_spaninfo *si)
 
static int process_dahdi (struct dahdi_chan_conf *confp, const char *cat, struct ast_variable *v, int reload, int options)
 
static void process_echocancel (struct dahdi_chan_conf *confp, const char *data, unsigned int line)
 
static void publish_channel_alarm (int channel, const char *alarm_txt)
 
static void publish_channel_alarm_clear (int channel)
 
static void publish_dahdichannel (struct ast_channel *chan, ast_group_t group, int span, const char *dahdi_channel)
 Sends a DAHDIChannel channel blob used to produce DAHDIChannel AMI messages.
 
static void publish_dnd_state (int channel, const char *status)
 
static void publish_span_alarm (int span, const char *alarm_txt)
 
static void publish_span_alarm_clear (int span)
 
static void release_doomed_pris (void)
 
static int reload (void)
 
static int reset_conf (struct dahdi_pvt *p)
 
static int restart_monitor (void)
 
static int restore_conference (struct dahdi_pvt *p)
 
static int restore_gains (struct dahdi_pvt *p)
 
static int revert_fax_buffers (struct dahdi_pvt *p, struct ast_channel *ast)
 
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, float rxgain, float txgain, float rxdrc, float txdrc, int law)
 
static int set_actual_rxgain (int fd, float gain, float drc, int law)
 
static int set_actual_txgain (int fd, float gain, float drc, int law)
 
static int set_hwgain (int fd, float gain, int tx_direction)
 
static int setup_dahdi (int reload)
 
static int setup_dahdi_int (int reload, struct dahdi_chan_conf *default_conf, struct dahdi_chan_conf *base_conf, struct dahdi_chan_conf *conf)
 
static int sig_pri_tone_to_dahditone (enum sig_pri_tone tone)
 
static int sigtype_to_signalling (int sigtype)
 
 STASIS_MESSAGE_TYPE_DEFN_LOCAL (dahdichannel_type,.to_ami=dahdichannel_to_ami,)
 
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 void wakeup_sub (struct dahdi_pvt *p, int a)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = tdesc , .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 = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, .requires = "ccss", .optional_modules = "res_smdi", }
 
struct {
   int   alarm
 
   char *   name
 
alarms []
 
struct analog_callback analog_callbacks
 
static struct dahdi_ring_cadence AS_RP_cadence = {{250, 10000}}
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct dahdi_ring_cadence cadences [NUM_CADENCE_MAX]
 
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 const char config [] = "chan_dahdi.conf"
 
static struct ast_cli_entry dahdi_cli []
 
static struct ast_cc_agent_callbacks dahdi_pri_cc_agent_callbacks
 
static struct ast_cc_monitor_callbacks dahdi_pri_cc_monitor_callbacks
 
static const char dahdi_pri_cc_type [] = "DAHDI/PRI"
 
static struct ast_cli_entry dahdi_pri_cli []
 
static struct dahdi_parms_pseudo dahdi_pseudo_parms
 
static char * dahdi_send_callrerouting_facility_app = "DAHDISendCallreroutingFacility"
 
static char * dahdi_send_keypad_facility_app = "DAHDISendKeypadFacility"
 
static struct ast_channel_tech dahdi_tech
 
static struct ast_jb_conf default_jbconf
 
static char defaultcic [64] = ""
 
static char defaultozz [64] = ""
 
static int distinctiveringaftercid = 0
 
static struct doomed_pris doomed_pris = { .first = NULL, .last = NULL, .lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } , }
 
static int dtmfcid_level = 256
 
static const char *const events []
 
static struct ast_jb_conf global_jbconf
 
static int has_pseudo
 
static int ifcount = 0
 
static struct dahdi_pvtifend = NULL
 
static struct dahdi_pvtiflist = NULL
 
static ast_mutex_t iflock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 Protect the interface list (of dahdi_pvt's)
 
static const char *const lbostr []
 
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 = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 Protect the monitoring thread, so only one process can kill or start it, and not when it's doing something critical.
 
static int mwilevel = 512
 
static char mwimonitornotify [PATH_MAX] = ""
 
static int num_cadence = 4
 
static int num_restart_pending = 0
 
static int numbufs = 4
 
static struct ast_custom_function polarity_function
 
static int pridebugfd = -1
 
static ast_mutex_t pridebugfdlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static char pridebugfilename [1024] = ""
 
static struct dahdi_pri pris [NUM_SPANS]
 
static char progzone [10] = ""
 
static int report_alarms = REPORT_CHANNEL_ALARMS
 
static ast_mutex_t restart_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static int ringt_base = DEFAULT_RINGT
 Configured ring timeout base. More...
 
static struct dahdi_pvtround_robin [64]
 
struct sig_pri_callback sig_pri_callbacks
 
static ast_cond_t ss_thread_complete
 
static int ss_thread_count = 0
 
static ast_mutex_t ss_thread_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
const char *const subnames []
 
static const char tdesc []
 
static int usedistinctiveringdetection = 0
 
static int user_has_defined_cadences = 0
 

Detailed Description

DAHDI for Pseudo TDM.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

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.

Todo:
Deprecate the "musiconhold" configuration option post 1.4

Definition in file chan_dahdi.c.

Macro Definition Documentation

#define CALLWAITING_REPEAT_SAMPLES   ((10000 * 8) / READ_SIZE)

10,000 ms

Definition at line 800 of file chan_dahdi.c.

#define CALLWAITING_SILENT_SAMPLES   ((300 * 8) / READ_SIZE)

300 ms

Definition at line 799 of file chan_dahdi.c.

#define CALLWAITING_SUPPRESS_SAMPLES   ((100 * 8) / READ_SIZE)

100 ms

Definition at line 801 of file chan_dahdi.c.

#define CIDCW_EXPIRE_SAMPLES   ((500 * 8) / READ_SIZE)

500 ms

Definition at line 802 of file chan_dahdi.c.

#define DEFAULT_CIDRINGS   1

Typically, how many rings before we should send Caller*ID.

Note
Define ZHONE_HACK to cause us to go off hook and then back on hook when the user hangs up to reset the state machine so ring works properly. This is used to be able to support kewlstart by putting the zhone in groundstart mode since their forward disconnect supervision is entirely broken even though their documentation says it isn't and their support is entirely unwilling to provide any assistance with their channel banks even though their web site says they support their products for life.

Definition at line 640 of file chan_dahdi.c.

Referenced by dahdi_chan_conf_default().

#define DEFAULT_DIALTONE_DETECT_TIMEOUT   ((10000 * 8) / READ_SIZE)

10,000 ms

Definition at line 805 of file chan_dahdi.c.

#define DEFAULT_RINGT   ((8000 * 8) / READ_SIZE)

8,000 ms

Definition at line 804 of file chan_dahdi.c.

#define gen_pvt_field_callback (   type,
  field 
)
Value:
static type my_get_##field(void *pvt) \
{ \
struct dahdi_pvt *p = pvt; \
return p->field; \
}

Definition at line 3603 of file chan_dahdi.c.

#define ISTRUNK (   p)
Value:
((p->sig == SIG_FXSLS) || (p->sig == SIG_FXSKS) || \
(p->sig == SIG_FXSGS) || (p->sig == SIG_PRI))

Definition at line 711 of file chan_dahdi.c.

#define MASK_AVAIL   (1 << 0)

Channel available for PRI use

Definition at line 796 of file chan_dahdi.c.

#define MASK_INUSE   (1 << 1)

Channel currently in use

Definition at line 797 of file chan_dahdi.c.

#define MAX_CHANLIST_LEN   80

The length of the parameters list of 'dahdichan'.

Todo:
Move definition of MAX_CHANLIST_LEN to a proper place.

Definition at line 18297 of file chan_dahdi.c.

#define MIN_MS_SINCE_FLASH   ((2000) )

2000 ms

Definition at line 803 of file chan_dahdi.c.

#define PROC_DAHDI_OPT_NOCHAN   (1 << 0)

process_dahdi() - ignore keyword 'channel' and similar

Definition at line 18432 of file chan_dahdi.c.

#define PROC_DAHDI_OPT_NOWARN   (1 << 1)

process_dahdi() - No warnings on non-existing cofiguration keywords

Definition at line 18434 of file chan_dahdi.c.

#define READ_SIZE   160

Chunk size to read – we use 20ms chunks to make things happy.

Definition at line 794 of file chan_dahdi.c.

Referenced by dahdi_setoption().

Function Documentation

static int dahdi_answer ( struct ast_channel ast)
static
Todo:
XXX this is redundantly set by the analog and PRI submodules!

Definition at line 6699 of file chan_dahdi.c.

References ast_debug, ast_setstate(), AST_STATE_UP, dahdi_pvt::channel, dahdi_pvt::lock, dahdi_pvt::oprmode, dahdi_pvt::radio, dahdi_pvt::sig, and SUB_REAL.

6700 {
6701  struct dahdi_pvt *p = ast_channel_tech_pvt(ast);
6702  int res = 0;
6703  int idx;
6704  ast_setstate(ast, AST_STATE_UP);/*! \todo XXX this is redundantly set by the analog and PRI submodules! */
6705  ast_mutex_lock(&p->lock);
6706  idx = dahdi_get_index(ast, p, 0);
6707  if (idx < 0)
6708  idx = SUB_REAL;
6709  /* nothing to do if a radio channel */
6710  if ((p->radio || (p->oprmode < 0))) {
6711  ast_mutex_unlock(&p->lock);
6712  return 0;
6713  }
6714 
6715  if (dahdi_analog_lib_handles(p->sig, p->radio, p->oprmode)) {
6716  res = analog_answer(p->sig_pvt, ast);
6717  ast_mutex_unlock(&p->lock);
6718  return res;
6719  }
6720 
6721  switch (p->sig) {
6722 #if defined(HAVE_PRI)
6723  case SIG_PRI_LIB_HANDLE_CASES:
6724  res = sig_pri_answer(p->sig_pvt, ast);
6725  break;
6726 #endif /* defined(HAVE_PRI) */
6727 #if defined(HAVE_SS7)
6728  case SIG_SS7:
6729  res = sig_ss7_answer(p->sig_pvt, ast);
6730  break;
6731 #endif /* defined(HAVE_SS7) */
6732 #ifdef HAVE_OPENR2
6733  case SIG_MFCR2:
6734  if (!p->mfcr2_call_accepted) {
6735  /* The call was not accepted on offer nor the user, so it must be accepted now before answering,
6736  openr2_chan_answer_call will be called when the callback on_call_accepted is executed */
6737  p->mfcr2_answer_pending = 1;
6738  if (p->mfcr2_charge_calls) {
6739  ast_debug(1, "Accepting MFC/R2 call with charge before answering on chan %d\n", p->channel);
6740  openr2_chan_accept_call(p->r2chan, OR2_CALL_WITH_CHARGE);
6741  } else {
6742  ast_debug(1, "Accepting MFC/R2 call with no charge before answering on chan %d\n", p->channel);
6743  openr2_chan_accept_call(p->r2chan, OR2_CALL_NO_CHARGE);
6744  }
6745  } else {
6746  ast_debug(1, "Answering MFC/R2 call on chan %d\n", p->channel);
6747  dahdi_r2_answer(p);
6748  }
6749  break;
6750 #endif
6751  case 0:
6752  ast_mutex_unlock(&p->lock);
6753  return 0;
6754  default:
6755  ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
6756  res = -1;
6757  break;
6758  }
6759  ast_mutex_unlock(&p->lock);
6760  return res;
6761 }
int oprmode
Definition: chan_dahdi.h:151
ast_mutex_t lock
Definition: chan_dahdi.h:125
#define ast_debug(level,...)
Log a DEBUG message.
#define SUB_REAL
Definition: chan_dahdi.h:57
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7386
int radio
Nonzero if the signaling type is sent over a radio.
Definition: chan_dahdi.h:148
int channel
Definition: chan_dahdi.h:585
static int dahdi_cc_callback ( struct ast_channel inbound,
const char *  dest,
ast_cc_callback_fn  callback 
)
static

Callback made when dial failed to get a channel out of dahdi_request().

Since
1.8
Parameters
inboundIncoming asterisk channel.
destSame dial string passed to dahdi_request().
callbackCallback into CC core to announce a busy channel available for CC.

This callback acts like a forked dial with all prongs of the fork busy. Essentially, for each channel that could have taken the call, indicate that it is busy.

Return values
0on success.
-1on error.

Definition at line 14146 of file chan_dahdi.c.

References AST_CC_GENERIC_MONITOR_TYPE, AST_CC_MONITOR_ALWAYS, AST_CC_MONITOR_GENERIC, AST_CC_MONITOR_NEVER, AST_CHANNEL_NAME, ast_get_cc_monitor_policy(), ast_str_buffer(), dahdi_starting_point::backwards, sig_pri_span::cc_params, dahdi_starting_point::channelmatch, dahdi_starting_point::groupmatch, iflist, iflock, dahdi_pvt::next, dahdi_pvt::prev, dahdi_pvt::sig, sig_pri_span::span, and dahdi_starting_point::span.

14147 {
14148  struct dahdi_pvt *p;
14149  struct dahdi_pvt *exitpvt;
14150  struct dahdi_starting_point start;
14151  int groupmatched = 0;
14152  int channelmatched = 0;
14153 
14154  ast_mutex_lock(&iflock);
14155  p = determine_starting_point(dest, &start);
14156  if (!p) {
14157  ast_mutex_unlock(&iflock);
14158  return -1;
14159  }
14160  exitpvt = p;
14161  for (;;) {
14162  if (is_group_or_channel_match(p, start.span, start.groupmatch, &groupmatched, start.channelmatch, &channelmatched)) {
14163  /* We found a potential match. call the callback */
14164  struct ast_str *device_name;
14165  char *dash;
14166  const char *monitor_type;
14167  char dialstring[AST_CHANNEL_NAME];
14168  char full_device_name[AST_CHANNEL_NAME];
14169 
14170  switch (ast_get_cc_monitor_policy(p->cc_params)) {
14171  case AST_CC_MONITOR_NEVER:
14172  break;
14173  case AST_CC_MONITOR_NATIVE:
14174  case AST_CC_MONITOR_ALWAYS:
14176 #if defined(HAVE_PRI)
14177  if (dahdi_sig_pri_lib_handles(p->sig)) {
14178  /*
14179  * ISDN is in a trunk busy condition so we need to monitor
14180  * the span congestion device state.
14181  */
14182  snprintf(full_device_name, sizeof(full_device_name),
14183  "DAHDI/I%d/congestion", p->pri->span);
14184  } else
14185 #endif /* defined(HAVE_PRI) */
14186  {
14187 #if defined(HAVE_PRI)
14188  device_name = create_channel_name(p, 1, "");
14189 #else
14190  device_name = create_channel_name(p);
14191 #endif /* defined(HAVE_PRI) */
14192  snprintf(full_device_name, sizeof(full_device_name), "DAHDI/%s",
14193  device_name ? ast_str_buffer(device_name) : "");
14194  ast_free(device_name);
14195  /*
14196  * The portion after the '-' in the channel name is either a random
14197  * number, a sequence number, or a subchannel number. None are
14198  * necessary so strip them off.
14199  */
14200  dash = strrchr(full_device_name, '-');
14201  if (dash) {
14202  *dash = '\0';
14203  }
14204  }
14205  snprintf(dialstring, sizeof(dialstring), "DAHDI/%s", dest);
14206 
14207  /*
14208  * Analog can only do generic monitoring.
14209  * ISDN is in a trunk busy condition and any "device" is going
14210  * to be busy until a B channel becomes available. The generic
14211  * monitor can do this task.
14212  */
14213  monitor_type = AST_CC_GENERIC_MONITOR_TYPE;
14214  callback(inbound,
14215 #if defined(HAVE_PRI)
14216  p->pri ? p->pri->cc_params : p->cc_params,
14217 #else
14218  p->cc_params,
14219 #endif /* defined(HAVE_PRI) */
14220  monitor_type, full_device_name, dialstring, NULL);
14221  break;
14222  }
14223  }
14224  p = start.backwards ? p->prev : p->next;
14225  if (!p) {
14226  p = start.backwards ? ifend : iflist;
14227  }
14228  if (p == exitpvt) {
14229  break;
14230  }
14231  }
14232  ast_mutex_unlock(&iflock);
14233  return 0;
14234 }
struct dahdi_pvt * next
Definition: chan_dahdi.h:169
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
struct ast_cc_config_params * cc_params
Definition: sig_pri.h:446
static struct dahdi_pvt * ifend
Definition: chan_dahdi.c:923
enum ast_cc_monitor_policies ast_get_cc_monitor_policy(struct ast_cc_config_params *config)
Get the cc_monitor_policy.
Definition: ccss.c:876
static ast_mutex_t iflock
Protect the interface list (of dahdi_pvt's)
Definition: chan_dahdi.c:746
#define AST_CC_GENERIC_MONITOR_TYPE
Definition: ccss.h:455
struct dahdi_pvt * prev
Definition: chan_dahdi.h:170
Support for dynamic strings.
Definition: strings.h:623
#define AST_CHANNEL_NAME
Definition: channel.h:171
static struct dahdi_pvt * iflist
Definition: chan_dahdi.c:922
static struct dahdi_chan_conf dahdi_chan_conf_default ( void  )
static

returns a new dahdi_chan_conf with default values (by-value)

Definition at line 990 of file chan_dahdi.c.

References ANALOG_FIRST_DIGIT_TIMEOUT, ANALOG_INTER_DIGIT_TIMEOUT, ANALOG_MATCH_DIGIT_TIMEOUT, ast_cc_config_params_init, DEFAULT_CIDRINGS, sig_pri_span::nsf, and SIG_PRI_COLP_UPDATE.

991 {
992  /* recall that if a field is not included here it is initialized
993  * to 0 or equivalent
994  */
995  struct dahdi_chan_conf conf = {
996 #ifdef HAVE_PRI
997  .pri.pri = {
998  .nsf = PRI_NSF_NONE,
999  .switchtype = PRI_SWITCH_NI2,
1000  .dialplan = PRI_UNKNOWN + 1,
1001  .localdialplan = PRI_NATIONAL_ISDN + 1,
1002  .nodetype = PRI_CPE,
1003  .qsigchannelmapping = DAHDI_CHAN_MAPPING_PHYSICAL,
1004 
1005 #if defined(HAVE_PRI_CCSS)
1006  .cc_ptmp_recall_mode = 1,/* specificRecall */
1007  .cc_qsig_signaling_link_req = 1,/* retain */
1008  .cc_qsig_signaling_link_rsp = 1,/* retain */
1009 #endif /* defined(HAVE_PRI_CCSS) */
1010 
1011  .minunused = 2,
1012  .idleext = "",
1013  .idledial = "",
1014  .internationalprefix = "",
1015  .nationalprefix = "",
1016  .localprefix = "",
1017  .privateprefix = "",
1018  .unknownprefix = "",
1019  .colp_send = SIG_PRI_COLP_UPDATE,
1020  .resetinterval = -1,
1021  },
1022 #endif
1023 #if defined(HAVE_SS7)
1024  .ss7.ss7 = {
1025  .called_nai = SS7_NAI_NATIONAL,
1026  .calling_nai = SS7_NAI_NATIONAL,
1027  .internationalprefix = "",
1028  .nationalprefix = "",
1029  .subscriberprefix = "",
1030  .unknownprefix = "",
1031  .networkroutedprefix = ""
1032  },
1033 #endif /* defined(HAVE_SS7) */
1034 #ifdef HAVE_OPENR2
1035  .mfcr2 = {
1036  .variant = OR2_VAR_ITU,
1037  .mfback_timeout = -1,
1038  .metering_pulse_timeout = -1,
1039  .max_ani = 10,
1040  .max_dnis = 4,
1041  .get_ani_first = -1,
1042 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 1
1043  .skip_category_request = -1,
1044 #endif
1045  .call_files = 0,
1046  .allow_collect_calls = 0,
1047  .charge_calls = 1,
1048  .accept_on_offer = 1,
1049  .forced_release = 0,
1050  .double_answer = 0,
1051  .immediate_accept = -1,
1052 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 2
1053  .dtmf_dialing = -1,
1054  .dtmf_detection = -1,
1055  .dtmf_time_on = OR2_DEFAULT_DTMF_ON,
1056  .dtmf_time_off = OR2_DEFAULT_DTMF_OFF,
1057 #endif
1058 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 3
1059  .dtmf_end_timeout = -1,
1060 #endif
1061  .logdir = "",
1062  .r2proto_file = "",
1063  .loglevel = OR2_LOG_ERROR | OR2_LOG_WARNING,
1064  .category = OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER
1065  },
1066 #endif
1067  .chan = {
1068  .context = "default",
1069  .immediatering = 1,
1070  .cid_num = "",
1071  .cid_name = "",
1072  .cid_tag = "",
1073  .mohinterpret = "default",
1074  .mohsuggest = "",
1075  .parkinglot = "",
1076  .transfertobusy = 1,
1077  .dialmode = 0,
1078 
1079  .ani_info_digits = 2,
1080  .ani_wink_time = 1000,
1081  .ani_timeout = 10000,
1082 
1083  .cid_signalling = CID_SIG_BELL,
1084  .cid_start = CID_START_RING,
1085  .dahditrcallerid = 0,
1086  .use_callerid = 1,
1087  .sig = -1,
1088  .outsigmod = -1,
1089 
1090  .cid_rxgain = +5.0,
1091 
1092  .tonezone = -1,
1093 
1094  .echocancel.head.tap_length = 1,
1095 
1096  .busycount = 3,
1097 
1098  .accountcode = "",
1099 
1100  .mailbox = "",
1101 
1102 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI
1103  .mwisend_fsk = 1,
1104 #endif
1105  .polarityonanswerdelay = 600,
1106 
1107  .sendcalleridafter = DEFAULT_CIDRINGS,
1108 
1109  .buf_policy = DAHDI_POLICY_IMMEDIATE,
1110  .buf_no = numbufs,
1111  .usefaxbuffers = 0,
1112  .cc_params = ast_cc_config_params_init(),
1113  .firstdigit_timeout = ANALOG_FIRST_DIGIT_TIMEOUT,
1114  .interdigit_timeout = ANALOG_INTER_DIGIT_TIMEOUT,
1115  .matchdigit_timeout = ANALOG_MATCH_DIGIT_TIMEOUT,
1116  },
1117  .timing = {
1118  .prewinktime = -1,
1119  .preflashtime = -1,
1120  .winktime = -1,
1121  .flashtime = -1,
1122  .starttime = -1,
1123  .rxwinktime = -1,
1124  .rxflashtime = -1,
1125  .debouncetime = -1
1126  },
1127  .is_sig_auto = 1,
1128  .ignore_failed_channels = 1,
1129  .smdi_port = "/dev/ttyS0",
1130  };
1131 
1132  return conf;
1133 }
#define ANALOG_MATCH_DIGIT_TIMEOUT
Default time (ms) to wait, in case of ambiguous match.
Definition: sig_analog.h:42
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
Definition: ccss.h:135
All configuration options for http media cache.
#define DEFAULT_CIDRINGS
Typically, how many rings before we should send Caller*ID.
Definition: chan_dahdi.c:640
Channel configuration from chan_dahdi.conf . This struct is used for parsing the [channels] section o...
Definition: chan_dahdi.c:952
#define ANALOG_FIRST_DIGIT_TIMEOUT
Default time (ms) to detect first digit.
Definition: sig_analog.h:38
#define ANALOG_INTER_DIGIT_TIMEOUT
Default time (ms) to detect following digits.
Definition: sig_analog.h:40
static int dahdi_dnd ( struct dahdi_pvt dahdichan,
int  flag 
)
static

enable or disable the chan_dahdi Do-Not-Disturb mode for a DAHDI channel

Parameters
dahdichan"Physical" DAHDI channel (e.g: DAHDI/5)
flagon 1 to enable, 0 to disable, -1 return dnd value

chan_dahdi has a DND (Do Not Disturb) mode for each dahdichan (physical DAHDI channel). Use this to enable or disable it.

Bug:
the use of the word "channel" for those dahdichans is really confusing.

Definition at line 9843 of file chan_dahdi.c.

References dahdi_pvt::channel, dahdi_pvt::dnd, dahdi_pvt::oprmode, dahdi_pvt::radio, and dahdi_pvt::sig.

9844 {
9845  if (dahdi_analog_lib_handles(dahdichan->sig, dahdichan->radio, dahdichan->oprmode)) {
9846  return analog_dnd(dahdichan->sig_pvt, flag);
9847  }
9848 
9849  if (flag == -1) {
9850  return dahdichan->dnd;
9851  }
9852 
9853  /* Do not disturb */
9854  dahdichan->dnd = flag;
9855  ast_verb(3, "%s DND on channel %d\n",
9856  flag? "Enabled" : "Disabled",
9857  dahdichan->channel);
9858  publish_dnd_state(dahdichan->channel, flag ? "enabled" : "disabled");
9859  return 0;
9860 }
unsigned int dnd
TRUE if Do-Not-Disturb is enabled, present only for non sig_analog.
Definition: chan_dahdi.h:262
int oprmode
Definition: chan_dahdi.h:151
int radio
Nonzero if the signaling type is sent over a radio.
Definition: chan_dahdi.h:148
int channel
Definition: chan_dahdi.h:585
static int dahdi_setoption ( struct ast_channel chan,
int  option,
void *  data,
int  datalen 
)
static
Todo:
XXX This is an abuse of the stack!!

Definition at line 6843 of file chan_dahdi.c.

References ast_check_hangup(), ast_debug, ast_dsp_set_digitmode(), ast_dsp_set_features(), AST_OPTION_AUDIO_MODE, AST_OPTION_DIGIT_DETECT, AST_OPTION_ECHOCAN, AST_OPTION_FAX_DETECT, AST_OPTION_RELAXDTMF, AST_OPTION_RXGAIN, AST_OPTION_TDD, AST_OPTION_TONE_VERIFY, AST_OPTION_TXGAIN, ast_tdd_gen_ecdisa(), dahdi_pvt::channel, dahdi_pvt::didtdd, dahdi_pvt::dsp, DSP_DIGITMODE_DTMF, DSP_DIGITMODE_MUTECONF, DSP_DIGITMODE_MUTEMAX, DSP_DIGITMODE_RELAXDTMF, dahdi_pvt::dsp_features, dahdi_pvt::dtmfrelax, dahdi_pvt::law, dahdi_pvt::mate, dahdi_pvt::oprmode, dahdi_pvt::oprpeer, READ_SIZE, dahdi_pvt::rxgain, dahdi_pvt::sig, SUB_REAL, dahdi_pvt::subs, dahdi_pvt::tdd, tdd_free(), tdd_new(), dahdi_pvt::txdrc, and dahdi_pvt::txgain.

6844 {
6845  char *cp;
6846  signed char *scp;
6847  int x;
6848  int idx;
6849  struct dahdi_pvt *p = ast_channel_tech_pvt(chan), *pp;
6850  struct oprmode *oprmode;
6851 
6852 
6853  /* all supported options require data */
6854  if (!p || !data || (datalen < 1)) {
6855  errno = EINVAL;
6856  return -1;
6857  }
6858 
6859  switch (option) {
6860  case AST_OPTION_TXGAIN:
6861  scp = (signed char *) data;
6862  idx = dahdi_get_index(chan, p, 0);
6863  if (idx < 0) {
6864  ast_log(LOG_WARNING, "No index in TXGAIN?\n");
6865  return -1;
6866  }
6867  ast_debug(1, "Setting actual tx gain on %s to %f\n", ast_channel_name(chan), p->txgain + (float) *scp);
6868  return set_actual_txgain(p->subs[idx].dfd, p->txgain + (float) *scp, p->txdrc, p->law);
6869  case AST_OPTION_RXGAIN:
6870  scp = (signed char *) data;
6871  idx = dahdi_get_index(chan, p, 0);
6872  if (idx < 0) {
6873  ast_log(LOG_WARNING, "No index in RXGAIN?\n");
6874  return -1;
6875  }
6876  ast_debug(1, "Setting actual rx gain on %s to %f\n", ast_channel_name(chan), p->rxgain + (float) *scp);
6877  return set_actual_rxgain(p->subs[idx].dfd, p->rxgain + (float) *scp, p->rxdrc, p->law);
6879  if (!p->dsp)
6880  break;
6881  cp = (char *) data;
6882  switch (*cp) {
6883  case 1:
6884  ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",ast_channel_name(chan));
6885  ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MUTECONF | p->dtmfrelax); /* set mute mode if desired */
6886  break;
6887  case 2:
6888  ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",ast_channel_name(chan));
6889  ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX | p->dtmfrelax); /* set mute mode if desired */
6890  break;
6891  default:
6892  ast_debug(1, "Set option TONE VERIFY, mode: OFF(0) on %s\n",ast_channel_name(chan));
6893  ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_DTMF | p->dtmfrelax); /* set mute mode if desired */
6894  break;
6895  }
6896  break;
6897  case AST_OPTION_TDD:
6898  /* turn on or off TDD */
6899  cp = (char *) data;
6900  p->mate = 0;
6901  if (!*cp) { /* turn it off */
6902  ast_debug(1, "Set option TDD MODE, value: OFF(0) on %s\n",ast_channel_name(chan));
6903  if (p->tdd)
6904  tdd_free(p->tdd);
6905  p->tdd = 0;
6906  break;
6907  }
6908  ast_debug(1, "Set option TDD MODE, value: %s(%d) on %s\n",
6909  (*cp == 2) ? "MATE" : "ON", (int) *cp, ast_channel_name(chan));
6910  dahdi_ec_disable(p);
6911  /* otherwise, turn it on */
6912  if (!p->didtdd) { /* if havent done it yet */
6913  unsigned char mybuf[41000];/*! \todo XXX This is an abuse of the stack!! */
6914  unsigned char *buf;
6915  int size, res, fd, len;
6916  struct pollfd fds[1];
6917 
6918  buf = mybuf;
6919  memset(buf, 0x7f, sizeof(mybuf)); /* set to silence */
6920  ast_tdd_gen_ecdisa(buf + 16000, 16000); /* put in tone */
6921  len = 40000;
6922  idx = dahdi_get_index(chan, p, 0);
6923  if (idx < 0) {
6924  ast_log(LOG_WARNING, "No index in TDD?\n");
6925  return -1;
6926  }
6927  fd = p->subs[idx].dfd;
6928  while (len) {
6929  if (ast_check_hangup(chan))
6930  return -1;
6931  size = len;
6932  if (size > READ_SIZE)
6933  size = READ_SIZE;
6934  fds[0].fd = fd;
6935  fds[0].events = POLLPRI | POLLOUT;
6936  fds[0].revents = 0;
6937  res = poll(fds, 1, -1);
6938  if (!res) {
6939  ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel);
6940  continue;
6941  }
6942  /* if got exception */
6943  if (fds[0].revents & POLLPRI)
6944  return -1;
6945  if (!(fds[0].revents & POLLOUT)) {
6946  ast_debug(1, "write fd not ready on channel %d\n", p->channel);
6947  continue;
6948  }
6949  res = write(fd, buf, size);
6950  if (res != size) {
6951  if (res == -1) return -1;
6952  ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
6953  break;
6954  }
6955  len -= size;
6956  buf += size;
6957  }
6958  p->didtdd = 1; /* set to have done it now */
6959  }
6960  if (*cp == 2) { /* Mate mode */
6961  if (p->tdd)
6962  tdd_free(p->tdd);
6963  p->tdd = 0;
6964  p->mate = 1;
6965  break;
6966  }
6967  if (!p->tdd) { /* if we don't have one yet */
6968  p->tdd = tdd_new(); /* allocate one */
6969  }
6970  break;
6971  case AST_OPTION_RELAXDTMF: /* Relax DTMF decoding (or not) */
6972  if (!p->dsp)
6973  break;
6974  cp = (char *) data;
6975  ast_debug(1, "Set option RELAX DTMF, value: %s(%d) on %s\n",
6976  *cp ? "ON" : "OFF", (int) *cp, ast_channel_name(chan));
6978  break;
6979  case AST_OPTION_AUDIO_MODE: /* Set AUDIO mode (or not) */
6980 #if defined(HAVE_PRI)
6981  if (dahdi_sig_pri_lib_handles(p->sig)
6982  && ((struct sig_pri_chan *) p->sig_pvt)->no_b_channel) {
6983  /* PRI nobch pseudo channel. Does not handle ioctl(DAHDI_AUDIOMODE) */
6984  break;
6985  }
6986 #endif /* defined(HAVE_PRI) */
6987 
6988  cp = (char *) data;
6989  if (!*cp) {
6990  ast_debug(1, "Set option AUDIO MODE, value: OFF(0) on %s\n", ast_channel_name(chan));
6991  x = 0;
6992  dahdi_ec_disable(p);
6993  } else {
6994  ast_debug(1, "Set option AUDIO MODE, value: ON(1) on %s\n", ast_channel_name(chan));
6995  x = 1;
6996  }
6997  if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &x) == -1)
6998  ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d: %s\n", p->channel, x, strerror(errno));
6999  break;
7000  case AST_OPTION_OPRMODE: /* Operator services mode */
7001  oprmode = (struct oprmode *) data;
7002  /* We don't support operator mode across technologies */
7003  if (strcasecmp(ast_channel_tech(chan)->type, ast_channel_tech(oprmode->peer)->type)) {
7004  ast_log(LOG_NOTICE, "Operator mode not supported on %s to %s calls.\n",
7005  ast_channel_tech(chan)->type, ast_channel_tech(oprmode->peer)->type);
7006  errno = EINVAL;
7007  return -1;
7008  }
7009  pp = ast_channel_tech_pvt(oprmode->peer);
7010  p->oprmode = pp->oprmode = 0;
7011  /* setup peers */
7012  p->oprpeer = pp;
7013  pp->oprpeer = p;
7014  /* setup modes, if any */
7015  if (oprmode->mode)
7016  {
7017  pp->oprmode = oprmode->mode;
7018  p->oprmode = -oprmode->mode;
7019  }
7020  ast_debug(1, "Set Operator Services mode, value: %d on %s/%s\n",
7021  oprmode->mode, ast_channel_name(chan),ast_channel_name(oprmode->peer));
7022  break;
7023  case AST_OPTION_ECHOCAN:
7024  cp = (char *) data;
7025  if (*cp) {
7026  ast_debug(1, "Enabling echo cancellation on %s\n", ast_channel_name(chan));
7027  dahdi_ec_enable(p);
7028  } else {
7029  ast_debug(1, "Disabling echo cancellation on %s\n", ast_channel_name(chan));
7030  dahdi_ec_disable(p);
7031  }
7032  break;
7034  cp = (char *) data;
7035  ast_debug(1, "%sabling digit detection on %s\n", *cp ? "En" : "Dis", ast_channel_name(chan));
7036  if (*cp) {
7037  dahdi_dtmf_detect_enable(p);
7038  } else {
7039  dahdi_dtmf_detect_disable(p);
7040  }
7041  break;
7042  case AST_OPTION_FAX_DETECT:
7043  cp = (char *) data;
7044  if (p->dsp) {
7045  ast_debug(1, "%sabling fax tone detection on %s\n", *cp ? "En" : "Dis", ast_channel_name(chan));
7046  if (*cp) {
7047  p->dsp_features |= DSP_FEATURE_FAX_DETECT;
7048  } else {
7049  p->dsp_features &= ~DSP_FEATURE_FAX_DETECT;
7050  }
7052  }
7053  break;
7054  default:
7055  return -1;
7056  }
7057  errno = 0;
7058 
7059  return 0;
7060 }
int dtmfrelax
Definition: chan_dahdi.h:720
#define AST_OPTION_TXGAIN
struct dahdi_subchannel subs[3]
Definition: chan_dahdi.h:131
#define DSP_DIGITMODE_DTMF
Definition: dsp.h:31
#define DSP_DIGITMODE_MUTECONF
Definition: dsp.h:35
float txdrc
Definition: chan_dahdi.h:164
int dsp_features
DSP feature flags: DSP_FEATURE_xxx.
Definition: chan_dahdi.h:738
#define AST_OPTION_TDD
int law
Active PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW.
Definition: chan_dahdi.h:556
struct dahdi_pvt * oprpeer
Definition: chan_dahdi.h:152
float txgain
Software Tx gain set by chan_dahdi.conf.
Definition: chan_dahdi.h:162
int oprmode
Definition: chan_dahdi.h:151
#define DSP_DIGITMODE_RELAXDTMF
Definition: dsp.h:37
unsigned int didtdd
Definition: chan_dahdi.h:251
int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len)
Definition: tdd.c:148
#define AST_OPTION_RELAXDTMF
#define ast_debug(level,...)
Log a DEBUG message.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:628
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:445
#define AST_OPTION_ECHOCAN
#define AST_OPTION_DIGIT_DETECT
#define DSP_DIGITMODE_MUTEMAX
Definition: dsp.h:36
struct ast_dsp * dsp
Opaque DSP configuration structure.
Definition: chan_dahdi.h:694
#define AST_OPTION_RXGAIN
struct tdd_state * tdd_new(void)
Definition: tdd.c:103
#define SUB_REAL
Definition: chan_dahdi.h:57
#define READ_SIZE
Definition: chan_dahdi.c:794
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
Definition: dsp.c:1768
#define AST_OPTION_AUDIO_MODE
struct tdd_state * tdd
Definition: chan_dahdi.h:702
#define AST_OPTION_FAX_DETECT
#define AST_OPTION_TONE_VERIFY
float rxgain
Software Rx gain set by chan_dahdi.conf.
Definition: chan_dahdi.h:160
void tdd_free(struct tdd_state *tdd)
Definition: tdd.c:218
int channel
Definition: chan_dahdi.h:585
unsigned int mate
TRUE if TDD in MATE mode.
Definition: chan_dahdi.h:326
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
Definition: dsp.c:1857
static int get_alarms ( struct dahdi_pvt p)
static

Checks channel for alarms

Parameters
pa channel to check for alarms.
Returns
the alarms on the span to which the channel belongs, or alarms on the channel if no span alarms.

Definition at line 7567 of file chan_dahdi.c.

References dahdi_pvt::channel, dahdi_pvt::span, SUB_REAL, and dahdi_pvt::subs.

Referenced by mkintf().

7568 {
7569  int res;
7570  struct dahdi_spaninfo zi;
7571  struct dahdi_params params;
7572 
7573  memset(&zi, 0, sizeof(zi));
7574  zi.spanno = p->span;
7575 
7576  if ((res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_SPANSTAT, &zi)) >= 0) {
7577  if (zi.alarms != DAHDI_ALARM_NONE)
7578  return zi.alarms;
7579  } else {
7580  ast_log(LOG_WARNING, "Unable to determine alarm on channel %d: %s\n", p->channel, strerror(errno));
7581  return 0;
7582  }
7583 
7584  /* No alarms on the span. Check for channel alarms. */
7585  memset(&params, 0, sizeof(params));
7586  if ((res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &params)) >= 0)
7587  return params.chan_alarms;
7588 
7589  ast_log(LOG_WARNING, "Unable to determine alarm on channel %d\n", p->channel);
7590 
7591  return DAHDI_ALARM_NONE;
7592 }
struct dahdi_subchannel subs[3]
Definition: chan_dahdi.h:131
#define SUB_REAL
Definition: chan_dahdi.h:57
int channel
Definition: chan_dahdi.h:585
static int load_module ( void  )
static

Load the module.

Module loading including tests for configuration or dependencies. This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails tests return AST_MODULE_LOAD_FAILURE. If the module can not load the configuration file or other non-critical problem return AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.

Definition at line 20279 of file chan_dahdi.c.

References ao2_ref, ast_cc_agent_register(), ast_cc_monitor_register(), ast_channel_register(), ast_cli_register_multiple, ast_custom_function_register, ast_format_alaw, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_slin, ast_format_ulaw, ast_manager_register_xml, AST_MODULE_LOAD_DECLINE, ast_register_application_xml, ast_channel_tech::capabilities, sig_pri_load(), and STASIS_MESSAGE_TYPE_INIT.

20280 {
20281  int res;
20282 #if defined(HAVE_PRI) || defined(HAVE_SS7)
20283  int y;
20284 #endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
20285 
20286  if (STASIS_MESSAGE_TYPE_INIT(dahdichannel_type)) {
20287  return AST_MODULE_LOAD_DECLINE;
20288  }
20289 
20291  return AST_MODULE_LOAD_DECLINE;
20292  }
20296 
20297  if (dahdi_native_load(&dahdi_tech)) {
20298  ao2_ref(dahdi_tech.capabilities, -1);
20299  return AST_MODULE_LOAD_DECLINE;
20300  }
20301 
20302 #ifdef HAVE_PRI
20303  memset(pris, 0, sizeof(pris));
20304  for (y = 0; y < NUM_SPANS; y++) {
20305  sig_pri_init_pri(&pris[y].pri);
20306  }
20307  pri_set_error(dahdi_pri_error);
20308  pri_set_message(dahdi_pri_message);
20309  ast_register_application_xml(dahdi_send_keypad_facility_app, dahdi_send_keypad_facility_exec);
20310 #ifdef HAVE_PRI_PROG_W_CAUSE
20311  ast_register_application_xml(dahdi_send_callrerouting_facility_app, dahdi_send_callrerouting_facility_exec);
20312 #endif
20313 #if defined(HAVE_PRI_CCSS)
20314  if (ast_cc_agent_register(&dahdi_pri_cc_agent_callbacks)
20315  || ast_cc_monitor_register(&dahdi_pri_cc_monitor_callbacks)) {
20316  __unload_module();
20317  return AST_MODULE_LOAD_DECLINE;
20318  }
20319 #endif /* defined(HAVE_PRI_CCSS) */
20320  if (sig_pri_load(
20321 #if defined(HAVE_PRI_CCSS)
20323 #else
20324  NULL
20325 #endif /* defined(HAVE_PRI_CCSS) */
20326  )) {
20327  __unload_module();
20328  return AST_MODULE_LOAD_DECLINE;
20329  }
20330 #endif
20331 #if defined(HAVE_SS7)
20332  memset(linksets, 0, sizeof(linksets));
20333  for (y = 0; y < NUM_SPANS; y++) {
20334  sig_ss7_init_linkset(&linksets[y].ss7);
20335  }
20336  ss7_set_error(dahdi_ss7_error);
20337  ss7_set_message(dahdi_ss7_message);
20338  ss7_set_hangup(sig_ss7_cb_hangup);
20339  ss7_set_notinservice(sig_ss7_cb_notinservice);
20340  ss7_set_call_null(sig_ss7_cb_call_null);
20341 #endif /* defined(HAVE_SS7) */
20342  res = setup_dahdi(0);
20343  /* Make sure we can register our DAHDI channel type */
20344  if (res) {
20345  __unload_module();
20346  return AST_MODULE_LOAD_DECLINE;
20347  }
20348  if (ast_channel_register(&dahdi_tech)) {
20349  ast_log(LOG_ERROR, "Unable to register channel class 'DAHDI'\n");
20350  __unload_module();
20351  return AST_MODULE_LOAD_DECLINE;
20352  }
20353 #ifdef HAVE_PRI
20354  ast_cli_register_multiple(dahdi_pri_cli, ARRAY_LEN(dahdi_pri_cli));
20355 #endif
20356 #if defined(HAVE_SS7)
20357  ast_cli_register_multiple(dahdi_ss7_cli, ARRAY_LEN(dahdi_ss7_cli));
20358 #endif /* defined(HAVE_SS7) */
20359 #ifdef HAVE_OPENR2
20360  ast_cli_register_multiple(dahdi_mfcr2_cli, ARRAY_LEN(dahdi_mfcr2_cli));
20361  ast_register_application_xml(dahdi_accept_r2_call_app, dahdi_accept_r2_call_exec);
20362 #endif
20363 
20364  ast_custom_function_register(&polarity_function);
20365 
20366  ast_cli_register_multiple(dahdi_cli, ARRAY_LEN(dahdi_cli));
20367  memset(round_robin, 0, sizeof(round_robin));
20368  ast_manager_register_xml("DAHDITransfer", 0, action_transfer);
20369  ast_manager_register_xml("DAHDIHangup", 0, action_transferhangup);
20370  ast_manager_register_xml("DAHDIDialOffhook", 0, action_dahdidialoffhook);
20371  ast_manager_register_xml("DAHDIDNDon", 0, action_dahdidndon);
20372  ast_manager_register_xml("DAHDIDNDoff", 0, action_dahdidndoff);
20373  ast_manager_register_xml("DAHDIShowChannels", 0, action_dahdishowchannels);
20374  ast_manager_register_xml("DAHDIShowStatus", 0, action_dahdishowstatus);
20375  ast_manager_register_xml("DAHDIRestart", 0, action_dahdirestart);
20376 #if defined(HAVE_PRI)
20377  ast_manager_register_xml("PRIShowSpans", 0, action_prishowspans);
20378  ast_manager_register_xml("PRIDebugSet", 0, action_pri_debug_set);
20379  ast_manager_register_xml("PRIDebugFileSet", EVENT_FLAG_SYSTEM, action_pri_debug_file_set);
20380  ast_manager_register_xml("PRIDebugFileUnset", 0, action_pri_debug_file_unset);
20381 #endif /* defined(HAVE_PRI) */
20382 
20383  ast_cond_init(&ss_thread_complete, NULL);
20384 
20385  return res;
20386 }
int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks)
Register a set of agent callbacks with the core.
Definition: ccss.c:1217
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition: channel.c:539
int sig_pri_load(const char *cc_type_name)
Load the sig_pri submodule.
Definition: sig_pri.c:10007
int ast_cc_monitor_register(const struct ast_cc_monitor_callbacks *callbacks)
Register a set of monitor callbacks with the core.
Definition: ccss.c:1162
static struct dahdi_pvt * round_robin[64]
Definition: chan_dahdi.c:3690
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition: format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
struct ast_format_cap * capabilities
Definition: channel.h:632
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
static const char dahdi_pri_cc_type[]
Definition: chan_dahdi.c:904
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:191
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640
static struct dahdi_pvt* mkintf ( int  channel,
const struct dahdi_chan_conf conf,
int  reloading 
)
static

< Current channel structure initializing

< TRUE if the channel interface already exists.

Definition at line 12493 of file chan_dahdi.c.

References dahdi_pvt::accountcode, dahdi_pvt::adsi, sig_pri_span::allow_call_waiting_calls, dahdi_pvt::amaflags, dahdi_pvt::ani_info_digits, dahdi_pvt::ani_timeout, dahdi_pvt::ani_wink_time, dahdi_pvt::answeronpolarityswitch, sig_pri_span::aoc_passthrough_flag, sig_pri_span::aoce_delayhangup, sig_pri_span::append_msn_to_user_tag, ast_calloc, ast_cc_config_params_init, ast_cc_copy_config_params(), ast_copy_string(), ast_db_del(), ast_db_get(), ast_dsp_set_digitmode(), ast_mwi_subscribe_pool(), ast_smdi_interface_find(), ast_variable_list_replace(), ast_variables_destroy(), dahdi_pvt::buf_no, dahdi_parms_pseudo::buf_no, dahdi_pvt::buf_policy, dahdi_parms_pseudo::buf_policy, dahdi_pvt::bufsize, dahdi_pvt::busy_cadence, dahdi_pvt::busycount, dahdi_pvt::busydetect, dahdi_pvt::calledsubscriberheld, analog_pvt::calledsubscriberheld, dahdi_pvt::callgroup, dahdi_pvt::callprogress, dahdi_pvt::callreturn, dahdi_pvt::callwaiting, dahdi_pvt::callwaitingcallerid, analog_pvt::callwaitingcallerid, dahdi_pvt::cancallforward, dahdi_pvt::canpark, sig_pri_span::cc_params, sig_pri_span::cc_ptmp_recall_mode, sig_pri_span::cc_qsig_signaling_link_req, sig_pri_span::cc_qsig_signaling_link_rsp, sig_ss7_chan::channel, sig_pri_chan::channel, analog_pvt::channel, dahdi_pvt::channel, sig_ss7_chan::cic, dahdi_pvt::cid_name, dahdi_pvt::cid_num, dahdi_pvt::cid_rxgain, analog_pvt::cid_signalling, dahdi_pvt::cid_signalling, dahdi_pvt::cid_start, dahdi_pvt::cid_subaddr, dahdi_pvt::cid_tag, dahdi_pvt::cid_ton, sig_pri_span::colp_send, dahdi_pvt::confno, dahdi_pvt::context, sig_pri_span::cpndialplan, dahdi_db, analog_pvt::dahditrcallerid, dahdi_pvt::dahditrcallerid, sig_pri_span::datetime_send, dahdi_pvt::defcontext, dahdi_pvt::description, dahdi_pvt::destroy, dahdi_pvt::dialmode, analog_pvt::dialmode, sig_pri_span::dialplan, dahdi_pvt::dialtone_detect, sig_pri_span::discardremoteholdretrieval, sig_pri_span::display_flags_receive, sig_pri_span::display_flags_send, sig_ss7_chan::dpc, dahdi_pvt::drings, dahdi_pvt::dsp, DSP_DIGITMODE_DTMF, dahdi_pvt::dtmfrelax, dahdi_pvt::echocanbridged, dahdi_pvt::echocancel, dahdi_pvt::echotraining, sig_pri_span::enable_service_message_support, sig_pri_span::facilityenable, dahdi_pvt::faxbuf_no, dahdi_parms_pseudo::faxbuf_no, dahdi_pvt::faxbuf_policy, dahdi_parms_pseudo::faxbuf_policy, dahdi_pvt::faxdetect_timeout, ast_variable::file, dahdi_pvt::firstdigit_timeout, dahdi_pvt::firstradio, sig_pri_span::force_restart_unavailable_chans, get_alarms(), dahdi_pvt::group, dahdi_pvt::hanguponpolarityswitch, sig_ss7_chan::hidecallerid, dahdi_pvt::hidecallerid, sig_pri_chan::hidecalleridname, dahdi_pvt::hidecalleridname, sig_pri_span::hidecalleridname, sig_pri_span::hold_disconnect_transfer, dahdi_pvt::hwrxgain, dahdi_pvt::hwrxgain_enabled, dahdi_pvt::hwtxgain, dahdi_pvt::hwtxgain_enabled, sig_pri_span::idledial, sig_pri_span::idleext, sig_ss7_chan::immediate, sig_pri_chan::immediate, dahdi_pvt::immediate, sig_pri_span::immediate, analog_pvt::immediatering, dahdi_pvt::immediatering, sig_ss7_chan::inalarm, dahdi_pvt::inalarm, sig_pri_span::inband_on_proceeding, sig_pri_span::inband_on_setup_ack, sig_pri_span::inbanddisconnect, sig_pri_span::initial_user_tag, sig_ss7_chan::inservice, dahdi_pvt::inservice, dahdi_pvt::interdigit_timeout, sig_pri_span::internationalprefix, dahdi_chan_conf::is_sig_auto, sig_pri_span::l2_persistence, dahdi_pvt::language, dahdi_pvt::law, dahdi_pvt::law_default, sig_pri_span::layer1_ignored, sig_pri_span::localdialplan, sig_ss7_chan::locallyblocked, dahdi_pvt::locallyblocked, sig_pri_span::localprefix, dahdi_pvt::lock, dahdi_pvt::mailbox, dahdi_pri::mastertrunkgroup, dahdi_pvt::matchdigit_timeout, sig_pri_span::max_call_waiting_calls, sig_pri_span::mcid_send, sig_pri_span::minidle, sig_pri_span::minunused, dahdi_pvt::mohinterpret, dahdi_pvt::mohsuggest, analog_pvt::msgstate, sig_pri_span::msn_list, dahdi_pvt::mwi_event_sub, sig_pri_span::mwi_mailboxes, sig_pri_span::mwi_vm_boxes, sig_pri_span::mwi_vm_numbers, dahdi_pvt::mwimonitor_fsk, dahdi_pvt::mwimonitor_neon, dahdi_pvt::mwimonitor_rpas, dahdi_pvt::mwisend_rpas, dahdi_pvt::mwisend_setting, ast_variable::name, dahdi_pvt::named_callgroups, dahdi_pvt::named_pickupgroups, sig_pri_span::nationalprefix, ast_variable::next, dahdi_pvt::next, sig_pri_span::nodetype, sig_pri_span::nsf, sig_pri_span::numchans, dahdi_pvt::oprmode, dahdi_pvt::outsigmod, sig_pri_span::overlapdial, dahdi_pvt::parkinglot, analog_pvt::permcallwaiting, dahdi_pvt::permcallwaiting, analog_pvt::permhidecallerid, dahdi_pvt::permhidecallerid, dahdi_pvt::pickupgroup, dahdi_pvt::polarityonanswerdelay, sig_pri_chan::priexclusive, dahdi_pvt::priexclusive, sig_pri_span::priexclusive, dahdi_pvt::priindication_oob, dahdi_pri::prilogicalspan, sig_pri_span::privateprefix, dahdi_pvt::propconfno, dahdi_pvt::pulse, sig_pri_span::pvts, sig_pri_span::qsigchannelmapping, dahdi_pvt::radio, sig_ss7_chan::remotelyblocked, dahdi_pvt::remotelyblocked, dahdi_pvt::reoriginate, sig_pri_span::resetinterval, dahdi_pvt::restrictcid, dahdi_pvt::ringt, dahdi_pvt::ringt_base, ringt_base, dahdi_pvt::rxgain, dahdi_pvt::sendcalleridafter, dahdi_pvt::sig, sig_pri_span::sig, SIG_PRI_NUM_DCHANS, analog_pvt::smdi_iface, dahdi_pvt::smdi_iface, dahdi_chan_conf::smdi_port, dahdi_pvt::span, SRVST_DBKEY, SRVST_FAREND, SRVST_NEAREND, stasis_subscription_cb_noop(), sig_ss7_chan::stripmsd, dahdi_pvt::stripmsd, SUB_REAL, dahdi_pvt::subs, sig_pri_span::switchtype, dahdi_pvt::threewaycalling, dahdi_pvt::threewaysilenthold, dahdi_pvt::tonezone, dahdi_pvt::transfer, sig_pri_span::transfer, analog_pvt::transfertobusy, dahdi_pvt::transfertobusy, dahdi_pvt::txdrc, dahdi_pvt::txgain, sig_pri_span::unknownprefix, sig_ss7_chan::use_callerid, sig_pri_chan::use_callerid, analog_pvt::use_callerid, dahdi_pvt::use_callerid, sig_pri_span::use_callerid, sig_ss7_chan::use_callingpres, sig_pri_chan::use_callingpres, dahdi_pvt::use_callingpres, sig_pri_span::use_callingpres, analog_pvt::use_smdi, dahdi_pvt::use_smdi, dahdi_pvt::usedistinctiveringdetection, dahdi_pvt::usefaxbuffers, ast_variable::value, dahdi_pvt::vars, and dahdi_pvt::waitfordialtone.

12494 {
12495  /* Make a dahdi_pvt structure for this interface */
12496  struct dahdi_pvt *tmp;/*!< Current channel structure initializing */
12497  char fn[80];
12498  struct dahdi_bufferinfo bi;
12499 
12500  int res;
12501 #if defined(HAVE_PRI)
12502  int span = 0;
12503 #endif /* defined(HAVE_PRI) */
12504  int here = 0;/*!< TRUE if the channel interface already exists. */
12505  int x;
12506  struct analog_pvt *analog_p = NULL;
12507  struct dahdi_params p;
12508 #if defined(HAVE_PRI)
12509  struct dahdi_spaninfo si;
12510  struct sig_pri_chan *pri_chan = NULL;
12511 #endif /* defined(HAVE_PRI) */
12512 #if defined(HAVE_SS7)
12513  struct sig_ss7_chan *ss7_chan = NULL;
12514 #endif /* defined(HAVE_SS7) */
12515 
12516  /* Search channel interface list to see if it already exists. */
12517  for (tmp = iflist; tmp; tmp = tmp->next) {
12518  if (!tmp->destroy) {
12519  if (tmp->channel == channel) {
12520  /* The channel interface already exists. */
12521  here = 1;
12522  break;
12523  }
12524  if (tmp->channel > channel) {
12525  /* No way it can be in the sorted list. */
12526  tmp = NULL;
12527  break;
12528  }
12529  }
12530  }
12531 
12532  if (!here && reloading != 1) {
12533  tmp = ast_calloc(1, sizeof(*tmp));
12534  if (!tmp) {
12535  return NULL;
12536  }
12537  tmp->cc_params = ast_cc_config_params_init();
12538  if (!tmp->cc_params) {
12539  ast_free(tmp);
12540  return NULL;
12541  }
12542  ast_mutex_init(&tmp->lock);
12543  ifcount++;
12544  for (x = 0; x < 3; x++)
12545  tmp->subs[x].dfd = -1;
12546  tmp->channel = channel;
12547  tmp->priindication_oob = conf->chan.priindication_oob;
12548  }
12549 
12550  if (tmp) {
12551  int chan_sig = conf->chan.sig;
12552 
12553  /* If there are variables in tmp before it is updated to match the new config, clear them */
12554  if (reloading && tmp->vars) {
12556  tmp->vars = NULL;
12557  }
12558 
12559  if (!here) {
12560  /* Can only get here if this is a new channel interface being created. */
12561  if ((channel != CHAN_PSEUDO)) {
12562  int count = 0;
12563 
12564  snprintf(fn, sizeof(fn), "%d", channel);
12565  /* Open non-blocking */
12566  tmp->subs[SUB_REAL].dfd = dahdi_open(fn);
12567  /* Retry open on restarts, but don't keep retrying if the channel doesn't exist (e.g. not configured) */
12568  while (tmp->subs[SUB_REAL].dfd < 0 && reloading == 2 && count < 1000 && errno != ENXIO) { /* the kernel may not call dahdi_release fast enough for the open flagbit to be cleared in time */
12569  usleep(1);
12570  tmp->subs[SUB_REAL].dfd = dahdi_open(fn);
12571  count++;
12572  }
12573  /* Allocate a DAHDI structure */
12574  if (tmp->subs[SUB_REAL].dfd < 0) {
12575  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);
12576  destroy_dahdi_pvt(tmp);
12577  return NULL;
12578  }
12579  memset(&p, 0, sizeof(p));
12580  res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &p);
12581  if (res < 0) {
12582  ast_log(LOG_ERROR, "Unable to get parameters: %s\n", strerror(errno));
12583  destroy_dahdi_pvt(tmp);
12584  return NULL;
12585  }
12586  if (conf->is_sig_auto)
12587  chan_sig = sigtype_to_signalling(p.sigtype);
12588  if (p.sigtype != (chan_sig & 0x3ffff)) {
12589  ast_log(LOG_ERROR, "Signalling requested on channel %d is %s but line is in %s signalling\n", channel, sig2str(chan_sig), sig2str(p.sigtype));
12590  destroy_dahdi_pvt(tmp);
12591  return NULL;
12592  }
12593  tmp->law_default = p.curlaw;
12594  tmp->law = p.curlaw;
12595  tmp->span = p.spanno;
12596 #if defined(HAVE_PRI)
12597  span = p.spanno - 1;
12598 #endif /* defined(HAVE_PRI) */
12599  } else {
12600  chan_sig = 0;
12601  }
12602  tmp->sig = chan_sig;
12603  tmp->outsigmod = conf->chan.outsigmod;
12604 
12605  if (dahdi_analog_lib_handles(chan_sig, tmp->radio, tmp->oprmode)) {
12606  analog_p = analog_new(dahdisig_to_analogsig(chan_sig), tmp);
12607  if (!analog_p) {
12608  destroy_dahdi_pvt(tmp);
12609  return NULL;
12610  }
12611  tmp->sig_pvt = analog_p;
12612  }
12613 #if defined(HAVE_SS7)
12614  if (chan_sig == SIG_SS7) {
12615  struct dahdi_ss7 *ss7;
12616  int clear = 0;
12617 
12618  if (ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &clear)) {
12619  ast_log(LOG_ERROR, "Unable to set clear mode on clear channel %d of span %d: %s\n", channel, p.spanno, strerror(errno));
12620  destroy_dahdi_pvt(tmp);
12621  return NULL;
12622  }
12623 
12624  ss7 = ss7_resolve_linkset(cur_linkset);
12625  if (!ss7) {
12626  ast_log(LOG_ERROR, "Unable to find linkset %d\n", cur_linkset);
12627  destroy_dahdi_pvt(tmp);
12628  return NULL;
12629  }
12630  ss7->ss7.span = cur_linkset;
12631  if (cur_cicbeginswith < 0) {
12632  ast_log(LOG_ERROR, "Need to set cicbeginswith for the channels!\n");
12633  destroy_dahdi_pvt(tmp);
12634  return NULL;
12635  }
12636  ss7_chan = sig_ss7_chan_new(tmp, &ss7->ss7);
12637  if (!ss7_chan) {
12638  destroy_dahdi_pvt(tmp);
12639  return NULL;
12640  }
12641  tmp->sig_pvt = ss7_chan;
12642  tmp->ss7 = &ss7->ss7;
12643 
12644  ss7_chan->channel = tmp->channel;
12645  ss7_chan->cic = cur_cicbeginswith++;
12646 
12647  /* DB: Add CIC's DPC information */
12648  ss7_chan->dpc = cur_defaultdpc;
12649 
12650  ss7->ss7.pvts[ss7->ss7.numchans++] = ss7_chan;
12651 
12652  ast_copy_string(ss7->ss7.internationalprefix, conf->ss7.ss7.internationalprefix, sizeof(ss7->ss7.internationalprefix));
12653  ast_copy_string(ss7->ss7.nationalprefix, conf->ss7.ss7.nationalprefix, sizeof(ss7->ss7.nationalprefix));
12654  ast_copy_string(ss7->ss7.subscriberprefix, conf->ss7.ss7.subscriberprefix, sizeof(ss7->ss7.subscriberprefix));
12655  ast_copy_string(ss7->ss7.unknownprefix, conf->ss7.ss7.unknownprefix, sizeof(ss7->ss7.unknownprefix));
12656  ast_copy_string(ss7->ss7.networkroutedprefix, conf->ss7.ss7.networkroutedprefix, sizeof(ss7->ss7.networkroutedprefix));
12657 
12658  ss7->ss7.called_nai = conf->ss7.ss7.called_nai;
12659  ss7->ss7.calling_nai = conf->ss7.ss7.calling_nai;
12660  }
12661 #endif /* defined(HAVE_SS7) */
12662 #ifdef HAVE_OPENR2
12663  if (chan_sig == SIG_MFCR2) {
12664  struct dahdi_mfcr2 *r2_link;
12665  struct r2link_entry *r2_le = dahdi_r2_get_link(conf);
12666  r2_link = &r2_le->mfcr2;
12667  if (!r2_link) {
12668  ast_log(LOG_WARNING, "Cannot get another R2 DAHDI context!\n");
12669  destroy_dahdi_pvt(tmp);
12670  return NULL;
12671  }
12672  if (!r2_link->protocol_context && dahdi_r2_set_context(r2_link, conf)) {
12673  ast_log(LOG_ERROR, "Cannot create OpenR2 protocol context.\n");
12674  destroy_dahdi_pvt(tmp);
12675  return NULL;
12676  }
12677  if (r2_link->numchans == ARRAY_LEN(r2_link->pvts)) {
12678  ast_log(LOG_ERROR, "Cannot add more channels to this link!\n");
12679  destroy_dahdi_pvt(tmp);
12680  return NULL;
12681  }
12682  r2_link->pvts[r2_link->numchans++] = tmp;
12683  tmp->r2chan = openr2_chan_new_from_fd(r2_link->protocol_context,
12684  tmp->subs[SUB_REAL].dfd,
12685  NULL, NULL);
12686  if (!tmp->r2chan) {
12687  openr2_liberr_t err = openr2_context_get_last_error(r2_link->protocol_context);
12688  ast_log(LOG_ERROR, "Cannot create OpenR2 channel: %s\n", openr2_context_error_string(err));
12689  destroy_dahdi_pvt(tmp);
12690  return NULL;
12691  }
12692  r2_link->live_chans++;
12693  tmp->mfcr2 = r2_link;
12694  if (conf->mfcr2.call_files) {
12695  openr2_chan_enable_call_files(tmp->r2chan);
12696  }
12697  openr2_chan_set_client_data(tmp->r2chan, tmp);
12698  /* cast seems to be needed to get rid of the annoying warning regarding format attribute */
12699  openr2_chan_set_logging_func(tmp->r2chan, (openr2_logging_func_t)dahdi_r2_on_chan_log);
12700  openr2_chan_set_log_level(tmp->r2chan, conf->mfcr2.loglevel);
12701  tmp->mfcr2_category = conf->mfcr2.category;
12702  tmp->mfcr2_charge_calls = conf->mfcr2.charge_calls;
12703  tmp->mfcr2_allow_collect_calls = conf->mfcr2.allow_collect_calls;
12704  tmp->mfcr2_forced_release = conf->mfcr2.forced_release;
12705  tmp->mfcr2_accept_on_offer = conf->mfcr2.accept_on_offer;
12706  tmp->mfcr2call = 0;
12707  tmp->mfcr2_dnis_index = 0;
12708  tmp->mfcr2_ani_index = 0;
12709  }
12710 #endif
12711 #ifdef HAVE_PRI
12712  if (dahdi_sig_pri_lib_handles(chan_sig)) {
12713  int offset;
12714  int matchesdchan;
12715  int x,y;
12716  int myswitchtype = 0;
12717 
12718  offset = 0;
12719  if (ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &offset)) {
12720  ast_log(LOG_ERROR, "Unable to set clear mode on clear channel %d of span %d: %s\n", channel, p.spanno, strerror(errno));
12721  destroy_dahdi_pvt(tmp);
12722  return NULL;
12723  }
12724  if (span >= NUM_SPANS) {
12725  ast_log(LOG_ERROR, "Channel %d does not lie on a span I know of (%d)\n", channel, span);
12726  destroy_dahdi_pvt(tmp);
12727  return NULL;
12728  } else {
12729  si.spanno = 0;
12730  if (ioctl(tmp->subs[SUB_REAL].dfd,DAHDI_SPANSTAT,&si) == -1) {
12731  ast_log(LOG_ERROR, "Unable to get span status: %s\n", strerror(errno));
12732  destroy_dahdi_pvt(tmp);
12733  return NULL;
12734  }
12735  /* Store the logical span first based upon the real span */
12736  tmp->logicalspan = pris[span].prilogicalspan;
12737  pri_resolve_span(&span, channel, (channel - p.chanpos), &si);
12738  if (span < 0) {
12739  ast_log(LOG_WARNING, "Channel %d: Unable to find locate channel/trunk group!\n", channel);
12740  destroy_dahdi_pvt(tmp);
12741  return NULL;
12742  }
12743  myswitchtype = conf->pri.pri.switchtype;
12744  /* Make sure this isn't a d-channel */
12745  matchesdchan=0;
12746  for (x = 0; x < NUM_SPANS; x++) {
12747  for (y = 0; y < SIG_PRI_NUM_DCHANS; y++) {
12748  if (pris[x].dchannels[y] == tmp->channel) {
12749  matchesdchan = 1;
12750  break;
12751  }
12752  }
12753  }
12754  if (!matchesdchan) {
12755  if (pris[span].pri.nodetype && (pris[span].pri.nodetype != conf->pri.pri.nodetype)) {
12756  ast_log(LOG_ERROR, "Span %d is already a %s node\n", span + 1, pri_node2str(pris[span].pri.nodetype));
12757  destroy_dahdi_pvt(tmp);
12758  return NULL;
12759  }
12760  if (pris[span].pri.switchtype && (pris[span].pri.switchtype != myswitchtype)) {
12761  ast_log(LOG_ERROR, "Span %d is already a %s switch\n", span + 1, pri_switch2str(pris[span].pri.switchtype));
12762  destroy_dahdi_pvt(tmp);
12763  return NULL;
12764  }
12765  if ((pris[span].pri.dialplan) && (pris[span].pri.dialplan != conf->pri.pri.dialplan)) {
12766  ast_log(LOG_ERROR, "Span %d is already a %s dialing plan\n", span + 1, pris[span].pri.dialplan == -1 ? "Dynamically set dialplan in ISDN" : pri_plan2str(pris[span].pri.dialplan));
12767  destroy_dahdi_pvt(tmp);
12768  return NULL;
12769  }
12770  if (!ast_strlen_zero(pris[span].pri.idledial) && strcmp(pris[span].pri.idledial, conf->pri.pri.idledial)) {
12771  ast_log(LOG_ERROR, "Span %d already has idledial '%s'.\n", span + 1, conf->pri.pri.idledial);
12772  destroy_dahdi_pvt(tmp);
12773  return NULL;
12774  }
12775  if (!ast_strlen_zero(pris[span].pri.idleext) && strcmp(pris[span].pri.idleext, conf->pri.pri.idleext)) {
12776  ast_log(LOG_ERROR, "Span %d already has idleext '%s'.\n", span + 1, conf->pri.pri.idleext);
12777  destroy_dahdi_pvt(tmp);
12778  return NULL;
12779  }
12780  if (pris[span].pri.minunused && (pris[span].pri.minunused != conf->pri.pri.minunused)) {
12781  ast_log(LOG_ERROR, "Span %d already has minunused of %d.\n", span + 1, conf->pri.pri.minunused);
12782  destroy_dahdi_pvt(tmp);
12783  return NULL;
12784  }
12785  if (pris[span].pri.minidle && (pris[span].pri.minidle != conf->pri.pri.minidle)) {
12786  ast_log(LOG_ERROR, "Span %d already has minidle of %d.\n", span + 1, conf->pri.pri.minidle);
12787  destroy_dahdi_pvt(tmp);
12788  return NULL;
12789  }
12790  if (pris[span].pri.numchans >= ARRAY_LEN(pris[span].pri.pvts)) {
12791  ast_log(LOG_ERROR, "Unable to add channel %d: Too many channels in trunk group %d!\n", channel,
12792  pris[span].pri.trunkgroup);
12793  destroy_dahdi_pvt(tmp);
12794  return NULL;
12795  }
12796 
12797  pri_chan = sig_pri_chan_new(tmp, &pris[span].pri, tmp->logicalspan, p.chanpos, pris[span].mastertrunkgroup);
12798  if (!pri_chan) {
12799  destroy_dahdi_pvt(tmp);
12800  return NULL;
12801  }
12802  tmp->sig_pvt = pri_chan;
12803  tmp->pri = &pris[span].pri;
12804 
12805  tmp->priexclusive = conf->chan.priexclusive;
12806 
12807  if (!tmp->pri->cc_params) {
12808  tmp->pri->cc_params = ast_cc_config_params_init();
12809  if (!tmp->pri->cc_params) {
12810  destroy_dahdi_pvt(tmp);
12811  return NULL;
12812  }
12813  }
12815  conf->chan.cc_params);
12816 
12817  pris[span].pri.sig = chan_sig;
12818  pris[span].pri.nodetype = conf->pri.pri.nodetype;
12819  pris[span].pri.switchtype = myswitchtype;
12820  pris[span].pri.nsf = conf->pri.pri.nsf;
12821  pris[span].pri.dialplan = conf->pri.pri.dialplan;
12822  pris[span].pri.localdialplan = conf->pri.pri.localdialplan;
12823  pris[span].pri.cpndialplan = conf->pri.pri.cpndialplan;
12824  pris[span].pri.pvts[pris[span].pri.numchans++] = tmp->sig_pvt;
12825  pris[span].pri.minunused = conf->pri.pri.minunused;
12826  pris[span].pri.minidle = conf->pri.pri.minidle;
12827  pris[span].pri.overlapdial = conf->pri.pri.overlapdial;
12828  pris[span].pri.qsigchannelmapping = conf->pri.pri.qsigchannelmapping;
12829  pris[span].pri.discardremoteholdretrieval = conf->pri.pri.discardremoteholdretrieval;
12830 #if defined(HAVE_PRI_SERVICE_MESSAGES)
12831  pris[span].pri.enable_service_message_support = conf->pri.pri.enable_service_message_support;
12832 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
12833 #ifdef HAVE_PRI_INBANDDISCONNECT
12834  pris[span].pri.inbanddisconnect = conf->pri.pri.inbanddisconnect;
12835 #endif
12836 #if defined(HAVE_PRI_CALL_HOLD)
12837  pris[span].pri.hold_disconnect_transfer =
12838  conf->pri.pri.hold_disconnect_transfer;
12839 #endif /* defined(HAVE_PRI_CALL_HOLD) */
12840 #if defined(HAVE_PRI_CCSS)
12841  pris[span].pri.cc_ptmp_recall_mode =
12842  conf->pri.pri.cc_ptmp_recall_mode;
12843  pris[span].pri.cc_qsig_signaling_link_req =
12844  conf->pri.pri.cc_qsig_signaling_link_req;
12845  pris[span].pri.cc_qsig_signaling_link_rsp =
12846  conf->pri.pri.cc_qsig_signaling_link_rsp;
12847 #endif /* defined(HAVE_PRI_CCSS) */
12848 #if defined(HAVE_PRI_CALL_WAITING)
12849  pris[span].pri.max_call_waiting_calls =
12850  conf->pri.pri.max_call_waiting_calls;
12851  pris[span].pri.allow_call_waiting_calls =
12852  conf->pri.pri.allow_call_waiting_calls;
12853 #endif /* defined(HAVE_PRI_CALL_WAITING) */
12854  pris[span].pri.transfer = conf->chan.transfer;
12855  pris[span].pri.facilityenable = conf->pri.pri.facilityenable;
12856 #if defined(HAVE_PRI_L2_PERSISTENCE)
12857  pris[span].pri.l2_persistence = conf->pri.pri.l2_persistence;
12858 #endif /* defined(HAVE_PRI_L2_PERSISTENCE) */
12859  pris[span].pri.colp_send = conf->pri.pri.colp_send;
12860 #if defined(HAVE_PRI_AOC_EVENTS)
12861  pris[span].pri.aoc_passthrough_flag = conf->pri.pri.aoc_passthrough_flag;
12862  pris[span].pri.aoce_delayhangup = conf->pri.pri.aoce_delayhangup;
12863 #endif /* defined(HAVE_PRI_AOC_EVENTS) */
12864  if (chan_sig == SIG_BRI_PTMP) {
12865  pris[span].pri.layer1_ignored = conf->pri.pri.layer1_ignored;
12866  } else {
12867  /* Option does not apply to this line type. */
12868  pris[span].pri.layer1_ignored = 0;
12869  }
12870  pris[span].pri.append_msn_to_user_tag = conf->pri.pri.append_msn_to_user_tag;
12871  pris[span].pri.inband_on_setup_ack = conf->pri.pri.inband_on_setup_ack;
12872  pris[span].pri.inband_on_proceeding = conf->pri.pri.inband_on_proceeding;
12873  ast_copy_string(pris[span].pri.initial_user_tag, conf->chan.cid_tag, sizeof(pris[span].pri.initial_user_tag));
12874  ast_copy_string(pris[span].pri.msn_list, conf->pri.pri.msn_list, sizeof(pris[span].pri.msn_list));
12875 #if defined(HAVE_PRI_MWI)
12876  ast_copy_string(pris[span].pri.mwi_mailboxes,
12877  conf->pri.pri.mwi_mailboxes,
12878  sizeof(pris[span].pri.mwi_mailboxes));
12879  ast_copy_string(pris[span].pri.mwi_vm_boxes,
12880  conf->pri.pri.mwi_vm_boxes,
12881  sizeof(pris[span].pri.mwi_vm_boxes));
12882  ast_copy_string(pris[span].pri.mwi_vm_numbers,
12883  conf->pri.pri.mwi_vm_numbers,
12884  sizeof(pris[span].pri.mwi_vm_numbers));
12885 #endif /* defined(HAVE_PRI_MWI) */
12886  ast_copy_string(pris[span].pri.idledial, conf->pri.pri.idledial, sizeof(pris[span].pri.idledial));
12887  ast_copy_string(pris[span].pri.idleext, conf->pri.pri.idleext, sizeof(pris[span].pri.idleext));
12888  ast_copy_string(pris[span].pri.internationalprefix, conf->pri.pri.internationalprefix, sizeof(pris[span].pri.internationalprefix));
12889  ast_copy_string(pris[span].pri.nationalprefix, conf->pri.pri.nationalprefix, sizeof(pris[span].pri.nationalprefix));
12890  ast_copy_string(pris[span].pri.localprefix, conf->pri.pri.localprefix, sizeof(pris[span].pri.localprefix));
12891  ast_copy_string(pris[span].pri.privateprefix, conf->pri.pri.privateprefix, sizeof(pris[span].pri.privateprefix));
12892  ast_copy_string(pris[span].pri.unknownprefix, conf->pri.pri.unknownprefix, sizeof(pris[span].pri.unknownprefix));
12893  pris[span].pri.moh_signaling = conf->pri.pri.moh_signaling;
12894  pris[span].pri.resetinterval = conf->pri.pri.resetinterval;
12895 #if defined(HAVE_PRI_DISPLAY_TEXT)
12896  pris[span].pri.display_flags_send = conf->pri.pri.display_flags_send;
12897  pris[span].pri.display_flags_receive = conf->pri.pri.display_flags_receive;
12898 #endif /* defined(HAVE_PRI_DISPLAY_TEXT) */
12899 #if defined(HAVE_PRI_MCID)
12900  pris[span].pri.mcid_send = conf->pri.pri.mcid_send;
12901 #endif /* defined(HAVE_PRI_MCID) */
12903 #if defined(HAVE_PRI_DATETIME_SEND)
12904  pris[span].pri.datetime_send = conf->pri.pri.datetime_send;
12905 #endif /* defined(HAVE_PRI_DATETIME_SEND) */
12906 
12907  for (x = 0; x < PRI_MAX_TIMERS; x++) {
12908  pris[span].pri.pritimers[x] = conf->pri.pri.pritimers[x];
12909  }
12910 
12911 #if defined(HAVE_PRI_CALL_WAITING)
12912  /* Channel initial config parameters. */
12913  pris[span].pri.ch_cfg.stripmsd = conf->chan.stripmsd;
12914  pris[span].pri.ch_cfg.hidecallerid = conf->chan.hidecallerid;
12915  pris[span].pri.ch_cfg.hidecalleridname = conf->chan.hidecalleridname;
12916  pris[span].pri.ch_cfg.immediate = conf->chan.immediate;
12917  pris[span].pri.ch_cfg.priexclusive = conf->chan.priexclusive;
12918  pris[span].pri.ch_cfg.priindication_oob = conf->chan.priindication_oob;
12919  pris[span].pri.ch_cfg.use_callerid = conf->chan.use_callerid;
12920  pris[span].pri.ch_cfg.use_callingpres = conf->chan.use_callingpres;
12921  ast_copy_string(pris[span].pri.ch_cfg.context, conf->chan.context, sizeof(pris[span].pri.ch_cfg.context));
12922  ast_copy_string(pris[span].pri.ch_cfg.mohinterpret, conf->chan.mohinterpret, sizeof(pris[span].pri.ch_cfg.mohinterpret));
12923 #endif /* defined(HAVE_PRI_CALL_WAITING) */
12924  } else {
12925  ast_log(LOG_ERROR, "Channel %d is reserved for D-channel.\n", p.chanpos);
12926  destroy_dahdi_pvt(tmp);
12927  return NULL;
12928  }
12929  }
12930  }
12931 #endif
12932  } else {
12933  /* already exists in interface list */
12934  ast_log(LOG_WARNING, "Attempt to configure channel %d with signaling %s ignored because it is already configured to be %s.\n", tmp->channel, dahdi_sig2str(chan_sig), dahdi_sig2str(tmp->sig));
12935  chan_sig = tmp->sig;
12936  if (tmp->subs[SUB_REAL].dfd > -1) {
12937  memset(&p, 0, sizeof(p));
12938  res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &p);
12939  }
12940  }
12941  /* Adjust starttime on loopstart and kewlstart trunks to reasonable values */
12942  switch (chan_sig) {
12943  case SIG_FXSKS:
12944  case SIG_FXSLS:
12945  case SIG_EM:
12946  case SIG_EM_E1:
12947  case SIG_EMWINK:
12948  case SIG_FEATD:
12949  case SIG_FEATDMF:
12950  case SIG_FEATDMF_TA:
12951  case SIG_FEATB:
12952  case SIG_E911:
12953  case SIG_SF:
12954  case SIG_SFWINK:
12955  case SIG_FGC_CAMA:
12956  case SIG_FGC_CAMAMF:
12957  case SIG_SF_FEATD:
12958  case SIG_SF_FEATDMF:
12959  case SIG_SF_FEATB:
12960  p.starttime = 250;
12961  break;
12962  }
12963 
12964  if (tmp->radio) {
12965  /* XXX Waiting to hear back from Jim if these should be adjustable XXX */
12966  p.channo = channel;
12967  p.rxwinktime = 1;
12968  p.rxflashtime = 1;
12969  p.starttime = 1;
12970  p.debouncetime = 5;
12971  } else {
12972  p.channo = channel;
12973  /* Override timing settings based on config file */
12974  if (conf->timing.prewinktime >= 0)
12975  p.prewinktime = conf->timing.prewinktime;
12976  if (conf->timing.preflashtime >= 0)
12977  p.preflashtime = conf->timing.preflashtime;
12978  if (conf->timing.winktime >= 0)
12979  p.winktime = conf->timing.winktime;
12980  if (conf->timing.flashtime >= 0)
12981  p.flashtime = conf->timing.flashtime;
12982  if (conf->timing.starttime >= 0)
12983  p.starttime = conf->timing.starttime;
12984  if (conf->timing.rxwinktime >= 0)
12985  p.rxwinktime = conf->timing.rxwinktime;
12986  if (conf->timing.rxflashtime >= 0)
12987  p.rxflashtime = conf->timing.rxflashtime;
12988  if (conf->timing.debouncetime >= 0)
12989  p.debouncetime = conf->timing.debouncetime;
12990  }
12991 
12992  /* don't set parms on a pseudo-channel */
12993  if (tmp->subs[SUB_REAL].dfd >= 0)
12994  {
12995  res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_SET_PARAMS, &p);
12996  if (res < 0) {
12997  ast_log(LOG_ERROR, "Unable to set parameters: %s\n", strerror(errno));
12998  destroy_dahdi_pvt(tmp);
12999  return NULL;
13000  }
13001  }
13002 #if 1
13003  if (!here && (tmp->subs[SUB_REAL].dfd > -1)) {
13004  memset(&bi, 0, sizeof(bi));
13005  res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_BUFINFO, &bi);
13006  if (!res) {
13007  bi.txbufpolicy = conf->chan.buf_policy;
13008  bi.rxbufpolicy = conf->chan.buf_policy;
13009  bi.numbufs = conf->chan.buf_no;
13010  res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_SET_BUFINFO, &bi);
13011  if (res < 0) {
13012  ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d: %s\n", channel, strerror(errno));
13013  }
13014  } else {
13015  ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d: %s\n", channel, strerror(errno));
13016  }
13017  tmp->buf_policy = conf->chan.buf_policy;
13018  tmp->buf_no = conf->chan.buf_no;
13019  tmp->usefaxbuffers = conf->chan.usefaxbuffers;
13020  tmp->faxbuf_policy = conf->chan.faxbuf_policy;
13021  tmp->faxbuf_no = conf->chan.faxbuf_no;
13022  /* This is not as gnarly as it may first appear. If the ioctl above failed, we'd be setting
13023  * tmp->bufsize to zero which would cause subsequent faxbuffer-related ioctl calls to fail.
13024  * The reason the ioctl call above failed should to be determined before worrying about the
13025  * faxbuffer-related ioctl calls */
13026  tmp->bufsize = bi.bufsize;
13027  }
13028 #endif
13029  tmp->immediate = conf->chan.immediate;
13030  tmp->immediatering = conf->chan.immediatering;
13031  tmp->transfertobusy = conf->chan.transfertobusy;
13032  tmp->dialmode = conf->chan.dialmode;
13033  if (chan_sig & __DAHDI_SIG_FXS) {
13034  tmp->mwimonitor_fsk = conf->chan.mwimonitor_fsk;
13035  tmp->mwimonitor_neon = conf->chan.mwimonitor_neon;
13036  tmp->mwimonitor_rpas = conf->chan.mwimonitor_rpas;
13037  }
13038  tmp->ringt_base = ringt_base;
13039  tmp->firstradio = 0;
13040  if ((chan_sig == SIG_FXOKS) || (chan_sig == SIG_FXOLS) || (chan_sig == SIG_FXOGS))
13041  tmp->permcallwaiting = conf->chan.callwaiting;
13042  else
13043  tmp->permcallwaiting = 0;
13044  /* Flag to destroy the channel must be cleared on new mkif. Part of changes for reload to work */
13045  tmp->destroy = 0;
13046  tmp->drings = conf->chan.drings;
13047 
13048  /* 10 is a nice default. */
13049  if (tmp->drings.ringnum[0].range == 0)
13050  tmp->drings.ringnum[0].range = 10;
13051  if (tmp->drings.ringnum[1].range == 0)
13052  tmp->drings.ringnum[1].range = 10;
13053  if (tmp->drings.ringnum[2].range == 0)
13054  tmp->drings.ringnum[2].range = 10;
13055 
13056  tmp->usedistinctiveringdetection = usedistinctiveringdetection;
13057  tmp->callwaitingcallerid = conf->chan.callwaitingcallerid;
13058  tmp->threewaycalling = conf->chan.threewaycalling;
13059  tmp->threewaysilenthold = conf->chan.threewaysilenthold;
13060  tmp->calledsubscriberheld = conf->chan.calledsubscriberheld; /* Not used in chan_dahdi.c, just analog pvt, but must exist on the DAHDI pvt anyways */
13061  tmp->adsi = conf->chan.adsi;
13062  tmp->use_smdi = conf->chan.use_smdi;
13063  tmp->permhidecallerid = conf->chan.hidecallerid;
13064  tmp->hidecalleridname = conf->chan.hidecalleridname;
13065  tmp->callreturn = conf->chan.callreturn;
13066  tmp->echocancel = conf->chan.echocancel;
13067  tmp->echotraining = conf->chan.echotraining;
13068  tmp->pulse = conf->chan.pulse;
13069  if (tmp->echocancel.head.tap_length) {
13070  tmp->echocanbridged = conf->chan.echocanbridged;
13071  } else {
13072  if (conf->chan.echocanbridged)
13073  ast_log(LOG_NOTICE, "echocancelwhenbridged requires echocancel to be enabled; ignoring\n");
13074  tmp->echocanbridged = 0;
13075  }
13076  tmp->busydetect = conf->chan.busydetect;
13077  tmp->busycount = conf->chan.busycount;
13078  tmp->busy_cadence = conf->chan.busy_cadence;
13079  tmp->callprogress = conf->chan.callprogress;
13080  tmp->waitfordialtone = conf->chan.waitfordialtone;
13081  tmp->dialtone_detect = conf->chan.dialtone_detect;
13082  tmp->faxdetect_timeout = conf->chan.faxdetect_timeout;
13083  tmp->firstdigit_timeout = conf->chan.firstdigit_timeout;
13084  tmp->interdigit_timeout = conf->chan.interdigit_timeout;
13085  tmp->matchdigit_timeout = conf->chan.matchdigit_timeout;
13086  tmp->cancallforward = conf->chan.cancallforward;
13087  tmp->dtmfrelax = conf->chan.dtmfrelax;
13088  tmp->callwaiting = tmp->permcallwaiting;
13089  tmp->hidecallerid = tmp->permhidecallerid;
13090  tmp->channel = channel;
13091  tmp->stripmsd = conf->chan.stripmsd;
13092  tmp->use_callerid = conf->chan.use_callerid;
13093  tmp->cid_signalling = conf->chan.cid_signalling;
13094  tmp->cid_start = conf->chan.cid_start;
13095  tmp->dahditrcallerid = conf->chan.dahditrcallerid;
13096  tmp->restrictcid = conf->chan.restrictcid;
13097  tmp->use_callingpres = conf->chan.use_callingpres;
13098  if (tmp->usedistinctiveringdetection) {
13099  if (!tmp->use_callerid) {
13100  ast_log(LOG_NOTICE, "Distinctive Ring detect requires 'usecallerid' be on\n");
13101  tmp->use_callerid = 1;
13102  }
13103  }
13104 
13105  if (tmp->cid_signalling == CID_SIG_SMDI) {
13106  if (!tmp->use_smdi) {
13107  ast_log(LOG_WARNING, "SMDI callerid requires SMDI to be enabled, enabling...\n");
13108  tmp->use_smdi = 1;
13109  }
13110  }
13111  if (tmp->use_smdi) {
13113  if (!(tmp->smdi_iface)) {
13114  ast_log(LOG_ERROR, "Invalid SMDI port specfied, disabling SMDI support\n");
13115  tmp->use_smdi = 0;
13116  }
13117  }
13118 
13119  ast_copy_string(tmp->accountcode, conf->chan.accountcode, sizeof(tmp->accountcode));
13120  tmp->amaflags = conf->chan.amaflags;
13121  if (!here) {
13122  tmp->confno = -1;
13123  tmp->propconfno = -1;
13124  }
13125  tmp->canpark = conf->chan.canpark;
13126  tmp->transfer = conf->chan.transfer;
13127  ast_copy_string(tmp->defcontext,conf->chan.context,sizeof(tmp->defcontext));
13128  ast_copy_string(tmp->language, conf->chan.language, sizeof(tmp->language));
13129  ast_copy_string(tmp->mohinterpret, conf->chan.mohinterpret, sizeof(tmp->mohinterpret));
13130  ast_copy_string(tmp->mohsuggest, conf->chan.mohsuggest, sizeof(tmp->mohsuggest));
13131  ast_copy_string(tmp->context, conf->chan.context, sizeof(tmp->context));
13132  ast_copy_string(tmp->description, conf->chan.description, sizeof(tmp->description));
13133  ast_copy_string(tmp->parkinglot, conf->chan.parkinglot, sizeof(tmp->parkinglot));
13134  tmp->cid_ton = 0;
13135  if (dahdi_analog_lib_handles(tmp->sig, tmp->radio, tmp->oprmode)) {
13136  ast_copy_string(tmp->cid_num, conf->chan.cid_num, sizeof(tmp->cid_num));
13137  ast_copy_string(tmp->cid_name, conf->chan.cid_name, sizeof(tmp->cid_name));
13138  } else {
13139  tmp->cid_num[0] = '\0';
13140  tmp->cid_name[0] = '\0';
13141  }
13142 #if defined(HAVE_PRI)
13143  if (dahdi_sig_pri_lib_handles(tmp->sig)) {
13144  tmp->cid_tag[0] = '\0';
13145  } else
13146 #endif /* defined(HAVE_PRI) */
13147  {
13148  ast_copy_string(tmp->cid_tag, conf->chan.cid_tag, sizeof(tmp->cid_tag));
13149  }
13150  tmp->cid_subaddr[0] = '\0';
13151  ast_copy_string(tmp->mailbox, conf->chan.mailbox, sizeof(tmp->mailbox));
13152  if (channel != CHAN_PSEUDO && !ast_strlen_zero(tmp->mailbox)) {
13153  /* This module does not handle MWI in an event-based manner. However, it
13154  * subscribes to MWI for each mailbox that is configured so that the core
13155  * knows that we care about it. Then, chan_dahdi will get the MWI from the
13156  * event cache instead of checking the mailbox directly. */
13158  }
13159 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI
13160  tmp->mwisend_setting = conf->chan.mwisend_setting;
13161  tmp->mwisend_fsk = conf->chan.mwisend_fsk;
13162  tmp->mwisend_rpas = conf->chan.mwisend_rpas;
13163 #endif
13164 
13165  tmp->group = conf->chan.group;
13166  tmp->callgroup = conf->chan.callgroup;
13167  tmp->pickupgroup= conf->chan.pickupgroup;
13168  ast_unref_namedgroups(tmp->named_callgroups);
13169  tmp->named_callgroups = ast_ref_namedgroups(conf->chan.named_callgroups);
13170  ast_unref_namedgroups(tmp->named_pickupgroups);
13171  tmp->named_pickupgroups = ast_ref_namedgroups(conf->chan.named_pickupgroups);
13172  if (conf->chan.vars) {
13173  struct ast_variable *v, *tmpvar;
13174  for (v = conf->chan.vars ; v ; v = v->next) {
13175  if ((tmpvar = ast_variable_new(v->name, v->value, v->file))) {
13176  if (ast_variable_list_replace(&tmp->vars, tmpvar)) {
13177  tmpvar->next = tmp->vars;
13178  tmp->vars = tmpvar;
13179  }
13180  }
13181  }
13182  }
13183  tmp->hwrxgain_enabled = conf->chan.hwrxgain_enabled;
13184  tmp->hwtxgain_enabled = conf->chan.hwtxgain_enabled;
13185  tmp->hwrxgain = conf->chan.hwrxgain;
13186  tmp->hwtxgain = conf->chan.hwtxgain;
13187  tmp->cid_rxgain = conf->chan.cid_rxgain;
13188  tmp->rxgain = conf->chan.rxgain;
13189  tmp->txgain = conf->chan.txgain;
13190  tmp->txdrc = conf->chan.txdrc;
13191  tmp->rxdrc = conf->chan.rxdrc;
13192  tmp->tonezone = conf->chan.tonezone;
13193  if (tmp->subs[SUB_REAL].dfd > -1) {
13194  if (tmp->hwrxgain_enabled) {
13195  tmp->hwrxgain_enabled = !set_hwgain(tmp->subs[SUB_REAL].dfd, tmp->hwrxgain, 0);
13196  }
13197  if (tmp->hwtxgain_enabled) {
13198  tmp->hwtxgain_enabled = !set_hwgain(tmp->subs[SUB_REAL].dfd, tmp->hwtxgain, 1);
13199  }
13200  set_actual_gain(tmp->subs[SUB_REAL].dfd, tmp->rxgain, tmp->txgain, tmp->rxdrc, tmp->txdrc, tmp->law);
13201  if (tmp->dsp)
13203  dahdi_conf_update(tmp);
13204  if (!here) {
13205  switch (chan_sig) {
13206  case SIG_PRI_LIB_HANDLE_CASES:
13207  case SIG_SS7:
13208  case SIG_MFCR2:
13209  break;
13210  default:
13211  /* Hang it up to be sure it's good */
13212  dahdi_set_hook(tmp->subs[SUB_REAL].dfd, DAHDI_ONHOOK);
13213  break;
13214  }
13215  }
13216  ioctl(tmp->subs[SUB_REAL].dfd,DAHDI_SETTONEZONE,&tmp->tonezone);
13217  if ((res = get_alarms(tmp)) != DAHDI_ALARM_NONE) {
13218  /* the dchannel is down so put the channel in alarm */
13219  switch (tmp->sig) {
13220 #ifdef HAVE_PRI
13221  case SIG_PRI_LIB_HANDLE_CASES:
13222  sig_pri_set_alarm(tmp->sig_pvt, 1);
13223  break;
13224 #endif
13225 #if defined(HAVE_SS7)
13226  case SIG_SS7:
13227  sig_ss7_set_alarm(tmp->sig_pvt, 1);
13228  break;
13229 #endif /* defined(HAVE_SS7) */
13230  default:
13231  /* The only sig submodule left should be sig_analog. */
13232  analog_p = tmp->sig_pvt;
13233  if (analog_p) {
13234  analog_p->inalarm = 1;
13235  }
13236  tmp->inalarm = 1;
13237  break;
13238  }
13239  handle_alarms(tmp, res);
13240  }
13241  }
13242 
13243  tmp->polarityonanswerdelay = conf->chan.polarityonanswerdelay;
13245  tmp->ani_info_digits = conf->chan.ani_info_digits;
13246  tmp->ani_wink_time = conf->chan.ani_wink_time;
13247  tmp->ani_timeout = conf->chan.ani_timeout;
13249  tmp->reoriginate = conf->chan.reoriginate;
13250  tmp->sendcalleridafter = conf->chan.sendcalleridafter;
13251  ast_cc_copy_config_params(tmp->cc_params, conf->chan.cc_params);
13252 
13253  if (!here) {
13254  tmp->locallyblocked = 0;
13255  tmp->remotelyblocked = 0;
13256  switch (tmp->sig) {
13257 #if defined(HAVE_PRI)
13258  case SIG_PRI_LIB_HANDLE_CASES:
13259  tmp->inservice = 1;/* Inservice until actually implemented. */
13260 #if defined(HAVE_PRI_SERVICE_MESSAGES)
13261  ((struct sig_pri_chan *) tmp->sig_pvt)->service_status = 0;
13262  if (chan_sig == SIG_PRI) {
13263  char db_chan_name[20];
13264  char db_answer[5];
13265 
13266  /*
13267  * Initialize the active out-of-service status
13268  * and delete any record if the feature is not enabled.
13269  */
13270  snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, tmp->span, tmp->channel);
13271  if (!ast_db_get(db_chan_name, SRVST_DBKEY, db_answer, sizeof(db_answer))) {
13272  unsigned *why;
13273 
13274  why = &((struct sig_pri_chan *) tmp->sig_pvt)->service_status;
13275  if (tmp->pri->enable_service_message_support) {
13276  char state;
13277 
13278  sscanf(db_answer, "%1c:%30u", &state, why);
13279 
13280  /* Ensure that only the implemented bits could be set.*/
13281  *why &= (SRVST_NEAREND | SRVST_FAREND);
13282  }
13283  if (!*why) {
13284  ast_db_del(db_chan_name, SRVST_DBKEY);
13285  }
13286  }
13287  }
13288 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
13289  break;
13290 #endif /* defined(HAVE_PRI) */
13291 #if defined(HAVE_SS7)
13292  case SIG_SS7:
13293  tmp->inservice = 0;
13294  if (tmp->ss7->flags & LINKSET_FLAG_INITIALHWBLO) {
13295  tmp->remotelyblocked |= SS7_BLOCKED_HARDWARE;
13296  }
13297  break;
13298 #endif /* defined(HAVE_SS7) */
13299  default:
13300  /* We default to in service on protocols that don't have a reset */
13301  tmp->inservice = 1;
13302  break;
13303  }
13304  }
13305 
13306  switch (tmp->sig) {
13307 #if defined(HAVE_PRI)
13308  case SIG_PRI_LIB_HANDLE_CASES:
13309  if (pri_chan) {
13310  pri_chan->channel = tmp->channel;
13311  pri_chan->hidecallerid = tmp->hidecallerid;
13312  pri_chan->hidecalleridname = tmp->hidecalleridname;
13313  pri_chan->immediate = tmp->immediate;
13314  pri_chan->inalarm = tmp->inalarm;
13315  pri_chan->priexclusive = tmp->priexclusive;
13316  pri_chan->priindication_oob = tmp->priindication_oob;
13317  pri_chan->use_callerid = tmp->use_callerid;
13318  pri_chan->use_callingpres = tmp->use_callingpres;
13319  ast_copy_string(pri_chan->context, tmp->context,
13320  sizeof(pri_chan->context));
13321  ast_copy_string(pri_chan->mohinterpret, tmp->mohinterpret,
13322  sizeof(pri_chan->mohinterpret));
13323  pri_chan->stripmsd = tmp->stripmsd;
13324  }
13325  break;
13326 #endif /* defined(HAVE_PRI) */
13327 #if defined(HAVE_SS7)
13328  case SIG_SS7:
13329  if (ss7_chan) {
13330  ss7_chan->inalarm = tmp->inalarm;
13331  ss7_chan->inservice = tmp->inservice;
13332 
13333  ss7_chan->stripmsd = tmp->stripmsd;
13334  ss7_chan->hidecallerid = tmp->hidecallerid;
13335  ss7_chan->use_callerid = tmp->use_callerid;
13336  ss7_chan->use_callingpres = tmp->use_callingpres;
13337  ss7_chan->immediate = tmp->immediate;
13338  ss7_chan->locallyblocked = tmp->locallyblocked;
13339  ss7_chan->remotelyblocked = tmp->remotelyblocked;
13340  ast_copy_string(ss7_chan->context, tmp->context,
13341  sizeof(ss7_chan->context));
13342  ast_copy_string(ss7_chan->mohinterpret, tmp->mohinterpret,
13343  sizeof(ss7_chan->mohinterpret));
13344  }
13345  break;
13346 #endif /* defined(HAVE_SS7) */
13347  default:
13348  /* The only sig submodule left should be sig_analog. */
13349  analog_p = tmp->sig_pvt;
13350  if (analog_p) {
13351  analog_p->channel = tmp->channel;
13352  analog_p->polarityonanswerdelay = conf->chan.polarityonanswerdelay;
13353  analog_p->answeronpolarityswitch = conf->chan.answeronpolarityswitch;
13354  analog_p->ani_info_digits = conf->chan.ani_info_digits;
13355  analog_p->ani_timeout = conf->chan.ani_timeout;
13356  analog_p->ani_wink_time = conf->chan.ani_wink_time;
13357  analog_p->hanguponpolarityswitch = conf->chan.hanguponpolarityswitch;
13358  analog_p->permcallwaiting = conf->chan.callwaiting; /* permcallwaiting possibly modified in analog_config_complete */
13359  analog_p->calledsubscriberheld = conf->chan.calledsubscriberheld; /* Only actually used in analog pvt, not DAHDI pvt */
13360  analog_p->callreturn = conf->chan.callreturn;
13361  analog_p->cancallforward = conf->chan.cancallforward;
13362  analog_p->canpark = conf->chan.canpark;
13363  analog_p->dahditrcallerid = conf->chan.dahditrcallerid;
13364  analog_p->immediate = conf->chan.immediate;
13365  analog_p->immediatering = conf->chan.immediatering;
13366  analog_p->permhidecallerid = conf->chan.hidecallerid; /* hidecallerid is the config setting, not permhidecallerid (~permcallwaiting above) */
13367  /* It's not necessary to set analog_p->hidecallerid here, sig_analog will set hidecallerid=permhidecaller before each call */
13368  analog_p->pulse = conf->chan.pulse;
13369  analog_p->threewaycalling = conf->chan.threewaycalling;
13370  analog_p->transfer = conf->chan.transfer;
13371  analog_p->transfertobusy = conf->chan.transfertobusy;
13372  analog_p->dialmode = conf->chan.dialmode;
13373  analog_p->use_callerid = tmp->use_callerid;
13374  analog_p->usedistinctiveringdetection = tmp->usedistinctiveringdetection;
13375  analog_p->use_smdi = tmp->use_smdi;
13376  analog_p->smdi_iface = tmp->smdi_iface;
13377  analog_p->outsigmod = ANALOG_SIG_NONE;
13378  analog_p->echotraining = conf->chan.echotraining;
13379  analog_p->cid_signalling = conf->chan.cid_signalling;
13380  analog_p->stripmsd = conf->chan.stripmsd;
13381  switch (conf->chan.cid_start) {
13382  case CID_START_POLARITY:
13383  analog_p->cid_start = ANALOG_CID_START_POLARITY;
13384  break;
13385  case CID_START_POLARITY_IN:
13386  analog_p->cid_start = ANALOG_CID_START_POLARITY_IN;
13387  break;
13388  case CID_START_DTMF_NOALERT:
13389  analog_p->cid_start = ANALOG_CID_START_DTMF_NOALERT;
13390  break;
13391  default:
13392  analog_p->cid_start = ANALOG_CID_START_RING;
13393  break;
13394  }
13395  analog_p->callwaitingcallerid = conf->chan.callwaitingcallerid;
13396  analog_p->ringt = conf->chan.ringt;
13397  analog_p->ringt_base = ringt_base;
13398  analog_p->onhooktime = time(NULL);
13399  if (chan_sig & __DAHDI_SIG_FXO) {
13400  memset(&p, 0, sizeof(p));
13401  res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &p);
13402  if (!res) {
13403  analog_p->fxsoffhookstate = p.rxisoffhook;
13404  }
13405 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI
13406  res = ioctl(tmp->subs[SUB_REAL].dfd, DAHDI_VMWI_CONFIG, &tmp->mwisend_setting);
13407 #endif
13408  }
13409  analog_p->msgstate = -1;
13410 
13411  ast_copy_string(analog_p->mohsuggest, conf->chan.mohsuggest, sizeof(analog_p->mohsuggest));
13412  ast_copy_string(analog_p->cid_num, conf->chan.cid_num, sizeof(analog_p->cid_num));
13413  ast_copy_string(analog_p->cid_name, conf->chan.cid_name, sizeof(analog_p->cid_name));
13414 
13415  analog_config_complete(analog_p);
13416  }
13417  break;
13418  }
13419 #if defined(HAVE_PRI)
13420  if (tmp->channel == CHAN_PSEUDO) {
13421  /*
13422  * Save off pseudo channel buffer policy values for dynamic creation of
13423  * no B channel interfaces.
13424  */
13425  dahdi_pseudo_parms.buf_no = tmp->buf_no;
13426  dahdi_pseudo_parms.buf_policy = tmp->buf_policy;
13427  dahdi_pseudo_parms.faxbuf_no = tmp->faxbuf_no;
13428  dahdi_pseudo_parms.faxbuf_policy = tmp->faxbuf_policy;
13429  }
13430 #endif /* defined(HAVE_PRI) */
13431  }
13432  if (tmp && !here) {
13433  /* Add the new channel interface to the sorted channel interface list. */
13434  dahdi_iflist_insert(tmp);
13435  }
13436  return tmp;
13437 }
int max_call_waiting_calls
Number of extra outgoing calls to allow on a span before considering that span congested.
Definition: sig_pri.h:569
char defcontext[AST_MAX_CONTEXT]
Default distinctive ring context.
Definition: chan_dahdi.h:500
int outsigmod
Definition: chan_dahdi.h:150
struct ast_variable * next
enum analog_dialmode dialmode
Definition: sig_analog.h:321
int matchdigit_timeout
Time (ms) to wait, in case of ambiguous match (in an analog phone)
Definition: chan_dahdi.h:690
char description[32]
A description for the channel configuration.
Definition: chan_dahdi.h:496
int dtmfrelax
Definition: chan_dahdi.h:720
unsigned int priexclusive
TRUE if PRI B channels are always exclusively selected.
Definition: chan_dahdi.h:349
int nodetype
Definition: sig_pri.h:555
long resetinterval
Definition: sig_pri.h:515
int faxbuf_no
Definition: chan_dahdi.h:141
unsigned int use_callerid
Definition: sig_analog.h:307
unsigned long display_flags_send
Definition: sig_pri.h:517
struct ast_smdi_interface * smdi_iface
The SMDI interface to get SMDI messages from.
Definition: sig_analog.h:315
char cid_subaddr[AST_MAX_EXTENSION]
Caller ID subaddress from an incoming call.
Definition: chan_dahdi.h:537
unsigned int permhidecallerid
TRUE if the outgoing caller ID is blocked/restricted/hidden.
Definition: chan_dahdi.h:339
unsigned int cancallforward
TRUE if support for call forwarding enabled. Dial *72 to enable call forwarding. Dial *73 to disable ...
Definition: chan_dahdi.h:238
unsigned int priexclusive
Definition: sig_pri.h:283
int cc_qsig_signaling_link_req
Definition: sig_pri.h:561
int cid_ton
Caller ID Q.931 TON/NPI field values. Set by PRI. Zero otherwise.
Definition: chan_dahdi.h:533
struct ast_namedgroups * named_pickupgroups
Named pickup groups this belongs to.
Definition: chan_dahdi.h:579
int tonezone
Definition: chan_dahdi.h:167
unsigned int reoriginate
TRUE if FXS (FXO-signalled) channel should reoriginate for user to make a new call.
Definition: chan_dahdi.h:289
unsigned int callwaiting
TRUE if busy extensions will hear the call-waiting tone and can use hook-flash to switch between call...
Definition: chan_dahdi.h:226
int firstdigit_timeout
Time (ms) to detect first digit (in an analog phone)
Definition: chan_dahdi.h:680
static const char dahdi_db[]
The AstDB family.
Definition: sig_pri.h:275
struct dahdi_subchannel subs[3]
Definition: chan_dahdi.h:131
unsigned int use_callingpres
Definition: sig_pri.h:286
unsigned int dpc
Definition: sig_ss7.h:202
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1262
char parkinglot[AST_MAX_EXTENSION]
Definition: chan_dahdi.h:518
int cid_signalling
Definition: chan_dahdi.h:588
unsigned int callwaitingcallerid
TRUE if send caller ID for Call Waiting.
Definition: chan_dahdi.h:231
unsigned int use_callerid
Definition: sig_pri.h:285
unsigned int hidecallerid
TRUE if the outgoing caller ID is blocked/hidden.
Definition: sig_ss7.h:213
struct dahdi_pvt * next
Definition: chan_dahdi.h:169
char idleext[AST_MAX_EXTENSION]
Definition: sig_pri.h:550
#define DSP_DIGITMODE_DTMF
Definition: dsp.h:31
int interdigit_timeout
Time (ms) to detect following digits (in an analog phone)
Definition: chan_dahdi.h:685
unsigned int hold_disconnect_transfer
TRUE if held calls are transferred on disconnect.
Definition: sig_pri.h:472
int cid_start
Definition: chan_dahdi.h:589
int ringt
Ring timeout timer??
Definition: chan_dahdi.h:603
unsigned int firstradio
TRUE if over a radio and dahdi_read() has been called.
Definition: chan_dahdi.h:280
char mwi_vm_boxes[SIG_PRI_MAX_MWI_VM_NUMBER_STR]
Comma separated list of mailbox numbers sent over ISDN span for MWI.
Definition: sig_pri.h:536
unsigned int transfer
TRUE if call transfer is enabled for the span.
Definition: sig_pri.h:478
unsigned int allow_call_waiting_calls
TRUE if we will allow incoming ISDN call waiting calls.
Definition: sig_pri.h:481
int facilityenable
Definition: sig_pri.h:451
struct ast_mwi_subscriber * mwi_event_sub
Opaque event subscription parameters for message waiting indication support.
Definition: chan_dahdi.h:711
unsigned int locallyblocked
Bitmask for the channel being locally blocked.
Definition: chan_dahdi.h:451
char nationalprefix[10]
Definition: sig_pri.h:508
float txdrc
Definition: chan_dahdi.h:164
unsigned int inservice
TRUE if channel is out of reset and ready.
Definition: chan_dahdi.h:442
struct ast_smdi_interface * ast_smdi_interface_find(const char *iface_name)
Find an SMDI interface with the specified name.
Definition: res_smdi.c:563
int channel
Definition: sig_ss7.h:200
Structure for variables, used for configurations and for channel variables.
int buf_no
Definition: chan_dahdi.h:139
unsigned int mcid_send
TRUE if allow sending MCID request on this span.
Definition: sig_pri.h:496
struct ast_cc_config_params * cc_params
Definition: sig_pri.h:446
unsigned int dahditrcallerid
TRUE if we should use the callerid from incoming call on dahdi transfer.
Definition: chan_dahdi.h:408
unsigned int hidecalleridname
Definition: sig_pri.h:573
unsigned int usefaxbuffers
Definition: chan_dahdi.h:276
int law_default
Default call PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW.
Definition: chan_dahdi.h:554
int minidle
Definition: sig_pri.h:554
unsigned int immediate
TRUE if the channel should be answered immediately without attempting to gather any digits...
Definition: chan_dahdi.h:316
unsigned int enable_service_message_support
Definition: sig_pri.h:465
unsigned int aoce_delayhangup
Definition: sig_pri.h:461
int cid_signalling
Definition: sig_analog.h:323
unsigned int immediatering
TRUE if audible ringback should be provided when immediate = yes.
Definition: chan_dahdi.h:322
float cid_rxgain
Amount of gain to increase during caller id.
Definition: chan_dahdi.h:158
struct ast_dsp_busy_pattern busy_cadence
Busy cadence pattern description.
Definition: chan_dahdi.h:646
unsigned int ani_wink_time
INTEGER, length of time to wait before sending ANI wink in ms.
Definition: chan_dahdi.h:200
int bufsize
Definition: chan_dahdi.h:138
unsigned int inalarm
TRUE if channel is associated with a link that is down.
Definition: sig_ss7.h:288
unsigned int transfertobusy
TRUE if allowed to flash-transfer to busy channels.
Definition: chan_dahdi.h:413
unsigned int transfertobusy
Definition: sig_analog.h:306
unsigned int ani_info_digits
INTEGER, number of ANI INFO digits on a CAMA trunk. older switches use 1 INFO digit, newer switches use 2 INFO digits.
Definition: chan_dahdi.h:190
int dialplan
Definition: sig_pri.h:504
int localdialplan
Definition: sig_pri.h:505
char localprefix[20]
Definition: sig_pri.h:509
int switchtype
Definition: sig_pri.h:556
int law
Active PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW.
Definition: chan_dahdi.h:556
int qsigchannelmapping
Definition: sig_pri.h:449
char mwi_vm_numbers[SIG_PRI_MAX_MWI_VM_NUMBER_STR]
Comma separated list of voicemail access controlling numbers for MWI.
Definition: sig_pri.h:542
enum sig_pri_colp_signaling colp_send
Definition: sig_pri.h:514
unsigned int adsi
TRUE if ADSI (Analog Display Services Interface) available.
Definition: chan_dahdi.h:178
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
Definition: ccss.h:135
unsigned int inband_on_setup_ack
Definition: sig_pri.h:491
int ringt_base
Ring timeout base.
Definition: chan_dahdi.h:608
float txgain
Software Tx gain set by chan_dahdi.conf.
Definition: chan_dahdi.h:162
unsigned int hidecalleridname
TRUE if hide just the name not the number for legacy PBX use.
Definition: chan_dahdi.h:308
unsigned int use_smdi
TRUE if SMDI (Simplified Message Desk Interface) is enabled.
Definition: sig_analog.h:313
unsigned int pulse
TRUE if we will pulse dial.
Definition: chan_dahdi.h:354
int oprmode
Definition: chan_dahdi.h:151
ast_group_t pickupgroup
Bitmapped pickup groups this belongs to.
Definition: chan_dahdi.h:569
char cid_name[AST_MAX_EXTENSION]
Caller ID name from an incoming call.
Definition: chan_dahdi.h:535
unsigned int hwtxgain_enabled
TRUE if hardware Tx gain set by Asterisk.
Definition: chan_dahdi.h:469
unsigned int use_callingpres
TRUE if we will use the calling presentation setting from the Asterisk channel for outgoing calls...
Definition: sig_ss7.h:220
int cc_qsig_signaling_link_rsp
Definition: sig_pri.h:562
unsigned int remotelyblocked
Bitmask for the channel being remotely blocked.
Definition: sig_ss7.h:235
unsigned int answeronpolarityswitch
TRUE if we can use a polarity reversal to mark when an outgoing call is answered by the remote party...
Definition: chan_dahdi.h:184
char smdi_port[SMDI_MAX_FILENAME_LEN]
The serial port to listen for SMDI data on.
Definition: chan_dahdi.c:974
unsigned int hanguponpolarityswitch
TRUE if the call will be considered "hung up" on a polarity reversal.
Definition: chan_dahdi.h:285
unsigned int callreturn
TRUE if call return is enabled. (*69, if your dialplan doesn't catch this first)
Definition: chan_dahdi.h:219
char unknownprefix[20]
Definition: sig_pri.h:511
unsigned int transfer
TRUE if call transfer is enabled.
Definition: chan_dahdi.h:382
unsigned int use_callerid
TRUE if caller ID is used on this channel.
Definition: sig_ss7.h:215
int amaflags
Definition: chan_dahdi.h:701
int stripmsd
Number of most significant digits/characters to strip from the dialed number.
Definition: sig_ss7.h:209
unsigned int inband_on_proceeding
Definition: sig_pri.h:493
struct dahdi_pvt::@112 echocancel
Echo cancel parameters.
char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Voice mailbox location.
Definition: chan_dahdi.h:709
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
Definition: main/config.c:667
#define SRVST_DBKEY
Persistent Service State.
Definition: sig_pri.h:258
int echotraining
Echo training time. 0 = disabled.
Definition: chan_dahdi.h:634
int cc_ptmp_recall_mode
Definition: sig_pri.h:560
ast_mutex_t lock
Definition: chan_dahdi.h:125
static int ringt_base
Configured ring timeout base.
Definition: chan_dahdi.c:811
unsigned int immediatering
Definition: sig_analog.h:299
struct dahdi_vmwi_info mwisend_setting
Definition: chan_dahdi.h:715
unsigned int permcallwaiting
TRUE if busy extensions will hear the call-waiting tone and can use hook-flash to switch between call...
Definition: chan_dahdi.h:334
char internationalprefix[10]
Definition: sig_pri.h:507
unsigned int busydetect
TRUE if busy detection is enabled. (Listens for the beep-beep busy pattern.)
Definition: chan_dahdi.h:206
unsigned int mwimonitor_fsk
TRUE if the FXO port monitors for fsk type MWI indications from the other end.
Definition: chan_dahdi.h:423
char privateprefix[20]
Definition: sig_pri.h:510
unsigned int inservice
TRUE if channel is in service.
Definition: sig_ss7.h:290
unsigned int use_callingpres
TRUE if we will use the calling presentation setting from the Asterisk channel for outgoing calls...
Definition: chan_dahdi.h:397
char cid_tag[AST_MAX_EXTENSION]
Caller ID tag from incoming call.
Definition: chan_dahdi.h:531
int prilogicalspan
Definition: chan_dahdi.c:896
int overlapdial
Definition: sig_pri.h:448
unsigned int calledsubscriberheld
TRUE if Called Subscriber held is enabled. This allows a single incoming call to hold a DAHDI channel...
Definition: chan_dahdi.h:213
unsigned int use_callingpres
Definition: sig_pri.h:578
unsigned int use_smdi
TRUE if SMDI (Simplified Message Desk Interface) is enabled.
Definition: chan_dahdi.h:479
unsigned int threewaysilenthold
TRUE if a three way dial tone should time out to silence.
Definition: chan_dahdi.h:373
struct ast_dsp * dsp
Opaque DSP configuration structure.
Definition: chan_dahdi.h:694
int busycount
Number of times to see "busy" tone before hanging up.
Definition: chan_dahdi.h:641
unsigned int destroy
TRUE if the channel is to be destroyed on hangup. (Used by pseudo channels.)
Definition: chan_dahdi.h:250
char mohinterpret[MAX_MUSICCLASS]
The configured music-on-hold class to use for calls.
Definition: chan_dahdi.h:512
char cid_num[AST_MAX_EXTENSION]
Caller ID number from an incoming call.
Definition: chan_dahdi.h:526
unsigned int force_restart_unavailable_chans
TRUE if forcing RESTART when receive cause 44 on this span.
Definition: sig_pri.h:499
int minunused
Definition: sig_pri.h:553
unsigned int use_callerid
TRUE if caller ID is used on this channel.
Definition: chan_dahdi.h:390
#define SUB_REAL
Definition: chan_dahdi.h:57
int confno
Definition: chan_dahdi.h:557
unsigned int inbanddisconnect
Definition: sig_pri.h:468
#define SIG_PRI_NUM_DCHANS
Definition: sig_pri.h:239
int propconfno
Definition: chan_dahdi.h:559
int cpndialplan
Definition: sig_pri.h:506
struct sig_pri_chan * pvts[SIG_PRI_MAX_CHANNELS]
Definition: sig_pri.h:614
char idledial[AST_MAX_EXTENSION]
Definition: sig_pri.h:552
unsigned int immediate
Definition: sig_pri.h:282
unsigned long display_flags_receive
Definition: sig_pri.h:518
void stasis_subscription_cb_noop(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Stasis subscription callback function that does nothing.
Definition: stasis.c:809
unsigned int usedistinctiveringdetection
TRUE if distinctive rings are to be detected.
Definition: chan_dahdi.h:403
unsigned int hidecalleridname
Definition: sig_pri.h:281
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
unsigned int append_msn_to_user_tag
Definition: sig_pri.h:489
unsigned int faxdetect_timeout
The number of seconds into call to disable fax detection. (0 = disabled)
Definition: chan_dahdi.h:675
unsigned int restrictcid
TRUE if caller ID is restricted.
Definition: chan_dahdi.h:363
static int get_alarms(struct dahdi_pvt *p)
Definition: chan_dahdi.c:7567
unsigned int dahditrcallerid
Definition: sig_analog.h:296
char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR]
Comma separated list of mailboxes to indicate MWI.
Definition: sig_pri.h:529
char context[AST_MAX_CONTEXT]
The configured context for incoming calls.
Definition: chan_dahdi.h:491
unsigned int remotelyblocked
Bitmask for the channel being remotely blocked. 1 maintenance, 2 blocked in hardware.
Definition: chan_dahdi.h:460
unsigned int threewaycalling
TRUE if three way calling is enabled.
Definition: chan_dahdi.h:368
int msgstate
-1 = unknown, 0 = no messages, 1 = new messages available
Definition: sig_analog.h:284
unsigned int permhidecallerid
Definition: sig_analog.h:301
int l2_persistence
Definition: sig_pri.h:454
void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src)
copy CCSS configuration parameters from one structure to another
Definition: ccss.c:854
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
Definition: main/db.c:427
int stripmsd
Number of most significant digits/characters to strip from the dialed number.
Definition: chan_dahdi.h:615
char msn_list[AST_MAX_EXTENSION]
Definition: sig_pri.h:549
struct ast_namedgroups * named_callgroups
Named call groups this belongs to.
Definition: chan_dahdi.h:574
struct ast_smdi_interface * smdi_iface
The SMDI interface to get SMDI messages from.
Definition: chan_dahdi.h:482
int buf_policy
Definition: chan_dahdi.h:140
int numchans
Definition: sig_pri.h:613
unsigned int mwimonitor_neon
TRUE if the FXO port monitors for neon type MWI indications from the other end.
Definition: chan_dahdi.h:418
int waitfordialtone
Number of milliseconds to wait for dialtone.
Definition: chan_dahdi.h:656
unsigned int locallyblocked
Bitmask for the channel being locally blocked.
Definition: sig_ss7.h:228
unsigned int immediate
Definition: sig_ss7.h:221
float hwtxgain
Hardware Tx gain set by chan_dahdi.conf.
Definition: chan_dahdi.h:156
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
Definition: main/db.c:476
unsigned int priexclusive
Definition: sig_pri.h:575
struct dahdi_distRings drings
Distinctive Ring data.
Definition: chan_dahdi.h:485
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
unsigned int callwaitingcallerid
Definition: sig_analog.h:309
static struct dahdi_pvt * iflist
Definition: chan_dahdi.c:922
int discardremoteholdretrieval
Definition: sig_pri.h:450
unsigned int use_callerid
Definition: sig_pri.h:577
struct ast_variable * vars
Channel variable list with associated values to set when a channel is created.
Definition: chan_dahdi.h:584
unsigned int priindication_oob
TRUE if PRI congestion/busy indications are sent out-of-band.
Definition: chan_dahdi.h:344
unsigned int hidecallerid
TRUE if the outgoing caller ID is blocked/hidden.
Definition: chan_dahdi.h:302
int faxbuf_policy
Definition: chan_dahdi.h:142
unsigned int layer1_ignored
Definition: sig_pri.h:484
unsigned int echocanbridged
TRUE if echo cancellation enabled when bridged.
Definition: chan_dahdi.h:270
int polarityonanswerdelay
Minimal time period (ms) between the answer polarity switch and hangup polarity switch.
Definition: chan_dahdi.h:727
float rxgain
Software Rx gain set by chan_dahdi.conf.
Definition: chan_dahdi.h:160
int radio
Nonzero if the signaling type is sent over a radio.
Definition: chan_dahdi.h:148
int aoc_passthrough_flag
Definition: sig_pri.h:460
#define SRVST_NEAREND
SRVST_NEAREND is used to indicate that the near end was put out-of-service.
Definition: sig_pri.h:268
int callprogress
Bitmapped call progress detection flags. CALLPROGRESS_xxx values.
Definition: chan_dahdi.h:651
float hwrxgain
Hardware Rx gain set by chan_dahdi.conf.
Definition: chan_dahdi.h:154
char language[MAX_LANGUAGE]
Language configured for calls.
Definition: chan_dahdi.h:507
unsigned int hwrxgain_enabled
TRUE if hardware Rx gain set by Asterisk.
Definition: chan_dahdi.h:467
ast_group_t group
Bitmapped groups this belongs to.
Definition: chan_dahdi.h:552
struct ast_mwi_subscriber * ast_mwi_subscribe_pool(const char *mailbox, stasis_subscription_cb callback, void *data)
Add an MWI state subscriber, and stasis subscription to the mailbox.
Definition: mwi.c:235
int dialtone_detect
Number of frames to watch for dialtone in incoming calls.
Definition: chan_dahdi.h:669
int dialmode
Definition: chan_dahdi.h:149
unsigned int inalarm
TRUE if in an alarm condition.
Definition: chan_dahdi.h:324
int datetime_send
Configured date/time ie send policy option.
Definition: sig_pri.h:502
int channel
Definition: chan_dahdi.h:585
int sendcalleridafter
Send caller ID on FXS after this many rings. Set to 1 for US.
Definition: chan_dahdi.h:734
unsigned int immediate
Definition: sig_pri.h:574
unsigned int calledsubscriberheld
Definition: sig_analog.h:292
ast_group_t callgroup
Bitmapped call groups this belongs to.
Definition: chan_dahdi.h:564
unsigned int permcallwaiting
Definition: sig_analog.h:300
unsigned int canpark
TRUE if support for call parking is enabled.
Definition: chan_dahdi.h:243
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
Definition: dsp.c:1857
int channel
Definition: sig_pri.h:290
unsigned int ani_timeout
INTEGER, length of ANI failure timeout in ms.
Definition: chan_dahdi.h:195
char mohsuggest[MAX_MUSICCLASS]
Suggested music-on-hold class for peer channel to use for calls.
Definition: chan_dahdi.h:517
unsigned int mwisend_rpas
Definition: chan_dahdi.h:717
#define SRVST_FAREND
SRVST_FAREND is used to indicate that the far end was taken out-of-service.
Definition: sig_pri.h:270
char accountcode[AST_MAX_ACCOUNT_CODE]
Definition: chan_dahdi.h:700
unsigned int mwimonitor_rpas
TRUE if the FXO port monitors for rpas precursor to fsk MWI indications from the other end...
Definition: chan_dahdi.h:429
static void notify_message ( char *  mailbox,
int  thereornot 
)
static

Send MWI state change.

Parameters
mailboxThis is the mailbox associated with the FXO line that the MWI state has changed on.
thereornotThis argument should simply be set to 1 or 0, to indicate whether there are messages waiting or not.

This function does two things:

1) It generates an internal Asterisk event notifying any other module that cares about MWI that the state of a mailbox has changed.

2) It runs the script specified by the mwimonitornotify option to allow some custom handling of the state change.

Definition at line 3553 of file chan_dahdi.c.

References ast_publish_mwi_state, ast_safe_system(), and mwimonitornotify.

3554 {
3555  char s[sizeof(mwimonitornotify) + 164];
3556 
3557  if (ast_strlen_zero(mailbox)) {
3558  return;
3559  }
3560 
3561  ast_publish_mwi_state(mailbox, NULL, thereornot, thereornot);
3562  if (!ast_strlen_zero(mwimonitornotify)) {
3563  snprintf(s, sizeof(s), "%s %s %d", mwimonitornotify, mailbox, thereornot);
3564  ast_safe_system(s);
3565  }
3566 }
#define ast_publish_mwi_state(mailbox, context, new_msgs, old_msgs)
Publish a MWI state update via stasis.
Definition: mwi.h:378
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
Definition: extconf.c:829
static char mwimonitornotify[PATH_MAX]
Definition: chan_dahdi.c:721
static void pri_queue_for_destruction ( struct sig_pri_span pri)
static

Queue a span for destruction.

Since
13.0
Parameters
prithe span to destroy

Add a span to the list of spans to be destroyed later on by the monitor thread. Allows destroying a span while holding its lock.

Definition at line 1313 of file chan_dahdi.c.

References ast_calloc, ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, and sig_pri_span::span.

1314 {
1315  struct doomed_pri *entry;
1316 
1318  AST_LIST_TRAVERSE(&doomed_pris, entry, list) {
1319  if (entry->pri == pri) {
1321  return;
1322  }
1323  }
1324  entry = ast_calloc(sizeof(struct doomed_pri), 1);
1325  if (!entry) {
1326  /* Nothing useful to do here. Panic? */
1327  ast_log(LOG_WARNING, "Failed allocating memory for a doomed_pri.\n");
1329  return;
1330  }
1331  entry->pri = pri;
1332  ast_debug(4, "Queue span %d for destruction.\n", pri->span);
1333  AST_LIST_INSERT_TAIL(&doomed_pris, entry, list);
1335 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
Definition: search.h:40

Variable Documentation

struct analog_callback analog_callbacks

Global analog callbacks to the upper layer.

Definition at line 3616 of file chan_dahdi.c.

const char dahdi_pri_cc_type[] = "DAHDI/PRI"
static

DAHDI PRI CCSS agent and monitor type name.

Definition at line 904 of file chan_dahdi.c.

struct ast_jb_conf default_jbconf
static

Global jitterbuffer configuration - by default, jb is disabled

Note
Values shown here match the defaults shown in chan_dahdi.conf.sample

Definition at line 618 of file chan_dahdi.c.

struct dahdi_pvt* ifend = NULL
static

Main interface list end

Definition at line 923 of file chan_dahdi.c.

struct dahdi_pvt* iflist = NULL
static

Main interface list start

Definition at line 922 of file chan_dahdi.c.

Referenced by dahdi_cc_callback().

char mwimonitornotify[PATH_MAX] = ""
static

Run this script when the MWI state changes on an FXO line, if mwimonitor is enabled

Definition at line 721 of file chan_dahdi.c.

Referenced by notify_message().

struct ast_custom_function polarity_function
static
Initial value:
= {
.name = "POLARITY",
.write = polarity_write,
.read = polarity_read,
}

Definition at line 2915 of file chan_dahdi.c.

int ringt_base = DEFAULT_RINGT
static

Configured ring timeout base.

Note
Value computed from "ringtimeout" read in from chan_dahdi.conf if it exists.

Definition at line 811 of file chan_dahdi.c.

Referenced by mkintf().

struct dahdi_pvt* round_robin[64]
static

Round robin search locations.

Definition at line 3690 of file chan_dahdi.c.

struct sig_pri_callback sig_pri_callbacks

Global sig_pri callbacks to the upper layer.

Definition at line 3310 of file chan_dahdi.c.

Referenced by sig_pri_dial_complete().

const char* const subnames[]
Initial value:
= {
"Real",
"Callwait",
"Threeway"
}

Definition at line 916 of file chan_dahdi.c.

const char tdesc[]
static
Initial value:
= "DAHDI Telephony"
" w/"
"PRI"

Definition at line 648 of file chan_dahdi.c.