Sat Mar 26 11:28:34 2011

Asterisk developer's documentation


sig_analog.h File Reference

Interface header for analog signaling module. More...

#include "asterisk/channel.h"
#include "asterisk/frame.h"

Include dependency graph for sig_analog.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  analog_callback
struct  analog_dialoperation
struct  analog_pvt
struct  analog_subchannel

Defines

#define ANALOG_MAX_CID   300
#define READ_SIZE   160
#define RING_PATTERNS   3

Enumerations

enum  analog_cid_start { ANALOG_CID_START_POLARITY = 1, ANALOG_CID_START_POLARITY_IN, ANALOG_CID_START_RING, ANALOG_CID_START_DTMF_NOALERT }
enum  analog_dsp_digitmode { ANALOG_DIGITMODE_DTMF = 1, ANALOG_DIGITMODE_MF }
enum  analog_event {
  ANALOG_EVENT_NONE = 0, ANALOG_EVENT_ONHOOK, ANALOG_EVENT_RINGOFFHOOK, ANALOG_EVENT_WINKFLASH,
  ANALOG_EVENT_ALARM, ANALOG_EVENT_NOALARM, ANALOG_EVENT_DIALCOMPLETE, ANALOG_EVENT_RINGERON,
  ANALOG_EVENT_RINGEROFF, ANALOG_EVENT_HOOKCOMPLETE, ANALOG_EVENT_PULSE_START, ANALOG_EVENT_POLARITY,
  ANALOG_EVENT_RINGBEGIN, ANALOG_EVENT_EC_DISABLED, ANALOG_EVENT_REMOVED, ANALOG_EVENT_NEONMWI_ACTIVE,
  ANALOG_EVENT_NEONMWI_INACTIVE, ANALOG_EVENT_TX_CED_DETECTED, ANALOG_EVENT_RX_CED_DETECTED, ANALOG_EVENT_EC_NLP_DISABLED,
  ANALOG_EVENT_EC_NLP_ENABLED, ANALOG_EVENT_ERROR, ANALOG_EVENT_DTMFCID, ANALOG_EVENT_PULSEDIGIT = (1 << 16),
  ANALOG_EVENT_DTMFDOWN = (1 << 17), ANALOG_EVENT_DTMFUP = (1 << 18)
}
enum  analog_sigtype {
  ANALOG_SIG_NONE = -1, ANALOG_SIG_FXOLS = 1, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOGS,
  ANALOG_SIG_FXSLS, ANALOG_SIG_FXSKS, ANALOG_SIG_FXSGS, ANALOG_SIG_EMWINK,
  ANALOG_SIG_EM, ANALOG_SIG_EM_E1, ANALOG_SIG_FEATD, ANALOG_SIG_FEATDMF,
  ANALOG_SIG_E911, ANALOG_SIG_FGC_CAMA, ANALOG_SIG_FGC_CAMAMF, ANALOG_SIG_FEATB,
  ANALOG_SIG_SFWINK, ANALOG_SIG_SF, ANALOG_SIG_SF_FEATD, ANALOG_SIG_SF_FEATDMF,
  ANALOG_SIG_FEATDMF_TA, ANALOG_SIG_SF_FEATB
}
enum  analog_sub { ANALOG_SUB_REAL = 0, ANALOG_SUB_CALLWAIT, ANALOG_SUB_THREEWAY }
enum  analog_tone {
  ANALOG_TONE_RINGTONE = 0, ANALOG_TONE_STUTTER, ANALOG_TONE_CONGESTION, ANALOG_TONE_DIALTONE,
  ANALOG_TONE_DIALRECALL, ANALOG_TONE_INFO
}
enum  dialop { ANALOG_DIAL_OP_REPLACE = 2 }

Functions

int analog_answer (struct analog_pvt *p, struct ast_channel *ast)
int analog_available (struct analog_pvt *p)
int analog_call (struct analog_pvt *p, struct ast_channel *ast, char *rdest, int timeout)
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)
void analog_delete (struct analog_pvt *doomed)
 Delete the analog private structure.
int analog_dnd (struct analog_pvt *p, int flag)
struct ast_frame * analog_exception (struct analog_pvt *p, struct ast_channel *ast)
int analog_fixup (struct ast_channel *oldchan, struct ast_channel *newchan, void *newp)
void analog_free (struct analog_pvt *p)
void analog_handle_dtmfup (struct analog_pvt *p, struct ast_channel *ast, enum analog_sub index, struct ast_frame **dest)
void * analog_handle_init_event (struct analog_pvt *i, int event)
int analog_hangup (struct analog_pvt *p, struct ast_channel *ast)
struct analog_pvt * analog_new (enum analog_sigtype signallingtype, struct analog_callback *c, void *private_data)
struct ast_channel * analog_request (struct analog_pvt *p, int *callwait, const struct ast_channel *requestor)
const char * analog_sigtype_to_str (enum analog_sigtype sigtype)
int analog_ss_thread_start (struct analog_pvt *p, struct ast_channel *ast)
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)


Detailed Description

Interface header for analog signaling module.

Author:
Matthew Fredrickson <creslin@digium.com>

Definition in file sig_analog.h.


Define Documentation

#define ANALOG_MAX_CID   300

Definition at line 31 of file sig_analog.h.

Referenced by __analog_ss_thread(), and my_get_callerid().

#define READ_SIZE   160

Definition at line 32 of file sig_analog.h.

#define RING_PATTERNS   3

Definition at line 33 of file sig_analog.h.

Referenced by __analog_ss_thread(), and my_distinctive_ring().


Enumeration Type Documentation

Enumerator:
ANALOG_CID_START_POLARITY 
ANALOG_CID_START_POLARITY_IN 
ANALOG_CID_START_RING 
ANALOG_CID_START_DTMF_NOALERT 

Definition at line 110 of file sig_analog.h.

Enumerator:
ANALOG_DIGITMODE_DTMF 
ANALOG_DIGITMODE_MF 

Definition at line 105 of file sig_analog.h.

00105                           {
00106    ANALOG_DIGITMODE_DTMF = 1,
00107    ANALOG_DIGITMODE_MF,
00108 };

Enumerator:
ANALOG_EVENT_NONE 
ANALOG_EVENT_ONHOOK 
ANALOG_EVENT_RINGOFFHOOK 
ANALOG_EVENT_WINKFLASH 
ANALOG_EVENT_ALARM 
ANALOG_EVENT_NOALARM 
ANALOG_EVENT_DIALCOMPLETE 
ANALOG_EVENT_RINGERON 
ANALOG_EVENT_RINGEROFF 
ANALOG_EVENT_HOOKCOMPLETE 
ANALOG_EVENT_PULSE_START 
ANALOG_EVENT_POLARITY 
ANALOG_EVENT_RINGBEGIN 
ANALOG_EVENT_EC_DISABLED 
ANALOG_EVENT_REMOVED 
ANALOG_EVENT_NEONMWI_ACTIVE 
ANALOG_EVENT_NEONMWI_INACTIVE 
ANALOG_EVENT_TX_CED_DETECTED 
ANALOG_EVENT_RX_CED_DETECTED 
ANALOG_EVENT_EC_NLP_DISABLED 
ANALOG_EVENT_EC_NLP_ENABLED 
ANALOG_EVENT_ERROR 
ANALOG_EVENT_DTMFCID 
ANALOG_EVENT_PULSEDIGIT 
ANALOG_EVENT_DTMFDOWN 
ANALOG_EVENT_DTMFUP 

Definition at line 70 of file sig_analog.h.

Enumerator:
ANALOG_SIG_NONE 
ANALOG_SIG_FXOLS 
ANALOG_SIG_FXOKS 
ANALOG_SIG_FXOGS 
ANALOG_SIG_FXSLS 
ANALOG_SIG_FXSKS 
ANALOG_SIG_FXSGS 
ANALOG_SIG_EMWINK 
ANALOG_SIG_EM 
ANALOG_SIG_EM_E1 
ANALOG_SIG_FEATD 
ANALOG_SIG_FEATDMF 
ANALOG_SIG_E911 
ANALOG_SIG_FGC_CAMA 
ANALOG_SIG_FGC_CAMAMF 
ANALOG_SIG_FEATB 
ANALOG_SIG_SFWINK 
ANALOG_SIG_SF 
ANALOG_SIG_SF_FEATD 
ANALOG_SIG_SF_FEATDMF 
ANALOG_SIG_FEATDMF_TA 
ANALOG_SIG_SF_FEATB 

