Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Macros | Functions | Variables
sig_analog.c File Reference

Analog signaling module. More...

#include "asterisk.h"
#include <errno.h>
#include <ctype.h>
#include "asterisk/utils.h"
#include "asterisk/options.h"
#include "asterisk/pickup.h"
#include "asterisk/pbx.h"
#include "asterisk/file.h"
#include "asterisk/callerid.h"
#include "asterisk/say.h"
#include "asterisk/manager.h"
#include "asterisk/astdb.h"
#include "asterisk/features.h"
#include "asterisk/causes.h"
#include "asterisk/features_config.h"
#include "asterisk/bridge.h"
#include "asterisk/parking.h"
#include "sig_analog.h"
Include dependency graph for sig_analog.c:

Go to the source code of this file.

Macros

#define analog_get_index(ast, p, nullok)   _analog_get_index(ast, p, nullok, __PRETTY_FUNCTION__, __LINE__)
 
#define ANALOG_NEED_MFDETECT(p)   (((p)->sig == ANALOG_SIG_FEATDMF) || ((p)->sig == ANALOG_SIG_FEATDMF_TA) || ((p)->sig == ANALOG_SIG_E911) || ((p)->sig == ANALOG_SIG_FGC_CAMA) || ((p)->sig == ANALOG_SIG_FGC_CAMAMF) || ((p)->sig == ANALOG_SIG_FEATB))
 
#define gen_analog_field_callback(type, callback_name, def_value)
 
#define ISTRUNK(p)
 
#define MIN_MS_SINCE_FLASH   ( (2000) )
 
#define POLARITY_IDLE   0
 
#define POLARITY_REV   1
 

Functions

static struct ast_frame__analog_handle_event (struct analog_pvt *p, struct ast_channel *ast)
 
static void * __analog_ss_thread (void *data)
 
static int _analog_get_index (struct ast_channel *ast, struct analog_pvt *p, int nullok, const char *fname, unsigned long line)
 
static void analog_all_subchannels_hungup (struct analog_pvt *p)
 
static int analog_alloc_sub (struct analog_pvt *p, enum analog_sub x)
 
int analog_answer (struct analog_pvt *p, struct ast_channel *ast)
 
static void analog_answer_polarityswitch (struct analog_pvt *p)
 
static int analog_attempt_transfer (struct analog_pvt *p)
 
int analog_available (struct analog_pvt *p)
 
int analog_call (struct analog_pvt *p, struct ast_channel *ast, const char *rdest, int timeout)
 
static int analog_callwait (struct analog_pvt *p)
 
static void analog_cancel_cidspill (struct analog_pvt *p)
 
static int analog_canmatch_featurecode (const char *pickupexten, const char *exten)
 
static void analog_cb_handle_dtmf (struct analog_pvt *p, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest)
 
static int analog_check_confirmanswer (struct analog_pvt *p)
 
static int analog_check_for_conference (struct analog_pvt *p)
 
static int analog_check_waitingfordt (struct analog_pvt *p)
 
const char * analog_cidstart_to_str (enum analog_cid_start cid_start)
 
const char * analog_cidtype_to_str (unsigned int cid_type)
 
int analog_config_complete (struct analog_pvt *p)
 
static int analog_confmute (struct analog_pvt *p, int mute)
 
static void analog_deadlock_avoidance_private (struct analog_pvt *p)
 
static void analog_decrease_ss_count (void)
 
void analog_delete (struct analog_pvt *doomed)
 Delete the analog private structure. More...
 
static int analog_dial_digits (struct analog_pvt *p, enum analog_sub sub, struct analog_dialoperation *dop)
 
static int analog_distinctive_ring (struct ast_channel *chan, struct analog_pvt *p, int idx, int *ringdata)
 
int analog_dnd (struct analog_pvt *p, int flag)
 
static int analog_dsp_reset_and_flush_digits (struct analog_pvt *p)
 
static int analog_dsp_set_digitmode (struct analog_pvt *p, enum analog_dsp_digitmode mode)
 
static char * analog_event2str (enum analog_event event)
 
struct ast_frameanalog_exception (struct analog_pvt *p, struct ast_channel *ast)
 
int analog_fixup (struct ast_channel *oldchan, struct ast_channel *newchan, void *newp)
 
static int analog_flash (struct analog_pvt *p)
 
void analog_free (struct analog_pvt *p)
 
static void analog_get_and_handle_alarms (struct analog_pvt *p)
 
static void * analog_get_bridged_channel (struct ast_channel *chan)
 
static int analog_get_callerid (struct analog_pvt *p, char *name, char *number, enum analog_event *ev, size_t timeout)
 
static int analog_get_event (struct analog_pvt *p)
 
static const char * analog_get_orig_dialstring (struct analog_pvt *p)
 
static int analog_get_sub_fd (struct analog_pvt *p, enum analog_sub sub)
 
void analog_handle_dtmf (struct analog_pvt *p, struct ast_channel *ast, enum analog_sub idx, struct ast_frame **dest)
 
void * analog_handle_init_event (struct analog_pvt *i, int event)
 
static int analog_handle_notify_message (struct ast_channel *chan, struct analog_pvt *p, int cid_flags, int neon_mwievent)
 
static int analog_handles_digit (struct ast_frame *f)
 
int analog_hangup (struct analog_pvt *p, struct ast_channel *ast)
 
static void analog_hangup_polarityswitch (struct analog_pvt *p)
 
static int analog_has_voicemail (struct analog_pvt *p)
 
static int analog_have_progressdetect (struct analog_pvt *p)
 
static void analog_increase_ss_count (void)
 
static int analog_is_dialing (struct analog_pvt *p, enum analog_sub index)
 
static int analog_is_off_hook (struct analog_pvt *p)
 
static void analog_lock_private (struct analog_pvt *p)
 
static void analog_lock_sub_owner (struct analog_pvt *pvt, enum analog_sub sub_idx)
 
static int analog_my_getsigstr (struct ast_channel *chan, char *str, const char *term, int ms)
 
struct analog_pvtanalog_new (enum analog_sigtype signallingtype, void *private_data)
 