Definition at line 36 of file sig_analog.h.

enum analog_sub

Enumerator:
ANALOG_SUB_REAL  Active call
ANALOG_SUB_CALLWAIT  Call-Waiting call on hold
ANALOG_SUB_THREEWAY  Three-way call

Definition at line 99 of file sig_analog.h.

00099                 {
00100    ANALOG_SUB_REAL = 0,       /*!< Active call */
00101    ANALOG_SUB_CALLWAIT,       /*!< Call-Waiting call on hold */
00102    ANALOG_SUB_THREEWAY,       /*!< Three-way call */
00103 };

Enumerator:
ANALOG_TONE_RINGTONE 
ANALOG_TONE_STUTTER 
ANALOG_TONE_CONGESTION 
ANALOG_TONE_DIALTONE 
ANALOG_TONE_DIALRECALL 
ANALOG_TONE_INFO 

Definition at line 61 of file sig_analog.h.

enum dialop

Enumerator:
ANALOG_DIAL_OP_REPLACE 

Definition at line 117 of file sig_analog.h.

00117             {
00118    ANALOG_DIAL_OP_REPLACE = 2,
00119 };


Function Documentation

int analog_answer ( struct analog_pvt *  p,
struct ast_channel *  ast 
)

Definition at line 1448 of file sig_analog.c.

References ast_channel::_state, analog_answer_polarityswitch(), analog_get_index(), analog_off_hook(), analog_play_tone(), analog_set_dialing(), 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_SUB_REAL, ANALOG_SUB_THREEWAY, analog_swap_subs(), analog_train_echocanceller(), ast_debug, ast_log(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, analog_pvt::channel, analog_pvt::hanguponpolarityswitch, analog_subchannel::inthreeway, LOG_DEBUG, LOG_WARNING, ast_channel::name, analog_subchannel::owner, analog_pvt::owner, analog_pvt::polaritydelaytv, analog_pvt::sig, and analog_pvt::subs.

Referenced by dahdi_answer().

01449 {
01450    int res = 0;
01451    int index;
01452    int oldstate = ast->_state;
01453    ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel);
01454    ast_setstate(ast, AST_STATE_UP);
01455    index = analog_get_index(ast, p, 1);
01456    if (index < 0) {
01457       index = ANALOG_SUB_REAL;
01458    }
01459    switch (p->sig) {
01460    case ANALOG_SIG_FXSLS:
01461    case ANALOG_SIG_FXSGS:
01462    case ANALOG_SIG_FXSKS:
01463       analog_set_ringtimeout(p, 0);
01464       /* Fall through */
01465    case ANALOG_SIG_EM:
01466    case ANALOG_SIG_EM_E1:
01467    case ANALOG_SIG_EMWINK:
01468    case ANALOG_SIG_FEATD:
01469    case ANALOG_SIG_FEATDMF:
01470    case ANALOG_SIG_FEATDMF_TA:
01471    case ANALOG_SIG_E911:
01472    case ANALOG_SIG_FGC_CAMA:
01473    case ANALOG_SIG_FGC_CAMAMF:
01474    case ANALOG_SIG_FEATB:
01475    case ANALOG_SIG_SF:
01476    case ANALOG_SIG_SFWINK:
01477    case ANALOG_SIG_SF_FEATD:
01478    case ANALOG_SIG_SF_FEATDMF:
01479    case ANALOG_SIG_SF_FEATB:
01480    case ANALOG_SIG_FXOLS:
01481    case ANALOG_SIG_FXOGS:
01482    case ANALOG_SIG_FXOKS:
01483       /* Pick up the line */
01484       ast_debug(1, "Took %s off hook\n", ast->name);
01485       if (p->hanguponpolarityswitch) {
01486          gettimeofday(&p->polaritydelaytv, NULL);
01487       }
01488       res = analog_off_hook(p);
01489       analog_play_tone(p, index, -1);
01490       analog_set_dialing(p, 0);
01491       if ((index == ANALOG_SUB_REAL) && p->subs[ANALOG_SUB_THREEWAY].inthreeway) {
01492          if (oldstate == AST_STATE_RINGING) {
01493             ast_debug(1, "Finally swapping real and threeway\n");
01494             analog_play_tone(p, ANALOG_SUB_THREEWAY, -1);
01495             analog_swap_subs(p, ANALOG_SUB_THREEWAY, ANALOG_SUB_REAL);
01496             p->owner = p->subs[ANALOG_SUB_REAL].owner;
01497          }
01498       }
01499 
01500       switch (p->sig) {
01501       case ANALOG_SIG_FXSLS:
01502       case ANALOG_SIG_FXSKS:
01503       case ANALOG_SIG_FXSGS:
01504          analog_set_echocanceller(p, 1);
01505          analog_train_echocanceller(p);
01506          break;
01507       case ANALOG_SIG_FXOLS:
01508       case ANALOG_SIG_FXOKS:
01509       case ANALOG_SIG_FXOGS:
01510          analog_answer_polarityswitch(p);
01511          break;
01512       default:
01513          break;
01514       }
01515       break;
01516    default:
01517       ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
01518       res = -1;
01519    }
01520    ast_setstate(ast, AST_STATE_UP);
01521    return res;
01522 }

int analog_available ( struct analog_pvt *  p  ) 

Definition at line 782 of file sig_analog.c.

References ast_channel::_state, 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_log(), AST_STATE_RINGING, AST_STATE_UP, analog_pvt::callwaiting, analog_pvt::channel, analog_pvt::dnd, analog_pvt::guardtime, analog_subchannel::inthreeway, LOG_DEBUG, analog_pvt::outgoing, analog_subchannel::owner, analog_pvt::owner, analog_pvt::sig, and analog_pvt::subs.

Referenced by available().

00783 {
00784    int offhook;
00785 
00786    ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel);
00787    /* If do not disturb, definitely not */
00788    if (p->dnd) {
00789       return 0;
00790    }
00791    /* If guard time, definitely not */
00792    if (p->guardtime && (time(NULL) < p->guardtime)) {
00793       return 0;
00794    }
00795 
00796    /* If no owner definitely available */
00797    if (!p->owner) {
00798       offhook = analog_is_off_hook(p);
00799 
00800       /* TDM FXO card, "onhook" means out of service (no battery on the line) */
00801       if ((p->sig == ANALOG_SIG_FXSLS) || (p->sig == ANALOG_SIG_FXSKS) || (p->sig == ANALOG_SIG_FXSGS)) {
00802 #ifdef DAHDI_CHECK_HOOKSTATE
00803          if (offhook) {
00804             return 1;
00805          }
00806          return 0;
00807 #endif
00808       /* TDM FXS card, "offhook" means someone took the hook off so it's unavailable! */
00809       } else if (offhook) {
00810          ast_debug(1, "Channel %d off hook, can't use\n", p->channel);
00811          return 0;
00812       }
00813       return 1;
00814    }
00815 
00816    /* If it's not an FXO, forget about call wait */
00817    if ((p->sig != ANALOG_SIG_FXOKS) && (p->sig != ANALOG_SIG_FXOLS) && (p->sig != ANALOG_SIG_FXOGS)) {
00818       return 0;
00819    }
00820 
00821    if (!p->callwaiting) {
00822       /* If they don't have call waiting enabled, then for sure they're unavailable at this point */
00823       return 0;
00824    }
00825 
00826    if (p->subs[ANALOG_SUB_CALLWAIT].allocd) {
00827       /* If there is already a call waiting call, then we can't take a second one */
00828       return 0;
00829    }
00830 
00831    if ((p->owner->_state != AST_STATE_UP) &&
00832        ((p->owner->_state != AST_STATE_RINGING) || p->outgoing)) {
00833       /* If the current call is not up, then don't allow the call */
00834       return 0;
00835    }
00836    if ((p->subs[ANALOG_SUB_THREEWAY].owner) && (!p->subs[ANALOG_SUB_THREEWAY].inthreeway)) {
00837       /* Can't take a call wait when the three way calling hasn't been merged yet. */
00838       return 0;
00839    }
00840    /* We're cool */
00841    return 1;
00842 }

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

Definition at line 966 of file sig_analog.c.

References ast_channel::_state, 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_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_get_cc_config_params(), 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_tvnow(), analog_pvt::caller, analog_pvt::callwait_name, analog_pvt::callwait_num, analog_pvt::channel, ast_channel::connected, 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, analog_pvt::hanguponpolarityswitch, ast_party_caller::id, ast_party_connected_line::id, analog_pvt::lastcid_name, analog_pvt::lastcid_num, LOG_DEBUG, LOG_WARNING, ast_channel::name, ast_party_id::name, ast_party_id::number, analog_dialoperation::op, analog_pvt::outgoing, analog_pvt::outsigmod, analog_pvt::owner, analog_subchannel::owner, pbx_builtin_getvar_helper(), analog_pvt::polaritydelaytv, analog_pvt::pulse, S_COR, analog_pvt::sig, ast_party_number::str, ast_party_name::str, analog_pvt::stripmsd, analog_pvt::subs, analog_pvt::use_callerid, ast_party_number::valid, ast_party_name::valid, and analog_pvt::whichwink.

Referenced by dahdi_call().

00967 {
00968    int res, index,mysig;
00969    char *c, *n, *l;
00970    char dest[256]; /* must be same length as p->dialdest */
00971 
00972    ast_log(LOG_DEBUG, "CALLING CID_NAME: %s CID_NUM:: %s\n",
00973       S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""),
00974       S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, ""));
00975 
00976    ast_copy_string(dest, rdest, sizeof(dest));
00977    ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest));
00978 
00979    if ((ast->_state == AST_STATE_BUSY)) {
00980       ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_BUSY);
00981       return 0;
00982    }
00983 
00984    if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
00985       ast_log(LOG_WARNING, "analog_call called on %s, neither down nor reserved\n", ast->name);
00986       return -1;
00987    }
00988 
00989    p->dialednone = 0;
00990    p->outgoing = 1;
00991 
00992    mysig = p->sig;
00993    if (p->outsigmod > -1) {
00994       mysig = p->outsigmod;
00995    }
00996 
00997    switch (mysig) {
00998    case ANALOG_SIG_FXOLS:
00999    case ANALOG_SIG_FXOGS:
01000    case ANALOG_SIG_FXOKS:
01001       if (p->owner == ast) {
01002          /* Normal ring, on hook */
01003 
01004          /* Don't send audio while on hook, until the call is answered */
01005          analog_set_dialing(p, 1);
01006          analog_set_cadence(p, ast); /* and set p->cidrings */
01007 
01008          /* nick@dccinc.com 4/3/03 mods to allow for deferred dialing */
01009          c = strchr(dest, '/');
01010          if (c) {
01011             c++;
01012          }
01013          if (c && (strlen(c) < p->stripmsd)) {
01014             ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
01015             c = NULL;
01016          }
01017          if (c) {
01018             p->dop.op = ANALOG_DIAL_OP_REPLACE;
01019             snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
01020             ast_debug(1, "FXO: setup deferred dialstring: %s\n", c);
01021          } else {
01022             p->dop.dialstr[0] = '\0';
01023          }
01024 
01025          if (analog_ring(p)) {
01026             ast_log(LOG_WARNING, "Unable to ring phone: %s\n", strerror(errno));
01027             return -1;
01028          }
01029          analog_set_dialing(p, 1);
01030       } else {
01031          if (ast->connected.id.number.valid && ast->connected.id.number.str) {
01032             ast_copy_string(p->callwait_num, ast->connected.id.number.str, sizeof(p->callwait_num));
01033          } else {
01034             p->callwait_num[0] = '\0';
01035          }
01036          if (ast->connected.id.name.valid && ast->connected.id.name.str) {
01037             ast_copy_string(p->callwait_name, ast->connected.id.name.str, sizeof(p->callwait_name));
01038          } else {
01039             p->callwait_name[0] = '\0';
01040          }
01041 
01042          /* Call waiting tone instead */
01043          if (analog_callwait(p)) {
01044             return -1;
01045          }
01046          /* Make ring-back */
01047          if (analog_play_tone(p, ANALOG_SUB_CALLWAIT, ANALOG_TONE_RINGTONE)) {
01048             ast_log(LOG_WARNING, "Unable to generate call-wait ring-back on channel %s\n", ast->name);
01049          }
01050 
01051       }
01052       n = ast->connected.id.name.valid ? ast->connected.id.name.str : NULL;
01053       l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
01054       if (l) {
01055          ast_copy_string(p->lastcid_num, l, sizeof(p->lastcid_num));
01056       } else {
01057          p->lastcid_num[0] = '\0';
01058       }
01059       if (n) {
01060          ast_copy_string(p->lastcid_name, n, sizeof(p->lastcid_name));
01061       } else {
01062          p->lastcid_name[0] = '\0';
01063       }
01064 
01065       if (p->use_callerid) {
01066          p->caller.id.name.str = p->lastcid_name;
01067          p->caller.id.number.str = p->lastcid_num;
01068       }
01069 
01070       ast_setstate(ast, AST_STATE_RINGING);
01071       index = analog_get_index(ast, p, 0);
01072       if (index > -1) {
01073          struct ast_cc_config_params *cc_params;
01074 
01075          /* This is where the initial ringing frame is queued for an analog call.
01076           * As such, this is a great time to offer CCNR to the caller if it's available.
01077           */
01078          cc_params = ast_channel_get_cc_config_params(p->subs[index].owner);
01079          if (cc_params) {
01080             switch (ast_get_cc_monitor_policy(cc_params)) {
01081             case AST_CC_MONITOR_NEVER:
01082                break;
01083             case AST_CC_MONITOR_NATIVE:
01084             case AST_CC_MONITOR_ALWAYS:
01085             case AST_CC_MONITOR_GENERIC:
01086                ast_queue_cc_frame(p->subs[index].owner, AST_CC_GENERIC_MONITOR_TYPE,
01087                   analog_get_orig_dialstring(p), AST_CC_CCNR, NULL);
01088                break;
01089             }
01090          }
01091          ast_queue_control(p->subs[index].owner, AST_CONTROL_RINGING);
01092       }
01093       break;
01094    case ANALOG_SIG_FXSLS:
01095    case ANALOG_SIG_FXSGS:
01096    case ANALOG_SIG_FXSKS:
01097       if (p->answeronpolarityswitch || p->hanguponpolarityswitch) {
01098          ast_debug(1, "Ignore possible polarity reversal on line seizure\n");
01099          p->polaritydelaytv = ast_tvnow();
01100       }
01101       /* fall through */
01102    case ANALOG_SIG_EMWINK:
01103    case ANALOG_SIG_EM:
01104    case ANALOG_SIG_EM_E1:
01105    case ANALOG_SIG_FEATD:
01106    case ANALOG_SIG_FEATDMF:
01107    case ANALOG_SIG_E911:
01108    case ANALOG_SIG_FGC_CAMA:
01109    case ANALOG_SIG_FGC_CAMAMF:
01110    case ANALOG_SIG_FEATB:
01111    case ANALOG_SIG_SFWINK:
01112    case ANALOG_SIG_SF:
01113    case ANALOG_SIG_SF_FEATD:
01114    case ANALOG_SIG_SF_FEATDMF:
01115    case ANALOG_SIG_FEATDMF_TA:
01116    case ANALOG_SIG_SF_FEATB:
01117       c = strchr(dest, '/');
01118       if (c) {
01119          c++;
01120       } else {
01121          c = "";
01122       }
01123       if (strlen(c) < p->stripmsd) {
01124          ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
01125          return -1;
01126       }
01127       res = analog_start(p);
01128       if (res < 0) {
01129          if (errno != EINPROGRESS) {
01130             return -1;
01131          }
01132       }
01133       ast_log(LOG_DEBUG, "Dialing '%s'\n", c);
01134       p->dop.op = ANALOG_DIAL_OP_REPLACE;
01135 
01136       c += p->stripmsd;
01137 
01138       switch (mysig) {
01139       case ANALOG_SIG_FEATD:
01140          l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
01141          if (l) {
01142             snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T*%s*%s*", l, c);
01143          } else {
01144             snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T**%s*", c);
01145          }
01146          break;
01147       case ANALOG_SIG_FEATDMF:
01148          l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
01149          if (l) {
01150             snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*00%s#*%s#", l, c);
01151          } else {
01152             snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*02#*%s#", c);
01153          }
01154          break;
01155       case ANALOG_SIG_FEATDMF_TA:
01156       {
01157          const char *cic = "", *ozz = "";
01158 
01159          /* If you have to go through a Tandem Access point you need to use this */
01160 #ifndef STANDALONE
01161          ozz = pbx_builtin_getvar_helper(p->owner, "FEATDMF_OZZ");
01162          if (!ozz) {
01163             ozz = analog_defaultozz;
01164          }
01165          cic = pbx_builtin_getvar_helper(p->owner, "FEATDMF_CIC");
01166          if (!cic) {
01167             cic = analog_defaultcic;
01168          }
01169 #endif
01170          if (!ozz || !cic) {
01171             ast_log(LOG_WARNING, "Unable to dial channel of type feature group D MF tandem access without CIC or OZZ set\n");
01172             return -1;
01173          }
01174          snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s%s#", ozz, cic);
01175          snprintf(p->finaldial, sizeof(p->finaldial), "M*%s#", c);
01176          p->whichwink = 0;
01177       }
01178          break;
01179       case ANALOG_SIG_E911:
01180          ast_copy_string(p->dop.dialstr, "M*911#", sizeof(p->dop.dialstr));
01181          break;
01182       case ANALOG_SIG_FGC_CAMA:
01183          snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%s", c);
01184          break;
01185       case ANALOG_SIG_FGC_CAMAMF:
01186       case ANALOG_SIG_FEATB:
01187          snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s#", c);
01188          break;
01189       default:
01190          if (p->pulse) {
01191             snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%sw", c);
01192          } else {
01193             snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T%sw", c);
01194          }
01195          break;
01196       }
01197 
01198       if (p->echotraining && (strlen(p->dop.dialstr) > 4)) {
01199          memset(p->echorest, 'w', sizeof(p->echorest) - 1);
01200          strcpy(p->echorest + (p->echotraining / 400) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
01201          p->echorest[sizeof(p->echorest) - 1] = '\0';
01202          p->echobreak = 1;
01203          p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0';
01204       } else {
01205          p->echobreak = 0;
01206       }
01207       analog_set_waitingfordt(p, ast);
01208       if (!res) {
01209          if (analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop)) {
01210             int saveerr = errno;
01211 
01212             analog_on_hook(p);
01213             ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(saveerr));
01214             return -1;
01215          }
01216       } else {
01217          ast_debug(1, "Deferring dialing...\n");
01218       }
01219       analog_set_dialing(p, 1);
01220       if (ast_strlen_zero(c)) {
01221          p->dialednone = 1;
01222       }
01223       ast_setstate(ast, AST_STATE_DIALING);
01224       break;
01225    default:
01226       ast_debug(1, "not yet implemented\n");
01227       return -1;
01228    }
01229    return 0;
01230 }