static struct ast_channelanalog_new_ast_channel (struct analog_pvt *p, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
 
static int analog_off_hook (struct analog_pvt *p)
 
static int analog_on_hook (struct analog_pvt *p)
 
static int analog_play_tone (struct analog_pvt *p, enum analog_sub sub, enum analog_tone tone)
 
static void analog_publish_channel_alarm_clear (int channel)
 
static void analog_publish_dnd_state (int channel, const char *status)
 
struct ast_channelanalog_request (struct analog_pvt *p, int *callwait, const struct ast_channel *requestor)
 
static int analog_ring (struct analog_pvt *p)
 
static int analog_send_callerid (struct analog_pvt *p, int cwcid, struct ast_party_caller *caller)
 
static void analog_set_alarm (struct analog_pvt *p, int in_alarm)
 
static void analog_set_cadence (struct analog_pvt *p, struct ast_channel *chan)
 
static void analog_set_callwaiting (struct analog_pvt *p, int callwaiting_enable)
 
static void analog_set_confirmanswer (struct analog_pvt *p, int flag)
 
static void analog_set_dialing (struct analog_pvt *p, int is_dialing)
 
static int analog_set_echocanceller (struct analog_pvt *p, int enable)
 
static void analog_set_inthreeway (struct analog_pvt *p, enum analog_sub sub, int inthreeway)
 
static int analog_set_linear_mode (struct analog_pvt *p, enum analog_sub sub, int linear_mode)
 
static void analog_set_needringing (struct analog_pvt *p, int value)
 
static void analog_set_new_owner (struct analog_pvt *p, struct ast_channel *new_owner)
 
static void analog_set_outgoing (struct analog_pvt *p, int is_outgoing)
 
static void analog_set_pulsedial (struct analog_pvt *p, int flag)
 
static void analog_set_ringtimeout (struct analog_pvt *p, int ringt)
 
static void analog_set_waitingfordt (struct analog_pvt *p, struct ast_channel *ast)
 
const char * analog_sigtype_to_str (enum analog_sigtype sigtype)
 
int analog_ss_thread_start (struct analog_pvt *p, struct ast_channel *chan)
 
static int analog_start (struct analog_pvt *p)
 
static int analog_start_cid_detect (struct analog_pvt *p, int cid_signalling)
 
static void analog_start_polarityswitch (struct analog_pvt *p)
 
static int analog_stop_callwait (struct analog_pvt *p)
 
static int analog_stop_cid_detect (struct analog_pvt *p)
 
enum analog_cid_start analog_str_to_cidstart (const char *value)
 
unsigned int analog_str_to_cidtype (const char *name)
 
enum analog_sigtype analog_str_to_sigtype (const char *name)
 
static void analog_swap_subs (struct analog_pvt *p, enum analog_sub a, enum analog_sub b)
 
static int analog_train_echocanceller (struct analog_pvt *p)
 
static int analog_unalloc_sub (struct analog_pvt *p, enum analog_sub x)
 
static void analog_unlock_private (struct analog_pvt *p)
 
static int analog_update_conf (struct analog_pvt *p)
 
static int analog_wait_event (struct analog_pvt *p)
 
static int analog_wink (struct analog_pvt *p, enum analog_sub index)
 
 gen_analog_field_callback (int, firstdigit_timeout, ANALOG_FIRST_DIGIT_TIMEOUT)
 
 gen_analog_field_callback (int, interdigit_timeout, ANALOG_INTER_DIGIT_TIMEOUT)
 
 gen_analog_field_callback (int, matchdigit_timeout, ANALOG_MATCH_DIGIT_TIMEOUT)
 

Variables

static char analog_defaultcic [64] = ""
 
static char analog_defaultozz [64] = ""
 
struct {
   unsigned int   cid_type
 
   const char *   name
 
cidtypes []
 
struct {
   const char *   name
 
   enum analog_sigtype   sigtype
 
sigtypes []
 

Detailed Description

Analog signaling module.

Author
Matthew Fredrickson cresl.nosp@m.in@d.nosp@m.igium.nosp@m..com

Definition in file sig_analog.c.

Macro Definition Documentation

◆ analog_get_index

#define analog_get_index (   ast,
  p,
  nullok 
)    _analog_get_index(ast, p, nullok, __PRETTY_FUNCTION__, __LINE__)

Definition at line 407 of file sig_analog.c.

◆ ANALOG_NEED_MFDETECT

#define ANALOG_NEED_MFDETECT (   p)    (((p)->sig == ANALOG_SIG_FEATDMF) || ((p)->sig == ANALOG_SIG_FEATDMF_TA) || ((p)->sig == ANALOG_SIG_E911) || ((p)->sig == ANALOG_SIG_FGC_CAMA) || ((p)->sig == ANALOG_SIG_FGC_CAMAMF) || ((p)->sig == ANALOG_SIG_FEATB))

Definition at line 1713 of file sig_analog.c.

◆ gen_analog_field_callback

#define gen_analog_field_callback (   type,
  callback_name,
  def_value 
)

Definition at line 219 of file sig_analog.c.

◆ ISTRUNK

#define ISTRUNK (   p)
Value:
((p->sig == ANALOG_SIG_FXSLS) || (p->sig == ANALOG_SIG_FXSKS) || \
(p->sig == ANALOG_SIG_FXSGS))
@ ANALOG_SIG_FXSLS
Definition: sig_analog.h:50
@ ANALOG_SIG_FXSGS
Definition: sig_analog.h:52
@ ANALOG_SIG_FXSKS
Definition: sig_analog.h:51

Definition at line 107 of file sig_analog.c.

◆ MIN_MS_SINCE_FLASH

#define MIN_MS_SINCE_FLASH   ( (2000) )

2000 ms

Definition at line 64 of file sig_analog.c.

◆ POLARITY_IDLE

#define POLARITY_IDLE   0
Note
Define if you want to check the hook state for an FXO (FXS signalled) interface before dialing on it. Certain FXO interfaces always think they're out of service with this method however.

Definition at line 62 of file sig_analog.c.

◆ POLARITY_REV

#define POLARITY_REV   1

Definition at line 63 of file sig_analog.c.

Function Documentation

◆ __analog_handle_event()

static struct ast_frame * __analog_handle_event ( struct analog_pvt p,
struct ast_channel ast 
)
static

< Digits (or equivalent) have been dialed

< Remote end is ringing

< Line is up

< Line is ringing

< Channel is down and available

< Channel is down, but reserved

< Channel is off hook

< Line is busy

< Digits (or equivalent) have been dialed while offhook

< Channel has detected an incoming call and is waiting for ring

< Digits (or equivalent) have been dialed

< Remote end is ringing

< Line is up

< Line is ringing

Definition at line 2799 of file sig_analog.c.

2800{
2801 int res, x;
2802 int mysig;
2803 int idx;
2804 char *c;
2805 pthread_t threadid;
2806 struct ast_channel *chan;
2807 struct ast_frame *f;
2808 struct ast_control_pvt_cause_code *cause_code = NULL;
2809 int data_size = sizeof(*cause_code);
2810 char *subclass = NULL;
2811
2812 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
2813
2814 idx = analog_get_index(ast, p, 0);
2815 if (idx < 0) {
2816 return &ast_null_frame;
2817 }
2818 if (idx != ANALOG_SUB_REAL) {
2819 ast_log(LOG_ERROR, "We got an event on a non real sub. Fix it!\n");
2820 }
2821
2822 mysig = p->sig;
2823 if (p->outsigmod > -1) {
2824 mysig = p->outsigmod;
2825 }
2826
2827 p->subs[idx].f.frametype = AST_FRAME_NULL;
2828 p->subs[idx].f.subclass.integer = 0;
2829 p->subs[idx].f.datalen = 0;
2830 p->subs[idx].f.samples = 0;
2831 p->subs[idx].f.mallocd = 0;
2832 p->subs[idx].f.offset = 0;
2833 p->subs[idx].f.src = "dahdi_handle_event";
2834 p->subs[idx].f.data.ptr = NULL;
2835 f = &p->subs[idx].f;
2836
2837 res = analog_get_event(p);
2838
2839 ast_debug(1, "Got event %s(%d) on channel %d (index %u)\n", analog_event2str(res), res, p->channel, idx);
2840
2843 ast_debug(1, "Detected %sdigit '%c'\n", (res & ANALOG_EVENT_PULSEDIGIT) ? "pulse ": "", res & 0xff);
2844 analog_confmute(p, 0);
2847 p->subs[idx].f.subclass.integer = res & 0xff;
2848 analog_handle_dtmf(p, ast, idx, &f);
2849 } else {
2850 ast_debug(1, "Dropping pulse digit '%c' because pulse dialing disabled on channel %d\n", res & 0xff, p->channel);
2851 }
2852 return f;
2853 }
2854
2855 if (res & ANALOG_EVENT_DTMFDOWN) {
2856 ast_debug(1, "DTMF Down '%c'\n", res & 0xff);
2857 /* Mute conference */
2858 analog_confmute(p, 1);
2860 p->subs[idx].f.subclass.integer = res & 0xff;
2861 analog_handle_dtmf(p, ast, idx, &f);
2862 return f;
2863 }
2864
2865 switch (res) {
2866 case ANALOG_EVENT_ALARM:
2869 /* add length of "ANALOG " */
2870 data_size += 7;
2871 subclass = analog_event2str(res);
2872 data_size += strlen(subclass);
2873 cause_code = ast_alloca(data_size);
2874 memset(cause_code, 0, data_size);
2877 snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "ANALOG %s", subclass);
2878 break;
2879 default:
2880 break;
2881 }
2882
2883 switch (res) {
2885 ast_verb(3, "Channel %d echo canceller disabled due to CED detection\n", p->channel);
2887 break;
2888#ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE
2890 ast_verb(3, "Channel %d detected a CED tone towards the network.\n", p->channel);
2891 break;
2893 ast_verb(3, "Channel %d detected a CED tone from the network.\n", p->channel);
2894 break;
2896 ast_verb(3, "Channel %d echo canceller disabled its NLP.\n", p->channel);
2897 break;
2899 ast_verb(3, "Channel %d echo canceller enabled its NLP.\n", p->channel);
2900 break;
2901#endif
2903 /* Stop tone if there's a pulse start and the PBX isn't started */
2904 if (!ast_channel_pbx(ast))
2906 break;
2908 if (p->inalarm) {
2909 break;
2910 }
2911 x = analog_is_dialing(p, idx);
2912 if (!x) { /* if not still dialing in driver */
2914 if (p->echobreak) {
2916 ast_copy_string(p->dop.dialstr, p->echorest, sizeof(p->dop.dialstr));
2919 p->echobreak = 0;
2920 } else {
2921 analog_set_dialing(p, 0);
2922 if ((mysig == ANALOG_SIG_E911) || (mysig == ANALOG_SIG_FGC_CAMA) || (mysig == ANALOG_SIG_FGC_CAMAMF)) {
2923 /* if thru with dialing after offhook */
2928 break;
2929 } else { /* if to state wait for offhook to dial rest */
2930 /* we now wait for off hook */
2932 }
2933 }
2936 ast_debug(1, "Done dialing, but waiting for progress detection before doing more...\n");
2937 } else if (analog_check_confirmanswer(p) || (!p->dialednone
2938 && ((mysig == ANALOG_SIG_EM) || (mysig == ANALOG_SIG_EM_E1)
2939 || (mysig == ANALOG_SIG_EMWINK) || (mysig == ANALOG_SIG_FEATD)
2940 || (mysig == ANALOG_SIG_FEATDMF_TA) || (mysig == ANALOG_SIG_FEATDMF)
2941 || (mysig == ANALOG_SIG_E911) || (mysig == ANALOG_SIG_FGC_CAMA)
2942 || (mysig == ANALOG_SIG_FGC_CAMAMF) || (mysig == ANALOG_SIG_FEATB)
2943 || (mysig == ANALOG_SIG_SF) || (mysig == ANALOG_SIG_SFWINK)
2944 || (mysig == ANALOG_SIG_SF_FEATD) || (mysig == ANALOG_SIG_SF_FEATDMF)
2945 || (mysig == ANALOG_SIG_SF_FEATB)))) {
2947 } else if (!p->answeronpolarityswitch) {
2951 /* If aops=0 and hops=1, this is necessary */
2953 } else {
2954 /* Start clean, so we can catch the change to REV polarity when party answers */
2956 }
2957 }
2958 }
2959 }
2960 break;
2961 case ANALOG_EVENT_ALARM:
2962 analog_set_alarm(p, 1);
2966 if (p->calledsubscriberheld && (p->sig == ANALOG_SIG_FXOLS || p->sig == ANALOG_SIG_FXOGS || p->sig == ANALOG_SIG_FXOKS) && idx == ANALOG_SUB_REAL) {
2967 ast_debug(4, "Channel state on %s is %d\n", ast_channel_name(ast), ast_channel_state(ast));
2968 /* Called Subscriber Held: don't let the called party hang up on an incoming call immediately (if it's the only call). */
2970 ast_debug(2, "Letting this call hang up normally, since it's not the only call\n");
2971 } else if (!p->owner || !p->subs[ANALOG_SUB_REAL].owner || ast_channel_state(ast) != AST_STATE_UP) {
2972 ast_debug(2, "Called Subscriber Held does not apply: channel state is %d\n", ast_channel_state(ast));
2973 } else if (!p->owner || !p->subs[ANALOG_SUB_REAL].owner || strcmp(ast_channel_appl(p->subs[ANALOG_SUB_REAL].owner), "AppDial")) {
2974 /* Called Subscriber held only applies to incoming calls, not outgoing calls.
2975 * We can't use p->outgoing because that is always true, for both incoming and outgoing calls, so it's not accurate.
2976 * We can check the channel application/data instead.
2977 * For incoming calls to the channel, it will look like: AppDial / (Outgoing Line)
2978 * We only want this behavior for regular calls anyways (and not, say, Queue),
2979 * so this would actually work great. But accessing ast_channel_appl can cause a crash if there are no calls left,
2980 * so this check must occur AFTER we confirm the channel state *is* still UP.
2981 */
2982 ast_debug(2, "Called Subscriber Held does not apply: not an incoming call\n");
2983 } else if (analog_is_off_hook(p)) {
2984 ast_log(LOG_WARNING, "Got ONHOOK but channel %d is off hook?\n", p->channel); /* Shouldn't happen */
2985 } else {
2986 ast_verb(3, "Holding incoming call %s for channel %d\n", ast_channel_name(ast), p->channel);
2987 /* Inhibit dahdi_hangup from getting called, and do nothing else now.
2988 * When the DAHDI channel goes off hook again, it'll just get reconnected with the incoming call,
2989 * to which, as far as its concerned, nothing has happened. */
2990 p->cshactive = 1; /* Keep track that this DAHDI channel is currently being held by an incoming call. */
2991 break;
2992 }
2993 }
2994 ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
2995 ast_channel_hangupcause_hash_set(ast, cause_code, data_size);
2996 switch (p->sig) {
2997 case ANALOG_SIG_FXOLS:
2998 case ANALOG_SIG_FXOGS:
2999 case ANALOG_SIG_FXOKS:
3001 p->fxsoffhookstate = 0;
3002 p->onhooktime = time(NULL);
3003 p->msgstate = -1;
3004 /* Check for some special conditions regarding call waiting */
3005 if (idx == ANALOG_SUB_REAL) {
3006 /* The normal line was hung up */
3007 if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
3008 /* Need to hold the lock for real-call, private, and call-waiting call */
3010 if (!p->subs[ANALOG_SUB_CALLWAIT].owner) {
3011 /*
3012 * The call waiting call disappeared.
3013 * This is now a normal hangup.
3014 */
3016 return NULL;
3017 }
3018
3019 /* There's a call waiting call, so ring the phone, but make it unowned in the meantime */
3021 ast_verb(3, "Channel %d still has (callwait) call, ringing phone\n", p->channel);
3025 /* Don't start streaming audio yet if the incoming call isn't up yet */
3027 analog_set_dialing(p, 1);
3028 }
3029 /* Unlock the call-waiting call that we swapped to real-call. */
3031 analog_ring(p);
3032 } else if (p->subs[ANALOG_SUB_THREEWAY].owner) {
3033 unsigned int mssinceflash;
3034
3035 /* Need to hold the lock for real-call, private, and 3-way call */
3037 if (!p->subs[ANALOG_SUB_THREEWAY].owner) {
3038 ast_log(LOG_NOTICE, "Whoa, threeway disappeared kinda randomly.\n");
3039 /* Just hangup */
3040 return NULL;
3041 }
3042 if (p->owner != ast) {
3044 ast_log(LOG_WARNING, "This isn't good...\n");
3045 /* Just hangup */
3046 return NULL;
3047 }
3048
3049 mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime);
3050 ast_debug(1, "Last flash was %u ms ago\n", mssinceflash);
3051 if (mssinceflash < MIN_MS_SINCE_FLASH) {
3052 /* It hasn't been long enough since the last flashook. This is probably a bounce on
3053 hanging up. Hangup both channels now */
3054 ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
3058 } else if ((ast_channel_pbx(ast)) || (ast_channel_state(ast) == AST_STATE_UP)) {
3059 if (p->transfer) {
3060 /* In any case this isn't a threeway call anymore */
3063
3064 /* Only attempt transfer if the phone is ringing; why transfer to busy tone eh? */
3065 if (!p->transfertobusy && ast_channel_state(ast) == AST_STATE_BUSY) {
3066 /* Swap subs and dis-own channel */
3068 /* Unlock the 3-way call that we swapped to real-call. */
3071 /* Ring the phone */
3072 analog_ring(p);
3073 } else if (!analog_attempt_transfer(p)) {
3074 /*
3075 * Transfer successful. Don't actually hang up at this point.
3076 * Let our channel legs of the calls die off as the transfer
3077 * percolates through the core.
3078 */
3079 break;
3080 }
3081 } else {
3084 }
3085 } else {
3086 /* Swap subs and dis-own channel */
3088 /* Unlock the 3-way call that we swapped to real-call. */
3091 /* Ring the phone */
3092 analog_ring(p);
3093 }
3094 }
3095 } else {
3096 ast_log(LOG_WARNING, "Got a hangup and my index is %u?\n", idx);
3097 }
3098 /* Fall through */
3099 default:
3101 return NULL;
3102 }
3103 break;
3105 if (p->inalarm) {
3106 break;
3107 }
3108 /* for E911, its supposed to wait for offhook then dial
3109 the second half of the dial string */
3110 if (((mysig == ANALOG_SIG_E911) || (mysig == ANALOG_SIG_FGC_CAMA) || (mysig == ANALOG_SIG_FGC_CAMAMF)) && (ast_channel_state(ast) == AST_STATE_DIALING_OFFHOOK)) {
3111 c = strchr(p->dialdest, '/');
3112 if (c) {
3113 c++;
3114 } else {
3115 c = p->dialdest;
3116 }
3117
3118 if (*c) {
3119 int numchars = snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*0%s#", c);
3120 if (numchars >= sizeof(p->dop.dialstr)) {
3121 ast_log(LOG_WARNING, "Dial string '%s' truncated\n", c);
3122 }
3123 } else {
3124 ast_copy_string(p->dop.dialstr,"M*2#", sizeof(p->dop.dialstr));
3125 }
3126
3127 if (strlen(p->dop.dialstr) > 4) {
3128 memset(p->echorest, 'w', sizeof(p->echorest) - 1);
3129 strcpy(p->echorest + (p->echotraining / 401) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
3130 p->echorest[sizeof(p->echorest) - 1] = '\0';
3131 p->echobreak = 1;
3132 p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0';
3133 } else {
3134 p->echobreak = 0;
3135 }
3136 if (analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop)) {
3137 analog_on_hook(p);
3138 return NULL;
3139 }
3140 analog_set_dialing(p, 1);
3141 return &p->subs[idx].f;
3142 }
3143 switch (p->sig) {
3144 case ANALOG_SIG_FXOLS:
3145 case ANALOG_SIG_FXOGS:
3146 case ANALOG_SIG_FXOKS:
3147 p->fxsoffhookstate = 1;
3148 switch (ast_channel_state(ast)) {
3149 case AST_STATE_RINGING:
3154 /* Make sure it stops ringing */
3156 analog_off_hook(p);
3157 ast_debug(1, "channel %d answered\n", p->channel);
3158
3159 /* Cancel any running CallerID spill */
3161
3162 analog_set_dialing(p, 0);
3163 p->callwaitcas = 0;
3165 /* Ignore answer if "confirm answer" is enabled */
3166 p->subs[idx].f.frametype = AST_FRAME_NULL;
3167 p->subs[idx].f.subclass.integer = 0;
3168 } else if (!ast_strlen_zero(p->dop.dialstr)) {
3169 /* nick@dccinc.com 4/3/03 - fxo should be able to do deferred dialing */
3170 res = analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop);
3171 if (res) {
3172 p->dop.dialstr[0] = '\0';
3173 return NULL;
3174 } else {
3175 ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
3176 p->subs[idx].f.frametype = AST_FRAME_NULL;
3177 p->subs[idx].f.subclass.integer = 0;
3178 analog_set_dialing(p, 1);
3179 }
3180 p->dop.dialstr[0] = '\0';
3182 } else {
3185 }
3186 return &p->subs[idx].f;
3187 case AST_STATE_DOWN:
3189 ast_channel_rings_set(ast, 1);
3192 ast_debug(1, "channel %d picked up\n", p->channel);
3193 return &p->subs[idx].f;
3194 case AST_STATE_UP:
3195 /* Make sure it stops ringing */
3196 analog_off_hook(p);
3197 /* Okay -- probably call waiting */
3199 break;
3200 case AST_STATE_RESERVED:
3201 /* Start up dialtone */
3202 if (analog_has_voicemail(p)) {
3204 } else {
3206 }
3207 break;
3208 default:
3209 ast_log(LOG_WARNING, "FXO phone off hook in weird state %u??\n", ast_channel_state(ast));
3210 }
3211 break;
3212 case ANALOG_SIG_FXSLS:
3213 case ANALOG_SIG_FXSGS:
3214 case ANALOG_SIG_FXSKS:
3215 if (ast_channel_state(ast) == AST_STATE_RING) {
3217 }
3218
3219 /* Fall through */
3220 case ANALOG_SIG_EM:
3221 case ANALOG_SIG_EM_E1:
3222 case ANALOG_SIG_EMWINK:
3223 case ANALOG_SIG_FEATD:
3224 case ANALOG_SIG_FEATDMF:
3226 case ANALOG_SIG_E911:
3229 case ANALOG_SIG_FEATB:
3230 case ANALOG_SIG_SF:
3231 case ANALOG_SIG_SFWINK:
3235 switch (ast_channel_state(ast)) {
3236 case AST_STATE_PRERING:
3238 /* Fall through */
3239 case AST_STATE_DOWN:
3240 case AST_STATE_RING:
3241 ast_debug(1, "Ring detected\n");
3244 break;
3245 case AST_STATE_RINGING:
3246 case AST_STATE_DIALING:
3247 if (p->outgoing) {
3248 ast_debug(1, "Line answered\n");
3250 p->subs[idx].f.frametype = AST_FRAME_NULL;
3251 p->subs[idx].f.subclass.integer = 0;
3252 } else {
3256 }
3257 break;
3258 }
3259 /* Fall through */
3260 default:
3261 ast_log(LOG_WARNING, "Ring/Off-hook in strange state %u on channel %d\n", ast_channel_state(ast), p->channel);
3262 break;
3263 }
3264 break;
3265 default:
3266 ast_log(LOG_WARNING, "Don't know how to handle ring/off hook for signalling %d\n", p->sig);
3267 break;
3268 }
3269 break;
3271 switch (p->sig) {
3272 case ANALOG_SIG_FXSLS:
3273 case ANALOG_SIG_FXSGS:
3274 case ANALOG_SIG_FXSKS:
3275 if (ast_channel_state(ast) == AST_STATE_RING) {
3277 }
3278 break;
3279 default:
3280 break;
3281 }
3282 break;
3284 if (p->inalarm) break;
3286 if (ast_channel_rings(ast) == p->cidrings) {
3287 analog_send_callerid(p, 0, &p->caller);
3288 }
3289
3290 if (ast_channel_rings(ast) > p->cidrings) {
3292 p->callwaitcas = 0;
3293 }
3296 break;
3298 break;
3300 analog_set_alarm(p, 0);
3302 break;
3304 if (p->inalarm) {
3305 break;
3306 }
3307 /* Remember last time we got a flash-hook */
3308 gettimeofday(&p->flashtime, NULL);
3309 switch (mysig) {
3310 case ANALOG_SIG_FXOLS:
3311 case ANALOG_SIG_FXOGS:
3312 case ANALOG_SIG_FXOKS:
3313 ast_debug(1, "Winkflash, index: %u, normal: %d, callwait: %d, thirdcall: %d\n",
3315
3316 /* Cancel any running CallerID spill */
3318 p->callwaitcas = 0;
3319
3320 if (idx != ANALOG_SUB_REAL) {
3321 ast_log(LOG_WARNING, "Got flash hook with index %u on channel %d?!?\n", idx, p->channel);
3322 goto winkflashdone;
3323 }
3324
3325 if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
3326 /* Need to hold the lock for real-call, private, and call-waiting call */
3328 if (!p->subs[ANALOG_SUB_CALLWAIT].owner) {
3329 /*
3330 * The call waiting call disappeared.
3331 * Let's just ignore this flash-hook.
3332 */
3333 ast_log(LOG_NOTICE, "Whoa, the call-waiting call disappeared.\n");
3334 goto winkflashdone;
3335 }
3336
3337 /* Swap to call-wait */
3341 ast_debug(1, "Making %s the new owner\n", ast_channel_name(p->owner));
3345 }
3347
3348 /* Start music on hold if appropriate */
3351 }
3354
3355 /* Unlock the call-waiting call that we swapped to real-call. */
3357 } else if (!p->subs[ANALOG_SUB_THREEWAY].owner) {
3358 if (!p->threewaycalling) {
3359 /* Just send a flash if no 3-way calling */
3361 goto winkflashdone;
3362 } else if (!analog_check_for_conference(p)) {
3363 ast_callid callid = 0;
3364 int callid_created;
3365 char cid_num[256];
3366 char cid_name[256];
3367
3368 cid_num[0] = '\0';
3369 cid_name[0] = '\0';
3370 if (p->dahditrcallerid && p->owner) {
3374 sizeof(cid_num));
3375 }
3379 sizeof(cid_name));
3380 }
3381 }
3382 /* XXX This section needs much more error checking!!! XXX */
3383 /* Start a 3-way call if feasible */
3384 if (!((ast_channel_pbx(ast)) ||
3385 (ast_channel_state(ast) == AST_STATE_UP) ||
3386 (ast_channel_state(ast) == AST_STATE_RING))) {
3387 ast_debug(1, "Flash when call not up or ringing\n");
3388 goto winkflashdone;
3389 }
3391 ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n");
3392 goto winkflashdone;
3393 }
3394
3395 callid_created = ast_callid_threadstorage_auto(&callid);
3396
3397 /*
3398 * Make new channel
3399 *
3400 * We cannot hold the p or ast locks while creating a new
3401 * channel.
3402 */
3404 ast_channel_unlock(ast);
3406 ast_channel_lock(ast);
3408 if (!chan) {
3410 "Cannot allocate new call structure on channel %d\n",
3411 p->channel);
3413 ast_callid_threadstorage_auto_clean(callid, callid_created);
3414 goto winkflashdone;
3415 }
3416 if (p->dahditrcallerid) {
3417 if (!p->origcid_num) {
3419 }
3420 if (!p->origcid_name) {
3422 }
3423 ast_copy_string(p->cid_num, cid_num, sizeof(p->cid_num));
3424 ast_copy_string(p->cid_name, cid_name, sizeof(p->cid_name));
3425 }
3426 /* Swap things around between the three-way and real call */
3428 /* Disable echo canceller for better dialing */
3431 if (res) {
3432 ast_log(LOG_WARNING, "Unable to start dial recall tone on channel %d\n", p->channel);
3433 }
3434 analog_set_new_owner(p, chan);
3435 p->ss_astchan = chan;
3437 ast_log(LOG_WARNING, "Unable to start simple switch on channel %d\n", p->channel);
3440 ast_hangup(chan);
3441 } else {
3442 ast_verb(3, "Started three way call on channel %d\n", p->channel);
3443
3444 /* Start music on hold */
3446 }
3447 ast_callid_threadstorage_auto_clean(callid, callid_created);
3448 }
3449 } else {
3450 /* Already have a 3 way call */
3451 enum analog_sub orig_3way_sub;
3452
3453 /* Need to hold the lock for real-call, private, and 3-way call */
3455 if (!p->subs[ANALOG_SUB_THREEWAY].owner) {
3456 /*
3457 * The 3-way call disappeared.
3458 * Let's just ignore this flash-hook.
3459 */
3460 ast_log(LOG_NOTICE, "Whoa, the 3-way call disappeared.\n");
3461 goto winkflashdone;
3462 }
3463 orig_3way_sub = ANALOG_SUB_THREEWAY;
3464
3466 /* Call is already up, drop the last person */
3467 ast_debug(1, "Got flash with three way call up, dropping last call on %d\n", p->channel);
3468 /* If the primary call isn't answered yet, use it */
3471 /* Swap back -- we're dropping the real 3-way that isn't finished yet*/
3473 orig_3way_sub = ANALOG_SUB_REAL;
3475 }
3476 /* Drop the last call and stop the conference */
3477 ast_verb(3, "Dropping three-way call on %s\n", ast_channel_name(p->subs[ANALOG_SUB_THREEWAY].owner));
3481 } else {
3482 /* Lets see what we're up to */
3483 if (((ast_channel_pbx(ast)) || (ast_channel_state(ast) == AST_STATE_UP)) &&
3485 ast_verb(3, "Building conference call with %s and %s\n",
3488 /* Put them in the threeway, and flip */
3492 orig_3way_sub = ANALOG_SUB_REAL;
3493 ast_queue_unhold(p->subs[orig_3way_sub].owner);
3495 } else {
3496 ast_verb(3, "Dumping incomplete call on %s\n", ast_channel_name(p->subs[ANALOG_SUB_THREEWAY].owner));
3498 orig_3way_sub = ANALOG_SUB_REAL;
3503 }
3504 }
3505 ast_channel_unlock(p->subs[orig_3way_sub].owner);
3506 }
3507winkflashdone:
3509 break;
3510 case ANALOG_SIG_EM:
3511 case ANALOG_SIG_EM_E1:
3512 case ANALOG_SIG_FEATD:
3513 case ANALOG_SIG_SF:
3514 case ANALOG_SIG_SFWINK:
3516 case ANALOG_SIG_FXSLS:
3517 case ANALOG_SIG_FXSGS:
3518 if (p->dialing) {
3519 ast_debug(1, "Ignoring wink on channel %d\n", p->channel);
3520 } else {
3521 ast_debug(1, "Got wink in weird state %u on channel %d\n", ast_channel_state(ast), p->channel);
3522 }
3523 break;
3525 switch (p->whichwink) {
3526 case 0:
3527 ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", ast_channel_caller(p->owner)->ani2,
3530 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#",
3534 break;
3535 case 1:
3536 ast_copy_string(p->dop.dialstr, p->finaldial, sizeof(p->dop.dialstr));
3537 break;
3538 case 2:
3539 ast_log(LOG_WARNING, "Received unexpected wink on channel of type ANALOG_SIG_FEATDMF_TA\n");
3540 return NULL;
3541 }
3542 p->whichwink++;
3543 /* Fall through */
3544 case ANALOG_SIG_FEATDMF:
3545 case ANALOG_SIG_E911:
3548 case ANALOG_SIG_FEATB:
3551 case ANALOG_SIG_EMWINK:
3552 /* FGD MF and EMWINK *Must* wait for wink */
3553 if (!ast_strlen_zero(p->dop.dialstr)) {
3554 res = analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop);
3555 if (res) {
3556 p->dop.dialstr[0] = '\0';
3557 return NULL;
3558 } else {
3559 ast_debug(1, "Sent deferred digit string on channel %d: %s\n", p->channel, p->dop.dialstr);
3560 }
3561 }
3562 p->dop.dialstr[0] = '\0';
3563 break;
3564 default:
3565 ast_log(LOG_WARNING, "Don't know how to handle ring/off hook for signalling %d\n", p->sig);
3566 }
3567 break;
3569 if (p->inalarm) break;
3571 break;
3572 }
3573 switch (mysig) {
3574 case ANALOG_SIG_FXSLS: /* only interesting for FXS */
3575 case ANALOG_SIG_FXSGS:
3576 case ANALOG_SIG_FXSKS:
3577 case ANALOG_SIG_EM:
3578 case ANALOG_SIG_EM_E1:
3579 case ANALOG_SIG_EMWINK:
3580 case ANALOG_SIG_FEATD:
3581 case ANALOG_SIG_SF:
3582 case ANALOG_SIG_SFWINK:
3584 if (!ast_strlen_zero(p->dop.dialstr)) {
3585 res = analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop);
3586 if (res) {
3587 p->dop.dialstr[0] = '\0';
3588 return NULL;
3589 } else {
3590 ast_debug(1, "Sent deferred digit string on channel %d: %s\n", p->channel, p->dop.dialstr);
3591 }
3592 }
3593 p->dop.dialstr[0] = '\0';
3595 break;
3596 case ANALOG_SIG_FEATDMF:
3598 case ANALOG_SIG_E911:
3601 case ANALOG_SIG_FEATB:
3604 ast_debug(1, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
3605 break;
3606 default:
3607 break;
3608 }
3609 break;
3611 /*
3612 * If we get a Polarity Switch event, this could be
3613 * due to line seizure, remote end connect or remote end disconnect.
3614 *
3615 * Check to see if we should change the polarity state and
3616 * mark the channel as UP or if this is an indication
3617 * of remote end disconnect.
3618 */
3619
3620 if (p->polarityonanswerdelay > 0) {
3621 /* check if event is not too soon after OffHook or Answer */
3623 switch (ast_channel_state(ast)) {
3624 case AST_STATE_DIALING: /*!< Digits (or equivalent) have been dialed */
3625 case AST_STATE_RINGING: /*!< Remote end is ringing */
3626 if (p->answeronpolarityswitch) {
3627 ast_debug(1, "Answering on polarity switch! channel %d\n", p->channel);
3630 if (p->hanguponpolarityswitch) {
3632 }
3633 } else {
3634 ast_debug(1, "Ignore Answer on polarity switch, channel %d\n", p->channel);
3635 }
3636 break;
3637
3638 case AST_STATE_UP: /*!< Line is up */
3639 case AST_STATE_RING: /*!< Line is ringing */
3640 if (p->hanguponpolarityswitch) {
3641 ast_debug(1, "HangingUp on polarity switch! channel %d\n", p->channel);
3642 ast_queue_control_data(ast, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);
3643 ast_channel_hangupcause_hash_set(ast, cause_code, data_size);
3646 } else {
3647 ast_debug(1, "Ignore Hangup on polarity switch, channel %d\n", p->channel);
3648 }
3649 break;
3650
3651 case AST_STATE_DOWN: /*!< Channel is down and available */
3652 case AST_STATE_RESERVED: /*!< Channel is down, but reserved */
3653 case AST_STATE_OFFHOOK: /*!< Channel is off hook */
3654 case AST_STATE_BUSY: /*!< Line is busy */
3655 case AST_STATE_DIALING_OFFHOOK: /*!< Digits (or equivalent) have been dialed while offhook */
3656 case AST_STATE_PRERING: /*!< Channel has detected an incoming call and is waiting for ring */
3657 default:
3659 ast_debug(1, "Ignoring Polarity switch on channel %d, state %u\n", p->channel, ast_channel_state(ast));
3660 }
3661 break;
3662 }
3663
3664 } else {
3665 /* event is too soon after OffHook or Answer */
3666 switch (ast_channel_state(ast)) {
3667 case AST_STATE_DIALING: /*!< Digits (or equivalent) have been dialed */
3668 case AST_STATE_RINGING: /*!< Remote end is ringing */
3669 if (p->answeronpolarityswitch) {
3670 ast_debug(1, "Polarity switch detected but NOT answering (too close to OffHook event) on channel %d, state %u\n", p->channel, ast_channel_state(ast));
3671 }
3672 break;
3673
3674 case AST_STATE_UP: /*!< Line is up */
3675 case AST_STATE_RING: /*!< Line is ringing */
3676 if (p->hanguponpolarityswitch) {
3677 ast_debug(1, "Polarity switch detected but NOT hanging up (too close to Answer event) on channel %d, state %u\n", p->channel, ast_channel_state(ast));
3678 }
3679 break;
3680
3681 default:
3683 ast_debug(1, "Polarity switch detected (too close to previous event) on channel %d, state %u\n", p->channel, ast_channel_state(ast));
3684 }
3685 break;
3686 }
3687 }
3688 }
3689
3690 /* Added more log_debug information below to provide a better indication of what is going on */
3691 ast_debug(1, "Polarity Reversal event occurred - DEBUG 2: channel %d, state %u, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64 "\n", p->channel, ast_channel_state(ast), p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
3692 break;
3693 default:
3694 ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);
3695 }
3696 return &p->subs[idx].f;
3697}
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_log
Definition: astobj2.c:42
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
Definition: causes.h:121
#define AST_CAUSE_NO_ANSWER
Definition: causes.h:109
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:106
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_rings_set(struct ast_channel *chan, int value)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2570
int ast_channel_rings(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2970
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1258
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
Definition: channel.c:1265
const char * ast_channel_appl(const struct ast_channel *chan)
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1193
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition: channel.c:2500
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
Definition: channel.c:4363
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Definition: channel.c:1243
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
Definition: channel.c:1218
#define AST_CHANNEL_NAME
Definition: channel.h:173
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2487
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2971
@ AST_SOFTHANGUP_EXPLICIT
Definition: channel.h:1168
@ AST_SOFTHANGUP_DEV
Definition: channel.h:1141
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_RING
Definition: channelstate.h:40
@ AST_STATE_DIALING_OFFHOOK
Definition: channelstate.h:44
@ AST_STATE_RINGING
Definition: channelstate.h:41
@ AST_STATE_PRERING
Definition: channelstate.h:45
@ AST_STATE_DOWN
Definition: channelstate.h:36
@ AST_STATE_OFFHOOK
Definition: channelstate.h:38
@ AST_STATE_BUSY
Definition: channelstate.h:43
@ AST_STATE_DIALING
Definition: channelstate.h:39
@ AST_STATE_UP
Definition: channelstate.h:42
@ AST_STATE_RESERVED
Definition: channelstate.h:37
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7407
@ AST_FRAME_NULL
@ AST_FRAME_DTMF_END
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_CONTROL
@ AST_CONTROL_RING
@ AST_CONTROL_OFFHOOK
@ AST_CONTROL_ANSWER
@ AST_CONTROL_RINGING
@ AST_CONTROL_FLASH
@ AST_CONTROL_PVT_CAUSE_CODE
struct ast_frame ast_null_frame
Definition: main/frame.c:79
void ast_callid_threadstorage_auto_clean(ast_callid callid, int callid_created)
Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was...
Definition: logger.c:2353
#define ast_debug(level,...)
Log a DEBUG message.
unsigned int ast_callid
int ast_callid_threadstorage_auto(ast_callid *callid)
Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will b...
Definition: logger.c:2331
#define LOG_ERROR
#define ast_verb(level,...)
#define LOG_NOTICE
#define LOG_WARNING
#define NULL
Definition: resample.c:96
static void analog_publish_channel_alarm_clear(int channel)
Definition: sig_analog.c:2786
static void analog_set_alarm(struct analog_pvt *p, int in_alarm)
Definition: sig_analog.c:903
static int analog_alloc_sub(struct analog_pvt *p, enum analog_sub x)
Definition: sig_analog.c:368
static int analog_send_callerid(struct analog_pvt *p, int cwcid, struct ast_party_caller *caller)
Definition: sig_analog.c:391
static int analog_update_conf(struct analog_pvt *p)
Definition: sig_analog.c:743
static void analog_unlock_private(struct analog_pvt *p)
Definition: sig_analog.c:560
static int analog_unalloc_sub(struct analog_pvt *p, enum analog_sub x)
Definition: sig_analog.c:381
static int analog_is_off_hook(struct analog_pvt *p)
Definition: sig_analog.c:489
static int analog_dial_digits(struct analog_pvt *p, enum analog_sub sub, struct analog_dialoperation *dop)
Definition: sig_analog.c:521
static void analog_set_new_owner(struct analog_pvt *p, struct ast_channel *new_owner)
Definition: sig_analog.c:446
static struct ast_channel * analog_new_ast_channel(struct analog_pvt *p, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
Definition: sig_analog.c:454
static void * __analog_ss_thread(void *data)
Definition: sig_analog.c:1743
static int analog_attempt_transfer(struct analog_pvt *p)
Definition: sig_analog.c:710
static void analog_set_needringing(struct analog_pvt *p, int value)
Definition: sig_analog.c:623
static int analog_check_waitingfordt(struct analog_pvt *p)
Definition: sig_analog.c:926
static int analog_train_echocanceller(struct analog_pvt *p)
Definition: sig_analog.c:481
static void analog_set_dialing(struct analog_pvt *p, int is_dialing)
Definition: sig_analog.c:895
static int analog_ring(struct analog_pvt *p)
Definition: sig_analog.c:497
static int analog_check_for_conference(struct analog_pvt *p)
Definition: sig_analog.c:545
void analog_handle_dtmf(struct analog_pvt *p, struct ast_channel *ast, enum analog_sub idx, struct ast_frame **dest)
Definition: sig_analog.c:1593
static void analog_set_ringtimeout(struct analog_pvt *p, int ringt)
Definition: sig_analog.c:911
static char * analog_event2str(enum analog_event event)
Definition: sig_analog.c:265
static void analog_lock_sub_owner(struct analog_pvt *pvt, enum analog_sub sub_idx)
Definition: sig_analog.c:599
static void analog_lock_private(struct analog_pvt *p)
Definition: sig_analog.c:567
static int analog_have_progressdetect(struct analog_pvt *p)
Definition: sig_analog.c:210
#define analog_get_index(ast, p, nullok)
Definition: sig_analog.c:407
static int analog_confmute(struct analog_pvt *p, int mute)
Definition: sig_analog.c:958
static void analog_answer_polarityswitch(struct analog_pvt *p)
Definition: sig_analog.c:645
static int analog_on_hook(struct analog_pvt *p)
Definition: sig_analog.c:529
static void analog_get_and_handle_alarms(struct analog_pvt *p)
Definition: sig_analog.c:1690
static int analog_stop_callwait(struct analog_pvt *p)
Definition: sig_analog.c:862
static void analog_set_pulsedial(struct analog_pvt *p, int flag)
Definition: sig_analog.c:966
static int analog_has_voicemail(struct analog_pvt *p)
Definition: sig_analog.c:682
static int analog_off_hook(struct analog_pvt *p)
Definition: sig_analog.c:615
static int analog_play_tone(struct analog_pvt *p, enum analog_sub sub, enum analog_tone tone)
Definition: sig_analog.c:438
#define MIN_MS_SINCE_FLASH
Definition: sig_analog.c:64
static int analog_get_event(struct analog_pvt *p)
Definition: sig_analog.c:194
static int analog_set_echocanceller(struct analog_pvt *p, int enable)
Definition: sig_analog.c:473
static void analog_set_inthreeway(struct analog_pvt *p, enum analog_sub sub, int inthreeway)
Definition: sig_analog.c:982
#define POLARITY_IDLE
Definition: sig_analog.c:62
static int analog_check_confirmanswer(struct analog_pvt *p)
Definition: sig_analog.c:942
static int analog_is_dialing(struct analog_pvt *p, enum analog_sub index)
Definition: sig_analog.c:690
static void analog_cancel_cidspill(struct analog_pvt *p)
Definition: sig_analog.c:951
static void analog_swap_subs(struct analog_pvt *p, enum analog_sub a, enum analog_sub b)
Definition: sig_analog.c:348
#define POLARITY_REV
Definition: sig_analog.c:63
static int analog_get_sub_fd(struct analog_pvt *p, enum analog_sub sub)
Definition: sig_analog.c:1705
static void analog_start_polarityswitch(struct analog_pvt *p)
Definition: sig_analog.c:639
@ ANALOG_DIALMODE_PULSE
Definition: sig_analog.h:121
@ ANALOG_DIALMODE_BOTH
Definition: sig_analog.h:120
@ ANALOG_EVENT_HOOKCOMPLETE
Definition: sig_analog.h:89
@ ANALOG_EVENT_DTMFDOWN
Definition: sig_analog.h:104
@ ANALOG_EVENT_RINGEROFF
Definition: sig_analog.h:88
@ ANALOG_EVENT_PULSE_START
Definition: sig_analog.h:90
@ ANALOG_EVENT_TX_CED_DETECTED
Definition: sig_analog.h:97
@ ANALOG_EVENT_RINGBEGIN
Definition: sig_analog.h:92
@ ANALOG_EVENT_ONHOOK
Definition: sig_analog.h:81
@ ANALOG_EVENT_EC_DISABLED
Definition: sig_analog.h:93
@ ANALOG_EVENT_WINKFLASH
Definition: sig_analog.h:83
@ ANALOG_EVENT_PULSEDIGIT
Definition: sig_analog.h:103
@ ANALOG_EVENT_RINGERON
Definition: sig_analog.h:87
@ ANALOG_EVENT_RX_CED_DETECTED
Definition: sig_analog.h:98
@ ANALOG_EVENT_ALARM
Definition: sig_analog.h:84
@ ANALOG_EVENT_DIALCOMPLETE
Definition: sig_analog.h:86
@ ANALOG_EVENT_EC_NLP_ENABLED
Definition: sig_analog.h:100
@ ANALOG_EVENT_POLARITY
Definition: sig_analog.h:91
@ ANALOG_EVENT_DTMFUP
Definition: sig_analog.h:105
@ ANALOG_EVENT_EC_NLP_DISABLED
Definition: sig_analog.h:99
@ ANALOG_EVENT_RINGOFFHOOK
Definition: sig_analog.h:82
@ ANALOG_EVENT_NOALARM
Definition: sig_analog.h:85
@ ANALOG_DIAL_OP_REPLACE
Definition: sig_analog.h:134
analog_sub
Definition: sig_analog.h:108
@ ANALOG_SUB_THREEWAY
Definition: sig_analog.h:111
@ ANALOG_SUB_REAL
Definition: sig_analog.h:109
@ ANALOG_SUB_CALLWAIT
Definition: sig_analog.h:110
@ ANALOG_SIG_FEATD
Definition: sig_analog.h:56
@ ANALOG_SIG_FEATDMF_TA
Definition: sig_analog.h:66
@ ANALOG_SIG_FGC_CAMAMF
Definition: sig_analog.h:60
@ ANALOG_SIG_FXOLS
Definition: sig_analog.h:47
@ ANALOG_SIG_FEATDMF
Definition: sig_analog.h:57
@ ANALOG_SIG_EM_E1
Definition: sig_analog.h:55
@ ANALOG_SIG_EMWINK
Definition: sig_analog.h:53
@ ANALOG_SIG_FXOKS
Definition: sig_analog.h:48
@ ANALOG_SIG_SF
Definition: sig_analog.h:63
@ ANALOG_SIG_FGC_CAMA
Definition: sig_analog.h:59
@ ANALOG_SIG_EM
Definition: sig_analog.h:54
@ ANALOG_SIG_FXOGS
Definition: sig_analog.h:49
@ ANALOG_SIG_SF_FEATB
Definition: sig_analog.h:67
@ ANALOG_SIG_SF_FEATDMF
Definition: sig_analog.h:65
@ ANALOG_SIG_SFWINK
Definition: sig_analog.h:62
@ ANALOG_SIG_E911
Definition: sig_analog.h:58
@ ANALOG_SIG_FEATB
Definition: sig_analog.h:61
@ ANALOG_SIG_SF_FEATD
Definition: sig_analog.h:64
@ ANALOG_TONE_CONGESTION
Definition: sig_analog.h:73
@ ANALOG_TONE_DIALTONE
Definition: sig_analog.h:74
@ ANALOG_TONE_DIALRECALL
Definition: sig_analog.h:75
@ ANALOG_TONE_STUTTER
Definition: sig_analog.h:72
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
char dialdest[256]
Definition: sig_analog.h:364
unsigned int dahditrcallerid
Definition: sig_analog.h:296
struct analog_dialoperation dop
Definition: sig_analog.h:280
int polarityonanswerdelay
Definition: sig_analog.h:325
char cid_num[AST_MAX_EXTENSION]
Definition: sig_analog.h:329
char * origcid_name
Definition: sig_analog.h:370
struct timeval flashtime
Definition: sig_analog.h:366
unsigned int outgoing
Definition: sig_analog.h:341
int whichwink
Definition: sig_analog.h:367
char * origcid_num
Definition: sig_analog.h:369
enum analog_sigtype outsigmod
Definition: sig_analog.h:321
unsigned int answeronpolarityswitch
Definition: sig_analog.h:291
unsigned int threewaycalling
Definition: sig_analog.h:304
int echotraining
Definition: sig_analog.h:323
int msgstate
-1 = unknown, 0 = no messages, 1 = new messages available
Definition: sig_analog.h:284
int onhooktime
Definition: sig_analog.h:281
struct timeval polaritydelaytv
Definition: sig_analog.h:363
unsigned int hanguponpolarityswitch
Definition: sig_analog.h:297
int cidrings
Definition: sig_analog.h:360
unsigned int callwaitcas
TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
Definition: sig_analog.h:349
unsigned int echobreak
Definition: sig_analog.h:339
unsigned int cshactive
Definition: sig_analog.h:335
struct ast_channel * owner
Definition: sig_analog.h:277
enum analog_sigtype sig
Definition: sig_analog.h:273
unsigned int dialednone
Definition: sig_analog.h:336
char echorest[20]
Definition: sig_analog.h:361
int ringt_base
Definition: sig_analog.h:378
int fxsoffhookstate
Definition: sig_analog.h:282
enum analog_dialmode dialmode
Definition: sig_analog.h:322
struct analog_subchannel subs[3]
Definition: sig_analog.h:279
char finaldial[64]
Definition: sig_analog.h:368
unsigned int transfer
Definition: sig_analog.h:306
unsigned int transfertobusy
Definition: sig_analog.h:307
unsigned int inalarm
Definition: sig_analog.h:342
char cid_name[AST_MAX_EXTENSION]
Definition: sig_analog.h:330
unsigned int calledsubscriberheld
Definition: sig_analog.h:292
char mohsuggest[MAX_MUSICCLASS]
Definition: sig_analog.h:328
int polarity
Definition: sig_analog.h:362
struct ast_channel * ss_astchan
Definition: sig_analog.h:374
unsigned int dialing
Definition: sig_analog.h:337
struct ast_party_caller caller
Definition: sig_analog.h:357
struct ast_frame f
Definition: sig_analog.h:265
unsigned int inthreeway
Definition: sig_analog.h:266
struct ast_channel * owner
Definition: sig_analog.h:264
Main Channel structure associated with a channel.
char chan_name[AST_CHANNEL_NAME]
Data structure associated with a single frame of data.
union ast_frame::@228 data
struct ast_frame_subclass subclass
enum ast_frame_type frametype
const char * src
struct ast_party_id id
Caller party ID.
Definition: channel.h:422
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:435
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:429
struct ast_party_name name
Subscriber name.
Definition: channel.h:342
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:344
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:281
char * str
Subscriber name (Malloced)
Definition: channel.h:266
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:299
char * str
Subscriber phone number (Malloced)
Definition: channel.h:293
static struct test_val c
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
#define ast_pthread_create_detached(a, b, c, d)
Definition: utils.h:588

References __analog_ss_thread(), analog_alloc_sub(), analog_answer_polarityswitch(), analog_attempt_transfer(), analog_cancel_cidspill(), analog_check_confirmanswer(), analog_check_for_conference(), analog_check_waitingfordt(), analog_confmute(), analog_dial_digits(), ANALOG_DIAL_OP_REPLACE, ANALOG_DIALMODE_BOTH, ANALOG_DIALMODE_PULSE, analog_event2str(), ANALOG_EVENT_ALARM, ANALOG_EVENT_DIALCOMPLETE, ANALOG_EVENT_DTMFDOWN, ANALOG_EVENT_DTMFUP, ANALOG_EVENT_EC_DISABLED, ANALOG_EVENT_EC_NLP_DISABLED, ANALOG_EVENT_EC_NLP_ENABLED, ANALOG_EVENT_HOOKCOMPLETE, ANALOG_EVENT_NOALARM, ANALOG_EVENT_ONHOOK, ANALOG_EVENT_POLARITY, ANALOG_EVENT_PULSE_START, ANALOG_EVENT_PULSEDIGIT, ANALOG_EVENT_RINGBEGIN, ANALOG_EVENT_RINGEROFF, ANALOG_EVENT_RINGERON, ANALOG_EVENT_RINGOFFHOOK, ANALOG_EVENT_RX_CED_DETECTED, ANALOG_EVENT_TX_CED_DETECTED, ANALOG_EVENT_WINKFLASH, analog_get_and_handle_alarms(), analog_get_event(), analog_get_index, analog_get_sub_fd(), analog_handle_dtmf(), analog_has_voicemail(), analog_have_progressdetect(), analog_is_dialing(), analog_is_off_hook(), analog_lock_private(), analog_lock_sub_owner(), analog_new_ast_channel(), analog_off_hook(), analog_on_hook(), analog_play_tone(), analog_publish_channel_alarm_clear(), analog_ring(), analog_send_callerid(), analog_set_alarm(), analog_set_dialing(), analog_set_echocanceller(), analog_set_inthreeway(), analog_set_needringing(), analog_set_new_owner(), analog_set_pulsedial(), analog_set_ringtimeout(), ANALOG_SIG_E911, ANALOG_SIG_EM, ANALOG_SIG_EM_E1, ANALOG_SIG_EMWINK, ANALOG_SIG_FEATB, ANALOG_SIG_FEATD, ANALOG_SIG_FEATDMF, ANALOG_SIG_FEATDMF_TA, ANALOG_SIG_FGC_CAMA, ANALOG_SIG_FGC_CAMAMF, ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, ANALOG_SIG_FXSGS, ANALOG_SIG_FXSKS, ANALOG_SIG_FXSLS, ANALOG_SIG_SF, ANALOG_SIG_SF_FEATB, ANALOG_SIG_SF_FEATD, ANALOG_SIG_SF_FEATDMF, ANALOG_SIG_SFWINK, analog_start_polarityswitch(), analog_stop_callwait(), ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY, analog_swap_subs(), ANALOG_TONE_CONGESTION, ANALOG_TONE_DIALRECALL, ANALOG_TONE_DIALTONE, ANALOG_TONE_STUTTER, analog_train_echocanceller(), analog_unalloc_sub(), analog_unlock_private(), analog_update_conf(), ast_party_caller::ani, ast_party_caller::ani2, analog_pvt::answeronpolarityswitch, ast_alloca, ast_callid_threadstorage_auto(), ast_callid_threadstorage_auto_clean(), ast_control_pvt_cause_code::ast_cause, AST_CAUSE_NETWORK_OUT_OF_ORDER, AST_CAUSE_NO_ANSWER, AST_CAUSE_NORMAL_CLEARING, ast_channel_appl(), ast_channel_caller(), ast_channel_hangupcause_hash_set(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_name(), ast_channel_pbx(), ast_channel_rings(), ast_channel_rings_set(), ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_FLASH, AST_CONTROL_OFFHOOK, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_RING, AST_CONTROL_RINGING, ast_copy_string(), ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_NULL, ast_hangup(), ast_log, ast_null_frame, ast_pthread_create_detached, ast_queue_control(), ast_queue_control_data(), ast_queue_hangup_with_cause(), ast_queue_hold(), ast_queue_unhold(), ast_setstate(), ast_softhangup(), AST_SOFTHANGUP_DEV, AST_SOFTHANGUP_EXPLICIT, ast_softhangup_nolock(), AST_STATE_BUSY, AST_STATE_DIALING, AST_STATE_DIALING_OFFHOOK, AST_STATE_DOWN, AST_STATE_OFFHOOK, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_strdup, ast_strlen_zero(), ast_tvdiff_ms(), ast_tvnow(), ast_verb, c, analog_pvt::calledsubscriberheld, analog_pvt::caller, analog_pvt::callwaitcas, ast_control_pvt_cause_code::chan_name, analog_pvt::channel, analog_pvt::cid_name, analog_pvt::cid_num, analog_pvt::cidrings, ast_control_pvt_cause_code::code, analog_pvt::cshactive, analog_pvt::dahditrcallerid, ast_frame::data, ast_frame::datalen, analog_pvt::dialdest, analog_pvt::dialednone, analog_pvt::dialing, analog_pvt::dialmode, analog_dialoperation::dialstr, analog_pvt::dop, analog_pvt::echobreak, analog_pvt::echorest, analog_pvt::echotraining, analog_subchannel::f, analog_pvt::finaldial, analog_pvt::flashtime, ast_frame::frametype, analog_pvt::fxsoffhookstate, analog_pvt::hanguponpolarityswitch, ast_party_caller::id, analog_pvt::inalarm, ast_frame_subclass::integer, analog_subchannel::inthreeway, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_frame::mallocd, MIN_MS_SINCE_FLASH, analog_pvt::mohsuggest, analog_pvt::msgstate, ast_party_id::name, NULL, ast_party_id::number, ast_frame::offset, analog_pvt::onhooktime, analog_dialoperation::op, analog_pvt::origcid_name, analog_pvt::origcid_num, analog_pvt::outgoing, analog_pvt::outsigmod, analog_subchannel::owner, analog_pvt::owner, analog_pvt::polarity, POLARITY_IDLE, POLARITY_REV, analog_pvt::polaritydelaytv, analog_pvt::polarityonanswerdelay, ast_frame::ptr, analog_pvt::ringt_base, S_COR, ast_frame::samples, analog_pvt::sig, ast_frame::src, analog_pvt::ss_astchan, ast_party_name::str, ast_party_number::str, ast_frame::subclass, analog_pvt::subs, analog_pvt::threewaycalling, analog_pvt::transfer, analog_pvt::transfertobusy, ast_party_name::valid, ast_party_number::valid, and analog_pvt::whichwink.

Referenced by analog_exception().

◆ __analog_ss_thread()

static void * __analog_ss_thread ( void *  data)
static

Definition at line 1743 of file sig_analog.c.

1744{
1745 struct analog_pvt *p = data;
1746 struct ast_channel *chan = p->ss_astchan;
1747 char exten[AST_MAX_EXTENSION] = "";
1748 char exten2[AST_MAX_EXTENSION] = "";
1749 char dtmfcid[300];
1750 char dtmfbuf[300];
1751 char namebuf[ANALOG_MAX_CID];
1752 char numbuf[ANALOG_MAX_CID];
1753 char *name = NULL, *number = NULL;
1754 int flags = 0;
1755 struct ast_smdi_md_message *smdi_msg = NULL;
1756 int timeout;
1757 int getforward = 0;
1758 char *s1, *s2;
1759 int len = 0;
1760 int res;
1761 int idx;
1762 ast_callid callid;
1763 RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
1764 const char *pickupexten;
1765
1767
1768 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
1769
1770 ast_assert(chan != NULL);
1771
1772 if ((callid = ast_channel_callid(chan))) {
1774 }
1775
1776 /* in the bizarre case where the channel has become a zombie before we
1777 even get started here, abort safely
1778 */
1779 if (!ast_channel_tech_pvt(chan)) {
1780 ast_log(LOG_WARNING, "Channel became a zombie before simple switch could be started (%s)\n", ast_channel_name(chan));
1781 ast_hangup(chan);
1782 goto quit;
1783 }
1784
1785 ast_verb(3, "Starting simple switch on '%s'\n", ast_channel_name(chan));
1786 idx = analog_get_index(chan, p, 0);
1787 if (idx < 0) {
1788 ast_hangup(chan);
1789 goto quit;
1790 }
1791
1792 ast_channel_lock(chan);
1793 pickup_cfg = ast_get_chan_features_pickup_config(chan);
1794 if (!pickup_cfg) {
1795 ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
1796 pickupexten = "";
1797 } else {
1798 pickupexten = ast_strdupa(pickup_cfg->pickupexten);
1799 }
1800 ast_channel_unlock(chan);
1801
1803 switch (p->sig) {
1804 case ANALOG_SIG_FEATD:
1805 case ANALOG_SIG_FEATDMF:
1807 case ANALOG_SIG_E911:
1809 case ANALOG_SIG_FEATB:
1810 case ANALOG_SIG_EMWINK:
1814 case ANALOG_SIG_SFWINK:
1815 if (analog_wink(p, idx))
1816 goto quit;
1817 /* Fall through */
1818 case ANALOG_SIG_EM:
1819 case ANALOG_SIG_EM_E1:
1820 case ANALOG_SIG_SF:
1822 res = analog_play_tone(p, idx, -1);
1823
1825
1826 /* set digit mode appropriately */
1827 if (ANALOG_NEED_MFDETECT(p)) {
1829 } else {
1831 }
1832
1833 memset(dtmfbuf, 0, sizeof(dtmfbuf));
1834 /* Wait for the first digit only if immediate=no */
1835 if (!p->immediate) {
1836 /* Wait for the first digit (up to 5 seconds). */
1837 res = ast_waitfordigit(chan, 5000);
1838 } else {
1839 res = 0;
1840 }
1841 if (res > 0) {
1842 /* save first char */
1843 dtmfbuf[0] = res;
1844 switch (p->sig) {
1845 case ANALOG_SIG_FEATD:
1847 res = analog_my_getsigstr(chan, dtmfbuf + 1, "*", 3000);
1848 if (res > 0) {
1849 res = analog_my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf), "*", 3000);
1850 }
1851 if (res < 1) {
1853 }
1854 break;
1856 res = analog_my_getsigstr(chan, dtmfbuf + 1, "#", 3000);
1857 if (res < 1) {
1859 }
1860 if (analog_wink(p, idx)) {
1861 goto quit;
1862 }
1863 dtmfbuf[0] = 0;
1864 /* Wait for the first digit (up to 5 seconds). */
1865 res = ast_waitfordigit(chan, 5000);
1866 if (res <= 0) {
1867 break;
1868 }
1869 dtmfbuf[0] = res;
1870 /* fall through intentionally */
1871 case ANALOG_SIG_FEATDMF:
1872 case ANALOG_SIG_E911:
1875 res = analog_my_getsigstr(chan, dtmfbuf + 1, "#", 3000);
1876 /* if international caca, do it again to get real ANO */
1877 if ((p->sig == ANALOG_SIG_FEATDMF) && (dtmfbuf[1] != '0')
1878 && (strlen(dtmfbuf) != 14)) {
1879 if (analog_wink(p, idx)) {
1880 goto quit;
1881 }
1882 dtmfbuf[0] = 0;
1883 /* Wait for the first digit (up to 5 seconds). */
1884 res = ast_waitfordigit(chan, 5000);
1885 if (res <= 0) {
1886 break;
1887 }
1888 dtmfbuf[0] = res;
1889 res = analog_my_getsigstr(chan, dtmfbuf + 1, "#", 3000);
1890 }
1891 if (res > 0) {
1892 /* if E911, take off hook */
1893 if (p->sig == ANALOG_SIG_E911) {
1894 analog_off_hook(p);
1895 }
1896 if (p->sig != ANALOG_SIG_FGC_CAMAMF) {
1897 /* CAMA signaling (CAMA and CAMAMF) are handled in an if block below.
1898 * Everything else, process here. */
1899 res = analog_my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf), "#", 3000);
1900 }
1901 }
1902 if (res < 1) {
1904 }
1905 break;
1906 case ANALOG_SIG_FEATB:
1908 res = analog_my_getsigstr(chan, dtmfbuf + 1, "#", 3000);
1909 if (res < 1) {
1911 }
1912 break;
1913 case ANALOG_SIG_EMWINK:
1914 /* if we received a '*', we are actually receiving Feature Group D
1915 dial syntax, so use that mode; otherwise, fall through to normal
1916 mode
1917 */
1918 if (res == '*') {
1919 res = analog_my_getsigstr(chan, dtmfbuf + 1, "*", 3000);
1920 if (res > 0) {
1921 res = analog_my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf), "*", 3000);
1922 }
1923 if (res < 1) {
1925 }
1926 break;
1927 }
1928 default:
1929 /* If we got the first digit, get the rest */
1930 len = 1;
1931 dtmfbuf[len] = '\0';
1932 while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, ast_channel_context(chan), dtmfbuf, 1, p->cid_num)) {
1933 if (ast_exists_extension(chan, ast_channel_context(chan), dtmfbuf, 1, p->cid_num)) {
1934 timeout = analog_get_matchdigit_timeout(p);
1935 } else {
1936 timeout = analog_get_interdigit_timeout(p);
1937 }
1938 res = ast_waitfordigit(chan, timeout);
1939 if (res < 0) {
1940 ast_debug(1, "waitfordigit returned < 0...\n");
1941 ast_hangup(chan);
1942 goto quit;
1943 } else if (res) {
1944 dtmfbuf[len++] = res;
1945 dtmfbuf[len] = '\0';
1946 } else {
1947 break;
1948 }
1949 }
1950 break;
1951 }
1952 }
1953 if (res == -1) {
1954 ast_log(LOG_WARNING, "getdtmf on channel %d: %s\n", p->channel, strerror(errno));
1955 ast_hangup(chan);
1956 goto quit;
1957 } else if (res < 0) {
1958 ast_debug(1, "Got hung up before digits finished\n");
1959 ast_hangup(chan);
1960 goto quit;
1961 }
1962
1963 if (p->sig == ANALOG_SIG_FGC_CAMA || p->sig == ANALOG_SIG_FGC_CAMAMF) {
1964 /* This if block is where we process ANI for CAMA */
1965
1966 char anibuf[100];
1967 struct ast_party_caller *caller;
1968
1969 /* cnoffset is the point at which we pull the calling number out
1970 * of anibuf. Must be the number of ani_info_digits + 1 to account
1971 * for the KP, which is considered a digit. */
1972
1973 /* The 1XB with ANI-B will send a full 10 digits
1974 * or 2 digits in case of ANI failure.
1975 * (CD-95811-01 Section II, page 10)
1976 * 10 digit string example: *08320123#
1977 * 2 digit string example: *2
1978 * KP (*) and ST (#) are considered to be digits */
1979
1980 int cnoffset = p->ani_info_digits + 1;
1981 ast_debug(1, "cnoffset: %d\n", cnoffset);
1982
1983 /* This is how long to wait before the wink to start ANI spill
1984 * Pulled from chan_dahdi.conf, default is 1000ms */
1985 if (ast_safe_sleep(chan,p->ani_wink_time) == -1) {
1986 ast_hangup(chan);
1987 goto quit;
1988 }
1989 analog_off_hook(p);
1990 ast_debug(1, "Sent wink to signal ANI start\n");
1992
1993 /* ani_timeout is configured in chan_dahdi.conf. default is 10000ms.
1994 * ST, STP, ST2P, ST3P can all signal transmission complete, regardless of timeout */
1995 res = analog_my_getsigstr(chan, anibuf, "#ABC", p->ani_timeout);
1996
1997 /* so we can work with the ani buffer */
1998 pbx_builtin_setvar_helper(chan, "ANIBUF", anibuf);
1999
2000 /* as long as we get a terminating pulse OR the length of ANI buffer is at least >=2, we can treat
2001 * this as a complete spill for the purposes of setting anistart */
2002 if ((res > 0) || (strlen(anibuf) >= 2)) {
2003 char anistart[2] = "X";
2004 char f[101] = {0};
2005 if (strchr("#ABC", anibuf[strlen(anibuf) - 1])) {
2006 anistart[0] = anibuf[strlen(anibuf) - 1];
2007 anibuf[strlen(anibuf) - 1] = 0;
2008 }
2009 ast_set_callerid(chan, anibuf + cnoffset, NULL, anibuf + cnoffset);
2010
2011 caller = ast_channel_caller(chan);
2012 strncpy(f, &(anibuf[1]), MIN((int)(p->ani_info_digits), sizeof(f)-1));
2013 caller->ani2 = atoi(f);
2014
2015 anibuf[cnoffset] = 0;
2016
2017 /* so we can work with the different start pulses as used in ANI-D */
2018 pbx_builtin_setvar_helper(chan, "ANISTART", anistart);
2019 /* so we can use our ANI INFO digits in our dialplan */
2020 pbx_builtin_setvar_helper(chan, "ANI2", anibuf + 1);
2021 }
2023 }
2024
2025 ast_copy_string(exten, dtmfbuf, sizeof(exten));
2026 if (ast_strlen_zero(exten)) {
2027 ast_copy_string(exten, "s", sizeof(exten));
2028 }
2029 if (p->sig == ANALOG_SIG_FEATD || p->sig == ANALOG_SIG_EMWINK) {
2030 /* Look for Feature Group D on all E&M Wink and Feature Group D trunks */
2031 if (exten[0] == '*') {
2032 char *stringp=NULL;
2033 ast_copy_string(exten2, exten, sizeof(exten2));
2034 /* Parse out extension and callerid */
2035 stringp=exten2 +1;
2036 s1 = strsep(&stringp, "*");
2037 s2 = strsep(&stringp, "*");
2038 if (s2) {
2039 if (!ast_strlen_zero(p->cid_num)) {
2040 ast_set_callerid(chan, p->cid_num, NULL, p->cid_num);
2041 } else {
2042 ast_set_callerid(chan, s1, NULL, s1);
2043 }
2044 ast_copy_string(exten, s2, sizeof(exten));
2045 } else {
2046 ast_copy_string(exten, s1, sizeof(exten));
2047 }
2048 } else if (p->sig == ANALOG_SIG_FEATD) {
2049 ast_log(LOG_WARNING, "Got a non-Feature Group D input on channel %d. Assuming E&M Wink instead\n", p->channel);
2050 }
2051 }
2052 if ((p->sig == ANALOG_SIG_FEATDMF) || (p->sig == ANALOG_SIG_FEATDMF_TA)) {
2053 if (exten[0] == '*') {
2054 char *stringp=NULL;
2055 struct ast_party_caller *caller;
2056
2057 ast_copy_string(exten2, exten, sizeof(exten2));
2058 /* Parse out extension and callerid */
2059 stringp=exten2 +1;
2060 s1 = strsep(&stringp, "#");
2061 s2 = strsep(&stringp, "#");
2062 if (s2) {
2063 if (!ast_strlen_zero(p->cid_num)) {
2064 ast_set_callerid(chan, p->cid_num, NULL, p->cid_num);
2065 } else {
2066 if (*(s1 + 2)) {
2067 ast_set_callerid(chan, s1 + 2, NULL, s1 + 2);
2068 }
2069 }
2070 ast_copy_string(exten, s2 + 1, sizeof(exten));
2071 } else {
2072 ast_copy_string(exten, s1 + 2, sizeof(exten));
2073 }
2074
2075 /* The first two digits are ani2 information. */
2076 caller = ast_channel_caller(chan);
2077 s1[2] = '\0';
2078 caller->ani2 = atoi(s1);
2079 } else {
2080 ast_log(LOG_WARNING, "Got a non-Feature Group D input on channel %d. Assuming E&M Wink instead\n", p->channel);
2081 }
2082 }
2083 if ((p->sig == ANALOG_SIG_E911) || (p->sig == ANALOG_SIG_FGC_CAMAMF)) {
2084 if (exten[0] == '*') {
2085 char *stringp=NULL;
2086 ast_copy_string(exten2, exten, sizeof(exten2));
2087 /* Parse out extension and callerid */
2088 stringp=exten2 +1;
2089 s1 = strsep(&stringp, "#");
2090 s2 = strsep(&stringp, "#");
2091 if (s2 && (*(s2 + 1) == '0')) {
2092 if (*(s2 + 2)) {
2093 ast_set_callerid(chan, s2 + 2, NULL, s2 + 2);
2094 }
2095 }
2096 if (s1) {
2097 ast_copy_string(exten, s1, sizeof(exten));
2098 } else {
2099 ast_copy_string(exten, "911", sizeof(exten));
2100 }
2101 } else {
2102 ast_log(LOG_WARNING, "A KP was expected to start signaling for Feature Group C CAMA-MF, but we got something else. Received: %s on channel %d\n", exten, p->channel);
2103 }
2104 }
2105 if (p->sig == ANALOG_SIG_FEATB) {
2106 if (exten[0] == '*') {
2107 char *stringp=NULL;
2108 ast_copy_string(exten2, exten, sizeof(exten2));
2109 /* Parse out extension and callerid */
2110 stringp=exten2 +1;
2111 s1 = strsep(&stringp, "#");
2112 ast_copy_string(exten, exten2 + 1, sizeof(exten));
2113 } else {
2114 ast_log(LOG_WARNING, "A KP was expected to start signaling for Feature Group B, but we got something else. Received: %s on channel %d\n", exten, p->channel);
2115 }
2116 }
2117 if ((p->sig == ANALOG_SIG_FEATDMF) || (p->sig == ANALOG_SIG_FEATDMF_TA)) {
2118 analog_wink(p, idx);
2119 /*
2120 * Some switches require a minimum guard time between the last
2121 * FGD wink and something that answers immediately. This
2122 * ensures it.
2123 */
2124 if (ast_safe_sleep(chan, 100)) {
2125 ast_hangup(chan);
2126 goto quit;
2127 }
2128 }
2130
2132
2133 if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1,
2134 ast_channel_caller(chan)->id.number.valid ? ast_channel_caller(chan)->id.number.str : NULL)) {
2135 ast_channel_exten_set(chan, exten);
2137 res = ast_pbx_run(chan);
2138 if (res) {
2139 ast_log(LOG_WARNING, "PBX exited non-zero\n");
2141 }
2142 goto quit;
2143 } else {
2144 ast_verb(3, "Unknown extension '%s' in context '%s' requested\n", exten, ast_channel_context(chan));
2145 sleep(2);
2146 res = analog_play_tone(p, idx, ANALOG_TONE_INFO);
2147 if (res < 0) {
2148 ast_log(LOG_WARNING, "Unable to start special tone on %d\n", p->channel);
2149 } else {
2150 sleep(1);
2151 }
2152 res = ast_streamfile(chan, "ss-noservice", ast_channel_language(chan));
2153 if (res >= 0) {
2154 ast_waitstream(chan, "");
2155 }
2157 ast_hangup(chan);
2158 goto quit;
2159 }
2160 break;
2161 case ANALOG_SIG_FXOLS:
2162 case ANALOG_SIG_FXOGS:
2163 case ANALOG_SIG_FXOKS:
2164 /* Set our default presentation.
2165 * This is necessary because the presentation for each call is independent
2166 * (though the default may be the same).
2167 * For example, if hidecallerid=yes and somebody makes a call with *82,
2168 * then makes a 3-way call, the presentation for the 2nd call should still
2169 * be blocked, unless that also had a *82.
2170 * For this reason, setting hidecallerid = permhidecallerid on hangup
2171 * is NOT sufficient, as the *82 from the first call could "leak" into
2172 * subsequent ones made before a hangup, improperly leaking a number
2173 * that should have been hidden.
2174 */
2176
2177 /* Read the first digit */
2178 timeout = analog_get_firstdigit_timeout(p);
2179 /* If starting a threeway call, never timeout on the first digit so someone
2180 * can use flash-hook as a "hold" feature...
2181 * ...Unless three-way dial tone should time out to silence, in which case the default suffices. */
2183 timeout = INT_MAX;
2184 }
2185 while (len < AST_MAX_EXTENSION-1) {
2186 int is_exten_parking = 0;
2187
2188 /* Read digit unless it's supposed to be immediate, in which case the
2189 only answer is 's' */
2190 if (p->immediate) {
2191 res = 's';
2192 } else {
2193 res = ast_waitfordigit(chan, timeout);
2194 }
2195 timeout = 0;
2196 if (res < 0) {
2197 ast_debug(1, "waitfordigit returned < 0...\n");
2198 res = analog_play_tone(p, idx, -1);
2199 ast_hangup(chan);
2200 goto quit;
2201 } else if (res) {
2202 ast_debug(1,"waitfordigit returned '%c' (%d), timeout = %d\n", res, res, timeout);
2203 exten[len++]=res;
2204 exten[len] = '\0';
2205 }
2206 if (!ast_ignore_pattern(ast_channel_context(chan), exten)) {
2207 analog_play_tone(p, idx, -1);
2208 } else {
2210 }
2212 is_exten_parking = ast_parking_is_exten_park(ast_channel_context(chan), exten);
2213 }
2214 if (p->lastnumredial && !strcmp(exten, "##") && !ast_exists_extension(chan, ast_channel_context(chan), "##", 1, p->cid_num)) {
2215 /* Last Number Redial */
2216 if (!ast_strlen_zero(p->lastexten)) {
2217 ast_verb(4, "Redialing last number dialed on channel %d\n", p->channel);
2218 ast_copy_string(exten, p->lastexten, sizeof(exten));
2219 } else {
2220 ast_verb(3, "Last Number Redial not possible on channel %d (no saved number)\n", p->channel);
2223 ast_hangup(chan);
2224 goto quit;
2225 }
2226 }
2227 if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num) && !is_exten_parking) {
2228 if (!res || !ast_matchmore_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num)) {
2229 if (getforward) {
2230 /* Record this as the forwarding extension */
2231 ast_copy_string(p->call_forward, exten, sizeof(p->call_forward));
2232 ast_verb(3, "Setting call forward to '%s' on channel %d\n", p->call_forward, p->channel);
2234 if (res) {
2235 break;
2236 }
2237 usleep(500000);
2238 res = analog_play_tone(p, idx, -1);
2239 sleep(1);
2240 memset(exten, 0, sizeof(exten));
2242 len = 0;
2243 getforward = 0;
2244 } else {
2245 res = analog_play_tone(p, idx, -1);
2246 ast_channel_lock(chan);
2247 ast_channel_exten_set(chan, exten);
2248
2249 /* Save the last number dialed, for Last Number Redial. */
2250 if (!p->immediate) {
2251 ast_copy_string(p->lastexten, exten, sizeof(p->lastexten));
2252 }
2253
2254 /* Properly set the presentation.
2255 * We need to do this here as well, because p->hidecallerid might be set
2256 * due to permanent blocking, not star-67/star-82 usage. */
2257 if (p->hidecallerid) {
2260 } else {
2263 }
2264
2266 ast_channel_unlock(chan);
2268 res = ast_pbx_run(chan);
2269 if (res) {
2270 ast_log(LOG_WARNING, "PBX exited non-zero\n");
2272 }
2273 goto quit;
2274 }
2275 } else {
2276 /* It's a match, but they just typed a digit, and there is an ambiguous match,
2277 so just set the timeout to analog_matchdigittimeout and wait some more */
2278 timeout = analog_get_matchdigit_timeout(p);
2279 }
2280 } else if (res == 0) {
2281 ast_debug(1, "not enough digits (and no ambiguous match)...\n");
2282 if (p->threewaysilenthold) {
2283 ast_debug(1, "Nothing dialed at three-way dial tone, timed out to silent hold\n");
2284 } else {
2286 }
2288 ast_hangup(chan);
2289 goto quit;
2290 } else if (p->callwaiting && !strcmp(exten, "*70")) {
2291 ast_verb(3, "Disabling call waiting on %s\n", ast_channel_name(chan));
2292 /* Disable call waiting if enabled */
2295 if (res) {
2296 ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n",
2297 ast_channel_name(chan), strerror(errno));
2298 }
2299 len = 0;
2300 memset(exten, 0, sizeof(exten));
2301 timeout = analog_get_firstdigit_timeout(p);
2302
2303 } else if (!strcmp(exten, pickupexten)) {
2304 /* Scan all channels and see if there are any
2305 * ringing channels that have call groups
2306 * that equal this channel's pickup group
2307 */
2308 if (idx == ANALOG_SUB_REAL) {
2309 /* Switch us from Third call to Call Wait */
2310 if (p->subs[ANALOG_SUB_THREEWAY].owner) {
2311 /* If you make a threeway call and then *8# a call, it should actually
2312 look like a callwait */
2316 }
2318 if (ast_pickup_call(chan)) {
2319 ast_debug(1, "No call pickup possible...\n");
2322 }
2323 ast_hangup(chan);
2324 goto quit;
2325 } else {
2326 ast_log(LOG_WARNING, "Huh? Got *8# on call not on real\n");
2327 ast_hangup(chan);
2328 goto quit;
2329 }
2330 /* While the DMS-100 allows dialing as many *67s and *82s in succession as one's heart may desire,
2331 * the 5ESS does not, it only allows pure toggling (and only once!). So, it's not incorrect
2332 * to prevent people from dialing *67 if that won't actually do anything. */
2333 } else if (!p->hidecallerid && !strcmp(exten, "*67")) {
2334 ast_verb(3, "Blocking Caller*ID on %s\n", ast_channel_name(chan));
2335 /* Disable Caller*ID if enabled */
2336 p->hidecallerid = 1;
2340 if (res) {
2341 ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n",
2342 ast_channel_name(chan), strerror(errno));
2343 }
2344 len = 0;
2345 memset(exten, 0, sizeof(exten));
2346 timeout = analog_get_firstdigit_timeout(p);
2347 } else if (p->callreturn && !strcmp(exten, "*69")) {
2348 res = 0;
2349 if (!ast_strlen_zero(p->lastcid_num)) {
2350 res = ast_say_digit_str(chan, p->lastcid_num, "", ast_channel_language(chan));
2351 }
2352 if (!res) {
2354 }
2355 break;
2356 } else if (!strcmp(exten, "*78")) {
2357 /* Do not disturb enabled */
2358 analog_dnd(p, 1);
2360 getforward = 0;
2361 memset(exten, 0, sizeof(exten));
2362 len = 0;
2363 } else if (!strcmp(exten, "*79")) {
2364 /* Do not disturb disabled */
2365 analog_dnd(p, 0);
2367 getforward = 0;
2368 memset(exten, 0, sizeof(exten));
2369 len = 0;
2370 } else if (p->cancallforward && !strcmp(exten, "*72")) {
2372 getforward = 1;
2373 memset(exten, 0, sizeof(exten));
2374 len = 0;
2375 } else if (p->cancallforward && !strcmp(exten, "*73")) {
2376 ast_verb(3, "Cancelling call forwarding on channel %d\n", p->channel);
2378 memset(p->call_forward, 0, sizeof(p->call_forward));
2379 getforward = 0;
2380 memset(exten, 0, sizeof(exten));
2381 len = 0;
2382 } else if ((p->transfer || p->canpark) && is_exten_parking
2384 struct ast_bridge_channel *bridge_channel;
2385
2386 /*
2387 * This is a three way call, the main call being a real channel,
2388 * and we're parking the first call.
2389 */
2393 if (bridge_channel) {
2394 if (!ast_parking_blind_transfer_park(bridge_channel, ast_channel_context(chan), exten, NULL, NULL)) {
2395 /*
2396 * Swap things around between the three-way and real call so we
2397 * can hear where the channel got parked.
2398 */
2403
2404 ast_verb(3, "%s: Parked call\n", ast_channel_name(chan));
2406 ao2_ref(bridge_channel, -1);
2407 goto quit;
2408 }
2409 ao2_ref(bridge_channel, -1);
2410 }
2411 break;
2412 } else if (!ast_strlen_zero(p->lastcid_num) && !strcmp(exten, "*60")) {
2413 ast_verb(3, "Blacklisting number %s\n", p->lastcid_num);
2414 res = ast_db_put("blacklist", p->lastcid_num, "1");
2415 if (!res) {
2417 memset(exten, 0, sizeof(exten));
2418 len = 0;
2419 }
2420 } else if (p->hidecallerid && !strcmp(exten, "*82")) {
2421 ast_verb(3, "Allowing Caller*ID on %s\n", ast_channel_name(chan));
2422 /* Enable Caller*ID if enabled */
2423 p->hidecallerid = 0;
2427 if (res) {
2428 ast_log(LOG_WARNING, "Unable to do dial recall on channel %s: %s\n",
2429 ast_channel_name(chan), strerror(errno));
2430 }
2431 len = 0;
2432 memset(exten, 0, sizeof(exten));
2433 timeout = analog_get_firstdigit_timeout(p);
2434 } else if (!strcmp(exten, "*0")) {
2435 struct ast_channel *nbridge = p->subs[ANALOG_SUB_THREEWAY].owner;
2436 struct analog_pvt *pbridge = NULL;
2437 /* set up the private struct of the bridged one, if any */
2438 if (nbridge) {
2439 pbridge = analog_get_bridged_channel(nbridge);
2440 }
2441 if (pbridge && ISTRUNK(pbridge)) {
2442 /* Clear out the dial buffer */
2443 p->dop.dialstr[0] = '\0';
2444 /* flash hookswitch */
2445 if ((analog_flash(pbridge) == -1) && (errno != EINPROGRESS)) {
2447 "Unable to flash-hook bridged trunk from channel %s: %s\n",
2448 ast_channel_name(nbridge), strerror(errno));
2449 }
2454 ast_hangup(chan);
2455 goto quit;
2456 } else {
2459 analog_play_tone(p, idx, -1);
2463 ast_hangup(chan);
2464 goto quit;
2465 }
2466 } else if (!ast_canmatch_extension(chan, ast_channel_context(chan), exten, 1,
2467 ast_channel_caller(chan)->id.number.valid ? ast_channel_caller(chan)->id.number.str : NULL)
2468 && !analog_canmatch_featurecode(pickupexten, exten)) {
2469 ast_debug(1, "Can't match %s from '%s' in context %s\n", exten,
2470 ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str
2471 ? ast_channel_caller(chan)->id.number.str : "<Unknown Caller>",
2472 ast_channel_context(chan));
2473 break;
2474 }
2475 if (!timeout) {
2476 timeout = analog_get_interdigit_timeout(p);
2477 }
2478 if (len && !ast_ignore_pattern(ast_channel_context(chan), exten)) {
2479 analog_play_tone(p, idx, -1);
2480 }
2481 }
2482 break;
2483 case ANALOG_SIG_FXSLS:
2484 case ANALOG_SIG_FXSGS:
2485 case ANALOG_SIG_FXSKS:
2486 /* check for SMDI messages */
2487 if (p->use_smdi && p->smdi_iface) {
2489 if (smdi_msg != NULL) {
2490 ast_channel_exten_set(chan, smdi_msg->fwd_st);
2491
2492 if (smdi_msg->type == 'B')
2493 pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "b");
2494 else if (smdi_msg->type == 'N')
2495 pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "u");
2496
2497 ast_debug(1, "Received SMDI message on %s\n", ast_channel_name(chan));
2498 } else {
2499 ast_log(LOG_WARNING, "SMDI enabled but no SMDI message present\n");
2500 }
2501 }
2502
2503 if (p->use_callerid && (p->cid_signalling == CID_SIG_SMDI && smdi_msg)) {
2504 number = smdi_msg->calling_st;
2505
2506 /* If we want caller id, we're in a prering state due to a polarity reversal
2507 * and we're set to use a polarity reversal to trigger the start of caller id,
2508 * grab the caller id and wait for ringing to start... */
2509 } else if (p->use_callerid && (ast_channel_state(chan) == AST_STATE_PRERING
2513 /* If set to use DTMF CID signalling, listen for DTMF */
2514 if (p->cid_signalling == CID_SIG_DTMF) {
2515 int k = 0;
2516 int oldlinearity;
2517 int timeout_ms;
2518 int ms;
2519 struct timeval start = ast_tvnow();
2520 ast_debug(1, "Receiving DTMF cid on channel %s\n", ast_channel_name(chan));
2521
2522 oldlinearity = analog_set_linear_mode(p, idx, 0);
2523
2524 /*
2525 * We are the only party interested in the Rx stream since
2526 * we have not answered yet. We don't need or even want DTMF
2527 * emulation. The DTMF digits can come so fast that emulation
2528 * can drop some of them.
2529 */
2530 ast_channel_lock(chan);
2532 ast_channel_unlock(chan);
2533 timeout_ms = 4000;/* This is a typical OFF time between rings. */
2534 for (;;) {
2535 struct ast_frame *f;
2536
2537 ms = ast_remaining_ms(start, timeout_ms);
2538 res = ast_waitfor(chan, ms);
2539 if (res <= 0) {
2540 /*
2541 * We do not need to restore the analog_set_linear_mode()
2542 * or AST_FLAG_END_DTMF_ONLY flag settings since we
2543 * are hanging up the channel.
2544 */
2546 "DTMFCID timed out waiting for ring. Exiting simple switch\n");
2547 ast_hangup(chan);
2548 goto quit;
2549 }
2550 f = ast_read(chan);
2551 if (!f) {
2552 break;
2553 }
2554 if (f->frametype == AST_FRAME_DTMF) {
2555 if (k < ARRAY_LEN(dtmfbuf) - 1) {
2556 dtmfbuf[k++] = f->subclass.integer;
2557 }
2558 ast_debug(1, "CID got digit '%c'\n", f->subclass.integer);
2559 start = ast_tvnow();
2560 }
2561 ast_frfree(f);
2562 if (ast_channel_state(chan) == AST_STATE_RING ||
2564 break; /* Got ring */
2565 }
2566 }
2567 ast_channel_lock(chan);
2569 ast_channel_unlock(chan);
2570 dtmfbuf[k] = '\0';
2571
2572 analog_set_linear_mode(p, idx, oldlinearity);
2573
2574 /* Got cid and ring. */
2575 ast_debug(1, "CID got string '%s'\n", dtmfbuf);
2576 callerid_get_dtmf(dtmfbuf, dtmfcid, &flags);
2577 ast_debug(1, "CID is '%s', flags %d\n", dtmfcid, flags);
2578 /* If first byte is NULL, we have no cid */
2579 if (!ast_strlen_zero(dtmfcid)) {
2580 number = dtmfcid;
2581 } else {
2582 number = NULL;
2583 }
2584
2585 /* If set to use V23 Signalling, launch our FSK gubbins and listen for it */
2586 } else if ((p->cid_signalling == CID_SIG_V23) || (p->cid_signalling == CID_SIG_V23_JP)) {
2587 namebuf[0] = 0;
2588 numbuf[0] = 0;
2589
2591 int timeout = 10000; /* Ten seconds */
2592 struct timeval start = ast_tvnow();
2593 enum analog_event ev;
2594 int off_ms;
2595 int ms;
2596 struct timeval off_start;
2597
2599 /* Disable distinctive ring timeout count */
2601 }
2602 while ((ms = ast_remaining_ms(start, timeout))) {
2603 res = analog_get_callerid(p, namebuf, numbuf, &ev, ms);
2604 if (res < 0) {
2606 "CallerID returned with error on channel '%s'\n",
2607 ast_channel_name(chan));
2608 break;
2609 }
2610 if (res == 0) {
2611 break;
2612 }
2613 if (res != 1) {
2614 continue;
2615 }
2616 if (ev == ANALOG_EVENT_NOALARM) {
2617 analog_set_alarm(p, 0);
2618 }
2619 if (p->cid_signalling == CID_SIG_V23_JP) {
2620 if (ev == ANALOG_EVENT_RINGBEGIN) {
2621 analog_off_hook(p);
2622 usleep(1);
2623 }
2624 } else {
2625 break;
2626 }
2627 }
2628
2629 name = namebuf;
2630 number = numbuf;
2631
2632 if (p->cid_signalling == CID_SIG_V23_JP) {
2633 analog_on_hook(p);
2634 usleep(1);
2635 }
2636
2637 /* Finished with Caller*ID, now wait for a ring to make sure there really is a call coming */
2638 off_start = ast_tvnow();
2639 off_ms = 4000;/* This is a typical OFF time between rings. */
2640 while ((ms = ast_remaining_ms(off_start, off_ms))) {
2641 struct ast_frame *f;
2642
2643 res = ast_waitfor(chan, ms);
2644 if (res <= 0) {
2646 "CID timed out waiting for ring. Exiting simple switch\n");
2648 ast_hangup(chan);
2649 goto quit;
2650 }
2651 if (!(f = ast_read(chan))) {
2652 ast_log(LOG_WARNING, "Hangup received waiting for ring. Exiting simple switch\n");
2654 ast_hangup(chan);
2655 goto quit;
2656 }
2657 ast_frfree(f);
2658 if (ast_channel_state(chan) == AST_STATE_RING ||
2660 break; /* Got ring */
2661 }
2662
2663 res = analog_distinctive_ring(chan, p, idx, NULL);
2665 if (res) {
2666 goto quit;
2667 }
2668 } else {
2669 ast_log(LOG_WARNING, "Unable to get caller ID space\n");
2670 }
2671 } else {
2673 "Channel %s in prering state, but I have nothing to do. Terminating simple switch, should be restarted by the actual ring.\n",
2674 ast_channel_name(chan));
2675 ast_hangup(chan);
2676 goto quit;
2677 }
2678 } else if (p->use_callerid && p->cid_start == ANALOG_CID_START_RING) {
2679 namebuf[0] = 0;
2680 numbuf[0] = 0;
2681
2683 int timeout = 10000; /* Ten seconds */
2684 struct timeval start = ast_tvnow();
2685 enum analog_event ev;
2686 int ring_data[RING_PATTERNS] = { 0 };
2687 int ring_data_idx = 0;
2688 int ms;
2689
2691 /* Disable distinctive ring timeout count */
2693 }
2694 while ((ms = ast_remaining_ms(start, timeout))) {
2695 res = analog_get_callerid(p, namebuf, numbuf, &ev, ms);
2696 if (res < 0) {
2698 "CallerID returned with error on channel '%s'\n",
2699 ast_channel_name(chan));
2700 break;
2701 }
2702 if (res == 0) {
2703 break;
2704 }
2705 if (res != 1) {
2706 continue;
2707 }
2708 if (ev == ANALOG_EVENT_NOALARM) {
2709 analog_set_alarm(p, 0);
2710 } else if (ev == ANALOG_EVENT_POLARITY
2712 && p->polarity == POLARITY_REV) {
2713 ast_debug(1,
2714 "Hanging up due to polarity reversal on channel %d while detecting callerid\n",
2715 p->channel);
2718 ast_hangup(chan);
2719 goto quit;
2720 } else if (ev == ANALOG_EVENT_RINGOFFHOOK
2722 && ring_data_idx < RING_PATTERNS) {
2723 /*
2724 * Detect callerid while collecting possible
2725 * distinctive ring pattern.
2726 */
2727 ring_data[ring_data_idx] = p->ringt;
2728 ++ring_data_idx;
2729 }
2730 }
2731
2732 name = namebuf;
2733 number = numbuf;
2734
2735 res = analog_distinctive_ring(chan, p, idx, ring_data);
2737 if (res) {
2738 goto quit;
2739 }
2740 } else {
2741 ast_log(LOG_WARNING, "Unable to get caller ID space\n");
2742 }
2743 }
2744
2745 if (number) {
2747 }
2749
2750 analog_handle_notify_message(chan, p, flags, -1);
2751
2752 ast_channel_lock(chan);
2754 ast_channel_rings_set(chan, 1);
2755 ast_channel_unlock(chan);
2757 res = ast_pbx_run(chan);
2758 if (res) {
2759 ast_hangup(chan);
2760 ast_log(LOG_WARNING, "PBX exited non-zero\n");
2761 }
2762 goto quit;
2763 default:
2764 ast_log(LOG_WARNING, "Don't know how to handle simple switch with signalling %s on channel %d\n", analog_sigtype_to_str(p->sig), p->channel);
2765 break;
2766 }
2768 if (res < 0) {
2769 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", p->channel);
2770 }
2771 ast_hangup(chan);
2772quit:
2773 ao2_cleanup(smdi_msg);
2775 return NULL;
2776}
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
Definition: db.c:335
char * strsep(char **str, const char *delims)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define CID_SIG_V23_JP
Definition: callerid.h:63
#define AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:449
#define CID_SIG_SMDI
Definition: callerid.h:64
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s,...
Definition: callerid.c:1101
#define CID_SIG_DTMF
Definition: callerid.h:62
#define CID_SIG_V23
Definition: callerid.h:61
void callerid_get_dtmf(char *cidstring, char *number, int *flags)
Get and parse DTMF-based callerid.
Definition: callerid.c:211
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:437
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
Definition: channel.c:3203
void * ast_channel_tech_pvt(const struct ast_channel *chan)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3190
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
ast_callid ast_channel_callid(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4274
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
Definition: channel.c:7355
@ AST_FLAG_END_DTMF_ONLY
Definition: channel.h:1027
const char * ast_channel_language(const struct ast_channel *chan)
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
Definition: channel.c:10608
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1601
#define AST_MAX_EXTENSION
Definition: channel.h:134
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Definition: file.c:1301
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
Definition: file.c:1848
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
#define AST_FRAME_DTMF
#define ast_frfree(fr)
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
Definition: logger.c:2295
int errno
int ast_parking_blind_transfer_park(struct ast_bridge_channel *parker, const char *context, const char *exten, transfer_channel_cb parked_channel_cb, struct transfer_channel_data *parked_channel_data)
Perform a blind transfer to a parking extension.
Definition: parking.c:143
int ast_parking_is_exten_park(const char *context, const char *exten)
Determine if the context/exten is a "parking" extension.
Definition: parking.c:179
int ast_parking_provider_registered(void)
Check whether a parking provider is registered.
Definition: parking.c:241
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
Definition: pbx.c:4770
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4190
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
Definition: pbx.c:4205
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
Definition: pbx.c:6894
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
Definition: pbx.c:4210
int ast_pickup_call(struct ast_channel *chan)
Pickup a call.
Definition: pickup.c:202
int ast_say_digit_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
says digits of a string
Definition: channel.c:8285
static void analog_set_callwaiting(struct analog_pvt *p, int callwaiting_enable)
Definition: sig_analog.c:880
static int analog_my_getsigstr(struct ast_channel *chan, char *str, const char *term, int ms)
Definition: sig_analog.c:1635
static int analog_stop_cid_detect(struct analog_pvt *p)
Definition: sig_analog.c:170
static int analog_dsp_reset_and_flush_digits(struct analog_pvt *p)
Definition: sig_analog.c:428
static void analog_increase_ss_count(void)
Definition: sig_analog.c:1664
static void * analog_get_bridged_channel(struct ast_channel *chan)
Definition: sig_analog.c:1697
static int analog_handle_notify_message(struct ast_channel *chan, struct analog_pvt *p, int cid_flags, int neon_mwievent)
Definition: sig_analog.c:1655
static int analog_canmatch_featurecode(const char *pickupexten, const char *exten)
Definition: sig_analog.c:1715
static int analog_flash(struct analog_pvt *p)
Definition: sig_analog.c:505
static int analog_set_linear_mode(struct analog_pvt *p, enum analog_sub sub, int linear_mode)
Definition: sig_analog.c:973
int analog_dnd(struct analog_pvt *p, int flag)
Definition: sig_analog.c:4191
static int analog_dsp_set_digitmode(struct analog_pvt *p, enum analog_dsp_digitmode mode)
Definition: sig_analog.c:659
const char * name
Definition: sig_analog.c:70
static void analog_decrease_ss_count(void)
Definition: sig_analog.c:1671
static int analog_wait_event(struct analog_pvt *p)
Definition: sig_analog.c:202
#define ISTRUNK(p)
Definition: sig_analog.c:107
static int analog_get_callerid(struct analog_pvt *p, char *name, char *number, enum analog_event *ev, size_t timeout)
Definition: sig_analog.c:178
static int analog_wink(struct analog_pvt *p, enum analog_sub index)
Definition: sig_analog.c:674
const char * analog_sigtype_to_str(enum analog_sigtype sigtype)
Definition: sig_analog.c:123
static int analog_start_cid_detect(struct analog_pvt *p, int cid_signalling)
Definition: sig_analog.c:162
static int analog_distinctive_ring(struct ast_channel *chan, struct analog_pvt *p, int idx, int *ringdata)
Definition: sig_analog.c:1678
#define ANALOG_NEED_MFDETECT(p)
Definition: sig_analog.c:1713
#define ANALOG_MAX_CID
Definition: sig_analog.h:33
@ ANALOG_DIGITMODE_DTMF
Definition: sig_analog.h:115
@ ANALOG_DIGITMODE_MF
Definition: sig_analog.h:116
#define ANALOG_SMDI_MD_WAIT_TIMEOUT
Definition: sig_analog.h:32
#define RING_PATTERNS
Definition: sig_analog.h:35
analog_event
Definition: sig_analog.h:79
@ ANALOG_TONE_INFO
Definition: sig_analog.h:76
@ ANALOG_CID_START_RING
Definition: sig_analog.h:129
@ ANALOG_CID_START_DTMF_NOALERT
Definition: sig_analog.h:130
@ ANALOG_CID_START_POLARITY
Definition: sig_analog.h:127
@ ANALOG_CID_START_POLARITY_IN
Definition: sig_analog.h:128
struct ast_smdi_md_message * ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout)
Get the next SMDI message from the queue.
Definition: res_smdi.c:545
unsigned int immediate
Definition: sig_analog.h:298
unsigned int threewaysilenthold
Definition: sig_analog.h:305
unsigned int canpark
Definition: sig_analog.h:295
char lastexten[AST_MAX_EXTENSION]
Definition: sig_analog.h:356
unsigned int permhidecallerid
Definition: sig_analog.h:302
unsigned int ani_wink_time
Definition: sig_analog.h:289
unsigned int usedistinctiveringdetection
Definition: sig_analog.h:309
unsigned int callwaiting
Definition: sig_analog.h:334
char call_forward[AST_MAX_EXTENSION]
Definition: sig_analog.h:371
enum analog_cid_start cid_start
Definition: sig_analog.h:327
unsigned int hidecallerid
Definition: sig_analog.h:340
unsigned int callreturn
Definition: sig_analog.h:293
unsigned int use_smdi
TRUE if SMDI (Simplified Message Desk Interface) is enabled.
Definition: sig_analog.h:314
unsigned int ani_timeout
Definition: sig_analog.h:288
unsigned int lastnumredial
Definition: sig_analog.h:300
unsigned int ani_info_digits
Definition: sig_analog.h:287
unsigned int cancallforward
Definition: sig_analog.h:294
char lastcid_num[AST_MAX_EXTENSION]
Definition: sig_analog.h:354
int cid_signalling
Definition: sig_analog.h:324
unsigned int use_callerid
Definition: sig_analog.h:308
struct ast_smdi_interface * smdi_iface
The SMDI interface to get SMDI messages from.
Definition: sig_analog.h:316
Structure that contains information regarding a channel in a bridge.
struct ast_channel * chan
char exten[AST_MAX_EXTENSION]
struct ast_flags flags
Configuration relating to call pickup.
unsigned int flags
Caller Party information.
Definition: channel.h:420
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:279
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:297
An SMDI message desk message.
Definition: smdi.h:65
char calling_st[SMDI_MAX_STATION_NUM_LEN+1]
Definition: smdi.h:70
char fwd_st[SMDI_MAX_STATION_NUM_LEN+1]
Definition: smdi.h:69
Number structure.
Definition: app_followme.c:157
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:2281
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941
#define ast_assert(a)
Definition: utils.h:739
#define MIN(a, b)
Definition: utils.h:231
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define ARRAY_LEN(a)
Definition: utils.h:666