const char* analog_cidstart_to_str ( enum analog_cid_start  cid_start  ) 

Definition at line 218 of file sig_analog.c.

References ANALOG_CID_START_DTMF_NOALERT, ANALOG_CID_START_POLARITY, ANALOG_CID_START_POLARITY_IN, and ANALOG_CID_START_RING.

00219 {
00220    switch (cid_start) {
00221    case ANALOG_CID_START_RING:
00222       return "Ring";
00223    case ANALOG_CID_START_POLARITY:
00224       return "Polarity";
00225    case ANALOG_CID_START_POLARITY_IN:
00226       return "Polarity_In";
00227    case ANALOG_CID_START_DTMF_NOALERT:
00228       return "DTMF";
00229    }
00230 
00231    return "Unknown";
00232 }

const char* analog_cidtype_to_str ( unsigned int  cid_type  ) 

Definition at line 142 of file sig_analog.c.

References ARRAY_LEN, and cidtypes.

00143 {
00144    int i;
00145 
00146    for (i = 0; i < ARRAY_LEN(cidtypes); i++) {
00147       if (cid_type == cidtypes[i].cid_type) {
00148          return cidtypes[i].name;
00149       }
00150    }
00151 
00152    return "Unknown";
00153 }

int analog_config_complete ( struct analog_pvt *  p  ) 

Definition at line 3794 of file sig_analog.c.

References ANALOG_SIG_FXOGS, ANALOG_SIG_FXOKS, ANALOG_SIG_FXOLS, analog_pvt::callwaiting, analog_pvt::permcallwaiting, and analog_pvt::sig.

Referenced by mkintf().

03795 {
03796    /* No call waiting on non FXS channels */
03797    if ((p->sig != ANALOG_SIG_FXOKS) && (p->sig != ANALOG_SIG_FXOLS) && (p->sig != ANALOG_SIG_FXOGS)) {
03798       p->permcallwaiting = 0;
03799    }
03800 
03801    p->callwaiting = p->permcallwaiting;
03802 
03803    return 0;
03804 }

void analog_delete ( struct analog_pvt *  doomed  ) 

Delete the analog private structure.

Since:
1.8
Parameters:
doomed Analog private structure to delete.
Returns:
Nothing

Definition at line 3789 of file sig_analog.c.

References ast_free.

Referenced by destroy_dahdi_pvt().

03790 {
03791    ast_free(doomed);
03792 }

int analog_dnd ( struct analog_pvt *  p,
int  flag 
)

Definition at line 3830 of file sig_analog.c.

References ast_verb, analog_pvt::channel, analog_pvt::dnd, EVENT_FLAG_SYSTEM, and manager_event.

Referenced by dahdi_dnd().

03831 {
03832    if (flag == -1) {
03833       return p->dnd;
03834    }
03835 
03836    p->dnd = flag;
03837 
03838    ast_verb(3, "%s DND on channel %d\n",
03839          flag? "Enabled" : "Disabled",
03840          p->channel);
03841    manager_event(EVENT_FLAG_SYSTEM, "DNDState",
03842          "Channel: DAHDI/%d\r\n"
03843          "Status: %s\r\n", p->channel,
03844          flag? "enabled" : "disabled");
03845 
03846    return 0;
03847 }

struct ast_frame* analog_exception ( struct analog_pvt *  p,
struct ast_channel *  ast 
) [read]

Definition at line 3407 of file sig_analog.c.