References analog_alloc_sub(), analog_canmatch_featurecode(), ANALOG_CID_START_DTMF_NOALERT, ANALOG_CID_START_POLARITY, ANALOG_CID_START_POLARITY_IN, ANALOG_CID_START_RING, analog_decrease_ss_count(), ANALOG_DIGITMODE_DTMF, ANALOG_DIGITMODE_MF, analog_distinctive_ring(), analog_dnd(), analog_dsp_reset_and_flush_digits(), analog_dsp_set_digitmode(), ANALOG_EVENT_NOALARM, ANALOG_EVENT_POLARITY, ANALOG_EVENT_RINGBEGIN, ANALOG_EVENT_RINGOFFHOOK, analog_flash(), analog_get_bridged_channel(), analog_get_callerid(), analog_get_index, analog_handle_notify_message(), analog_increase_ss_count(), analog_lock_private(), ANALOG_MAX_CID, analog_my_getsigstr(), ANALOG_NEED_MFDETECT, analog_off_hook(), analog_on_hook(), analog_play_tone(), analog_set_alarm(), analog_set_callwaiting(), analog_set_echocanceller(), analog_set_linear_mode(), analog_set_new_owner(), analog_set_ringtimeout(), ANALOG_SIG_E911, ANALOG_SIG_EM, ANALOG_SIG_EM_E1, ANALOG_SIG_EMWINK, ANALOG_SIG_FEATB, ANALOG_SIG_FEATD, ANALOG_SIG_FEATDMF, ANALOG_SIG_FEATDMF_TA, ANALOG_SIG_FGC_CAMA, ANALOG_SIG_FGC_CAMAMF, ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, ANALOG_SIG_FXSGS, ANALOG_SIG_FXSKS, ANALOG_SIG_FXSLS, ANALOG_SIG_SF, ANALOG_SIG_SF_FEATB, ANALOG_SIG_SF_FEATD, ANALOG_SIG_SF_FEATDMF, ANALOG_SIG_SFWINK, analog_sigtype_to_str(), ANALOG_SMDI_MD_WAIT_TIMEOUT, analog_start_cid_detect(), analog_stop_cid_detect(), ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY, analog_swap_subs(), ANALOG_TONE_CONGESTION, ANALOG_TONE_DIALRECALL, ANALOG_TONE_DIALTONE, ANALOG_TONE_INFO, analog_unalloc_sub(), analog_unlock_private(), analog_wait_event(), analog_wink(), ast_party_caller::ani2, analog_pvt::ani_info_digits, analog_pvt::ani_timeout, analog_pvt::ani_wink_time, ao2_cleanup, ao2_ref, ARRAY_LEN, ast_assert, ast_callid_threadassoc_add(), ast_canmatch_extension(), ast_channel_caller(), ast_channel_callid(), ast_channel_context(), ast_channel_exten_set(), ast_channel_flags(), ast_channel_get_bridge_channel(), ast_channel_language(), ast_channel_lock, ast_channel_name(), ast_channel_rings_set(), ast_channel_tech_pvt(), ast_channel_unlock, ast_clear_flag, ast_copy_string(), ast_db_put(), ast_debug, ast_exists_extension(), AST_FLAG_END_DTMF_ONLY, AST_FRAME_DTMF, ast_frfree, ast_get_chan_features_pickup_config(), ast_hangup(), ast_ignore_pattern(), ast_log, ast_matchmore_extension(), AST_MAX_EXTENSION, ast_parking_blind_transfer_park(), ast_parking_is_exten_park(), ast_parking_provider_registered(), ast_pbx_run(), ast_pickup_call(), AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, ast_queue_unhold(), ast_read(), ast_remaining_ms(), ast_safe_sleep(), ast_say_digit_str(), ast_set_callerid(), ast_set_flag, ast_setstate(), ast_shrink_phone_number(), ast_smdi_md_message_wait(), AST_STATE_PRERING, AST_STATE_RING, AST_STATE_RINGING, ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_tvnow(), ast_verb, ast_waitfor(), ast_waitfordigit(), ast_waitstream(), analog_pvt::call_forward, callerid_get_dtmf(), ast_smdi_md_message::calling_st, analog_pvt::callreturn, analog_pvt::callwaiting, analog_pvt::cancallforward, analog_pvt::canpark, ast_bridge_channel::chan, analog_pvt::channel, analog_pvt::cid_num, CID_SIG_DTMF, CID_SIG_SMDI, CID_SIG_V23, CID_SIG_V23_JP, analog_pvt::cid_signalling, analog_pvt::cid_start, analog_dialoperation::dialstr, analog_pvt::dop, errno, ast_channel::exten, ast_frame::flags, ast_channel::flags, ast_frame::frametype, ast_smdi_md_message::fwd_st, analog_pvt::hanguponpolarityswitch, analog_pvt::hidecallerid, ast_party_caller::id, analog_pvt::immediate, ast_frame_subclass::integer, ISTRUNK, analog_pvt::lastcid_num, analog_pvt::lastexten, analog_pvt::lastnumredial, len(), LOG_ERROR, LOG_WARNING, MIN, name, ast_party_id::name, NULL, ast_party_id::number, analog_subchannel::owner, pbx_builtin_setvar_helper(), analog_pvt::permhidecallerid, analog_pvt::polarity, POLARITY_IDLE, POLARITY_REV, ast_party_name::presentation, ast_party_number::presentation, RAII_VAR, RING_PATTERNS, analog_pvt::ringt, analog_pvt::ringt_base, analog_pvt::sig, analog_pvt::smdi_iface, analog_pvt::ss_astchan, strsep(), ast_frame::subclass, analog_pvt::subs, analog_pvt::threewaysilenthold, analog_pvt::transfer, ast_smdi_md_message::type, analog_pvt::use_callerid, analog_pvt::use_smdi, and analog_pvt::usedistinctiveringdetection.