References __analog_handle_event(), ast_channel::_state, 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_off_hook(), analog_ring(), analog_set_dialing(), analog_set_echocanceller(), analog_stop_callwait(), ANALOG_SUB_REAL, analog_update_conf(), ast_bridged_channel(), AST_CONTROL_ANSWER, AST_CONTROL_UNHOLD, ast_debug, AST_FRAME_NULL, ast_log(), ast_queue_control(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, ast_tv(), ast_verb, analog_pvt::channel, ast_frame::data, ast_frame::datalen, ast_frame::delivery, analog_subchannel::f, f, ast_channel::fds, analog_pvt::flashtime, ast_frame::frametype, ast_frame_subclass::integer, LOG_DEBUG, LOG_WARNING, ast_frame::mallocd, ast_channel::name, 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().

03408 {
03409    int res;
03410    int index;
03411    struct ast_frame *f;
03412 
03413    ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel);
03414 
03415    index = analog_get_index(ast, p, 1);
03416    if (index < 0) {
03417       index = ANALOG_SUB_REAL;
03418    }
03419 
03420    p->subs[index].f.frametype = AST_FRAME_NULL;
03421    p->subs[index].f.datalen = 0;
03422    p->subs[index].f.samples = 0;
03423    p->subs[index].f.mallocd = 0;
03424    p->subs[index].f.offset = 0;
03425    p->subs[index].f.subclass.integer = 0;
03426    p->subs[index].f.delivery = ast_tv(0,0);
03427    p->subs[index].f.src = "dahdi_exception";
03428    p->subs[index].f.data.ptr = NULL;
03429 
03430    if (!p->owner) {
03431       /* If nobody owns us, absorb the event appropriately, otherwise
03432          we loop indefinitely.  This occurs when, during call waiting, the
03433          other end hangs up our channel so that it no longer exists, but we
03434          have neither FLASH'd nor ONHOOK'd to signify our desire to
03435          change to the other channel. */
03436       res = analog_get_event(p);
03437 
03438       /* Switch to real if there is one and this isn't something really silly... */
03439       if ((res != ANALOG_EVENT_RINGEROFF) && (res != ANALOG_EVENT_RINGERON) &&
03440          (res != ANALOG_EVENT_HOOKCOMPLETE)) {
03441          ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
03442          p->owner = p->subs[ANALOG_SUB_REAL].owner;
03443          if (p->owner && ast != p->owner) {
03444             /*
03445              * Could this even happen?
03446              * Possible deadlock because we do not have the real-call lock.
03447              */
03448             ast_log(LOG_WARNING, "Event %s on %s is not restored owner %s\n",
03449                analog_event2str(res), ast->name, p->owner->name);
03450          }
03451          if (p->owner && ast_bridged_channel(p->owner)) {
03452             ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
03453          }
03454       }
03455       switch (res) {
03456       case ANALOG_EVENT_ONHOOK:
03457          analog_set_echocanceller(p, 0);
03458          if (p->owner) {
03459             ast_verb(3, "Channel %s still has call, ringing phone\n", p->owner->name);
03460             analog_ring(p);
03461             analog_stop_callwait(p);
03462          } else {
03463             ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
03464                analog_event2str(res));
03465          }
03466          analog_update_conf(p);
03467          break;
03468       case ANALOG_EVENT_RINGOFFHOOK:
03469          analog_set_echocanceller(p, 1);
03470          analog_off_hook(p);
03471          if (p->owner && (p->owner->_state == AST_STATE_RINGING)) {
03472             ast_queue_control(p->owner, AST_CONTROL_ANSWER);
03473             analog_set_dialing(p, 0);
03474          }
03475          break;
03476       case ANALOG_EVENT_HOOKCOMPLETE:
03477       case ANALOG_EVENT_RINGERON:
03478       case ANALOG_EVENT_RINGEROFF:
03479          /* Do nothing */
03480          break;
03481       case ANALOG_EVENT_WINKFLASH:
03482          gettimeofday(&p->flashtime, NULL);
03483          if (p->owner) {
03484             ast_verb(3, "Channel %d flashed to other channel %s\n", p->channel, p->owner->name);
03485             if (p->owner->_state != AST_STATE_UP) {
03486                /* Answer if necessary */
03487                ast_queue_control(p->owner, AST_CONTROL_ANSWER);
03488                ast_setstate(p->owner, AST_STATE_UP);
03489             }
03490             analog_stop_callwait(p);
03491             if (ast_bridged_channel(p->owner)) {
03492                ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
03493             }
03494          } else {
03495             ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
03496                analog_event2str(res));
03497          }
03498          analog_update_conf(p);
03499          break;
03500       default:
03501          ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", analog_event2str(res));
03502          break;
03503       }
03504       f = &p->subs[index].f;
03505       return f;
03506    }
03507    ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
03508    /* If it's not us, return NULL immediately */
03509    if (ast != p->owner) {
03510       ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
03511       f = &p->subs[index].f;
03512       return f;
03513    }
03514    f = __analog_handle_event(p, ast);
03515    return f;
03516 }

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

Definition at line 3812 of file sig_analog.c.

References analog_update_conf(), ast_debug, analog_pvt::channel, ast_channel::name, analog_subchannel::owner, analog_pvt::owner, and analog_pvt::subs.

Referenced by dahdi_fixup().

03813 {
03814    struct analog_pvt *new_pvt = newp;
03815    int x;
03816    ast_debug(1, "New owner for channel %d is %s\n", new_pvt->channel, newchan->name);
03817    if (new_pvt->owner == oldchan) {
03818       new_pvt->owner = newchan;
03819    }
03820    for (x = 0; x < 3; x++) {
03821       if (new_pvt->subs[x].owner == oldchan) {
03822          new_pvt->subs[x].owner = newchan;
03823       }
03824    }
03825 
03826    analog_update_conf(new_pvt);
03827    return 0;
03828 }

void analog_free ( struct analog_pvt *  p  ) 

Definition at line 3806 of file sig_analog.c.

References free.

03807 {
03808    free(p);
03809 }

void analog_handle_dtmfup ( struct analog_pvt *  p,
struct ast_channel *  ast,
enum analog_sub  index,
struct ast_frame **  dest 
)

Definition at line 1549 of file sig_analog.c.

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

Referenced by __analog_handle_event(), and dahdi_read().

01550 {
01551    struct ast_frame *f = *dest;
01552 
01553    if (analog_check_confirmanswer(p)) {
01554       ast_debug(1, "Confirm answer on %s!\n", ast->name);
01555       /* Upon receiving a DTMF digit, consider this an answer confirmation instead
01556       of a DTMF digit */
01557       p->subs[index].f.frametype = AST_FRAME_CONTROL;
01558       p->subs[index].f.subclass.integer = AST_CONTROL_ANSWER;
01559       *dest = &p->subs[index].f;
01560       /* Reset confirmanswer so DTMF's will behave properly for the duration of the call */
01561       analog_set_confirmanswer(p, 0);
01562    }
01563    if (p->callwaitcas) {
01564       if ((f->subclass.integer == 'A') || (f->subclass.integer == 'D')) {
01565          ast_debug(1, "Got some DTMF, but it's for the CAS\n");
01566          p->caller.id.name.str = p->callwait_name;
01567          p->caller.id.number.str = p->callwait_num;
01568          analog_send_callerid(p, 1, &p->caller);
01569       }
01570       if (analog_handles_digit(f))
01571          p->callwaitcas = 0;
01572       p->subs[index].f.frametype = AST_FRAME_NULL;
01573       p->subs[index].f.subclass.integer = 0;
01574       *dest = &p->subs[index].f;
01575    } else {
01576       analog_cb_handle_dtmfup(p, ast, index, dest);
01577    }
01578 }

void* analog_handle_init_event ( struct analog_pvt *  i,
int  event 
)

Definition at line 3518 of file sig_analog.c.

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_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_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_debug, ast_hangup(), ast_log(), ast_pthread_create_detached, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, ast_verbose, analog_pvt::chan_pvt, analog_pvt::channel, analog_pvt::cid_start, errno, EVENT_FLAG_SYSTEM, analog_pvt::fxsoffhookstate, analog_pvt::hanguponpolarityswitch, analog_pvt::immediate, analog_pvt::inalarm, LOG_NOTICE, LOG_WARNING, manager_event, analog_pvt::polarity, POLARITY_REV, analog_pvt::ringt_base, analog_pvt::sig, analog_pvt::ss_astchan, analog_pvt::unknown_alarm, and VERBOSE_PREFIX_2.

Referenced by do_monitor().

03519 {
03520    int res;
03521    pthread_t threadid;
03522    struct ast_channel *chan;
03523 
03524    ast_debug(1, "channel (%d) - signaling (%d) - event (%s)\n",
03525             i->channel, i->sig, analog_event2str(event));
03526 
03527    /* Handle an event on a given channel for the monitor thread. */
03528    switch (event) {
03529    case ANALOG_EVENT_WINKFLASH:
03530    case ANALOG_EVENT_RINGOFFHOOK:
03531       if (i->inalarm) {
03532          break;
03533       }
03534       /* Got a ring/answer.  What kind of channel are we? */
03535       switch (i->sig) {
03536       case ANALOG_SIG_FXOLS:
03537       case ANALOG_SIG_FXOGS:
03538       case ANALOG_SIG_FXOKS:
03539          res = analog_off_hook(i);
03540          i->fxsoffhookstate = 1;
03541          if (res && (errno == EBUSY)) {
03542             break;
03543          }
03544          analog_cancel_cidspill(i);
03545          if (i->immediate) {
03546             analog_set_echocanceller(i, 1);
03547             /* The channel is immediately up.  Start right away */
03548             res = analog_play_tone(i, ANALOG_SUB_REAL, ANALOG_TONE_RINGTONE);
03549             chan = analog_new_ast_channel(i, AST_STATE_RING, 1, ANALOG_SUB_REAL, NULL);
03550             if (!chan) {
03551                ast_log(LOG_WARNING, "Unable to start PBX on channel %d\n", i->channel);
03552                res = analog_play_tone(i, ANALOG_SUB_REAL, ANALOG_TONE_CONGESTION);
03553                if (res < 0) {
03554                   ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
03555                }
03556             }
03557          } else {
03558             /* Check for callerid, digits, etc */
03559             chan = analog_new_ast_channel(i, AST_STATE_RESERVED, 0, ANALOG_SUB_REAL, NULL);
03560             i->ss_astchan = chan;
03561             if (chan) {
03562                if (analog_has_voicemail(i)) {
03563                   res = analog_play_tone(i, ANALOG_SUB_REAL, ANALOG_TONE_STUTTER);
03564                } else {
03565                   res = analog_play_tone(i, ANALOG_SUB_REAL, ANALOG_TONE_DIALTONE);
03566                }
03567                if (res < 0)
03568                   ast_log(LOG_WARNING, "Unable to play dialtone on channel %d, do you have defaultzone and loadzone defined?\n", i->channel);
03569 
03570                if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
03571                   ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
03572                   res = analog_play_tone(i, ANALOG_SUB_REAL, ANALOG_TONE_CONGESTION);
03573                   if (res < 0) {
03574                      ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
03575                   }
03576                   ast_hangup(chan);
03577                }
03578             } else
03579                ast_log(LOG_WARNING, "Unable to create channel\n");
03580          }
03581          break;
03582       case ANALOG_SIG_FXSLS:
03583       case ANALOG_SIG_FXSGS:
03584       case ANALOG_SIG_FXSKS:
03585          analog_set_ringtimeout(i, i->ringt_base);
03586          /* Fall through */
03587       case ANALOG_SIG_EMWINK:
03588       case ANALOG_SIG_FEATD:
03589       case ANALOG_SIG_FEATDMF:
03590       case ANALOG_SIG_FEATDMF_TA:
03591       case ANALOG_SIG_E911:
03592       case ANALOG_SIG_FGC_CAMA:
03593       case ANALOG_SIG_FGC_CAMAMF:
03594       case ANALOG_SIG_FEATB:
03595       case ANALOG_SIG_EM:
03596       case ANALOG_SIG_EM_E1:
03597       case ANALOG_SIG_SFWINK:
03598       case ANALOG_SIG_SF_FEATD:
03599       case ANALOG_SIG_SF_FEATDMF:
03600       case ANALOG_SIG_SF_FEATB:
03601       case ANALOG_SIG_SF:
03602          /* Check for callerid, digits, etc */
03603          if (i->cid_start == ANALOG_CID_START_POLARITY_IN || i->cid_start == ANALOG_CID_START_DTMF_NOALERT) {
03604             chan = analog_new_ast_channel(i, AST_STATE_PRERING, 0, ANALOG_SUB_REAL, NULL);
03605          } else {
03606             chan = analog_new_ast_channel(i, AST_STATE_RING, 0, ANALOG_SUB_REAL, NULL);
03607          }
03608          i->ss_astchan = chan;
03609          if (chan && ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
03610             ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
03611             res = analog_play_tone(i, ANALOG_SUB_REAL, ANALOG_TONE_CONGESTION);
03612             if (res < 0) {
03613                ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
03614             }
03615             ast_hangup(chan);
03616          } else if (!chan) {
03617             ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
03618          }
03619          break;
03620       default:
03621          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);
03622          res = analog_play_tone(i, ANALOG_SUB_REAL, ANALOG_TONE_CONGESTION);
03623          if (res < 0) {
03624             ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
03625          }
03626          return NULL;
03627       }
03628       break;
03629    case ANALOG_EVENT_NOALARM:
03630       analog_set_alarm(i, 0);
03631       if (!i->unknown_alarm) {
03632          ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel);
03633          manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
03634                   "Channel: %d\r\n", i->channel);
03635       } else {
03636          i->unknown_alarm = 0;
03637       }
03638       break;
03639    case ANALOG_EVENT_ALARM:
03640       analog_set_alarm(i, 1);
03641       analog_get_and_handle_alarms(i);
03642 
03643       /* fall thru intentionally */
03644    case ANALOG_EVENT_ONHOOK:
03645       /* Back on hook.  Hang up. */
03646       switch (i->sig) {
03647       case ANALOG_SIG_FXOLS:
03648       case ANALOG_SIG_FXOGS:
03649          i->fxsoffhookstate = 0;
03650          analog_start_polarityswitch(i);
03651       case ANALOG_SIG_FEATD:
03652       case ANALOG_SIG_FEATDMF:
03653       case ANALOG_SIG_FEATDMF_TA:
03654       case ANALOG_SIG_E911:
03655       case ANALOG_SIG_FGC_CAMA:
03656       case ANALOG_SIG_FGC_CAMAMF:
03657       case ANALOG_SIG_FEATB:
03658       case ANALOG_SIG_EM:
03659       case ANALOG_SIG_EM_E1:
03660       case ANALOG_SIG_EMWINK:
03661       case ANALOG_SIG_SF_FEATD:
03662       case ANALOG_SIG_SF_FEATDMF:
03663       case ANALOG_SIG_SF_FEATB:
03664       case ANALOG_SIG_SF:
03665       case ANALOG_SIG_SFWINK:
03666       case ANALOG_SIG_FXSLS:
03667       case ANALOG_SIG_FXSGS:
03668       case ANALOG_SIG_FXSKS:
03669          analog_set_echocanceller(i, 0);
03670          res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
03671          analog_on_hook(i);
03672          break;
03673       case ANALOG_SIG_FXOKS:
03674          i->fxsoffhookstate = 0;
03675          analog_start_polarityswitch(i);
03676          analog_set_echocanceller(i, 0);
03677          /* Diddle the battery for the zhone */
03678 #ifdef ZHONE_HACK
03679          analog_off_hook(i);
03680          usleep(1);
03681 #endif
03682          res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
03683          analog_on_hook(i);
03684          break;
03685       default:
03686          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);
03687          res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
03688          return NULL;
03689       }
03690       break;
03691    case ANALOG_EVENT_POLARITY:
03692       switch (i->sig) {
03693       case ANALOG_SIG_FXSLS:
03694       case ANALOG_SIG_FXSKS:
03695       case ANALOG_SIG_FXSGS:
03696          /* We have already got a PR before the channel was
03697             created, but it wasn't handled. We need polarity
03698             to be REV for remote hangup detection to work.
03699             At least in Spain */
03700          if (i->hanguponpolarityswitch) {
03701             i->polarity = POLARITY_REV;
03702          }
03703 
03704          if (i->cid_start == ANALOG_CID_START_POLARITY || i->cid_start == ANALOG_CID_START_POLARITY_IN) {
03705             i->polarity = POLARITY_REV;
03706             ast_verbose(VERBOSE_PREFIX_2 "Starting post polarity "
03707                    "CID detection on channel %d\n",
03708                    i->channel);
03709             chan = analog_new_ast_channel(i, AST_STATE_PRERING, 0, ANALOG_SUB_REAL, NULL);
03710             i->ss_astchan = chan;
03711             if (chan && ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
03712                ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
03713             }
03714          }
03715          break;
03716       default:
03717          ast_log(LOG_WARNING, "handle_init_event detected "
03718             "polarity reversal on non-FXO (ANALOG_SIG_FXS) "
03719             "interface %d\n", i->channel);
03720       }
03721       break;
03722    case ANALOG_EVENT_DTMFCID:
03723       switch (i->sig) {
03724          case ANALOG_SIG_FXSLS:
03725          case ANALOG_SIG_FXSKS:
03726          case ANALOG_SIG_FXSGS:
03727             if (i->cid_start == ANALOG_CID_START_DTMF_NOALERT) {
03728                ast_verbose(VERBOSE_PREFIX_2 "Starting DTMF CID detection on channel %d\n",
03729                         i->channel);
03730                chan = analog_new_ast_channel(i, AST_STATE_PRERING, 0, ANALOG_SUB_REAL, NULL);
03731                i->ss_astchan = chan;
03732                if (chan && ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
03733                   ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
03734                }
03735             }
03736             break;
03737          default:
03738             ast_log(LOG_WARNING, "handle_init_event detected "
03739                   "dtmfcid generation event on non-FXO (ANALOG_SIG_FXS) "
03740                         "interface %d\n", i->channel);
03741       }
03742       break;
03743    case ANALOG_EVENT_REMOVED: /* destroy channel, will actually do so in do_monitor */
03744       ast_log(LOG_NOTICE, "Got DAHDI_EVENT_REMOVED. Destroying channel %d\n",
03745          i->channel);
03746       return i->chan_pvt;
03747    case ANALOG_EVENT_NEONMWI_ACTIVE:
03748       analog_handle_notify_message(NULL, i, -1, ANALOG_EVENT_NEONMWI_ACTIVE);
03749       break;
03750    case ANALOG_EVENT_NEONMWI_INACTIVE:
03751       analog_handle_notify_message(NULL, i, -1, ANALOG_EVENT_NEONMWI_INACTIVE);
03752       break;
03753    }
03754    return NULL;
03755 }

int analog_hangup ( struct analog_pvt *  p,
struct ast_channel *  ast 
)

Definition at line 1232 of file sig_analog.c.