Referenced by __analog_handle_event(), analog_handle_init_event(), and analog_ss_thread_start().

◆ _analog_get_index()

static int _analog_get_index ( struct ast_channel ast,
struct analog_pvt p,
int  nullok,
const char *  fname,
unsigned long  line 
)
static

Definition at line 408 of file sig_analog.c.

409{
410 int res;
411 if (p->subs[ANALOG_SUB_REAL].owner == ast) {
412 res = ANALOG_SUB_REAL;
413 } else if (p->subs[ANALOG_SUB_CALLWAIT].owner == ast) {
415 } else if (p->subs[ANALOG_SUB_THREEWAY].owner == ast) {
417 } else {
418 res = -1;
419 if (!nullok) {
421 "Unable to get index for '%s' on channel %d (%s(), line %lu)\n",
422 ast ? ast_channel_name(ast) : "", p->channel, fname, line);
423 }
424 }
425 return res;
426}

References ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY, ast_channel_name(), ast_log, analog_pvt::channel, LOG_WARNING, analog_subchannel::owner, and analog_pvt::subs.

◆ analog_all_subchannels_hungup()

static void analog_all_subchannels_hungup ( struct analog_pvt p)
static

Definition at line 553 of file sig_analog.c.

554{
557 }
558}
struct analog_callback analog_callbacks
Definition: chan_dahdi.c:3686
void(*const all_subchannels_hungup)(void *pvt)
Definition: sig_analog.h:220
void * chan_pvt
Definition: sig_analog.h:275