References ast_channel::_state, 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_confirmanswer(), analog_set_dialing(), analog_set_echocanceller(), analog_set_linear_mode(), 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_bridged_channel(), ast_channel_setoption(), ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, ast_copy_string(), ast_debug, ast_log(), AST_OPTION_TDD, AST_OPTION_TONE_VERIFY, ast_queue_control(), ast_queue_control_data(), AST_STATE_RESERVED, AST_STATE_UP, ast_strlen_zero(), ast_verb, analog_pvt::callwaitcas, analog_pvt::callwaiting, analog_pvt::channel, analog_pvt::cid_name, analog_pvt::cid_num, analog_pvt::cidrings, free, analog_pvt::guardtime, analog_pvt::hidecallerid, analog_subchannel::inthreeway, LOG_DEBUG, LOG_ERROR, LOG_WARNING, analog_pvt::mohsuggest, ast_channel::name, analog_pvt::onhooktime, analog_pvt::origcid_name, analog_pvt::origcid_num, analog_pvt::outgoing, analog_pvt::owner, analog_subchannel::owner, analog_pvt::permcallwaiting, analog_pvt::permhidecallerid, analog_pvt::polarity, POLARITY_IDLE, S_OR, analog_pvt::sig, analog_pvt::subs, and ast_channel::tech_pvt.

Referenced by dahdi_hangup().

01233 {
01234    int res;
01235    int index, x;
01236 
01237    ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel);
01238    if (!ast->tech_pvt) {
01239       ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
01240       return 0;
01241    }
01242 
01243    index = analog_get_index(ast, p, 1);
01244 
01245    x = 0;
01246    if (p->origcid_num) {
01247       ast_copy_string(p->cid_num, p->origcid_num, sizeof(p->cid_num));
01248       free(p->origcid_num);
01249       p->origcid_num = NULL;
01250    }
01251    if (p->origcid_name) {
01252       ast_copy_string(p->cid_name, p->origcid_name, sizeof(p->cid_name));
01253       free(p->origcid_name);
01254       p->origcid_name = NULL;
01255    }
01256 
01257    analog_dsp_set_digitmode(p, ANALOG_DIGITMODE_DTMF);
01258 
01259    ast_debug(1, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
01260       p->channel, index, p->subs[ANALOG_SUB_REAL].allocd, p->subs[ANALOG_SUB_CALLWAIT].allocd, p->subs[ANALOG_SUB_THREEWAY].allocd);
01261    if (index > -1) {
01262       /* Real channel, do some fixup */
01263       p->subs[index].owner = NULL;
01264       p->polarity = POLARITY_IDLE;
01265       analog_set_linear_mode(p, index, 0);
01266       switch (index) {
01267       case ANALOG_SUB_REAL:
01268          if (p->subs[ANALOG_SUB_CALLWAIT].allocd && p->subs[ANALOG_SUB_THREEWAY].allocd) {
01269             ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
01270             if (p->subs[ANALOG_SUB_CALLWAIT].inthreeway) {
01271                /* We had flipped over to answer a callwait and now it's gone */
01272                ast_debug(1, "We were flipped over to the callwait, moving back and unowning.\n");
01273                /* Move to the call-wait, but un-own us until they flip back. */
01274                analog_swap_subs(p, ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL);
01275                analog_unalloc_sub(p, ANALOG_SUB_CALLWAIT);
01276                p->owner = NULL;
01277             } else {
01278                /* The three way hung up, but we still have a call wait */
01279                ast_debug(1, "We were in the threeway and have a callwait still.  Ditching the threeway.\n");
01280                analog_swap_subs(p, ANALOG_SUB_THREEWAY, ANALOG_SUB_REAL);
01281                analog_unalloc_sub(p, ANALOG_SUB_THREEWAY);
01282                if (p->subs[ANALOG_SUB_REAL].inthreeway) {
01283                   /* This was part of a three way call.  Immediately make way for
01284                      another call */
01285                   ast_debug(1, "Call was complete, setting owner to former third call\n");
01286                   p->subs[ANALOG_SUB_REAL].inthreeway = 0;
01287                   p->owner = p->subs[ANALOG_SUB_REAL].owner;
01288                } else {
01289                   /* This call hasn't been completed yet...  Set owner to NULL */
01290                   ast_debug(1, "Call was incomplete, setting owner to NULL\n");
01291                   p->owner = NULL;
01292                }
01293             }
01294          } else if (p->subs[ANALOG_SUB_CALLWAIT].allocd) {
01295             /* Need to hold the lock for real-call, private, and call-waiting call */
01296             analog_lock_sub_owner(p, ANALOG_SUB_CALLWAIT);
01297             if (!p->subs[ANALOG_SUB_CALLWAIT].owner) {
01298                /* The call waiting call dissappeared. */
01299                p->owner = NULL;
01300                break;
01301             }
01302 
01303             /* Move to the call-wait and switch back to them. */
01304             analog_swap_subs(p, ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL);
01305             analog_unalloc_sub(p, ANALOG_SUB_CALLWAIT);
01306             p->owner = p->subs[ANALOG_SUB_REAL].owner;
01307             if (p->owner->_state != AST_STATE_UP) {
01308                ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_ANSWER);
01309             }
01310             if (ast_bridged_channel(p->subs[ANALOG_SUB_REAL].owner)) {
01311                ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
01312             }
01313             /* Unlock the call-waiting call that we swapped to real-call. */
01314             ast_channel_unlock(p->subs[ANALOG_SUB_REAL].owner);
01315          } else if (p->subs[ANALOG_SUB_THREEWAY].allocd) {
01316             analog_swap_subs(p, ANALOG_SUB_THREEWAY, ANALOG_SUB_REAL);
01317             analog_unalloc_sub(p, ANALOG_SUB_THREEWAY);
01318             if (p->subs[ANALOG_SUB_REAL].inthreeway) {
01319                /* This was part of a three way call.  Immediately make way for
01320                   another call */
01321                ast_debug(1, "Call was complete, setting owner to former third call\n");
01322                p->subs[ANALOG_SUB_REAL].inthreeway = 0;
01323                p->owner = p->subs[ANALOG_SUB_REAL].owner;
01324             } else {
01325                /* This call hasn't been completed yet...  Set owner to NULL */
01326                ast_debug(1, "Call was incomplete, setting owner to NULL\n");
01327                p->owner = NULL;
01328             }
01329          }
01330          break;
01331       case ANALOG_SUB_CALLWAIT:
01332          /* Ditch the holding callwait call, and immediately make it available */
01333          if (p->subs[ANALOG_SUB_CALLWAIT].inthreeway) {
01334             /* Need to hold the lock for call-waiting call, private, and 3-way call */
01335             analog_lock_sub_owner(p, ANALOG_SUB_THREEWAY);
01336 
01337             /* This is actually part of a three way, placed on hold.  Place the third part
01338                on music on hold now */
01339             if (p->subs[ANALOG_SUB_THREEWAY].owner && ast_bridged_channel(p->subs[ANALOG_SUB_THREEWAY].owner)) {
01340                ast_queue_control_data(p->subs[ANALOG_SUB_THREEWAY].owner, AST_CONTROL_HOLD,
01341                   S_OR(p->mohsuggest, NULL),
01342                   !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
01343             }
01344             p->subs[ANALOG_SUB_THREEWAY].inthreeway = 0;
01345             /* Make it the call wait now */
01346             analog_swap_subs(p, ANALOG_SUB_CALLWAIT, ANALOG_SUB_THREEWAY);
01347             analog_unalloc_sub(p, ANALOG_SUB_THREEWAY);
01348             if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
01349                /* Unlock the 3-way call that we swapped to call-waiting call. */
01350                ast_channel_unlock(p->subs[ANALOG_SUB_CALLWAIT].owner);
01351             }
01352          } else {
01353             analog_unalloc_sub(p, ANALOG_SUB_CALLWAIT);
01354          }
01355          break;
01356       case ANALOG_SUB_THREEWAY:
01357          /* Need to hold the lock for 3-way call, private, and call-waiting call */
01358          analog_lock_sub_owner(p, ANALOG_SUB_CALLWAIT);
01359          if (p->subs[ANALOG_SUB_CALLWAIT].inthreeway) {
01360             /* The other party of the three way call is currently in a call-wait state.
01361                Start music on hold for them, and take the main guy out of the third call */
01362             p->subs[ANALOG_SUB_CALLWAIT].inthreeway = 0;
01363             if (p->subs[ANALOG_SUB_CALLWAIT].owner && ast_bridged_channel(p->subs[ANALOG_SUB_CALLWAIT].owner)) {
01364                ast_queue_control_data(p->subs[ANALOG_SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
01365                   S_OR(p->mohsuggest, NULL),
01366                   !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
01367             }
01368          }
01369          if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
01370             ast_channel_unlock(p->subs[ANALOG_SUB_CALLWAIT].owner);
01371          }
01372          p->subs[ANALOG_SUB_REAL].inthreeway = 0;
01373          /* If this was part of a three way call index, let us make
01374             another three way call */
01375          analog_unalloc_sub(p, ANALOG_SUB_THREEWAY);
01376          break;
01377       default:
01378          /*
01379           * Should never happen.
01380           * This wasn't any sort of call, so how are we an index?
01381           */
01382          ast_log(LOG_ERROR, "Index found but not any type of call?\n");
01383          break;
01384       }
01385    }
01386 
01387    if (!p->subs[ANALOG_SUB_REAL].owner && !p->subs[ANALOG_SUB_CALLWAIT].owner && !p->subs[ANALOG_SUB_THREEWAY].owner) {
01388       p->owner = NULL;
01389       analog_set_ringtimeout(p, 0);
01390       analog_set_confirmanswer(p, 0);
01391       analog_set_pulsedial(p, 0);
01392       p->outgoing = 0;
01393       p->onhooktime = time(NULL);
01394       p->cidrings = 1;
01395 
01396       /* Perform low level hangup if no owner left */
01397       res = analog_on_hook(p);
01398       if (res < 0) {
01399          ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name);
01400       }
01401       switch (p->sig) {
01402       case ANALOG_SIG_FXOGS:
01403       case ANALOG_SIG_FXOLS:
01404       case ANALOG_SIG_FXOKS:
01405          /* If they're off hook, try playing congestion */
01406          if (analog_is_off_hook(p)) {
01407             analog_hangup_polarityswitch(p);
01408             analog_play_tone(p, ANALOG_SUB_REAL, ANALOG_TONE_CONGESTION);
01409          } else {
01410             analog_play_tone(p, ANALOG_SUB_REAL, -1);
01411          }
01412          break;
01413       case ANALOG_SIG_FXSGS:
01414       case ANALOG_SIG_FXSLS:
01415       case ANALOG_SIG_FXSKS:
01416          /* Make sure we're not made available for at least two seconds assuming
01417             we were actually used for an inbound or outbound call. */
01418          if (ast->_state != AST_STATE_RESERVED) {
01419             time(&p->guardtime);
01420             p->guardtime += 2;
01421          }
01422          break;
01423       default:
01424          analog_play_tone(p, ANALOG_SUB_REAL, -1);
01425       }
01426 
01427       analog_set_echocanceller(p, 0);
01428 
01429       x = 0;
01430       ast_channel_setoption(ast,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0);
01431       ast_channel_setoption(ast,AST_OPTION_TDD,&x,sizeof(char),0);
01432       p->callwaitcas = 0;
01433       p->callwaiting = p->permcallwaiting;
01434       p->hidecallerid = p->permhidecallerid;
01435       analog_set_dialing(p, 0);
01436       analog_update_conf(p);
01437       analog_all_subchannels_hungup(p);
01438    }
01439 
01440    analog_stop_callwait(p);
01441    ast->tech_pvt = NULL;
01442 
01443    ast_verb(3, "Hanging up on '%s'\n", ast->name);
01444 
01445    return 0;
01446 }

struct analog_pvt* analog_new ( enum analog_sigtype  signallingtype,
struct analog_callback *  c,
void *  private_data 
) [read]

Definition at line 3758 of file sig_analog.c.

References analog_subchannel::allocd, ANALOG_CID_START_RING, ANALOG_SIG_NONE, ANALOG_SUB_REAL, ast_calloc, analog_pvt::calls, 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().

03759 {
03760    struct analog_pvt *p;
03761 
03762    p = ast_calloc(1, sizeof(*p));
03763    if (!p) {
03764       return p;
03765    }
03766 
03767    p->calls = c;
03768    p->outsigmod = ANALOG_SIG_NONE;
03769    p->sig = signallingtype;
03770    p->chan_pvt = private_data;
03771 
03772    /* Some defaults for values */
03773    p->cid_start = ANALOG_CID_START_RING;
03774    p->cid_signalling = CID_SIG_BELL;
03775    /* Sub real is assumed to always be alloc'd */
03776    p->subs[ANALOG_SUB_REAL].allocd = 1;
03777 
03778    return p;
03779 }

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

Definition at line 759 of file sig_analog.c.

References analog_alloc_sub(), analog_new_ast_channel(), ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL, ast_log(), AST_STATE_RESERVED, analog_pvt::channel, LOG_DEBUG, LOG_ERROR, analog_pvt::outgoing, and analog_pvt::owner.

Referenced by dahdi_request().

00760 {
00761    struct ast_channel *ast;
00762 
00763    ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel);
00764    *callwait = (p->owner != NULL);
00765 
00766    if (p->owner) {
00767       if (analog_alloc_sub(p, ANALOG_SUB_CALLWAIT)) {
00768          ast_log(LOG_ERROR, "Unable to alloc subchannel\n");
00769          return NULL;
00770       }
00771    }
00772 
00773    p->outgoing = 1;
00774    ast = analog_new_ast_channel(p, AST_STATE_RESERVED, 0,
00775       p->owner ? ANALOG_SUB_CALLWAIT : ANALOG_SUB_REAL, requestor);
00776    if (!ast) {
00777       p->outgoing = 0;
00778    }
00779    return ast;
00780 }

const char* analog_sigtype_to_str ( enum analog_sigtype  sigtype  ) 

Definition at line 116 of file sig_analog.c.

References ARRAY_LEN, and sigtypes.

Referenced by __analog_ss_thread(), and analog_handle_init_event().

00117 {
00118    int i;
00119 
00120    for (i = 0; i < ARRAY_LEN(sigtypes); i++) {
00121       if (sigtype == sigtypes[i].sigtype) {
00122          return sigtypes[i].name;
00123       }
00124    }
00125 
00126    return "Unknown";
00127 }

int analog_ss_thread_start ( struct analog_pvt *  p,
struct ast_channel *  ast 
)

Definition at line 2532 of file sig_analog.c.

References __analog_ss_thread(), and ast_pthread_create_detached.

Referenced by mwi_thread().

02533 {
02534    pthread_t threadid;
02535 
02536    return ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, p);
02537 }

enum analog_cid_start analog_str_to_cidstart ( const char *  value  ) 

Definition at line 203 of file sig_analog.c.

References ANALOG_CID_START_DTMF_NOALERT, ANALOG_CID_START_POLARITY, ANALOG_CID_START_POLARITY_IN, and ANALOG_CID_START_RING.

00204 {
00205    if (!strcasecmp(value, "ring")) {
00206       return ANALOG_CID_START_RING;
00207    } else if (!strcasecmp(value, "polarity")) {
00208       return ANALOG_CID_START_POLARITY;
00209    } else if (!strcasecmp(value, "polarity_in")) {
00210       return ANALOG_CID_START_POLARITY_IN;
00211    } else if (!strcasecmp(value, "dtmf")) {
00212       return ANALOG_CID_START_DTMF_NOALERT;
00213    }
00214 
00215    return 0;
00216 }

unsigned int analog_str_to_cidtype ( const char *  name  ) 

Definition at line 129 of file sig_analog.c.

References ARRAY_LEN, and cidtypes.

00130 {
00131    int i;
00132 
00133    for (i = 0; i < ARRAY_LEN(cidtypes); i++) {
00134       if (!strcasecmp(cidtypes[i].name, name)) {
00135          return cidtypes[i].cid_type;
00136       }
00137    }
00138 
00139    return 0;
00140 }

enum analog_sigtype analog_str_to_sigtype ( const char *  name  ) 

Definition at line 103 of file sig_analog.c.

References ARRAY_LEN, and sigtypes.

00104 {
00105    int i;
00106 
00107    for (i = 0; i < ARRAY_LEN(sigtypes); i++) {
00108       if (!strcasecmp(sigtypes[i].name, name)) {
00109          return sigtypes[i].sigtype;
00110       }
00111    }
00112 
00113    return 0;
00114 }


Generated on Sat Mar 26 11:28:38 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.9