References analog_callback::all_subchannels_hungup, analog_callbacks, and analog_pvt::chan_pvt.

Referenced by analog_hangup().

◆ analog_alloc_sub()

static int analog_alloc_sub ( struct analog_pvt p,
enum analog_sub  x 
)
static

Definition at line 368 of file sig_analog.c.

369{
371 int res;
373 if (!res) {
374 p->subs[x].allocd = 1;
375 }
376 return res;
377 }
378 return 0;
379}
int(*const allocate_sub)(void *pvt, enum analog_sub sub)
Definition: sig_analog.h:202
unsigned int allocd
Definition: sig_analog.h:268

References analog_callback::allocate_sub, analog_subchannel::allocd, analog_callbacks, analog_pvt::chan_pvt, analog_pvt::subs, and ast_channel::x.

Referenced by __analog_handle_event(), __analog_ss_thread(), and analog_request().

◆ analog_answer()

int analog_answer ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 1490 of file sig_analog.c.

1491{
1492 int res = 0;
1493 int idx;
1494 int oldstate = ast_channel_state(ast);
1495
1496 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
1498 idx = analog_get_index(ast, p, 1);
1499 if (idx < 0) {
1500 idx = ANALOG_SUB_REAL;
1501 }
1502 switch (p->sig) {
1503 case ANALOG_SIG_FXSLS:
1504 case ANALOG_SIG_FXSGS:
1505 case ANALOG_SIG_FXSKS:
1507 /* Fall through */
1508 case ANALOG_SIG_EM:
1509 case ANALOG_SIG_EM_E1:
1510 case ANALOG_SIG_EMWINK:
1511 case ANALOG_SIG_FEATD:
1512 case ANALOG_SIG_FEATDMF:
1514 case ANALOG_SIG_E911:
1517 case ANALOG_SIG_FEATB:
1518 case ANALOG_SIG_SF:
1519 case ANALOG_SIG_SFWINK:
1523 case ANALOG_SIG_FXOLS:
1524 case ANALOG_SIG_FXOGS:
1525 case ANALOG_SIG_FXOKS:
1526 /* Pick up the line */
1527 ast_debug(1, "Took %s off hook\n", ast_channel_name(ast));
1528 if (p->hanguponpolarityswitch) {
1529 gettimeofday(&p->polaritydelaytv, NULL);
1530 }
1531 res = analog_off_hook(p);
1532 analog_play_tone(p, idx, -1);
1533 analog_set_dialing(p, 0);
1534 if ((idx == ANALOG_SUB_REAL) && p->subs[ANALOG_SUB_THREEWAY].inthreeway) {
1535 if (oldstate == AST_STATE_RINGING) {
1536 ast_debug(1, "Finally swapping real and threeway\n");
1540 }
1541 }
1542
1543 switch (p->sig) {
1544 case ANALOG_SIG_FXSLS:
1545 case ANALOG_SIG_FXSKS:
1546 case ANALOG_SIG_FXSGS:
1549 break;
1550 case ANALOG_SIG_FXOLS:
1551 case ANALOG_SIG_FXOKS:
1552 case ANALOG_SIG_FXOGS:
1554 break;
1555 default:
1556 break;
1557 }
1558 break;
1559 default:
1560 ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
1561 res = -1;
1562 break;
1563 }
1565 return res;
1566}

References analog_answer_polarityswitch(), analog_get_index, analog_off_hook(), analog_play_tone(), analog_set_dialing(), analog_set_echocanceller(), analog_set_new_owner(), analog_set_ringtimeout(), ANALOG_SIG_E911, ANALOG_SIG_EM, ANALOG_SIG_EM_E1, ANALOG_SIG_EMWINK, ANALOG_SIG_FEATB, ANALOG_SIG_FEATD, ANALOG_SIG_FEATDMF, ANALOG_SIG_FEATDMF_TA, ANALOG_SIG_FGC_CAMA, ANALOG_SIG_FGC_CAMAMF, ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, ANALOG_SIG_FXSGS, ANALOG_SIG_FXSKS, ANALOG_SIG_FXSLS, ANALOG_SIG_SF, ANALOG_SIG_SF_FEATB, ANALOG_SIG_SF_FEATD, ANALOG_SIG_SF_FEATDMF, ANALOG_SIG_SFWINK, ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY, analog_swap_subs(), analog_train_echocanceller(), ast_channel_name(), ast_debug, ast_log, ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, analog_pvt::channel, analog_pvt::hanguponpolarityswitch, analog_subchannel::inthreeway, LOG_WARNING, NULL, analog_subchannel::owner, analog_pvt::polaritydelaytv, analog_pvt::sig, and analog_pvt::subs.

Referenced by dahdi_answer().

◆ analog_answer_polarityswitch()

static void analog_answer_polarityswitch ( struct analog_pvt p)
static

Definition at line 645 of file sig_analog.c.

646{
649 }
650}
void(*const answer_polarityswitch)(void *pvt)
Switch FXS line polarity, based on answeronpolarityswitch=yes.
Definition: sig_analog.h:174

References analog_callbacks, analog_callback::answer_polarityswitch, and analog_pvt::chan_pvt.

Referenced by __analog_handle_event(), and analog_answer().

◆ analog_attempt_transfer()

static int analog_attempt_transfer ( struct analog_pvt p)
static

Definition at line 710 of file sig_analog.c.

711{
712 struct ast_channel *owner_real;
713 struct ast_channel *owner_3way;
714 enum ast_transfer_result xfer_res;
715 int res = 0;
716
717 owner_real = ast_channel_ref(p->subs[ANALOG_SUB_REAL].owner);
719
720 ast_verb(3, "TRANSFERRING %s to %s\n",
721 ast_channel_name(owner_3way), ast_channel_name(owner_real));
722
723 ast_channel_unlock(owner_real);
724 ast_channel_unlock(owner_3way);
726
727 xfer_res = ast_bridge_transfer_attended(owner_3way, owner_real);
728 if (xfer_res != AST_BRIDGE_TRANSFER_SUCCESS) {
730 res = -1;
731 }
732
733 /* Must leave with these locked. */
734 ast_channel_lock(owner_real);
736
737 ast_channel_unref(owner_real);
738 ast_channel_unref(owner_3way);
739
740 return res;
741}
ast_transfer_result
Definition: bridge.h:1102
@ AST_BRIDGE_TRANSFER_SUCCESS
Definition: bridge.h:1104
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee, struct ast_channel *to_transfer_target)
Attended transfer.
Definition: bridge.c:4746
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2995
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:3006

References analog_lock_private(), ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY, analog_unlock_private(), ast_bridge_transfer_attended(), AST_BRIDGE_TRANSFER_SUCCESS, ast_channel_lock, ast_channel_name(), ast_channel_ref, ast_channel_unlock, ast_channel_unref, ast_softhangup(), AST_SOFTHANGUP_DEV, ast_verb, analog_subchannel::owner, and analog_pvt::subs.

Referenced by __analog_handle_event().

◆ analog_available()

int analog_available ( struct analog_pvt p)

Definition at line 793 of file sig_analog.c.

794{
795 int offhook;
796
797 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
798
799 /* If do not disturb, definitely not */
800 if (p->dnd) {
801 return 0;
802 }
803 /* If guard time, definitely not */
804 if (p->guardtime && (time(NULL) < p->guardtime)) {
805 return 0;
806 }
807
808 /* If line is being held, definitely not (don't allow call waitings to an on-hook phone) */
809 if (p->cshactive) {
810 return 0;
811 }
812
813 /* If no owner definitely available */
814 if (!p->owner) {
815 offhook = analog_is_off_hook(p);
816
817 /* TDM FXO card, "onhook" means out of service (no battery on the line) */
818 if ((p->sig == ANALOG_SIG_FXSLS) || (p->sig == ANALOG_SIG_FXSKS) || (p->sig == ANALOG_SIG_FXSGS)) {
819#ifdef DAHDI_CHECK_HOOKSTATE
820 if (offhook) {
821 return 1;
822 }
823 return 0;
824#endif
825 /* TDM FXS card, "offhook" means someone took the hook off so it's unavailable! */
826 } else if (offhook) {
827 ast_debug(1, "Channel %d off hook, can't use\n", p->channel);
828 /* Not available when the other end is off hook */
829 return 0;
830 }
831 return 1;
832 }
833
834 /* If it's not an FXO, forget about call wait */
835 if ((p->sig != ANALOG_SIG_FXOKS) && (p->sig != ANALOG_SIG_FXOLS) && (p->sig != ANALOG_SIG_FXOGS)) {
836 return 0;
837 }
838
839 if (!p->callwaiting) {
840 /* If they don't have call waiting enabled, then for sure they're unavailable at this point */
841 return 0;
842 }
843
845 /* If there is already a call waiting call, then we can't take a second one */
846 return 0;
847 }
848
849 if ((ast_channel_state(p->owner) != AST_STATE_UP) &&
851 /* If the current call is not up, then don't allow the call */
852 return 0;
853 }
855 /* Can't take a call wait when the three way calling hasn't been merged yet. */
856 return 0;
857 }
858 /* We're cool */
859 return 1;
860}
unsigned int dnd
Definition: sig_analog.h:338
time_t guardtime
Definition: sig_analog.h:365

References analog_subchannel::allocd, analog_is_off_hook(), ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, ANALOG_SIG_FXSGS, ANALOG_SIG_FXSKS, ANALOG_SIG_FXSLS, ANALOG_SUB_CALLWAIT, ANALOG_SUB_THREEWAY, ast_debug, AST_STATE_RINGING, AST_STATE_UP, analog_pvt::callwaiting, analog_pvt::channel, analog_pvt::cshactive, analog_pvt::dnd, analog_pvt::guardtime, analog_subchannel::inthreeway, NULL, analog_pvt::outgoing, analog_subchannel::owner, analog_pvt::owner, analog_pvt::sig, and analog_pvt::subs.

Referenced by available().

◆ analog_call()

int analog_call ( struct analog_pvt p,
struct ast_channel ast,
const char *  rdest,
int  timeout 
)

Definition at line 990 of file sig_analog.c.

991{
992 int res, idx, mysig;
993 char *c, *n, *l;
994 char dest[256]; /* must be same length as p->dialdest */
995
996 ast_debug(1, "CALLING CID_NAME: %s CID_NUM:: %s\n",
997 S_COR(ast_channel_connected(ast)->id.name.valid, ast_channel_connected(ast)->id.name.str, ""),
998 S_COR(ast_channel_connected(ast)->id.number.valid, ast_channel_connected(ast)->id.number.str, ""));
999
1000 ast_copy_string(dest, rdest, sizeof(dest));
1001 ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest));
1002
1003 if ((ast_channel_state(ast) == AST_STATE_BUSY)) {
1005 return 0;
1006 }
1007
1009 ast_log(LOG_WARNING, "analog_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
1010 return -1;
1011 }
1012
1013 p->dialednone = 0;
1014 analog_set_outgoing(p, 1);
1015
1016 mysig = p->sig;
1017 if (p->outsigmod > -1) {
1018 mysig = p->outsigmod;
1019 }
1020
1021 switch (mysig) {
1022 case ANALOG_SIG_FXOLS:
1023 case ANALOG_SIG_FXOGS:
1024 case ANALOG_SIG_FXOKS:
1025 if (p->owner == ast) {
1026 /* Normal ring, on hook */
1027
1028 /* Don't send audio while on hook, until the call is answered */
1029 analog_set_dialing(p, 1);
1030 analog_set_cadence(p, ast); /* and set p->cidrings */
1031
1032 /* nick@dccinc.com 4/3/03 mods to allow for deferred dialing */
1033 c = strchr(dest, '/');
1034 if (c) {
1035 c++;
1036 }
1037 if (c && (strlen(c) < p->stripmsd)) {
1038 ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
1039 c = NULL;
1040 }
1041 if (c && (strlen(c) > sizeof(p->dop.dialstr) - 3 /* "Tw\0" */)) {
1042 ast_log(LOG_WARNING, "Number '%s' is longer than %d bytes\n", c, (int)sizeof(p->dop.dialstr) - 2);
1043 c = NULL;
1044 }
1045 if (c) {
1047 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
1048 ast_debug(1, "FXO: setup deferred dialstring: %s\n", c);
1049 } else {
1050 p->dop.dialstr[0] = '\0';
1051 }
1052
1053 if (analog_ring(p)) {
1054 ast_log(LOG_WARNING, "Unable to ring phone: %s\n", strerror(errno));
1055 return -1;
1056 }
1057 analog_set_dialing(p, 1);
1058 } else {
1059 /* Call waiting call */
1060 if (ast_channel_connected(ast)->id.number.valid && ast_channel_connected(ast)->id.number.str) {
1062 } else {
1063 p->callwait_num[0] = '\0';
1064 }
1065 if (ast_channel_connected(ast)->id.name.valid && ast_channel_connected(ast)->id.name.str) {
1067 } else {
1068 p->callwait_name[0] = '\0';
1069 }
1070
1071 /* Call waiting tone instead */
1072 if (analog_callwait(p)) {
1073 return -1;
1074 }
1075 /* Make ring-back */
1077 ast_log(LOG_WARNING, "Unable to generate call-wait ring-back on channel %s\n", ast_channel_name(ast));
1078 }
1079
1080 }
1081
1082 /* Name and Number */
1085 if (l) {
1086 ast_copy_string(p->lastcid_num, l, sizeof(p->lastcid_num));
1087 } else {
1088 p->lastcid_num[0] = '\0';
1089 }
1090 if (n) {
1091 ast_copy_string(p->lastcid_name, n, sizeof(p->lastcid_name));
1092 } else {
1093 p->lastcid_name[0] = '\0';
1094 }
1095
1096 if (p->use_callerid) {
1097 const char *qual_var;
1098
1099 /* Caller ID Name and Number */
1100 p->caller.id.name.str = p->lastcid_name;
1101 p->caller.id.number.str = p->lastcid_num;
1106
1107 /* Redirecting Reason */
1109
1110 /* Call Qualifier */
1111 ast_channel_lock(ast);
1112 /* XXX In the future, we may want to make this a CALLERID or CHANNEL property and fetch it from there. */
1113 qual_var = pbx_builtin_getvar_helper(ast, "CALL_QUALIFIER");
1114 p->call_qualifier = ast_true(qual_var) ? 1 : 0;
1115 ast_channel_unlock(ast);
1116 }
1117
1119 idx = analog_get_index(ast, p, 0);
1120 if (idx > -1) {
1121 struct ast_cc_config_params *cc_params;
1122
1123 /* This is where the initial ringing frame is queued for an analog call.
1124 * As such, this is a great time to offer CCNR to the caller if it's available.
1125 */
1126 cc_params = ast_channel_get_cc_config_params(p->subs[idx].owner);
1127 if (cc_params) {
1128 switch (ast_get_cc_monitor_policy(cc_params)) {
1130 break;
1136 break;
1137 }
1138 }
1140 }
1141 break;
1142 case ANALOG_SIG_FXSLS:
1143 case ANALOG_SIG_FXSGS:
1144 case ANALOG_SIG_FXSKS:
1146 ast_debug(1, "Ignore possible polarity reversal on line seizure\n");
1148 }
1149 /* fall through */
1150 case ANALOG_SIG_EMWINK:
1151 case ANALOG_SIG_EM:
1152 case ANALOG_SIG_EM_E1:
1153 case ANALOG_SIG_FEATD:
1154 case ANALOG_SIG_FEATDMF:
1155 case ANALOG_SIG_E911:
1158 case ANALOG_SIG_FEATB:
1159 case ANALOG_SIG_SFWINK:
1160 case ANALOG_SIG_SF:
1165 c = strchr(dest, '/');
1166 if (c) {
1167 c++;
1168 } else {
1169 c = "";
1170 }
1171 if (strlen(c) < p->stripmsd) {
1172 ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
1173 return -1;
1174 }
1175 res = analog_start(p);
1176 if (res < 0) {
1177 if (errno != EINPROGRESS) {
1178 return -1;
1179 }
1180 }
1181 ast_debug(1, "Dialing '%s'\n", c);
1183
1184 c += p->stripmsd;
1185
1186 switch (mysig) {
1187 case ANALOG_SIG_FEATD:
1189 if (l) {
1190 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T*%s*%s*", l, c);
1191 } else {
1192 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T**%s*", c);
1193 }
1194 break;
1195 case ANALOG_SIG_FEATDMF:
1197 if (l) {
1198 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*00%s#*%s#", l, c);
1199 } else {
1200 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*02#*%s#", c);
1201 }
1202 break;
1204 {
1205 const char *cic = "", *ozz = "";
1206
1207 /* If you have to go through a Tandem Access point you need to use this */
1208#ifndef STANDALONE
1209 ozz = pbx_builtin_getvar_helper(p->owner, "FEATDMF_OZZ");
1210 if (!ozz) {
1211 ozz = analog_defaultozz;
1212 }
1213 cic = pbx_builtin_getvar_helper(p->owner, "FEATDMF_CIC");
1214 if (!cic) {
1215 cic = analog_defaultcic;
1216 }
1217#endif
1218 if (!ozz || !cic) {
1219 ast_log(LOG_WARNING, "Unable to dial channel of type feature group D MF tandem access without CIC or OZZ set\n");
1220 return -1;
1221 }
1222 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s%s#", ozz, cic);
1223 snprintf(p->finaldial, sizeof(p->finaldial), "M*%s#", c);
1224 p->whichwink = 0;
1225 }
1226 break;
1227 case ANALOG_SIG_E911:
1228 ast_copy_string(p->dop.dialstr, "M*911#", sizeof(p->dop.dialstr));
1229 break;
1231 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%s", c);
1232 break;
1234 case ANALOG_SIG_FEATB:
1235 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s#", c);
1236 break;
1237 default:
1238 if (p->pulse) {
1239 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%sw", c);
1240 } else {
1241 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T%sw", c);
1242 }
1243 break;
1244 }
1245
1246 if (p->echotraining && (strlen(p->dop.dialstr) > 4)) {
1247 memset(p->echorest, 'w', sizeof(p->echorest) - 1);
1248 strcpy(p->echorest + (p->echotraining / 400) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
1249 p->echorest[sizeof(p->echorest) - 1] = '\0';
1250 p->echobreak = 1;
1251 p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0';
1252 } else {
1253 p->echobreak = 0;
1254 }
1256 if (!res) {
1257 if (analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop)) {
1258 analog_on_hook(p);
1259 return -1;
1260 }
1261 } else {
1262 ast_debug(1, "Deferring dialing...\n");
1263 }
1264 analog_set_dialing(p, 1);
1265 if (ast_strlen_zero(c)) {
1266 p->dialednone = 1;
1267 }
1269 break;
1270 default:
1271 ast_debug(1, "not yet implemented\n");
1272 return -1;
1273 }
1274 return 0;
1275}
#define AST_CC_GENERIC_MONITOR_TYPE
Definition: ccss.h:455
@ AST_CC_CCNR
Definition: ccss.h:38
@ AST_CC_MONITOR_NEVER
Definition: ccss.h:76
@ AST_CC_MONITOR_ALWAYS
Definition: ccss.h:87
@ AST_CC_MONITOR_NATIVE
Definition: ccss.h:78
@ AST_CC_MONITOR_GENERIC
Definition: ccss.h:83
enum ast_cc_monitor_policies ast_get_cc_monitor_policy(struct ast_cc_config_params *config)
Get the cc_monitor_policy.
Definition: ccss.c:882
int ast_queue_cc_frame(struct ast_channel *chan, const char *const monitor_type, const char *const dialstring, enum ast_cc_service_type service, void *private_data)
Queue an AST_CONTROL_CC frame.
Definition: ccss.c:4120
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
Definition: channel.c:10500
@ AST_CONTROL_BUSY
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
static const char * analog_get_orig_dialstring(struct analog_pvt *p)
Definition: sig_analog.c:186
static char analog_defaultozz[64]
Definition: sig_analog.c:66
static int analog_callwait(struct analog_pvt *p)
Definition: sig_analog.c:871
static void analog_set_outgoing(struct analog_pvt *p, int is_outgoing)
Definition: sig_analog.c:537
static char analog_defaultcic[64]
Definition: sig_analog.c:65
static void analog_set_cadence(struct analog_pvt *p, struct ast_channel *chan)
Definition: sig_analog.c:888
static int analog_start(struct analog_pvt *p)
Definition: sig_analog.c:513
static void analog_set_waitingfordt(struct analog_pvt *p, struct ast_channel *ast)
Definition: sig_analog.c:919
@ ANALOG_TONE_RINGTONE
Definition: sig_analog.h:71
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: utils.c:2199
int redirecting_reason
Definition: sig_analog.h:358
unsigned int pulse
Definition: sig_analog.h:303
char callwait_num[AST_MAX_EXTENSION]
Definition: sig_analog.h:352
char lastcid_name[AST_MAX_EXTENSION]
Definition: sig_analog.h:355
unsigned int call_qualifier
Definition: sig_analog.h:350
int stripmsd
Definition: sig_analog.h:326
char callwait_name[AST_MAX_EXTENSION]
Definition: sig_analog.h:353
struct ast_party_id id
Connected party ID.
Definition: channel.h:460
int code
enum AST_REDIRECTING_REASON value for redirection
Definition: channel.h:512
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition: channel.h:544
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:529

References analog_callwait(), analog_defaultcic, analog_defaultozz, analog_dial_digits(), ANALOG_DIAL_OP_REPLACE, analog_get_index, analog_get_orig_dialstring(), analog_on_hook(), analog_play_tone(), analog_ring(), analog_set_cadence(), analog_set_dialing(), analog_set_outgoing(), analog_set_waitingfordt(), ANALOG_SIG_E911, ANALOG_SIG_EM, ANALOG_SIG_EM_E1, ANALOG_SIG_EMWINK, ANALOG_SIG_FEATB, ANALOG_SIG_FEATD, ANALOG_SIG_FEATDMF, ANALOG_SIG_FEATDMF_TA, ANALOG_SIG_FGC_CAMA, ANALOG_SIG_FGC_CAMAMF, ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, ANALOG_SIG_FXSGS, ANALOG_SIG_FXSKS, ANALOG_SIG_FXSLS, ANALOG_SIG_SF, ANALOG_SIG_SF_FEATB, ANALOG_SIG_SF_FEATD, ANALOG_SIG_SF_FEATDMF, ANALOG_SIG_SFWINK, analog_start(), ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL, ANALOG_TONE_RINGTONE, analog_pvt::answeronpolarityswitch, AST_CC_CCNR, AST_CC_GENERIC_MONITOR_TYPE, AST_CC_MONITOR_ALWAYS, AST_CC_MONITOR_GENERIC, AST_CC_MONITOR_NATIVE, AST_CC_MONITOR_NEVER, ast_channel_connected(), ast_channel_get_cc_config_params(), ast_channel_lock, ast_channel_name(), ast_channel_redirecting(), ast_channel_unlock, AST_CONTROL_BUSY, AST_CONTROL_RINGING, ast_copy_string(), ast_debug, ast_get_cc_monitor_policy(), ast_log, ast_queue_cc_frame(), ast_queue_control(), ast_setstate(), AST_STATE_BUSY, AST_STATE_DIALING, AST_STATE_DOWN, AST_STATE_RESERVED, AST_STATE_RINGING, ast_strlen_zero(), ast_true(), ast_tvnow(), c, analog_pvt::call_qualifier, analog_pvt::caller, analog_pvt::callwait_name, analog_pvt::callwait_num, ast_party_redirecting_reason::code, analog_pvt::dialdest, analog_pvt::dialednone, analog_dialoperation::dialstr, analog_pvt::dop, analog_pvt::echobreak, analog_pvt::echorest, analog_pvt::echotraining, errno, analog_pvt::finaldial, ast_party_redirecting::from, analog_pvt::hanguponpolarityswitch, ast_party_caller::id, ast_party_connected_line::id, analog_pvt::lastcid_name, analog_pvt::lastcid_num, LOG_WARNING, name, ast_party_id::name, NULL, ast_party_id::number, analog_dialoperation::op, analog_pvt::outsigmod, analog_subchannel::owner, analog_pvt::owner, pbx_builtin_getvar_helper(), analog_pvt::polaritydelaytv, ast_party_name::presentation, ast_party_number::presentation, analog_pvt::pulse, ast_party_redirecting::reason, analog_pvt::redirecting_reason, S_COR, analog_pvt::sig, ast_party_name::str, ast_party_number::str, analog_pvt::stripmsd, analog_pvt::subs, analog_pvt::use_callerid, ast_party_name::valid, ast_party_number::valid, and analog_pvt::whichwink.

Referenced by dahdi_call().

◆ analog_callwait()

static int analog_callwait ( struct analog_pvt p)
static

Definition at line 871 of file sig_analog.c.

872{
876 }
877 return 0;
878}
int(*const callwait)(void *pvt)
Definition: sig_analog.h:197
unsigned int callwaitingcallerid
Definition: sig_analog.h:310

References analog_callbacks, analog_callback::callwait, analog_pvt::callwaitcas, analog_pvt::callwaitingcallerid, and analog_pvt::chan_pvt.

Referenced by analog_call().

◆ analog_cancel_cidspill()

static void analog_cancel_cidspill ( struct analog_pvt p)
static

Definition at line 951 of file sig_analog.c.

952{
955 }
956}
void(*const cancel_cidspill)(void *pvt)
Definition: sig_analog.h:247

References analog_callbacks, analog_callback::cancel_cidspill, and analog_pvt::chan_pvt.

Referenced by __analog_handle_event(), and analog_handle_init_event().

◆ analog_canmatch_featurecode()

static int analog_canmatch_featurecode ( const char *  pickupexten,
const char *  exten 
)
static

Definition at line 1715 of file sig_analog.c.

1716{
1717 int extlen = strlen(exten);
1718 if (!extlen) {
1719 return 1;
1720 }
1721 if (extlen < strlen(pickupexten) && !strncmp(pickupexten, exten, extlen)) {
1722 return 1;
1723 }
1724 if (exten[0] == '#' && extlen < 2) {
1725 return 1; /* Could match ## */
1726 }
1727 /* hardcoded features are *60, *67, *69, *70, *72, *73, *78, *79, *82, *0 */
1728 if (exten[0] == '*' && extlen < 3) {
1729 if (extlen == 1) {
1730 return 1;
1731 }
1732 /* "*0" should be processed before it gets here */
1733 switch (exten[1]) {
1734 case '6':
1735 case '7':
1736 case '8':
1737 return 1;
1738 }
1739 }
1740 return 0;
1741}

Referenced by __analog_ss_thread().

◆ analog_cb_handle_dtmf()

static void analog_cb_handle_dtmf ( struct analog_pvt p,
struct ast_channel ast,
enum analog_sub  analog_index,
struct ast_frame **  dest 
)
static

Definition at line 667 of file sig_analog.c.

668{
670 analog_callbacks.handle_dtmf(p->chan_pvt, ast, analog_index, dest);
671 }
672}
void(*const handle_dtmf)(void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest)
Definition: sig_analog.h:154

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::handle_dtmf.

Referenced by analog_handle_dtmf().

◆ analog_check_confirmanswer()

static int analog_check_confirmanswer ( struct analog_pvt p)
static

Definition at line 942 of file sig_analog.c.

943{
946 }
947
948 return 0;
949}
int(*const check_confirmanswer)(void *pvt)
Definition: sig_analog.h:245

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::check_confirmanswer.

Referenced by __analog_handle_event(), and analog_handle_dtmf().

◆ analog_check_for_conference()

static int analog_check_for_conference ( struct analog_pvt p)
static

Definition at line 545 of file sig_analog.c.

546{
549 }
550 return -1;
551}
int(*const check_for_conference)(void *pvt)
Definition: sig_analog.h:223

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::check_for_conference.

Referenced by __analog_handle_event().

◆ analog_check_waitingfordt()

static int analog_check_waitingfordt ( struct analog_pvt p)
static

Definition at line 926 of file sig_analog.c.

927{
930 }
931
932 return 0;
933}
int(*const check_waitingfordt)(void *pvt)
Definition: sig_analog.h:243

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::check_waitingfordt.

Referenced by __analog_handle_event().

◆ analog_cidstart_to_str()

const char * analog_cidstart_to_str ( enum analog_cid_start  cid_start)

Definition at line 249 of file sig_analog.c.

250{
251 switch (cid_start) {
253 return "Ring";
255 return "Polarity";
257 return "Polarity_In";
259 return "DTMF";
260 }
261
262 return "Unknown";
263}

References ANALOG_CID_START_DTMF_NOALERT, ANALOG_CID_START_POLARITY, ANALOG_CID_START_POLARITY_IN, and ANALOG_CID_START_RING.

◆ analog_cidtype_to_str()

const char * analog_cidtype_to_str ( unsigned int  cid_type)

Definition at line 149 of file sig_analog.c.

150{
151 int i;
152
153 for (i = 0; i < ARRAY_LEN(cidtypes); i++) {
154 if (cid_type == cidtypes[i].cid_type) {
155 return cidtypes[i].name;
156 }
157 }
158
159 return "Unknown";
160}
static const struct @142 cidtypes[]
unsigned int cid_type
Definition: sig_analog.c:96

References ARRAY_LEN, cid_type, and cidtypes.

◆ analog_config_complete()

int analog_config_complete ( struct analog_pvt p)

Definition at line 4135 of file sig_analog.c.

4136{
4137 /* No call waiting on non FXS channels */
4138 if ((p->sig != ANALOG_SIG_FXOKS) && (p->sig != ANALOG_SIG_FXOLS) && (p->sig != ANALOG_SIG_FXOGS)) {
4139 p->permcallwaiting = 0;
4140 }
4141
4143
4144 return 0;
4145}
unsigned int permcallwaiting
Definition: sig_analog.h:301

References analog_set_callwaiting(), ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, analog_pvt::permcallwaiting, and analog_pvt::sig.

Referenced by mkintf().

◆ analog_confmute()

static int analog_confmute ( struct analog_pvt p,
int  mute 
)
static

Definition at line 958 of file sig_analog.c.

959{
961 return analog_callbacks.confmute(p->chan_pvt, mute);
962 }
963 return 0;
964}
int(*const confmute)(void *pvt, int mute)
Definition: sig_analog.h:248

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::confmute.

Referenced by __analog_handle_event().

◆ analog_deadlock_avoidance_private()

static void analog_deadlock_avoidance_private ( struct analog_pvt p)
static

Definition at line 574 of file sig_analog.c.

575{
578 } else {
579 /* Fallback to manual avoidance if callback not present. */
581 usleep(1);
583 }
584}
void(*const deadlock_avoidance_private)(void *pvt)
Definition: sig_analog.h:149

References analog_callbacks, analog_lock_private(), analog_unlock_private(), analog_pvt::chan_pvt, and analog_callback::deadlock_avoidance_private.

Referenced by analog_lock_sub_owner().

◆ analog_decrease_ss_count()

static void analog_decrease_ss_count ( void  )
static

Definition at line 1671 of file sig_analog.c.

1672{
1675 }
1676}
void(*const decrease_ss_count)(void)
Definition: sig_analog.h:228

References analog_callbacks, and analog_callback::decrease_ss_count.

Referenced by __analog_ss_thread().

◆ analog_delete()

void analog_delete ( struct analog_pvt doomed)

Delete the analog private structure.

Since
1.8
Parameters
doomedAnalog private structure to delete.

Definition at line 4130 of file sig_analog.c.

4131{
4132 ast_free(doomed);
4133}
#define ast_free(a)
Definition: astmm.h:180

References ast_free.

Referenced by destroy_dahdi_pvt().

◆ analog_dial_digits()

static int analog_dial_digits ( struct analog_pvt p,
enum analog_sub  sub,
struct analog_dialoperation dop 
)
static

Definition at line 521 of file sig_analog.c.

522{
524 return analog_callbacks.dial_digits(p->chan_pvt, sub, dop);
525 }
526 return -1;
527}
struct stasis_forward * sub
Definition: res_corosync.c:240
int(*const dial_digits)(void *pvt, enum analog_sub sub, struct analog_dialoperation *dop)
Definition: sig_analog.h:180

References analog_callbacks, analog_pvt::chan_pvt, analog_callback::dial_digits, and sub.

Referenced by __analog_handle_event(), and analog_call().

◆ analog_distinctive_ring()

static int analog_distinctive_ring ( struct ast_channel chan,
struct analog_pvt p,
int  idx,
int *  ringdata 
)
static

Definition at line 1678 of file sig_analog.c.

1679{
1681 return 0;
1682 }
1684 return analog_callbacks.distinctive_ring(chan, p->chan_pvt, idx, ringdata);
1685 }
1686 return -1;
1687
1688}
int(*const distinctive_ring)(struct ast_channel *chan, void *pvt, int idx, int *ringdata)
Definition: sig_analog.h:230

References analog_callbacks, analog_pvt::chan_pvt, analog_callback::distinctive_ring, and analog_pvt::usedistinctiveringdetection.

Referenced by __analog_ss_thread().

◆ analog_dnd()

int analog_dnd ( struct analog_pvt p,
int  flag 
)

Definition at line 4191 of file sig_analog.c.

4192{
4193 if (flag == -1) {
4194 return p->dnd;
4195 }
4196
4197 p->dnd = flag;
4198
4199 ast_verb(3, "%s DND on channel %d\n",
4200 flag ? "Enabled" : "Disabled",
4201 p->channel);
4202 analog_publish_dnd_state(p->channel, flag ? "enabled" : "disabled");
4203
4204 return 0;
4205}
long int flag
Definition: f2c.h:83
static void analog_publish_dnd_state(int channel, const char *status)
Definition: sig_analog.c:4171

References analog_publish_dnd_state(), ast_verb, analog_pvt::channel, and analog_pvt::dnd.

Referenced by __analog_ss_thread(), and dahdi_dnd().

◆ analog_dsp_reset_and_flush_digits()

static int analog_dsp_reset_and_flush_digits ( struct analog_pvt p)
static

Definition at line 428 of file sig_analog.c.

429{
432 }
433
434 /* Return 0 since I think this is unnecessary to do in most cases it is used. Mostly only for ast_dsp */
435 return 0;
436}
int(*const dsp_reset_and_flush_digits)(void *pvt)
Definition: sig_analog.h:187

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::dsp_reset_and_flush_digits.

Referenced by __analog_ss_thread().

◆ analog_dsp_set_digitmode()

static int analog_dsp_set_digitmode ( struct analog_pvt p,
enum analog_dsp_digitmode  mode 
)
static

Definition at line 659 of file sig_analog.c.

660{
663 }
664 return -1;
665}
int(*const dsp_set_digitmode)(void *pvt, enum analog_dsp_digitmode mode)
Definition: sig_analog.h:186

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::dsp_set_digitmode.

Referenced by __analog_ss_thread(), and analog_hangup().

◆ analog_event2str()

static char * analog_event2str ( enum analog_event  event)
static

Definition at line 265 of file sig_analog.c.

266{
267 char *res;
268 switch (event) {
270 res = "ANALOG_EVENT_ONHOOK";
271 break;
273 res = "ANALOG_EVENT_RINGOFFHOOK";
274 break;
276 res = "ANALOG_EVENT_WINKFLASH";
277 break;
279 res = "ANALOG_EVENT_ALARM";
280 break;
282 res = "ANALOG_EVENT_NOALARM";
283 break;
285 res = "ANALOG_EVENT_DIALCOMPLETE";
286 break;
288 res = "ANALOG_EVENT_HOOKCOMPLETE";
289 break;
291 res = "ANALOG_EVENT_PULSE_START";
292 break;
294 res = "ANALOG_EVENT_POLARITY";
295 break;
297 res = "ANALOG_EVENT_RINGBEGIN";
298 break;
300 res = "ANALOG_EVENT_EC_DISABLED";
301 break;
303 res = "ANALOG_EVENT_RINGERON";
304 break;
306 res = "ANALOG_EVENT_RINGEROFF";
307 break;
309 res = "ANALOG_EVENT_REMOVED";
310 break;
312 res = "ANALOG_EVENT_NEONMWI_ACTIVE";
313 break;
315 res = "ANALOG_EVENT_NEONMWI_INACTIVE";
316 break;
317#ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE
319 res = "ANALOG_EVENT_TX_CED_DETECTED";
320 break;
322 res = "ANALOG_EVENT_RX_CED_DETECTED";
323 break;
325 res = "ANALOG_EVENT_EC_NLP_DISABLED";
326 break;
328 res = "ANALOG_EVENT_EC_NLP_ENABLED";
329 break;
330#endif
332 res = "ANALOG_EVENT_PULSEDIGIT";
333 break;
335 res = "ANALOG_EVENT_DTMFDOWN";
336 break;
338 res = "ANALOG_EVENT_DTMFUP";
339 break;
340 default:
341 res = "UNKNOWN/OTHER";
342 break;
343 }
344
345 return res;
346}
@ ANALOG_EVENT_NEONMWI_ACTIVE
Definition: sig_analog.h:95
@ ANALOG_EVENT_NEONMWI_INACTIVE
Definition: sig_analog.h:96
@ ANALOG_EVENT_REMOVED
Definition: sig_analog.h:94
Definition: astman.c:222

References ANALOG_EVENT_ALARM, ANALOG_EVENT_DIALCOMPLETE, ANALOG_EVENT_DTMFDOWN, ANALOG_EVENT_DTMFUP, ANALOG_EVENT_EC_DISABLED, ANALOG_EVENT_EC_NLP_DISABLED, ANALOG_EVENT_EC_NLP_ENABLED, ANALOG_EVENT_HOOKCOMPLETE, ANALOG_EVENT_NEONMWI_ACTIVE, ANALOG_EVENT_NEONMWI_INACTIVE, ANALOG_EVENT_NOALARM, ANALOG_EVENT_ONHOOK, ANALOG_EVENT_POLARITY, ANALOG_EVENT_PULSE_START, ANALOG_EVENT_PULSEDIGIT, ANALOG_EVENT_REMOVED, ANALOG_EVENT_RINGBEGIN, ANALOG_EVENT_RINGEROFF, ANALOG_EVENT_RINGERON, ANALOG_EVENT_RINGOFFHOOK, ANALOG_EVENT_RX_CED_DETECTED, ANALOG_EVENT_TX_CED_DETECTED, and ANALOG_EVENT_WINKFLASH.

Referenced by __analog_handle_event(), analog_exception(), and analog_handle_init_event().

◆ analog_exception()

struct ast_frame * analog_exception ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 3699 of file sig_analog.c.

3700{
3701 int res;
3702 int idx;
3703 struct ast_frame *f;
3704
3705 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
3706
3707 idx = analog_get_index(ast, p, 1);
3708 if (idx < 0) {
3709 idx = ANALOG_SUB_REAL;
3710 }
3711
3712 p->subs[idx].f.frametype = AST_FRAME_NULL;
3713 p->subs[idx].f.datalen = 0;
3714 p->subs[idx].f.samples = 0;
3715 p->subs[idx].f.mallocd = 0;
3716 p->subs[idx].f.offset = 0;
3717 p->subs[idx].f.subclass.integer = 0;
3718 p->subs[idx].f.delivery = ast_tv(0,0);
3719 p->subs[idx].f.src = "dahdi_exception";
3720 p->subs[idx].f.data.ptr = NULL;
3721
3722 if (!p->owner) {
3723 /* If nobody owns us, absorb the event appropriately, otherwise
3724 we loop indefinitely. This occurs when, during call waiting, the
3725 other end hangs up our channel so that it no longer exists, but we
3726 have neither FLASH'd nor ONHOOK'd to signify our desire to
3727 change to the other channel. */
3728 res = analog_get_event(p);
3729
3730 /* Switch to real if there is one and this isn't something really silly... */
3731 if ((res != ANALOG_EVENT_RINGEROFF) && (res != ANALOG_EVENT_RINGERON) &&
3732 (res != ANALOG_EVENT_HOOKCOMPLETE)) {
3733 ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
3735 if (p->owner && ast != p->owner) {
3736 /*
3737 * Could this even happen?
3738 * Possible deadlock because we do not have the real-call lock.
3739 */
3740 ast_log(LOG_WARNING, "Event %s on %s is not restored owner %s\n",
3742 }
3743 if (p->owner) {
3745 }
3746 }
3747 switch (res) {
3750 if (p->owner) {
3751 ast_verb(3, "Channel %s still has call, ringing phone\n", ast_channel_name(p->owner));
3752 analog_ring(p);
3754 } else {
3755 ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
3756 analog_event2str(res));
3757 }
3759 break;
3762 analog_off_hook(p);
3763 if (p->owner && (ast_channel_state(p->owner) == AST_STATE_RINGING)) {
3765 analog_set_dialing(p, 0);
3766 }
3767 break;
3771 /* Do nothing */
3772 break;
3774 gettimeofday(&p->flashtime, NULL);
3775 if (p->owner) {
3776 ast_verb(3, "Channel %d flashed to other channel %s\n", p->channel, ast_channel_name(p->owner));
3778 /* Answer if necessary */
3781 }
3784 } else {
3785 ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
3786 analog_event2str(res));
3787 }
3789 break;
3790 default:
3791 ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", analog_event2str(res));
3792 break;
3793 }
3794 f = &p->subs[idx].f;
3795 return f;
3796 }
3797 ast_debug(1, "Exception on %d, channel %d\n", ast_channel_fd(ast, 0), p->channel);
3798 /* If it's not us, return NULL immediately */
3799 if (ast != p->owner) {
3800 ast_log(LOG_WARNING, "We're %s, not %s\n", ast_channel_name(ast), ast_channel_name(p->owner));
3801 f = &p->subs[idx].f;
3802 return f;
3803 }
3804
3805 f = __analog_handle_event(p, ast);
3806 if (!f) {
3807 const char *name = ast_strdupa(ast_channel_name(ast));
3808
3809 /* Tell the CDR this DAHDI device hung up */
3811 ast_channel_unlock(ast);
3812 ast_set_hangupsource(ast, name, 0);
3813 ast_channel_lock(ast);
3815 }
3816 return f;
3817}
int ast_channel_fd(const struct ast_channel *chan, int which)
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
Definition: channel.c:2528
static struct ast_frame * __analog_handle_event(struct analog_pvt *p, struct ast_channel *ast)
Definition: sig_analog.c:2799
struct timeval delivery
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Definition: time.h:235

References __analog_handle_event(), analog_event2str(), ANALOG_EVENT_HOOKCOMPLETE, ANALOG_EVENT_ONHOOK, ANALOG_EVENT_RINGEROFF, ANALOG_EVENT_RINGERON, ANALOG_EVENT_RINGOFFHOOK, ANALOG_EVENT_WINKFLASH, analog_get_event(), analog_get_index, analog_lock_private(), analog_off_hook(), analog_ring(), analog_set_dialing(), analog_set_echocanceller(), analog_set_new_owner(), analog_stop_callwait(), ANALOG_SUB_REAL, analog_unlock_private(), analog_update_conf(), ast_channel_fd(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, AST_CONTROL_ANSWER, ast_debug, AST_FRAME_NULL, ast_log, ast_queue_control(), ast_queue_unhold(), ast_set_hangupsource(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, ast_strdupa, ast_tv(), ast_verb, analog_pvt::channel, ast_frame::data, ast_frame::datalen, ast_frame::delivery, analog_subchannel::f, analog_pvt::flashtime, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_frame::mallocd, name, NULL, ast_frame::offset, analog_subchannel::owner, analog_pvt::owner, ast_frame::ptr, ast_frame::samples, ast_frame::src, ast_frame::subclass, and analog_pvt::subs.

Referenced by dahdi_exception(), and dahdi_read().

◆ analog_fixup()

int analog_fixup ( struct ast_channel oldchan,
struct ast_channel newchan,
void *  newp 
)

Definition at line 4153 of file sig_analog.c.

4154{
4155 struct analog_pvt *new_pvt = newp;
4156 int x;
4157 ast_debug(1, "New owner for channel %d is %s\n", new_pvt->channel, ast_channel_name(newchan));
4158 if (new_pvt->owner == oldchan) {
4159 analog_set_new_owner(new_pvt, newchan);
4160 }
4161 for (x = 0; x < 3; x++) {
4162 if (new_pvt->subs[x].owner == oldchan) {
4163 new_pvt->subs[x].owner = newchan;
4164 }
4165 }
4166
4167 analog_update_conf(new_pvt);
4168 return 0;
4169}

References analog_set_new_owner(), analog_update_conf(), ast_channel_name(), ast_debug, analog_pvt::channel, analog_subchannel::owner, analog_pvt::owner, and analog_pvt::subs.

Referenced by dahdi_fixup().

◆ analog_flash()

static int analog_flash ( struct analog_pvt p)
static

Definition at line 505 of file sig_analog.c.

506{
509 }
510 return -1;
511}
int(*const flash)(void *pvt)
Definition: sig_analog.h:163

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::flash.

Referenced by __analog_ss_thread().

◆ analog_free()

void analog_free ( struct analog_pvt p)

Definition at line 4147 of file sig_analog.c.

4148{
4149 ast_free(p);
4150}

References ast_free.

◆ analog_get_and_handle_alarms()

static void analog_get_and_handle_alarms ( struct analog_pvt p)
static

◆ analog_get_bridged_channel()

static void * analog_get_bridged_channel ( struct ast_channel chan)
static

Definition at line 1697 of file sig_analog.c.

1698{
1701 }
1702 return NULL;
1703}
void *(*const get_sigpvt_bridged_channel)(struct ast_channel *chan)
Definition: sig_analog.h:235

References analog_callbacks, analog_callback::get_sigpvt_bridged_channel, and NULL.

Referenced by __analog_ss_thread().

◆ analog_get_callerid()

static int analog_get_callerid ( struct analog_pvt p,
char *  name,
char *  number,
enum analog_event ev,
size_t  timeout 
)
static

Definition at line 178 of file sig_analog.c.

179{
181 return analog_callbacks.get_callerid(p->chan_pvt, name, number, ev, timeout);
182 }
183 return -1;
184}
int(*const get_callerid)(void *pvt, char *name, char *num, enum analog_event *ev, size_t timeout)
Definition: sig_analog.h:190

References analog_callbacks, analog_pvt::chan_pvt, analog_callback::get_callerid, and name.

Referenced by __analog_ss_thread().

◆ analog_get_event()

static int analog_get_event ( struct analog_pvt p)
static

Definition at line 194 of file sig_analog.c.

195{
198 }
199 return -1;
200}
int(*const get_event)(void *pvt)
Definition: sig_analog.h:156

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::get_event.

Referenced by __analog_handle_event(), and analog_exception().

◆ analog_get_orig_dialstring()

static const char * analog_get_orig_dialstring ( struct analog_pvt p)
static

Definition at line 186 of file sig_analog.c.

187{
190 }
191 return "";
192}
const char *(*const get_orig_dialstring)(void *pvt)
Definition: sig_analog.h:252

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::get_orig_dialstring.

Referenced by analog_call().

◆ analog_get_sub_fd()

static int analog_get_sub_fd ( struct analog_pvt p,
enum analog_sub  sub 
)
static

Definition at line 1705 of file sig_analog.c.

1706{
1709 }
1710 return -1;
1711}
int(*const get_sub_fd)(void *pvt, enum analog_sub sub)
Definition: sig_analog.h:236

References analog_callbacks, analog_pvt::chan_pvt, analog_callback::get_sub_fd, and sub.

Referenced by __analog_handle_event().

◆ analog_handle_dtmf()

void analog_handle_dtmf ( struct analog_pvt p,
struct ast_channel ast,
enum analog_sub  idx,
struct ast_frame **  dest 
)

Definition at line 1593 of file sig_analog.c.

1594{
1595 struct ast_frame *f = *dest;
1596
1597 ast_debug(1, "%s DTMF digit: 0x%02X '%c' on %s\n",
1598 f->frametype == AST_FRAME_DTMF_BEGIN ? "Begin" : "End",
1599 (unsigned)f->subclass.integer, f->subclass.integer, ast_channel_name(ast));
1600
1602 if (f->frametype == AST_FRAME_DTMF_END) {
1603 ast_debug(1, "Confirm answer on %s!\n", ast_channel_name(ast));
1604 /* Upon receiving a DTMF digit, consider this an answer confirmation instead
1605 of a DTMF digit */
1608 /* Reset confirmanswer so DTMF's will behave properly for the duration of the call */
1610 } else {
1611 p->subs[idx].f.frametype = AST_FRAME_NULL;
1612 p->subs[idx].f.subclass.integer = 0;
1613 }
1614 *dest = &p->subs[idx].f;
1615 } else if (p->callwaitcas) {
1616 if (f->frametype == AST_FRAME_DTMF_END) {
1617 if ((f->subclass.integer == 'A') || (f->subclass.integer == 'D')) {
1618 ast_debug(1, "Got some DTMF, but it's for the CAS\n");
1619 p->caller.id.name.str = p->callwait_name;
1621 analog_send_callerid(p, 1, &p->caller);
1622 }
1623 if (analog_handles_digit(f)) {
1624 p->callwaitcas = 0;
1625 }
1626 }
1627 p->subs[idx].f.frametype = AST_FRAME_NULL;
1628 p->subs[idx].f.subclass.integer = 0;
1629 *dest = &p->subs[idx].f;
1630 } else {
1631 analog_cb_handle_dtmf(p, ast, idx, dest);
1632 }
1633}
static void analog_set_confirmanswer(struct analog_pvt *p, int flag)
Definition: sig_analog.c:935
static void analog_cb_handle_dtmf(struct analog_pvt *p, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest)
Definition: sig_analog.c:667
static int analog_handles_digit(struct ast_frame *f)
Definition: sig_analog.c:1568

References analog_cb_handle_dtmf(), analog_check_confirmanswer(), analog_handles_digit(), analog_send_callerid(), analog_set_confirmanswer(), ast_channel_name(), AST_CONTROL_ANSWER, ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_NULL, analog_pvt::caller, analog_pvt::callwait_name, analog_pvt::callwait_num, analog_pvt::callwaitcas, analog_subchannel::f, ast_frame::frametype, ast_party_caller::id, ast_frame_subclass::integer, ast_party_id::name, ast_party_id::number, ast_party_name::str, ast_party_number::str, ast_frame::subclass, and analog_pvt::subs.

Referenced by __analog_handle_event(), and dahdi_read().

◆ analog_handle_init_event()

void * analog_handle_init_event ( struct analog_pvt i,
int  event 
)

Definition at line 3819 of file sig_analog.c.

3820{
3821 int res;
3822 pthread_t threadid;
3823 struct ast_channel *chan;
3824 ast_callid callid = 0;
3825 int callid_created;
3826
3827 ast_debug(1, "channel (%d) - signaling (%d) - event (%s)\n",
3829
3830 /* Handle an event on a given channel for the monitor thread. */
3831 switch (event) {
3834 switch (i->sig) {
3835 case ANALOG_SIG_FXSLS:
3836 case ANALOG_SIG_FXSGS:
3837 case ANALOG_SIG_FXSKS:
3838 if (i->immediate) {
3840 ast_log(LOG_WARNING, "Can't start PBX immediately, must wait for Caller ID / distinctive ring\n");
3841 } else {
3842 /* If we don't care about Caller ID or Distinctive Ring, then there's
3843 * no need to wait for anything before accepting the call, as
3844 * waiting will buy us nothing.
3845 * So if the channel is configured for immediate, actually start immediately
3846 * and get the show on the road as soon as possible. */
3847 ast_debug(1, "Disabling ring timeout (previously %d) to begin handling immediately\n", i->ringt_base);
3849 }
3850 }
3851 break;
3852 default:
3853 break;
3854 }
3855 /* Fall through */
3856 if (!(ISTRUNK(i) && i->immediate && !i->use_callerid && !i->usedistinctiveringdetection)) {
3857 break;
3858 }
3860 if (i->inalarm) {
3861 break;
3862 }
3863 /* Got a ring/answer. What kind of channel are we? */
3864 switch (i->sig) {
3865 case ANALOG_SIG_FXOLS:
3866 case ANALOG_SIG_FXOGS:
3867 case ANALOG_SIG_FXOKS:
3868 res = analog_off_hook(i);
3869 i->fxsoffhookstate = 1;
3870 i->cshactive = 0;
3871 if (res && (errno == EBUSY)) {
3872 break;
3873 }
3874 callid_created = ast_callid_threadstorage_auto(&callid);
3875
3876 /* Cancel VMWI spill */
3878
3879 if (i->immediate) {
3881 /* The channel is immediately up. Start right away */
3882 if (i->immediatering) {
3883 /* Play fake ringing, if we've been told to... */
3885 }
3887 if (!chan) {
3888 ast_log(LOG_WARNING, "Unable to start PBX on channel %d\n", i->channel);
3890 if (res < 0) {
3891 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3892 }
3893 }
3894 } else {
3895 /* Check for callerid, digits, etc */
3897 i->ss_astchan = chan;
3898 if (chan) {
3899 if (analog_has_voicemail(i)) {
3901 } else {
3903 }
3904 if (res < 0)
3905 ast_log(LOG_WARNING, "Unable to play dialtone on channel %d, do you have defaultzone and loadzone defined?\n", i->channel);
3906
3908 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
3910 if (res < 0) {
3911 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3912 }
3913 ast_hangup(chan);
3914 }
3915 } else
3916 ast_log(LOG_WARNING, "Unable to create channel\n");
3917 }
3919 break;
3920 case ANALOG_SIG_FXSLS:
3921 case ANALOG_SIG_FXSGS:
3922 case ANALOG_SIG_FXSKS:
3924 /* Fall through */
3925 case ANALOG_SIG_EMWINK:
3926 case ANALOG_SIG_FEATD:
3927 case ANALOG_SIG_FEATDMF:
3929 case ANALOG_SIG_E911:
3932 case ANALOG_SIG_FEATB:
3933 case ANALOG_SIG_EM:
3934 case ANALOG_SIG_EM_E1:
3935 case ANALOG_SIG_SFWINK:
3939 case ANALOG_SIG_SF:
3940 callid_created = ast_callid_threadstorage_auto(&callid);
3941 /* Check for callerid, digits, etc */
3944 } else {
3946 }
3947 i->ss_astchan = chan;
3948 if (!chan) {
3949 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
3950 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
3951 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
3953 if (res < 0) {
3954 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3955 }
3956 ast_hangup(chan);
3957 }
3959 break;
3960 default:
3961 ast_log(LOG_WARNING, "Don't know how to handle ring/answer with signalling %s on channel %d\n", analog_sigtype_to_str(i->sig), i->channel);
3963 if (res < 0) {
3964 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3965 }
3966 return NULL;
3967 }
3968 break;
3970 analog_set_alarm(i, 0);
3972 break;
3973 case ANALOG_EVENT_ALARM:
3974 analog_set_alarm(i, 1);
3976 /* fall thru intentionally */
3978 /* Back on hook. Hang up. */
3979 switch (i->sig) {
3980 case ANALOG_SIG_FXOLS:
3981 case ANALOG_SIG_FXOGS:
3982 i->fxsoffhookstate = 0;
3984 /* Fall through */
3985 case ANALOG_SIG_FEATD:
3986 case ANALOG_SIG_FEATDMF:
3988 case ANALOG_SIG_E911:
3991 case ANALOG_SIG_FEATB:
3992 case ANALOG_SIG_EM:
3993 case ANALOG_SIG_EM_E1:
3994 case ANALOG_SIG_EMWINK:
3998 case ANALOG_SIG_SF:
3999 case ANALOG_SIG_SFWINK:
4000 case ANALOG_SIG_FXSLS:
4001 case ANALOG_SIG_FXSGS:
4002 case ANALOG_SIG_FXSKS:
4004 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
4005 analog_on_hook(i);
4006 break;
4007 case ANALOG_SIG_FXOKS:
4008 i->fxsoffhookstate = 0;
4011 /* Diddle the battery for the zhone */
4012#ifdef ZHONE_HACK
4013 analog_off_hook(i);
4014 usleep(1);
4015#endif
4016 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
4017 analog_on_hook(i);
4018 break;
4019 default:
4020 ast_log(LOG_WARNING, "Don't know how to handle on hook with signalling %s on channel %d\n", analog_sigtype_to_str(i->sig), i->channel);
4021 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
4022 return NULL;
4023 }
4024 break;
4026 switch (i->sig) {
4027 case ANALOG_SIG_FXSLS:
4028 case ANALOG_SIG_FXSKS:
4029 case ANALOG_SIG_FXSGS:
4030 callid_created = ast_callid_threadstorage_auto(&callid);
4031 /* We have already got a PR before the channel was
4032 created, but it wasn't handled. We need polarity
4033 to be REV for remote hangup detection to work.
4034 At least in Spain */
4035 if (i->hanguponpolarityswitch) {
4037 }
4040 ast_verb(2, "Starting post polarity CID detection on channel %d\n",
4041 i->channel);
4043 i->ss_astchan = chan;
4044 if (!chan) {
4045 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
4046 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
4047 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
4048 ast_hangup(chan);
4049 }
4050 }
4052 break;
4053 default:
4055 "handle_init_event detected polarity reversal on non-FXO (ANALOG_SIG_FXS) interface %d\n",
4056 i->channel);
4057 break;
4058 }
4059 break;
4061 switch (i->sig) {
4062 case ANALOG_SIG_FXSLS:
4063 case ANALOG_SIG_FXSKS:
4064 case ANALOG_SIG_FXSGS:
4065 callid_created = ast_callid_threadstorage_auto(&callid);
4067 ast_verb(2, "Starting DTMF CID detection on channel %d\n",
4068 i->channel);
4070 i->ss_astchan = chan;
4071 if (!chan) {
4072 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
4073 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
4074 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
4075 ast_hangup(chan);
4076 }
4077 }
4079 break;
4080 default:
4082 "handle_init_event detected dtmfcid generation event on non-FXO (ANALOG_SIG_FXS) interface %d\n",
4083 i->channel);
4084 break;
4085 }
4086 break;
4087 case ANALOG_EVENT_REMOVED: /* destroy channel, will actually do so in do_monitor */
4088 ast_log(LOG_NOTICE, "Got ANALOG_EVENT_REMOVED. Destroying channel %d\n",
4089 i->channel);
4090 return i->chan_pvt;
4093 break;
4096 break;
4097 }
4098 return NULL;
4099}
@ ANALOG_EVENT_DTMFCID
Definition: sig_analog.h:102
unsigned int immediatering
Definition: sig_analog.h:299

References __analog_ss_thread(), analog_cancel_cidspill(), ANALOG_CID_START_DTMF_NOALERT, ANALOG_CID_START_POLARITY, ANALOG_CID_START_POLARITY_IN, analog_event2str(), ANALOG_EVENT_ALARM, ANALOG_EVENT_DTMFCID, ANALOG_EVENT_NEONMWI_ACTIVE, ANALOG_EVENT_NEONMWI_INACTIVE, ANALOG_EVENT_NOALARM, ANALOG_EVENT_ONHOOK, ANALOG_EVENT_POLARITY, ANALOG_EVENT_REMOVED, ANALOG_EVENT_RINGBEGIN, ANALOG_EVENT_RINGOFFHOOK, ANALOG_EVENT_WINKFLASH, analog_get_and_handle_alarms(), analog_handle_notify_message(), analog_has_voicemail(), analog_new_ast_channel(), analog_off_hook(), analog_on_hook(), analog_play_tone(), analog_publish_channel_alarm_clear(), analog_set_alarm(), analog_set_echocanceller(), analog_set_ringtimeout(), ANALOG_SIG_E911, ANALOG_SIG_EM, ANALOG_SIG_EM_E1, ANALOG_SIG_EMWINK, ANALOG_SIG_FEATB, ANALOG_SIG_FEATD, ANALOG_SIG_FEATDMF, ANALOG_SIG_FEATDMF_TA, ANALOG_SIG_FGC_CAMA, ANALOG_SIG_FGC_CAMAMF, ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, ANALOG_SIG_FXSGS, ANALOG_SIG_FXSKS, ANALOG_SIG_FXSLS, ANALOG_SIG_SF, ANALOG_SIG_SF_FEATB, ANALOG_SIG_SF_FEATD, ANALOG_SIG_SF_FEATDMF, ANALOG_SIG_SFWINK, analog_sigtype_to_str(), analog_start_polarityswitch(), ANALOG_SUB_REAL, ANALOG_TONE_CONGESTION, ANALOG_TONE_DIALTONE, ANALOG_TONE_RINGTONE, ANALOG_TONE_STUTTER, ast_callid_threadstorage_auto(), ast_callid_threadstorage_auto_clean(), ast_debug, ast_hangup(), ast_log, ast_pthread_create_detached, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, ast_verb, ast_channel::callid, analog_pvt::chan_pvt, analog_pvt::channel, analog_pvt::cid_start, analog_pvt::cshactive, errno, analog_pvt::fxsoffhookstate, analog_pvt::hanguponpolarityswitch, analog_pvt::immediate, analog_pvt::immediatering, analog_pvt::inalarm, ISTRUNK, LOG_NOTICE, LOG_WARNING, NULL, analog_pvt::polarity, POLARITY_REV, analog_pvt::ringt_base, analog_pvt::sig, analog_pvt::ss_astchan, analog_pvt::use_callerid, and analog_pvt::usedistinctiveringdetection.

Referenced by do_monitor().

◆ analog_handle_notify_message()

static int analog_handle_notify_message ( struct ast_channel chan,
struct analog_pvt p,
int  cid_flags,
int  neon_mwievent 
)
static

Definition at line 1655 of file sig_analog.c.

1656{
1658 analog_callbacks.handle_notify_message(chan, p->chan_pvt, cid_flags, neon_mwievent);
1659 return 0;
1660 }
1661 return -1;
1662}
void(*const handle_notify_message)(struct ast_channel *chan, void *pvt, int cid_flags, int neon_mwievent)
Definition: sig_analog.h:224

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::handle_notify_message.

Referenced by __analog_ss_thread(), and analog_handle_init_event().

◆ analog_handles_digit()

static int analog_handles_digit ( struct ast_frame f)
static

Definition at line 1568 of file sig_analog.c.

1569{
1570 char subclass = toupper(f->subclass.integer);
1571
1572 switch (subclass) {
1573 case '1':
1574 case '2':
1575 case '3':
1576 case '4':
1577 case '5':
1578 case '6':
1579 case '7':
1580 case '9':
1581 case 'A':
1582 case 'B':
1583 case 'C':
1584 case 'D':
1585 case 'E':
1586 case 'F':
1587 return 1;
1588 default:
1589 return 0;
1590 }
1591}

References ast_frame_subclass::integer, and ast_frame::subclass.

Referenced by analog_handle_dtmf().

◆ analog_hangup()

int analog_hangup ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 1277 of file sig_analog.c.

1278{
1279 int res;
1280 int idx, x;
1281
1282 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
1283 if (!ast_channel_tech_pvt(ast)) {
1284 ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
1285 return 0;
1286 }
1287
1288 idx = analog_get_index(ast, p, 1);
1289
1290 x = 0;
1291 if (p->origcid_num) {
1292 ast_copy_string(p->cid_num, p->origcid_num, sizeof(p->cid_num));
1294 p->origcid_num = NULL;
1295 }
1296 if (p->origcid_name) {
1297 ast_copy_string(p->cid_name, p->origcid_name, sizeof(p->cid_name));
1299 p->origcid_name = NULL;
1300 }
1301
1303
1304 ast_debug(1, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
1306 if (idx > -1) {
1307 /* Real channel, do some fixup */
1308 p->cshactive = 0;
1309 p->subs[idx].owner = NULL;
1311 analog_set_linear_mode(p, idx, 0);
1312 switch (idx) {
1313 case ANALOG_SUB_REAL:
1315 ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
1317 /* We had flipped over to answer a callwait and now it's gone */
1318 ast_debug(1, "We were flipped over to the callwait, moving back and not owning.\n");
1319 /* Move to the call-wait, but un-own us until they flip back. */
1323 } else {
1324 /* The three way hung up, but we still have a call wait */
1325 ast_debug(1, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
1329 /* This was part of a three way call. Immediately make way for
1330 another call */
1331 ast_debug(1, "Call was complete, setting owner to former third call\n");
1334 } else {
1335 /* This call hasn't been completed yet... Set owner to NULL */
1336 ast_debug(1, "Call was incomplete, setting owner to NULL\n");
1338 }
1339 }
1340 } else if (p->subs[ANALOG_SUB_CALLWAIT].allocd) {
1341 /* Need to hold the lock for real-call, private, and call-waiting call */
1343 if (!p->subs[ANALOG_SUB_CALLWAIT].owner) {
1344 /* The call waiting call disappeared. */
1346 break;
1347 }
1348
1349 /* Move to the call-wait and switch back to them. */
1355 }
1357 /* Unlock the call-waiting call that we swapped to real-call. */
1359 } else if (p->subs[ANALOG_SUB_THREEWAY].allocd) {
1363 /* This was part of a three way call. Immediately make way for
1364 another call */
1365 ast_debug(1, "Call was complete, setting owner to former third call\n");
1368 } else {
1369 /* This call hasn't been completed yet... Set owner to NULL */
1370 ast_debug(1, "Call was incomplete, setting owner to NULL\n");
1372 }
1373 }
1374 break;
1376 /* Ditch the holding callwait call, and immediately make it available */
1378 /* Need to hold the lock for call-waiting call, private, and 3-way call */
1380
1381 /* This is actually part of a three way, placed on hold. Place the third part
1382 on music on hold now */
1383 if (p->subs[ANALOG_SUB_THREEWAY].owner) {
1385 }
1387 /* Make it the call wait now */
1390 if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
1391 /* Unlock the 3-way call that we swapped to call-waiting call. */
1393 }
1394 } else {
1396 }
1397 break;
1399 /* Need to hold the lock for 3-way call, private, and call-waiting call */
1402 /* The other party of the three way call is currently in a call-wait state.
1403 Start music on hold for them, and take the main guy out of the third call */
1405 if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
1407 }
1408 }
1409 if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
1411 }
1413 /* If this was part of a three way call index, let us make
1414 another three way call */
1416 break;
1417 default:
1418 /*
1419 * Should never happen.
1420 * This wasn't any sort of call, so how are we an index?
1421 */
1422 ast_log(LOG_ERROR, "Index found but not any type of call?\n");
1423 break;
1424 }
1425 }
1426
1432 analog_set_outgoing(p, 0);
1433 p->onhooktime = time(NULL);
1434 p->cidrings = 1;
1435
1436 /* Perform low level hangup if no owner left */
1437 res = analog_on_hook(p);
1438 if (res < 0) {
1439 ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast_channel_name(ast));
1440 }
1441 switch (p->sig) {
1442 case ANALOG_SIG_FXOGS:
1443 case ANALOG_SIG_FXOLS:
1444 case ANALOG_SIG_FXOKS:
1445 /* If they're off hook, try playing congestion */
1446 if (analog_is_off_hook(p)) {
1449 } else {
1451 }
1452 break;
1453 case ANALOG_SIG_FXSGS:
1454 case ANALOG_SIG_FXSLS:
1455 case ANALOG_SIG_FXSKS:
1456 /* Make sure we're not made available for at least two seconds assuming
1457 we were actually used for an inbound or outbound call. */
1459 time(&p->guardtime);
1460 p->guardtime += 2;
1461 }
1462 break;
1463 default:
1465 break;
1466 }
1467
1469
1470 x = 0;
1471 ast_channel_setoption(ast,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0);
1472 ast_channel_setoption(ast,AST_OPTION_TDD,&x,sizeof(char),0);
1473 p->callwaitcas = 0;
1475 /* In theory, the below is not necessary since we set hidecallerid = permhidecaller when calls start,
1476 * but this ensures the setting is defaulted properly when channels are idle, too. */
1478 analog_set_dialing(p, 0);
1481 }
1482
1484
1485 ast_verb(3, "Hanging up on '%s'\n", ast_channel_name(ast));
1486
1487 return 0;
1488}
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition: channel.c:7443
#define AST_OPTION_TONE_VERIFY
#define AST_OPTION_TDD
static void analog_hangup_polarityswitch(struct analog_pvt *p)
Definition: sig_analog.c:652
static void analog_all_subchannels_hungup(struct analog_pvt *p)
Definition: sig_analog.c:553

References analog_subchannel::allocd, analog_all_subchannels_hungup(), ANALOG_DIGITMODE_DTMF, analog_dsp_set_digitmode(), analog_get_index, analog_hangup_polarityswitch(), analog_is_off_hook(), analog_lock_sub_owner(), analog_on_hook(), analog_play_tone(), analog_set_callwaiting(), analog_set_confirmanswer(), analog_set_dialing(), analog_set_echocanceller(), analog_set_inthreeway(), analog_set_linear_mode(), analog_set_new_owner(), analog_set_outgoing(), analog_set_pulsedial(), analog_set_ringtimeout(), ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, ANALOG_SIG_FXSGS, ANALOG_SIG_FXSKS, ANALOG_SIG_FXSLS, analog_stop_callwait(), ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY, analog_swap_subs(), ANALOG_TONE_CONGESTION, analog_unalloc_sub(), analog_update_conf(), ast_channel_name(), ast_channel_setoption(), ast_channel_tech_pvt(), ast_channel_unlock, AST_CONTROL_ANSWER, ast_copy_string(), ast_debug, ast_free, ast_log, AST_OPTION_TDD, AST_OPTION_TONE_VERIFY, ast_queue_control(), ast_queue_hold(), ast_queue_unhold(), AST_STATE_RESERVED, AST_STATE_UP, ast_verb, analog_pvt::callwaitcas, analog_pvt::channel, analog_pvt::cid_name, analog_pvt::cid_num, analog_pvt::cidrings, analog_pvt::cshactive, analog_pvt::guardtime, analog_pvt::hidecallerid, analog_subchannel::inthreeway, LOG_ERROR, LOG_WARNING, analog_pvt::mohsuggest, NULL, analog_pvt::onhooktime, analog_pvt::origcid_name, analog_pvt::origcid_num, analog_subchannel::owner, analog_pvt::owner, analog_pvt::permcallwaiting, analog_pvt::permhidecallerid, analog_pvt::polarity, POLARITY_IDLE, analog_pvt::sig, and analog_pvt::subs.

Referenced by dahdi_hangup().

◆ analog_hangup_polarityswitch()

static void analog_hangup_polarityswitch ( struct analog_pvt p)
static

Definition at line 652 of file sig_analog.c.

653{
656 }
657}
void(*const hangup_polarityswitch)(void *pvt)
Switch FXS line polarity, based on answeronpolarityswitch and hanguponpolarityswitch.
Definition: sig_analog.h:176

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::hangup_polarityswitch.

Referenced by analog_hangup().

◆ analog_has_voicemail()

static int analog_has_voicemail ( struct analog_pvt p)
static

Definition at line 682 of file sig_analog.c.

683{
686 }
687 return -1;
688}
int(*const has_voicemail)(void *pvt)
Definition: sig_analog.h:222

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::has_voicemail.

Referenced by __analog_handle_event(), and analog_handle_init_event().

◆ analog_have_progressdetect()

static int analog_have_progressdetect ( struct analog_pvt p)
static

Definition at line 210 of file sig_analog.c.

211{
214 }
215 /* Don't have progress detection. */
216 return 0;
217}
int(*const have_progressdetect)(void *pvt)
Definition: sig_analog.h:253

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::have_progressdetect.

Referenced by __analog_handle_event().

◆ analog_increase_ss_count()

static void analog_increase_ss_count ( void  )
static

Definition at line 1664 of file sig_analog.c.

1665{
1668 }
1669}
void(*const increase_ss_count)(void)
Definition: sig_analog.h:227

References analog_callbacks, and analog_callback::increase_ss_count.

Referenced by __analog_ss_thread().

◆ analog_is_dialing()

static int analog_is_dialing ( struct analog_pvt p,
enum analog_sub  index 
)
static

Definition at line 690 of file sig_analog.c.

691{
693 return analog_callbacks.is_dialing(p->chan_pvt, index);
694 }
695 return -1;
696}
int(*const is_dialing)(void *pvt, enum analog_sub sub)
Definition: sig_analog.h:159

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::is_dialing.

Referenced by __analog_handle_event().

◆ analog_is_off_hook()

static int analog_is_off_hook ( struct analog_pvt p)
static

Definition at line 489 of file sig_analog.c.

490{
493 }
494 return -1;
495}
int(*const is_off_hook)(void *pvt)
Definition: sig_analog.h:158

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::is_off_hook.

Referenced by __analog_handle_event(), analog_available(), and analog_hangup().

◆ analog_lock_private()

static void analog_lock_private ( struct analog_pvt p)
static

◆ analog_lock_sub_owner()

static void analog_lock_sub_owner ( struct analog_pvt pvt,
enum analog_sub  sub_idx 
)
static

Definition at line 599 of file sig_analog.c.

600{
601 for (;;) {
602 if (!pvt->subs[sub_idx].owner) {
603 /* No subchannel owner pointer */
604 break;
605 }
606 if (!ast_channel_trylock(pvt->subs[sub_idx].owner)) {
607 /* Got subchannel owner lock */
608 break;
609 }
610 /* We must unlock the private to avoid the possibility of a deadlock */
612 }
613}
#define ast_channel_trylock(chan)
Definition: channel.h:2972
static void analog_deadlock_avoidance_private(struct analog_pvt *p)
Definition: sig_analog.c:574

References analog_deadlock_avoidance_private(), ast_channel_trylock, analog_subchannel::owner, and analog_pvt::subs.

Referenced by __analog_handle_event(), and analog_hangup().

◆ analog_my_getsigstr()

static int analog_my_getsigstr ( struct ast_channel chan,
char *  str,
const char *  term,
int  ms 
)
static

Definition at line 1635 of file sig_analog.c.

1636{
1637 char c;
1638
1639 *str = 0; /* start with empty output buffer */
1640 for (;;) {
1641 /* Wait for the first digit (up to specified ms). */
1642 c = ast_waitfordigit(chan, ms);
1643 /* if timeout, hangup or error, return as such */
1644 if (c < 1) {
1645 return c;
1646 }
1647 *str++ = c;
1648 *str = 0;
1649 if (strchr(term, c)) {
1650 return 1;
1651 }
1652 }
1653}
const char * str
Definition: app_jack.c:150

References ast_waitfordigit(), c, and str.

Referenced by __analog_ss_thread().

◆ analog_new()

struct analog_pvt * analog_new ( enum analog_sigtype  signallingtype,
void *  private_data 
)

Definition at line 4102 of file sig_analog.c.

4103{
4104 struct analog_pvt *p;
4105
4106 p = ast_calloc(1, sizeof(*p));
4107 if (!p) {
4108 return p;
4109 }
4110
4112 p->sig = signallingtype;
4113 p->chan_pvt = private_data;
4114
4115 /* Some defaults for values */
4118 /* Sub real is assumed to always be alloc'd */
4119 p->subs[ANALOG_SUB_REAL].allocd = 1;
4120
4121 return p;
4122}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define CID_SIG_BELL
Definition: callerid.h:60
@ ANALOG_SIG_NONE
Definition: sig_analog.h:46

References analog_subchannel::allocd, ANALOG_CID_START_RING, ANALOG_SIG_NONE, ANALOG_SUB_REAL, ast_calloc, analog_pvt::chan_pvt, CID_SIG_BELL, analog_pvt::cid_signalling, analog_pvt::cid_start, analog_pvt::outsigmod, analog_pvt::sig, and analog_pvt::subs.

Referenced by mkintf().

◆ analog_new_ast_channel()

static struct ast_channel * analog_new_ast_channel ( struct analog_pvt p,
int  state,
int  startpbx,
enum analog_sub  sub,
const struct ast_channel requestor 
)
static

Definition at line 454 of file sig_analog.c.

455{
456 struct ast_channel *c;
457
459 return NULL;
460 }
461
462 c = analog_callbacks.new_ast_channel(p->chan_pvt, state, startpbx, sub, requestor);
463 if (c) {
464 ast_channel_call_forward_set(c, p->call_forward);
465 }
466 p->subs[sub].owner = c;
467 if (!p->owner) {
469 }
470 return c;
471}
struct ast_channel *(*const new_ast_channel)(void *pvt, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
Definition: sig_analog.h:207

References analog_callbacks, analog_set_new_owner(), c, analog_pvt::call_forward, analog_pvt::chan_pvt, analog_callback::new_ast_channel, NULL, analog_subchannel::owner, analog_pvt::owner, sub, and analog_pvt::subs.

Referenced by __analog_handle_event(), analog_handle_init_event(), and analog_request().

◆ analog_off_hook()

static int analog_off_hook ( struct analog_pvt p)
static

Definition at line 615 of file sig_analog.c.

616{
619 }
620 return -1;
621}
int(*const off_hook)(void *pvt)
Set channel off hook.
Definition: sig_analog.h:167

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::off_hook.

Referenced by __analog_handle_event(), __analog_ss_thread(), analog_answer(), analog_exception(), and analog_handle_init_event().

◆ analog_on_hook()

static int analog_on_hook ( struct analog_pvt p)
static

Definition at line 529 of file sig_analog.c.

530{
533 }
534 return -1;
535}
int(*const on_hook)(void *pvt)
Set channel on hook.
Definition: sig_analog.h:165

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::on_hook.

Referenced by __analog_handle_event(), __analog_ss_thread(), analog_call(), analog_handle_init_event(), and analog_hangup().

◆ analog_play_tone()

static int analog_play_tone ( struct analog_pvt p,
enum analog_sub  sub,
enum analog_tone  tone 
)
static

Definition at line 438 of file sig_analog.c.

439{
441 return analog_callbacks.play_tone(p->chan_pvt, sub, tone);
442 }
443 return -1;
444}
int(*const play_tone)(void *pvt, enum analog_sub sub, enum analog_tone tone)
Definition: sig_analog.h:182

References analog_callbacks, analog_pvt::chan_pvt, analog_callback::play_tone, and sub.

Referenced by __analog_handle_event(), __analog_ss_thread(), analog_answer(), analog_call(), analog_handle_init_event(), and analog_hangup().

◆ analog_publish_channel_alarm_clear()

static void analog_publish_channel_alarm_clear ( int  channel)
static

Definition at line 2786 of file sig_analog.c.

2787{
2788 RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
2789
2790 ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", channel);
2791 body = ast_json_pack("{s: i}", "Channel", channel);
2792 if (!body) {
2793 return;
2794 }
2795
2796 ast_manager_publish_event("AlarmClear", EVENT_FLAG_SYSTEM, body);
2797}
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
Definition: manager.c:638
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
#define EVENT_FLAG_SYSTEM
Definition: manager.h:75
Abstract JSON element (object, array, string, int, ...).

References ast_json_pack(), ast_json_unref(), ast_log, ast_manager_publish_event(), EVENT_FLAG_SYSTEM, LOG_NOTICE, NULL, and RAII_VAR.

Referenced by __analog_handle_event(), and analog_handle_init_event().

◆ analog_publish_dnd_state()

static void analog_publish_dnd_state ( int  channel,
const char *  status 
)
static

Definition at line 4171 of file sig_analog.c.

4172{
4173 RAII_VAR(struct ast_json *, body, NULL, ast_json_unref);
4174 RAII_VAR(struct ast_str *, dahdichan, ast_str_create(32), ast_free);
4175 if (!dahdichan) {
4176 return;
4177 }
4178
4179 ast_str_set(&dahdichan, 0, "DAHDI/%d", channel);
4180
4181 body = ast_json_pack("{s: s, s: s}",
4182 "Channel", ast_str_buffer(dahdichan),
4183 "Status", status);
4184 if (!body) {
4185 return;
4186 }
4187
4189}
jack_status_t status
Definition: app_jack.c:149
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1113
Support for dynamic strings.
Definition: strings.h:623

References ast_free, ast_json_pack(), ast_json_unref(), ast_manager_publish_event(), ast_str_buffer(), ast_str_create, ast_str_set(), analog_pvt::channel, EVENT_FLAG_SYSTEM, NULL, RAII_VAR, and status.

Referenced by analog_dnd().

◆ analog_request()

struct ast_channel * analog_request ( struct analog_pvt p,
int *  callwait,
const struct ast_channel requestor 
)

Definition at line 770 of file sig_analog.c.

771{
772 struct ast_channel *ast;
773
774 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
775 *callwait = (p->owner != NULL);
776
777 if (p->owner) {
779 ast_log(LOG_ERROR, "Unable to alloc subchannel\n");
780 return NULL;
781 }
782 }
783
786 p->owner ? ANALOG_SUB_CALLWAIT : ANALOG_SUB_REAL, requestor);
787 if (!ast) {
789 }
790 return ast;
791}

References analog_alloc_sub(), analog_new_ast_channel(), analog_set_outgoing(), ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL, ast_debug, ast_log, AST_STATE_RESERVED, analog_pvt::channel, LOG_ERROR, NULL, and analog_pvt::owner.

Referenced by dahdi_request().

◆ analog_ring()

static int analog_ring ( struct analog_pvt p)
static

Definition at line 497 of file sig_analog.c.

498{
500 return analog_callbacks.ring(p->chan_pvt);
501 }
502 return -1;
503}
int(*const ring)(void *pvt)
Definition: sig_analog.h:162

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::ring.

Referenced by __analog_handle_event(), analog_call(), and analog_exception().

◆ analog_send_callerid()

static int analog_send_callerid ( struct analog_pvt p,
int  cwcid,
struct ast_party_caller caller 
)
static

Definition at line 391 of file sig_analog.c.

392{
393 ast_debug(1, "Sending callerid. CID_NAME: '%s' CID_NUM: '%s'\n",
394 caller->id.name.str,
395 caller->id.number.str);
396
397 if (cwcid) {
398 p->callwaitcas = 0;
399 }
400
402 return analog_callbacks.send_callerid(p->chan_pvt, cwcid, caller);
403 }
404 return 0;
405}
int(*const send_callerid)(void *pvt, int cwcid, struct ast_party_caller *caller)
Definition: sig_analog.h:188

References analog_callbacks, ast_debug, ast_channel::caller, analog_pvt::callwaitcas, analog_pvt::chan_pvt, ast_party_caller::id, ast_party_id::name, ast_party_id::number, analog_callback::send_callerid, ast_party_name::str, and ast_party_number::str.

Referenced by __analog_handle_event(), and analog_handle_dtmf().

◆ analog_set_alarm()

static void analog_set_alarm ( struct analog_pvt p,
int  in_alarm 
)
static

Definition at line 903 of file sig_analog.c.

904{
905 p->inalarm = in_alarm;
907 analog_callbacks.set_alarm(p->chan_pvt, in_alarm);
908 }
909}
void(*const set_alarm)(void *pvt, int in_alarm)
Definition: sig_analog.h:238

References analog_callbacks, analog_pvt::chan_pvt, analog_pvt::inalarm, and analog_callback::set_alarm.

Referenced by __analog_handle_event(), __analog_ss_thread(), and analog_handle_init_event().

◆ analog_set_cadence()

static void analog_set_cadence ( struct analog_pvt p,
struct ast_channel chan 
)
static

Definition at line 888 of file sig_analog.c.

889{
892 }
893}
void(*const set_cadence)(void *pvt, int *cidrings, struct ast_channel *chan)
Definition: sig_analog.h:237

References analog_callbacks, analog_pvt::chan_pvt, analog_pvt::cidrings, and analog_callback::set_cadence.

Referenced by analog_call().

◆ analog_set_callwaiting()

static void analog_set_callwaiting ( struct analog_pvt p,
int  callwaiting_enable 
)
static

Definition at line 880 of file sig_analog.c.

881{
882 p->callwaiting = callwaiting_enable;
884 analog_callbacks.set_callwaiting(p->chan_pvt, callwaiting_enable);
885 }
886}
void(*const set_callwaiting)(void *pvt, int callwaiting_enable)
Definition: sig_analog.h:246

References analog_callbacks, analog_pvt::callwaiting, analog_pvt::chan_pvt, and analog_callback::set_callwaiting.

Referenced by __analog_ss_thread(), analog_config_complete(), and analog_hangup().

◆ analog_set_confirmanswer()

static void analog_set_confirmanswer ( struct analog_pvt p,
int  flag 
)
static

Definition at line 935 of file sig_analog.c.

936{
939 }
940}
void(*const set_confirmanswer)(void *pvt, int flag)
Definition: sig_analog.h:244

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::set_confirmanswer.

Referenced by analog_handle_dtmf(), and analog_hangup().

◆ analog_set_dialing()

static void analog_set_dialing ( struct analog_pvt p,
int  is_dialing 
)
static

Definition at line 895 of file sig_analog.c.

896{
897 p->dialing = is_dialing;
899 analog_callbacks.set_dialing(p->chan_pvt, is_dialing);
900 }
901}
void(*const set_dialing)(void *pvt, int is_dialing)
Definition: sig_analog.h:239

References analog_callbacks, analog_pvt::chan_pvt, analog_pvt::dialing, and analog_callback::set_dialing.

Referenced by __analog_handle_event(), analog_answer(), analog_call(), analog_exception(), and analog_hangup().

◆ analog_set_echocanceller()

static int analog_set_echocanceller ( struct analog_pvt p,
int  enable 
)
static

Definition at line 473 of file sig_analog.c.

474{
477 }
478 return -1;
479}
int(*const set_echocanceller)(void *pvt, int enable)
Definition: sig_analog.h:184

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::set_echocanceller.

Referenced by __analog_handle_event(), __analog_ss_thread(), analog_answer(), analog_exception(), analog_handle_init_event(), and analog_hangup().

◆ analog_set_inthreeway()

static void analog_set_inthreeway ( struct analog_pvt p,
enum analog_sub  sub,
int  inthreeway 
)
static

Definition at line 982 of file sig_analog.c.

983{
984 p->subs[sub].inthreeway = inthreeway;
987 }
988}
void(*const set_inthreeway)(void *pvt, enum analog_sub sub, int inthreeway)
Definition: sig_analog.h:233

References analog_callbacks, analog_pvt::chan_pvt, analog_subchannel::inthreeway, analog_callback::set_inthreeway, sub, and analog_pvt::subs.

Referenced by __analog_handle_event(), and analog_hangup().

◆ analog_set_linear_mode()

static int analog_set_linear_mode ( struct analog_pvt p,
enum analog_sub  sub,
int  linear_mode 
)
static

Definition at line 973 of file sig_analog.c.

974{
976 /* Return provides old linear_mode setting or error indication */
977 return analog_callbacks.set_linear_mode(p->chan_pvt, sub, linear_mode);
978 }
979 return -1;
980}
int(*const set_linear_mode)(void *pvt, enum analog_sub sub, int linear_mode)
Definition: sig_analog.h:232

References analog_callbacks, analog_pvt::chan_pvt, analog_callback::set_linear_mode, and sub.

Referenced by __analog_ss_thread(), and analog_hangup().

◆ analog_set_needringing()

static void analog_set_needringing ( struct analog_pvt p,
int  value 
)
static

Definition at line 623 of file sig_analog.c.

624{
627 }
628}
void(*const set_needringing)(void *pvt, int value)
Definition: sig_analog.h:168
int value
Definition: syslog.c:37

References analog_callbacks, analog_pvt::chan_pvt, analog_callback::set_needringing, and value.

Referenced by __analog_handle_event().

◆ analog_set_new_owner()

static void analog_set_new_owner ( struct analog_pvt p,
struct ast_channel new_owner 
)
static

Definition at line 446 of file sig_analog.c.

447{
448 p->owner = new_owner;
451 }
452}
void(*const set_new_owner)(void *pvt, struct ast_channel *new_owner)
Definition: sig_analog.h:250

References analog_callbacks, analog_pvt::chan_pvt, analog_pvt::owner, and analog_callback::set_new_owner.

Referenced by __analog_handle_event(), __analog_ss_thread(), analog_answer(), analog_exception(), analog_fixup(), analog_hangup(), and analog_new_ast_channel().

◆ analog_set_outgoing()

static void analog_set_outgoing ( struct analog_pvt p,
int  is_outgoing 
)
static

Definition at line 537 of file sig_analog.c.

538{
539 p->outgoing = is_outgoing;
541 analog_callbacks.set_outgoing(p->chan_pvt, is_outgoing);
542 }
543}
void(*const set_outgoing)(void *pvt, int is_outgoing)
Definition: sig_analog.h:240

References analog_callbacks, analog_pvt::chan_pvt, analog_pvt::outgoing, and analog_callback::set_outgoing.

Referenced by analog_call(), analog_hangup(), and analog_request().

◆ analog_set_pulsedial()

static void analog_set_pulsedial ( struct analog_pvt p,
int  flag 
)
static

Definition at line 966 of file sig_analog.c.

967{
970 }
971}
void(*const set_pulsedial)(void *pvt, int flag)
Definition: sig_analog.h:249

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::set_pulsedial.

Referenced by __analog_handle_event(), and analog_hangup().

◆ analog_set_ringtimeout()

static void analog_set_ringtimeout ( struct analog_pvt p,
int  ringt 
)
static

◆ analog_set_waitingfordt()

static void analog_set_waitingfordt ( struct analog_pvt p,
struct ast_channel ast 
)
static

Definition at line 919 of file sig_analog.c.

920{
923 }
924}
void(*const set_waitingfordt)(void *pvt, struct ast_channel *ast)
Definition: sig_analog.h:242

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::set_waitingfordt.

Referenced by analog_call().

◆ analog_sigtype_to_str()

const char * analog_sigtype_to_str ( enum analog_sigtype  sigtype)

Definition at line 123 of file sig_analog.c.

124{
125 int i;
126
127 for (i = 0; i < ARRAY_LEN(sigtypes); i++) {
128 if (sigtype == sigtypes[i].sigtype) {
129 return sigtypes[i].name;
130 }
131 }
132
133 return "Unknown";
134}
static const struct @141 sigtypes[]
enum analog_sigtype sigtype
Definition: sig_analog.c:69

References ARRAY_LEN, sigtype, and sigtypes.

Referenced by __analog_ss_thread(), and analog_handle_init_event().

◆ analog_ss_thread_start()

int analog_ss_thread_start ( struct analog_pvt p,
struct ast_channel chan 
)

Definition at line 2778 of file sig_analog.c.

2779{
2780 pthread_t threadid;
2781
2782 p->ss_astchan = chan;
2784}

References __analog_ss_thread(), ast_pthread_create_detached, NULL, and analog_pvt::ss_astchan.

Referenced by mwi_thread().

◆ analog_start()

static int analog_start ( struct analog_pvt p)
static

Definition at line 513 of file sig_analog.c.

514{
517 }
518 return -1;
519}
int(*const start)(void *pvt)
Definition: sig_analog.h:161

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::start.

Referenced by analog_call().

◆ analog_start_cid_detect()

static int analog_start_cid_detect ( struct analog_pvt p,
int  cid_signalling 
)
static

Definition at line 162 of file sig_analog.c.

163{
165 return analog_callbacks.start_cid_detect(p->chan_pvt, cid_signalling);
166 }
167 return -1;
168}
int(*const start_cid_detect)(void *pvt, int cid_signalling)
Definition: sig_analog.h:192

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::start_cid_detect.

Referenced by __analog_ss_thread().

◆ analog_start_polarityswitch()

static void analog_start_polarityswitch ( struct analog_pvt p)
static

Definition at line 639 of file sig_analog.c.

640{
643 }
644}
void(*const start_polarityswitch)(void *pvt)
Reset FXS line polarity to IDLE, based on answeronpolarityswitch and hanguponpolarityswitch.
Definition: sig_analog.h:172

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::start_polarityswitch.

Referenced by __analog_handle_event(), and analog_handle_init_event().

◆ analog_stop_callwait()

static int analog_stop_callwait ( struct analog_pvt p)
static

Definition at line 862 of file sig_analog.c.

863{
864 p->callwaitcas = 0;
867 }
868 return 0;
869}
int(*const stop_callwait)(void *pvt)
Definition: sig_analog.h:199

References analog_callbacks, analog_pvt::callwaitcas, analog_pvt::chan_pvt, and analog_callback::stop_callwait.

Referenced by __analog_handle_event(), analog_exception(), and analog_hangup().

◆ analog_stop_cid_detect()

static int analog_stop_cid_detect ( struct analog_pvt p)
static

Definition at line 170 of file sig_analog.c.

171{
174 }
175 return -1;
176}
int(*const stop_cid_detect)(void *pvt)
Definition: sig_analog.h:194

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::stop_cid_detect.

Referenced by __analog_ss_thread().

◆ analog_str_to_cidstart()

enum analog_cid_start analog_str_to_cidstart ( const char *  value)

Definition at line 234 of file sig_analog.c.

235{
236 if (!strcasecmp(value, "ring")) {
238 } else if (!strcasecmp(value, "polarity")) {
240 } else if (!strcasecmp(value, "polarity_in")) {
242 } else if (!strcasecmp(value, "dtmf")) {
244 }
245
246 return 0;
247}

References ANALOG_CID_START_DTMF_NOALERT, ANALOG_CID_START_POLARITY, ANALOG_CID_START_POLARITY_IN, ANALOG_CID_START_RING, and value.

◆ analog_str_to_cidtype()

unsigned int analog_str_to_cidtype ( const char *  name)

Definition at line 136 of file sig_analog.c.

137{
138 int i;
139
140 for (i = 0; i < ARRAY_LEN(cidtypes); i++) {
141 if (!strcasecmp(cidtypes[i].name, name)) {
142 return cidtypes[i].cid_type;
143 }
144 }
145
146 return 0;
147}

References ARRAY_LEN, cidtypes, and name.

◆ analog_str_to_sigtype()

enum analog_sigtype analog_str_to_sigtype ( const char *  name)

Definition at line 110 of file sig_analog.c.

111{
112 int i;
113
114 for (i = 0; i < ARRAY_LEN(sigtypes); i++) {
115 if (!strcasecmp(sigtypes[i].name, name)) {
116 return sigtypes[i].sigtype;
117 }
118 }
119
120 return 0;
121}

References ARRAY_LEN, name, and sigtypes.

◆ analog_swap_subs()

static void analog_swap_subs ( struct analog_pvt p,
enum analog_sub  a,
enum analog_sub  b 
)
static

Definition at line 348 of file sig_analog.c.

349{
350 int tinthreeway;
351 struct ast_channel *towner;
352
353 ast_debug(1, "Swapping %u and %u\n", a, b);
354
355 towner = p->subs[a].owner;
356 p->subs[a].owner = p->subs[b].owner;
357 p->subs[b].owner = towner;
358
359 tinthreeway = p->subs[a].inthreeway;
360 p->subs[a].inthreeway = p->subs[b].inthreeway;
361 p->subs[b].inthreeway = tinthreeway;
362
365 }
366}
void(*const swap_subs)(void *pvt, enum analog_sub a, struct ast_channel *new_a_owner, enum analog_sub b, struct ast_channel *new_b_owner)
Definition: sig_analog.h:206
static struct test_val b
static struct test_val a

References a, analog_callbacks, ast_debug, b, analog_pvt::chan_pvt, analog_subchannel::inthreeway, analog_subchannel::owner, analog_pvt::subs, and analog_callback::swap_subs.

Referenced by __analog_handle_event(), __analog_ss_thread(), analog_answer(), and analog_hangup().

◆ analog_train_echocanceller()

static int analog_train_echocanceller ( struct analog_pvt p)
static

Definition at line 481 of file sig_analog.c.

482{
485 }
486 return -1;
487}
int(*const train_echocanceller)(void *pvt)
Definition: sig_analog.h:185

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::train_echocanceller.

Referenced by __analog_handle_event(), and analog_answer().

◆ analog_unalloc_sub()

static int analog_unalloc_sub ( struct analog_pvt p,
enum analog_sub  x 
)
static

Definition at line 381 of file sig_analog.c.

382{
383 p->subs[x].allocd = 0;
384 p->subs[x].owner = NULL;
387 }
388 return 0;
389}
int(*const unallocate_sub)(void *pvt, enum analog_sub sub)
Definition: sig_analog.h:203

References analog_subchannel::allocd, analog_callbacks, analog_pvt::chan_pvt, NULL, analog_subchannel::owner, analog_pvt::subs, analog_callback::unallocate_sub, and ast_channel::x.

Referenced by __analog_handle_event(), __analog_ss_thread(), and analog_hangup().

◆ analog_unlock_private()

static void analog_unlock_private ( struct analog_pvt p)
static

◆ analog_update_conf()

static int analog_update_conf ( struct analog_pvt p)
static

Definition at line 743 of file sig_analog.c.

744{
745 int x;
746 int needconf = 0;
747
748 /* Start with the obvious, general stuff */
749 for (x = 0; x < 3; x++) {
750 /* Look for three way calls */
751 if ((p->subs[x].allocd) && p->subs[x].inthreeway) {
754 }
755 needconf++;
756 } else {
759 }
760 }
761 }
762 ast_debug(1, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
763
766 }
767 return 0;
768}
int(*const conf_add)(void *pvt, enum analog_sub sub)
Definition: sig_analog.h:210
int(*const complete_conference_update)(void *pvt, int needconf)
Definition: sig_analog.h:216
int(*const conf_del)(void *pvt, enum analog_sub sub)
Definition: sig_analog.h:212

References analog_subchannel::allocd, analog_callbacks, ast_debug, analog_pvt::chan_pvt, analog_pvt::channel, analog_callback::complete_conference_update, analog_callback::conf_add, analog_callback::conf_del, analog_subchannel::inthreeway, analog_pvt::subs, and ast_channel::x.

Referenced by __analog_handle_event(), analog_exception(), analog_fixup(), and analog_hangup().

◆ analog_wait_event()

static int analog_wait_event ( struct analog_pvt p)
static

Definition at line 202 of file sig_analog.c.

203{
206 }
207 return -1;
208}
int(*const wait_event)(void *pvt)
Definition: sig_analog.h:157

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::wait_event.

Referenced by __analog_ss_thread().

◆ analog_wink()

static int analog_wink ( struct analog_pvt p,
enum analog_sub  index 
)
static

Definition at line 674 of file sig_analog.c.

675{
677 return analog_callbacks.wink(p->chan_pvt, index);
678 }
679 return -1;
680}
int(*const wink)(void *pvt, enum analog_sub sub)
Definition: sig_analog.h:179

References analog_callbacks, analog_pvt::chan_pvt, and analog_callback::wink.

Referenced by __analog_ss_thread().

◆ gen_analog_field_callback() [1/3]

gen_analog_field_callback ( int  ,
firstdigit_timeout  ,
ANALOG_FIRST_DIGIT_TIMEOUT   
)

◆ gen_analog_field_callback() [2/3]

gen_analog_field_callback ( int  ,
interdigit_timeout  ,
ANALOG_INTER_DIGIT_TIMEOUT   
)

◆ gen_analog_field_callback() [3/3]

gen_analog_field_callback ( int  ,
matchdigit_timeout  ,
ANALOG_MATCH_DIGIT_TIMEOUT   
)

Variable Documentation

◆ analog_defaultcic

char analog_defaultcic[64] = ""
static

Definition at line 65 of file sig_analog.c.

Referenced by analog_call().

◆ analog_defaultozz

char analog_defaultozz[64] = ""
static

Definition at line 66 of file sig_analog.c.

Referenced by analog_call().

◆ cid_type

unsigned int cid_type

Definition at line 96 of file sig_analog.c.

Referenced by analog_cidtype_to_str().

◆ 

const struct { ... } cidtypes[]

◆ name

const char* name

◆ sigtype

enum analog_sigtype sigtype

Definition at line 69 of file sig_analog.c.

Referenced by analog_sigtype_to_str(), and sigtype_to_signalling().

◆ 

const struct { ... } sigtypes[]