Wed Jan 8 2020 09:50:20

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 "asterisk/smdi.h"

Go to the source code of this file.

Data Structures

struct  analog_callback
 
struct  analog_dialoperation
 
struct  analog_pvt
 
struct  analog_subchannel
 

Macros

#define ANALOG_MAX_CID   300
 
#define ANALOG_SMDI_MD_WAIT_TIMEOUT   1500 /* 1.5 seconds */
 
#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. More...
 
int analog_dnd (struct analog_pvt *p, int flag)
 
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)
 
void analog_free (struct analog_pvt *p)
 
void analog_handle_dtmf (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_pvtanalog_new (enum analog_sigtype signallingtype, struct analog_callback *c, void *private_data)
 
struct ast_channelanalog_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 cresl.nosp@m.in@d.nosp@m.igium.nosp@m..com

Definition in file sig_analog.h.

Macro Definition Documentation

#define ANALOG_MAX_CID   300

Definition at line 33 of file sig_analog.h.

Referenced by __analog_ss_thread(), and my_get_callerid().

#define ANALOG_SMDI_MD_WAIT_TIMEOUT   1500 /* 1.5 seconds */

Definition at line 32 of file sig_analog.h.

Referenced by __analog_ss_thread().

#define READ_SIZE   160

Definition at line 34 of file sig_analog.h.

#define RING_PATTERNS   3

Definition at line 35 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 112 of file sig_analog.h.

Enumerator
ANALOG_DIGITMODE_DTMF 
ANALOG_DIGITMODE_MF 

Definition at line 107 of file sig_analog.h.

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 72 of file sig_analog.h.

72  {
94  ANALOG_EVENT_ERROR, /* not a DAHDI event */
95  ANALOG_EVENT_DTMFCID, /* not a DAHDI event */
96  ANALOG_EVENT_PULSEDIGIT = (1 << 16),
97  ANALOG_EVENT_DTMFDOWN = (1 << 17),
98  ANALOG_EVENT_DTMFUP = (1 << 18),
99 };
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 38 of file sig_analog.h.

38  {
39  ANALOG_SIG_NONE = -1,
40  ANALOG_SIG_FXOLS = 1,
61 };
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 101 of file sig_analog.h.

101  {
102  ANALOG_SUB_REAL = 0, /*!< Active call */
103  ANALOG_SUB_CALLWAIT, /*!< Call-Waiting call on hold */
104  ANALOG_SUB_THREEWAY, /*!< Three-way call */
105 };
Enumerator
ANALOG_TONE_RINGTONE 
ANALOG_TONE_STUTTER 
ANALOG_TONE_CONGESTION 
ANALOG_TONE_DIALTONE 
ANALOG_TONE_DIALRECALL 
ANALOG_TONE_INFO 

Definition at line 63 of file sig_analog.h.

enum dialop
Enumerator
ANALOG_DIAL_OP_REPLACE 

Definition at line 119 of file sig_analog.h.

119  {
121 };

Function Documentation

int analog_answer ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 1486 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_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_debug, ast_log(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, analog_pvt::channel, analog_pvt::hanguponpolarityswitch, analog_subchannel::inthreeway, LOG_WARNING, ast_channel::name, analog_subchannel::owner, analog_pvt::polaritydelaytv, analog_pvt::sig, and analog_pvt::subs.

Referenced by dahdi_answer().

1487 {
1488  int res = 0;
1489  int idx;
1490  int oldstate = ast->_state;
1491 
1492  ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
1493  ast_setstate(ast, AST_STATE_UP);
1494  idx = analog_get_index(ast, p, 1);
1495  if (idx < 0) {
1496  idx = ANALOG_SUB_REAL;
1497  }
1498  switch (p->sig) {
1499  case ANALOG_SIG_FXSLS:
1500  case ANALOG_SIG_FXSGS:
1501  case ANALOG_SIG_FXSKS:
1502  analog_set_ringtimeout(p, 0);
1503  /* Fall through */
1504  case ANALOG_SIG_EM:
1505  case ANALOG_SIG_EM_E1:
1506  case ANALOG_SIG_EMWINK:
1507  case ANALOG_SIG_FEATD:
1508  case ANALOG_SIG_FEATDMF:
1509  case ANALOG_SIG_FEATDMF_TA:
1510  case ANALOG_SIG_E911:
1511  case ANALOG_SIG_FGC_CAMA:
1512  case ANALOG_SIG_FGC_CAMAMF:
1513  case ANALOG_SIG_FEATB:
1514  case ANALOG_SIG_SF:
1515  case ANALOG_SIG_SFWINK:
1516  case ANALOG_SIG_SF_FEATD:
1517  case ANALOG_SIG_SF_FEATDMF:
1518  case ANALOG_SIG_SF_FEATB:
1519  case ANALOG_SIG_FXOLS:
1520  case ANALOG_SIG_FXOGS:
1521  case ANALOG_SIG_FXOKS:
1522  /* Pick up the line */
1523  ast_debug(1, "Took %s off hook\n", ast->name);
1524  if (p->hanguponpolarityswitch) {
1525  gettimeofday(&p->polaritydelaytv, NULL);
1526  }
1527  res = analog_off_hook(p);
1528  analog_play_tone(p, idx, -1);
1529  analog_set_dialing(p, 0);
1530  if ((idx == ANALOG_SUB_REAL) && p->subs[ANALOG_SUB_THREEWAY].inthreeway) {
1531  if (oldstate == AST_STATE_RINGING) {
1532  ast_debug(1, "Finally swapping real and threeway\n");
1536  }
1537  }
1538 
1539  switch (p->sig) {
1540  case ANALOG_SIG_FXSLS:
1541  case ANALOG_SIG_FXSKS:
1542  case ANALOG_SIG_FXSGS:
1545  break;
1546  case ANALOG_SIG_FXOLS:
1547  case ANALOG_SIG_FXOKS:
1548  case ANALOG_SIG_FXOGS:
1550  break;
1551  default:
1552  break;
1553  }
1554  break;
1555  default:
1556  ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
1557  res = -1;
1558  break;
1559  }
1560  ast_setstate(ast, AST_STATE_UP);
1561  return res;
1562 }
#define analog_get_index(ast, p, nullok)
Definition: sig_analog.c:389
struct timeval polaritydelaytv
Definition: sig_analog.h:331
static int analog_off_hook(struct analog_pvt *p)
Definition: sig_analog.c:592
static int analog_play_tone(struct analog_pvt *p, enum analog_sub sub, enum analog_tone tone)
Definition: sig_analog.c:420
#define LOG_WARNING
Definition: logger.h:144
static int analog_train_echocanceller(struct analog_pvt *p)
Definition: sig_analog.c:463
struct ast_channel * owner
Definition: sig_analog.h:245
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
static void analog_swap_subs(struct analog_pvt *p, enum analog_sub a, enum analog_sub b)
Definition: sig_analog.c:330
static void analog_answer_polarityswitch(struct analog_pvt *p)
Definition: sig_analog.c:622
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
unsigned int inthreeway
Definition: sig_analog.h:247
static int analog_set_echocanceller(struct analog_pvt *p, int enable)
Definition: sig_analog.c:455
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
static void analog_set_new_owner(struct analog_pvt *p, struct ast_channel *new_owner)
Definition: sig_analog.c:428
struct analog_subchannel subs[3]
Definition: sig_analog.h:262
unsigned int hanguponpolarityswitch
Definition: sig_analog.h:275
static void analog_set_ringtimeout(struct analog_pvt *p, int ringt)
Definition: sig_analog.c:919
static void analog_set_dialing(struct analog_pvt *p, int is_dialing)
Definition: sig_analog.c:903
enum analog_sigtype sig
Definition: sig_analog.h:254
int analog_available ( struct analog_pvt p)

Definition at line 806 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_STATE_RINGING, AST_STATE_UP, analog_pvt::callwaiting, analog_pvt::channel, analog_pvt::dnd, analog_pvt::guardtime, analog_subchannel::inthreeway, analog_pvt::outgoing, analog_subchannel::owner, analog_pvt::owner, analog_pvt::sig, and analog_pvt::subs.

Referenced by available().

807 {
808  int offhook;
809 
810  ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
811 
812  /* If do not disturb, definitely not */
813  if (p->dnd) {
814  return 0;
815  }
816  /* If guard time, definitely not */
817  if (p->guardtime && (time(NULL) < p->guardtime)) {
818  return 0;
819  }
820 
821  /* If no owner definitely available */
822  if (!p->owner) {
823  offhook = analog_is_off_hook(p);
824 
825  /* TDM FXO card, "onhook" means out of service (no battery on the line) */
826  if ((p->sig == ANALOG_SIG_FXSLS) || (p->sig == ANALOG_SIG_FXSKS) || (p->sig == ANALOG_SIG_FXSGS)) {
827 #ifdef DAHDI_CHECK_HOOKSTATE
828  if (offhook) {
829  return 1;
830  }
831  return 0;
832 #endif
833  /* TDM FXS card, "offhook" means someone took the hook off so it's unavailable! */
834  } else if (offhook) {
835  ast_debug(1, "Channel %d off hook, can't use\n", p->channel);
836  /* Not available when the other end is off hook */
837  return 0;
838  }
839  return 1;
840  }
841 
842  /* If it's not an FXO, forget about call wait */
843  if ((p->sig != ANALOG_SIG_FXOKS) && (p->sig != ANALOG_SIG_FXOLS) && (p->sig != ANALOG_SIG_FXOGS)) {
844  return 0;
845  }
846 
847  if (!p->callwaiting) {
848  /* If they don't have call waiting enabled, then for sure they're unavailable at this point */
849  return 0;
850  }
851 
852  if (p->subs[ANALOG_SUB_CALLWAIT].allocd) {
853  /* If there is already a call waiting call, then we can't take a second one */
854  return 0;
855  }
856 
857  if ((p->owner->_state != AST_STATE_UP) &&
858  ((p->owner->_state != AST_STATE_RINGING) || p->outgoing)) {
859  /* If the current call is not up, then don't allow the call */
860  return 0;
861  }
863  /* Can't take a call wait when the three way calling hasn't been merged yet. */
864  return 0;
865  }
866  /* We're cool */
867  return 1;
868 }
struct ast_channel * owner
Definition: sig_analog.h:245
time_t guardtime
Definition: sig_analog.h:333
unsigned int allocd
Definition: sig_analog.h:249
struct ast_channel * owner
Definition: sig_analog.h:260
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
unsigned int outgoing
Definition: sig_analog.h:313
enum ast_channel_state _state
Definition: channel.h:839
unsigned int callwaiting
Definition: sig_analog.h:307
unsigned int inthreeway
Definition: sig_analog.h:247
static int analog_is_off_hook(struct analog_pvt *p)
Definition: sig_analog.c:471
unsigned int dnd
Definition: sig_analog.h:310
struct analog_subchannel subs[3]
Definition: sig_analog.h:262
enum analog_sigtype sig
Definition: sig_analog.h:254
int analog_call ( struct analog_pvt p,
struct ast_channel ast,
char *  rdest,
int  timeout 
)

Definition at line 1003 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_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_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_WARNING, ast_party_id::name, ast_channel::name, ast_party_id::number, analog_dialoperation::op, analog_pvt::outsigmod, analog_subchannel::owner, analog_pvt::owner, pbx_builtin_getvar_helper(), analog_pvt::polaritydelaytv, analog_pvt::pulse, 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().

1004 {
1005  int res, idx, mysig;
1006  char *c, *n, *l;
1007  char dest[256]; /* must be same length as p->dialdest */
1008 
1009  ast_debug(1, "CALLING CID_NAME: %s CID_NUM:: %s\n",
1010  S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""),
1011  S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, ""));
1012 
1013  ast_copy_string(dest, rdest, sizeof(dest));
1014  ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest));
1015 
1016  if ((ast->_state == AST_STATE_BUSY)) {
1018  return 0;
1019  }
1020 
1021  if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
1022  ast_log(LOG_WARNING, "analog_call called on %s, neither down nor reserved\n", ast->name);
1023  return -1;
1024  }
1025 
1026  p->dialednone = 0;
1027  analog_set_outgoing(p, 1);
1028 
1029  mysig = p->sig;
1030  if (p->outsigmod > -1) {
1031  mysig = p->outsigmod;
1032  }
1033 
1034  switch (mysig) {
1035  case ANALOG_SIG_FXOLS:
1036  case ANALOG_SIG_FXOGS:
1037  case ANALOG_SIG_FXOKS:
1038  if (p->owner == ast) {
1039  /* Normal ring, on hook */
1040 
1041  /* Don't send audio while on hook, until the call is answered */
1042  analog_set_dialing(p, 1);
1043  analog_set_cadence(p, ast); /* and set p->cidrings */
1044 
1045  /* nick@dccinc.com 4/3/03 mods to allow for deferred dialing */
1046  c = strchr(dest, '/');
1047  if (c) {
1048  c++;
1049  }
1050  if (c && (strlen(c) < p->stripmsd)) {
1051  ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
1052  c = NULL;
1053  }
1054  if (c) {
1056  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
1057  ast_debug(1, "FXO: setup deferred dialstring: %s\n", c);
1058  } else {
1059  p->dop.dialstr[0] = '\0';
1060  }
1061 
1062  if (analog_ring(p)) {
1063  ast_log(LOG_WARNING, "Unable to ring phone: %s\n", strerror(errno));
1064  return -1;
1065  }
1066  analog_set_dialing(p, 1);
1067  } else {
1068  /* Call waiting call */
1069  if (ast->connected.id.number.valid && ast->connected.id.number.str) {
1071  } else {
1072  p->callwait_num[0] = '\0';
1073  }
1074  if (ast->connected.id.name.valid && ast->connected.id.name.str) {
1076  } else {
1077  p->callwait_name[0] = '\0';
1078  }
1079 
1080  /* Call waiting tone instead */
1081  if (analog_callwait(p)) {
1082  return -1;
1083  }
1084  /* Make ring-back */
1086  ast_log(LOG_WARNING, "Unable to generate call-wait ring-back on channel %s\n", ast->name);
1087  }
1088 
1089  }
1090  n = ast->connected.id.name.valid ? ast->connected.id.name.str : NULL;
1091  l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
1092  if (l) {
1093  ast_copy_string(p->lastcid_num, l, sizeof(p->lastcid_num));
1094  } else {
1095  p->lastcid_num[0] = '\0';
1096  }
1097  if (n) {
1098  ast_copy_string(p->lastcid_name, n, sizeof(p->lastcid_name));
1099  } else {
1100  p->lastcid_name[0] = '\0';
1101  }
1102 
1103  if (p->use_callerid) {
1104  p->caller.id.name.str = p->lastcid_name;
1105  p->caller.id.number.str = p->lastcid_num;
1106  }
1107 
1109  idx = analog_get_index(ast, p, 0);
1110  if (idx > -1) {
1111  struct ast_cc_config_params *cc_params;
1112 
1113  /* This is where the initial ringing frame is queued for an analog call.
1114  * As such, this is a great time to offer CCNR to the caller if it's available.
1115  */
1116  cc_params = ast_channel_get_cc_config_params(p->subs[idx].owner);
1117  if (cc_params) {
1118  switch (ast_get_cc_monitor_policy(cc_params)) {
1119  case AST_CC_MONITOR_NEVER:
1120  break;
1121  case AST_CC_MONITOR_NATIVE:
1122  case AST_CC_MONITOR_ALWAYS:
1126  break;
1127  }
1128  }
1130  }
1131  break;
1132  case ANALOG_SIG_FXSLS:
1133  case ANALOG_SIG_FXSGS:
1134  case ANALOG_SIG_FXSKS:
1136  ast_debug(1, "Ignore possible polarity reversal on line seizure\n");
1137  p->polaritydelaytv = ast_tvnow();
1138  }
1139  /* fall through */
1140  case ANALOG_SIG_EMWINK:
1141  case ANALOG_SIG_EM:
1142  case ANALOG_SIG_EM_E1:
1143  case ANALOG_SIG_FEATD:
1144  case ANALOG_SIG_FEATDMF:
1145  case ANALOG_SIG_E911:
1146  case ANALOG_SIG_FGC_CAMA:
1147  case ANALOG_SIG_FGC_CAMAMF:
1148  case ANALOG_SIG_FEATB:
1149  case ANALOG_SIG_SFWINK:
1150  case ANALOG_SIG_SF:
1151  case ANALOG_SIG_SF_FEATD:
1152  case ANALOG_SIG_SF_FEATDMF:
1153  case ANALOG_SIG_FEATDMF_TA:
1154  case ANALOG_SIG_SF_FEATB:
1155  c = strchr(dest, '/');
1156  if (c) {
1157  c++;
1158  } else {
1159  c = "";
1160  }
1161  if (strlen(c) < p->stripmsd) {
1162  ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
1163  return -1;
1164  }
1165  res = analog_start(p);
1166  if (res < 0) {
1167  if (errno != EINPROGRESS) {
1168  return -1;
1169  }
1170  }
1171  ast_debug(1, "Dialing '%s'\n", c);
1173 
1174  c += p->stripmsd;
1175 
1176  switch (mysig) {
1177  case ANALOG_SIG_FEATD:
1178  l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
1179  if (l) {
1180  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T*%s*%s*", l, c);
1181  } else {
1182  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T**%s*", c);
1183  }
1184  break;
1185  case ANALOG_SIG_FEATDMF:
1186  l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
1187  if (l) {
1188  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*00%s#*%s#", l, c);
1189  } else {
1190  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*02#*%s#", c);
1191  }
1192  break;
1193  case ANALOG_SIG_FEATDMF_TA:
1194  {
1195  const char *cic = "", *ozz = "";
1196 
1197  /* If you have to go through a Tandem Access point you need to use this */
1198 #ifndef STANDALONE
1199  ozz = pbx_builtin_getvar_helper(p->owner, "FEATDMF_OZZ");
1200  if (!ozz) {
1201  ozz = analog_defaultozz;
1202  }
1203  cic = pbx_builtin_getvar_helper(p->owner, "FEATDMF_CIC");
1204  if (!cic) {
1205  cic = analog_defaultcic;
1206  }
1207 #endif
1208  if (!ozz || !cic) {
1209  ast_log(LOG_WARNING, "Unable to dial channel of type feature group D MF tandem access without CIC or OZZ set\n");
1210  return -1;
1211  }
1212  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s%s#", ozz, cic);
1213  snprintf(p->finaldial, sizeof(p->finaldial), "M*%s#", c);
1214  p->whichwink = 0;
1215  }
1216  break;
1217  case ANALOG_SIG_E911:
1218  ast_copy_string(p->dop.dialstr, "M*911#", sizeof(p->dop.dialstr));
1219  break;
1220  case ANALOG_SIG_FGC_CAMA:
1221  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%s", c);
1222  break;
1223  case ANALOG_SIG_FGC_CAMAMF:
1224  case ANALOG_SIG_FEATB:
1225  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s#", c);
1226  break;
1227  default:
1228  if (p->pulse) {
1229  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%sw", c);
1230  } else {
1231  snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T%sw", c);
1232  }
1233  break;
1234  }
1235 
1236  if (p->echotraining && (strlen(p->dop.dialstr) > 4)) {
1237  memset(p->echorest, 'w', sizeof(p->echorest) - 1);
1238  strcpy(p->echorest + (p->echotraining / 400) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
1239  p->echorest[sizeof(p->echorest) - 1] = '\0';
1240  p->echobreak = 1;
1241  p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0';
1242  } else {
1243  p->echobreak = 0;
1244  }
1245  analog_set_waitingfordt(p, ast);
1246  if (!res) {
1247  if (analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop)) {
1248  int saveerr = errno;
1249 
1250  analog_on_hook(p);
1251  ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(saveerr));
1252  return -1;
1253  }
1254  } else {
1255  ast_debug(1, "Deferring dialing...\n");
1256  }
1257  analog_set_dialing(p, 1);
1258  if (ast_strlen_zero(c)) {
1259  p->dialednone = 1;
1260  }
1262  break;
1263  default:
1264  ast_debug(1, "not yet implemented\n");
1265  return -1;
1266  }
1267  return 0;
1268 }
#define analog_get_index(ast, p, nullok)
Definition: sig_analog.c:389
unsigned int use_callerid
Definition: sig_analog.h:283
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
Definition: channel.c:1601
struct ast_party_caller caller
Definition: sig_analog.h:327
struct timeval polaritydelaytv
Definition: sig_analog.h:331
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
static int analog_start(struct analog_pvt *p)
Definition: sig_analog.c:495
static int analog_play_tone(struct analog_pvt *p, enum analog_sub sub, enum analog_tone tone)
Definition: sig_analog.c:420
int echotraining
Definition: sig_analog.h:296
#define LOG_WARNING
Definition: logger.h:144
char dialdest[256]
Definition: sig_analog.h:332
char finaldial[64]
Definition: sig_analog.h:336
char callwait_name[AST_MAX_EXTENSION]
Definition: sig_analog.h:324
struct ast_channel * owner
Definition: sig_analog.h:245
char * str
Subscriber name (Malloced)
Definition: channel.h:214
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
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:3886
static void analog_set_outgoing(struct analog_pvt *p, int is_outgoing)
Definition: sig_analog.c:519
char echorest[20]
Definition: sig_analog.h:329
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Definition: pbx.c:10475
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:9754
static const char * analog_get_orig_dialstring(struct analog_pvt *p)
Definition: sig_analog.c:183
static void analog_set_waitingfordt(struct analog_pvt *p, struct ast_channel *ast)
Definition: sig_analog.c:928
enum ast_cc_monitor_policies ast_get_cc_monitor_policy(struct ast_cc_config_params *config)
Get the cc_monitor_policy.
Definition: ccss.c:763
struct ast_channel * owner
Definition: sig_analog.h:260
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
int stripmsd
Definition: sig_analog.h:299
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
static int analog_dial_digits(struct analog_pvt *p, enum analog_sub sub, struct analog_dialoperation *dop)
Definition: sig_analog.c:503
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#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:83
static char analog_defaultcic[64]
Definition: sig_analog.c:62
char callwait_num[AST_MAX_EXTENSION]
Definition: sig_analog.h:323
unsigned int dialednone
Definition: sig_analog.h:308
#define AST_CC_GENERIC_MONITOR_TYPE
Definition: ccss.h:472
char lastcid_name[AST_MAX_EXTENSION]
Definition: sig_analog.h:326
static int analog_on_hook(struct analog_pvt *p)
Definition: sig_analog.c:511
struct analog_dialoperation dop
Definition: sig_analog.h:263
static char analog_defaultozz[64]
Definition: sig_analog.c:63
static int analog_callwait(struct analog_pvt *p)
Definition: sig_analog.c:879
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
int whichwink
Definition: sig_analog.h:335
static void analog_set_cadence(struct analog_pvt *p, struct ast_channel *chan)
Definition: sig_analog.c:896
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
char lastcid_num[AST_MAX_EXTENSION]
Definition: sig_analog.h:325
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
enum analog_sigtype outsigmod
Definition: sig_analog.h:295
unsigned int pulse
Definition: sig_analog.h:279
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
struct analog_subchannel subs[3]
Definition: sig_analog.h:262
unsigned int hanguponpolarityswitch
Definition: sig_analog.h:275
static void analog_set_dialing(struct analog_pvt *p, int is_dialing)
Definition: sig_analog.c:903
enum analog_sigtype sig
Definition: sig_analog.h:254
unsigned int echobreak
Definition: sig_analog.h:311
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
static int analog_ring(struct analog_pvt *p)
Definition: sig_analog.c:479
unsigned int answeronpolarityswitch
Definition: sig_analog.h:270
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
const char* analog_cidstart_to_str ( enum analog_cid_start  cid_start)

Definition at line 231 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.

232 {
233  switch (cid_start) {
235  return "Ring";
237  return "Polarity";
239  return "Polarity_In";
241  return "DTMF";
242  }
243 
244  return "Unknown";
245 }
const char* analog_cidtype_to_str ( unsigned int  cid_type)

Definition at line 146 of file sig_analog.c.

References ARRAY_LEN, and cidtypes.

147 {
148  int i;
149 
150  for (i = 0; i < ARRAY_LEN(cidtypes); i++) {
151  if (cid_type == cidtypes[i].cid_type) {
152  return cidtypes[i].name;
153  }
154  }
155 
156  return "Unknown";
157 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct @119 cidtypes[]
unsigned int cid_type
Definition: sig_analog.c:93
int analog_config_complete ( struct analog_pvt p)

Definition at line 3919 of file sig_analog.c.

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

Referenced by mkintf().

3920 {
3921  /* No call waiting on non FXS channels */
3922  if ((p->sig != ANALOG_SIG_FXOKS) && (p->sig != ANALOG_SIG_FXOLS) && (p->sig != ANALOG_SIG_FXOGS)) {
3923  p->permcallwaiting = 0;
3924  }
3925 
3927 
3928  return 0;
3929 }
static void analog_set_callwaiting(struct analog_pvt *p, int callwaiting_enable)
Definition: sig_analog.c:888
enum analog_sigtype sig
Definition: sig_analog.h:254
unsigned int permcallwaiting
Definition: sig_analog.h:277
void analog_delete ( struct analog_pvt doomed)

Delete the analog private structure.

Since
1.8
Parameters
doomedAnalog private structure to delete.
Returns
Nothing

Definition at line 3914 of file sig_analog.c.

References ast_free.

Referenced by destroy_dahdi_pvt().

3915 {
3916  ast_free(doomed);
3917 }
#define ast_free(a)
Definition: astmm.h:97
int analog_dnd ( struct analog_pvt p,
int  flag 
)

Definition at line 3955 of file sig_analog.c.

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

Referenced by __analog_ss_thread(), and dahdi_dnd().

3956 {
3957  if (flag == -1) {
3958  return p->dnd;
3959  }
3960 
3961  p->dnd = flag;
3962 
3963  ast_verb(3, "%s DND on channel %d\n",
3964  flag ? "Enabled" : "Disabled",
3965  p->channel);
3966  manager_event(EVENT_FLAG_SYSTEM, "DNDState",
3967  "Channel: DAHDI/%d\r\n"
3968  "Status: %s\r\n", p->channel,
3969  flag ? "enabled" : "disabled");
3970 
3971  return 0;
3972 }
#define ast_verb(level,...)
Definition: logger.h:243
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
unsigned int dnd
Definition: sig_analog.h:310
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Definition: manager.h:219
struct ast_frame* analog_exception ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 3515 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_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_bridged_channel(), ast_channel_lock, ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_UNHOLD, ast_debug, AST_FRAME_NULL, ast_log(), ast_queue_control(), 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, f, analog_subchannel::f, ast_channel::fds, analog_pvt::flashtime, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_frame::mallocd, name, 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().

3516 {
3517  int res;
3518  int idx;
3519  struct ast_frame *f;
3520 
3521  ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
3522 
3523  idx = analog_get_index(ast, p, 1);
3524  if (idx < 0) {
3525  idx = ANALOG_SUB_REAL;
3526  }
3527 
3528  p->subs[idx].f.frametype = AST_FRAME_NULL;
3529  p->subs[idx].f.datalen = 0;
3530  p->subs[idx].f.samples = 0;
3531  p->subs[idx].f.mallocd = 0;
3532  p->subs[idx].f.offset = 0;
3533  p->subs[idx].f.subclass.integer = 0;
3534  p->subs[idx].f.delivery = ast_tv(0,0);
3535  p->subs[idx].f.src = "dahdi_exception";
3536  p->subs[idx].f.data.ptr = NULL;
3537 
3538  if (!p->owner) {
3539  /* If nobody owns us, absorb the event appropriately, otherwise
3540  we loop indefinitely. This occurs when, during call waiting, the
3541  other end hangs up our channel so that it no longer exists, but we
3542  have neither FLASH'd nor ONHOOK'd to signify our desire to
3543  change to the other channel. */
3544  res = analog_get_event(p);
3545 
3546  /* Switch to real if there is one and this isn't something really silly... */
3547  if ((res != ANALOG_EVENT_RINGEROFF) && (res != ANALOG_EVENT_RINGERON) &&
3548  (res != ANALOG_EVENT_HOOKCOMPLETE)) {
3549  ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
3551  if (p->owner && ast != p->owner) {
3552  /*
3553  * Could this even happen?
3554  * Possible deadlock because we do not have the real-call lock.
3555  */
3556  ast_log(LOG_WARNING, "Event %s on %s is not restored owner %s\n",
3557  analog_event2str(res), ast->name, p->owner->name);
3558  }
3559  if (p->owner && ast_bridged_channel(p->owner)) {
3561  }
3562  }
3563  switch (res) {
3564  case ANALOG_EVENT_ONHOOK:
3566  if (p->owner) {
3567  ast_verb(3, "Channel %s still has call, ringing phone\n", p->owner->name);
3568  analog_ring(p);
3570  } else {
3571  ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
3572  analog_event2str(res));
3573  }
3574  analog_update_conf(p);
3575  break;
3578  analog_off_hook(p);
3579  if (p->owner && (p->owner->_state == AST_STATE_RINGING)) {
3581  analog_set_dialing(p, 0);
3582  }
3583  break;
3585  case ANALOG_EVENT_RINGERON:
3587  /* Do nothing */
3588  break;
3590  gettimeofday(&p->flashtime, NULL);
3591  if (p->owner) {
3592  ast_verb(3, "Channel %d flashed to other channel %s\n", p->channel, p->owner->name);
3593  if (p->owner->_state != AST_STATE_UP) {
3594  /* Answer if necessary */
3597  }
3599  if (ast_bridged_channel(p->owner)) {
3601  }
3602  } else {
3603  ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
3604  analog_event2str(res));
3605  }
3606  analog_update_conf(p);
3607  break;
3608  default:
3609  ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", analog_event2str(res));
3610  break;
3611  }
3612  f = &p->subs[idx].f;
3613  return f;
3614  }
3615  ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
3616  /* If it's not us, return NULL immediately */
3617  if (ast != p->owner) {
3618  ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
3619  f = &p->subs[idx].f;
3620  return f;
3621  }
3622 
3623  f = __analog_handle_event(p, ast);
3624  if (!f) {
3625  const char *name = ast_strdupa(ast->name);
3626 
3627  /* Tell the CDR this DAHDI device hung up */
3629  ast_channel_unlock(ast);
3630  ast_set_hangupsource(ast, name, 0);
3631  ast_channel_lock(ast);
3633  }
3634  return f;
3635 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define analog_get_index(ast, p, nullok)
Definition: sig_analog.c:389
#define ast_channel_lock(chan)
Definition: channel.h:2466
int offset
Definition: frame.h:156
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
Definition: channel.c:1601
static struct ast_frame * __analog_handle_event(struct analog_pvt *p, struct ast_channel *ast)
Definition: sig_analog.c:2651
static int analog_off_hook(struct analog_pvt *p)
Definition: sig_analog.c:592
void * ptr
Definition: frame.h:160
#define LOG_WARNING
Definition: logger.h:144
struct ast_channel * owner
Definition: sig_analog.h:245
static int analog_get_event(struct analog_pvt *p)
Definition: sig_analog.c:191
struct timeval flashtime
Definition: sig_analog.h:334
#define ast_verb(level,...)
Definition: logger.h:243
struct ast_channel * owner
Definition: sig_analog.h:260
static void analog_unlock_private(struct analog_pvt *p)
Definition: sig_analog.c:542
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it&#39;s bridge.
Definition: channel.c:2769
const char * src
Definition: frame.h:158
int datalen
Definition: frame.h:148
static int analog_stop_callwait(struct analog_pvt *p)
Definition: sig_analog.c:870
int fds[AST_MAX_FDS]
Definition: channel.h:829
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static char * analog_event2str(enum analog_event event)
Definition: sig_analog.c:247
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_channel_unlock(chan)
Definition: channel.h:2467
static const char name[]
static struct ast_format f[]
Definition: format_g726.c:181
struct timeval delivery
Definition: frame.h:162
int mallocd
Definition: frame.h:152
static void analog_lock_private(struct analog_pvt *p)
Definition: sig_analog.c:549
static int analog_set_echocanceller(struct analog_pvt *p, int enable)
Definition: sig_analog.c:455
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Definition: time.h:179
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
static void analog_set_new_owner(struct analog_pvt *p, struct ast_channel *new_owner)
Definition: sig_analog.c:428
Data structure associated with a single frame of data.
Definition: frame.h:142
struct ast_frame f
Definition: sig_analog.h:246
enum ast_frame_type frametype
Definition: frame.h:144
static int analog_update_conf(struct analog_pvt *p)
Definition: sig_analog.c:756
struct analog_subchannel subs[3]
Definition: sig_analog.h:262
static void analog_set_dialing(struct analog_pvt *p, int is_dialing)
Definition: sig_analog.c:903
union ast_frame::@172 data
static int analog_ring(struct analog_pvt *p)
Definition: sig_analog.c:479
int samples
Definition: frame.h:150
int analog_fixup ( struct ast_channel oldchan,
struct ast_channel newchan,
void *  newp 
)

Definition at line 3937 of file sig_analog.c.

References analog_set_new_owner(), 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().

3938 {
3939  struct analog_pvt *new_pvt = newp;
3940  int x;
3941  ast_debug(1, "New owner for channel %d is %s\n", new_pvt->channel, newchan->name);
3942  if (new_pvt->owner == oldchan) {
3943  analog_set_new_owner(new_pvt, newchan);
3944  }
3945  for (x = 0; x < 3; x++) {
3946  if (new_pvt->subs[x].owner == oldchan) {
3947  new_pvt->subs[x].owner = newchan;
3948  }
3949  }
3950 
3951  analog_update_conf(new_pvt);
3952  return 0;
3953 }
struct ast_channel * owner
Definition: sig_analog.h:245
struct ast_channel * owner
Definition: sig_analog.h:260
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
const ast_string_field name
Definition: channel.h:787
static void analog_set_new_owner(struct analog_pvt *p, struct ast_channel *new_owner)
Definition: sig_analog.c:428
static int analog_update_conf(struct analog_pvt *p)
Definition: sig_analog.c:756
struct analog_subchannel subs[3]
Definition: sig_analog.h:262
void analog_free ( struct analog_pvt p)

Definition at line 3931 of file sig_analog.c.

References ast_free.

3932 {
3933  ast_free(p);
3934 }
#define ast_free(a)
Definition: astmm.h:97
void analog_handle_dtmf ( struct analog_pvt p,
struct ast_channel ast,
enum analog_sub  index,
struct ast_frame **  dest 
)

Definition at line 1589 of file sig_analog.c.

References analog_cb_handle_dtmf(), analog_check_confirmanswer(), analog_handles_digit(), analog_send_callerid(), analog_set_confirmanswer(), 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, f, analog_subchannel::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_name::str, ast_party_number::str, ast_frame::subclass, and analog_pvt::subs.

Referenced by __analog_handle_event(), and dahdi_read().

1590 {
1591  struct ast_frame *f = *dest;
1592 
1593  ast_debug(1, "%s DTMF digit: 0x%02X '%c' on %s\n",
1594  f->frametype == AST_FRAME_DTMF_BEGIN ? "Begin" : "End",
1595  (unsigned)f->subclass.integer, f->subclass.integer, ast->name);
1596 
1597  if (analog_check_confirmanswer(p)) {
1598  if (f->frametype == AST_FRAME_DTMF_END) {
1599  ast_debug(1, "Confirm answer on %s!\n", ast->name);
1600  /* Upon receiving a DTMF digit, consider this an answer confirmation instead
1601  of a DTMF digit */
1602  p->subs[idx].f.frametype = AST_FRAME_CONTROL;
1604  /* Reset confirmanswer so DTMF's will behave properly for the duration of the call */
1606  } else {
1607  p->subs[idx].f.frametype = AST_FRAME_NULL;
1608  p->subs[idx].f.subclass.integer = 0;
1609  }
1610  *dest = &p->subs[idx].f;
1611  } else if (p->callwaitcas) {
1612  if (f->frametype == AST_FRAME_DTMF_END) {
1613  if ((f->subclass.integer == 'A') || (f->subclass.integer == 'D')) {
1614  ast_debug(1, "Got some DTMF, but it's for the CAS\n");
1615  p->caller.id.name.str = p->callwait_name;
1616  p->caller.id.number.str = p->callwait_num;
1617  analog_send_callerid(p, 1, &p->caller);
1618  }
1619  if (analog_handles_digit(f)) {
1620  p->callwaitcas = 0;
1621  }
1622  }
1623  p->subs[idx].f.frametype = AST_FRAME_NULL;
1624  p->subs[idx].f.subclass.integer = 0;
1625  *dest = &p->subs[idx].f;
1626  } else {
1627  analog_cb_handle_dtmf(p, ast, idx, dest);
1628  }
1629 }
static int analog_send_callerid(struct analog_pvt *p, int cwcid, struct ast_party_caller *caller)
Definition: sig_analog.c:373
static int analog_handles_digit(struct ast_frame *f)
Definition: sig_analog.c:1564
union ast_frame_subclass subclass
Definition: frame.h:146
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Definition: sig_analog.h:327
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
char callwait_name[AST_MAX_EXTENSION]
Definition: sig_analog.h:324
char * str
Subscriber name (Malloced)
Definition: channel.h:214
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
char callwait_num[AST_MAX_EXTENSION]
Definition: sig_analog.h:323
const ast_string_field name
Definition: channel.h:787
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:644
static int analog_check_confirmanswer(struct analog_pvt *p)
Definition: sig_analog.c:952
static struct ast_format f[]
Definition: format_g726.c:181
static void analog_set_confirmanswer(struct analog_pvt *p, int flag)
Definition: sig_analog.c:944
Data structure associated with a single frame of data.
Definition: frame.h:142
unsigned int callwaitcas
TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
Definition: sig_analog.h:321
struct ast_frame f
Definition: sig_analog.h:246
enum ast_frame_type frametype
Definition: frame.h:144
struct analog_subchannel subs[3]
Definition: sig_analog.h:262
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
void* analog_handle_init_event ( struct analog_pvt i,
int  event 
)

Definition at line 3637 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_verb, 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, and analog_pvt::ss_astchan.

Referenced by do_monitor().

3638 {
3639  int res;
3640  pthread_t threadid;
3641  struct ast_channel *chan;
3642 
3643  ast_debug(1, "channel (%d) - signaling (%d) - event (%s)\n",
3644  i->channel, i->sig, analog_event2str(event));
3645 
3646  /* Handle an event on a given channel for the monitor thread. */
3647  switch (event) {
3650  if (i->inalarm) {
3651  break;
3652  }
3653  /* Got a ring/answer. What kind of channel are we? */
3654  switch (i->sig) {
3655  case ANALOG_SIG_FXOLS:
3656  case ANALOG_SIG_FXOGS:
3657  case ANALOG_SIG_FXOKS:
3658  res = analog_off_hook(i);
3659  i->fxsoffhookstate = 1;
3660  if (res && (errno == EBUSY)) {
3661  break;
3662  }
3663 
3664  /* Cancel VMWI spill */
3666 
3667  if (i->immediate) {
3669  /* The channel is immediately up. Start right away */
3672  if (!chan) {
3673  ast_log(LOG_WARNING, "Unable to start PBX on channel %d\n", i->channel);
3675  if (res < 0) {
3676  ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3677  }
3678  }
3679  } else {
3680  /* Check for callerid, digits, etc */
3682  i->ss_astchan = chan;
3683  if (chan) {
3684  if (analog_has_voicemail(i)) {
3686  } else {
3688  }
3689  if (res < 0)
3690  ast_log(LOG_WARNING, "Unable to play dialtone on channel %d, do you have defaultzone and loadzone defined?\n", i->channel);
3691 
3692  if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
3693  ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
3695  if (res < 0) {
3696  ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3697  }
3698  ast_hangup(chan);
3699  }
3700  } else
3701  ast_log(LOG_WARNING, "Unable to create channel\n");
3702  }
3703  break;
3704  case ANALOG_SIG_FXSLS:
3705  case ANALOG_SIG_FXSGS:
3706  case ANALOG_SIG_FXSKS:
3708  /* Fall through */
3709  case ANALOG_SIG_EMWINK:
3710  case ANALOG_SIG_FEATD:
3711  case ANALOG_SIG_FEATDMF:
3712  case ANALOG_SIG_FEATDMF_TA:
3713  case ANALOG_SIG_E911:
3714  case ANALOG_SIG_FGC_CAMA:
3715  case ANALOG_SIG_FGC_CAMAMF:
3716  case ANALOG_SIG_FEATB:
3717  case ANALOG_SIG_EM:
3718  case ANALOG_SIG_EM_E1:
3719  case ANALOG_SIG_SFWINK:
3720  case ANALOG_SIG_SF_FEATD:
3721  case ANALOG_SIG_SF_FEATDMF:
3722  case ANALOG_SIG_SF_FEATB:
3723  case ANALOG_SIG_SF:
3724  /* Check for callerid, digits, etc */
3727  } else {
3729  }
3730  i->ss_astchan = chan;
3731  if (!chan) {
3732  ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
3733  } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
3734  ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
3736  if (res < 0) {
3737  ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3738  }
3739  ast_hangup(chan);
3740  }
3741  break;
3742  default:
3743  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);
3745  if (res < 0) {
3746  ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3747  }
3748  return NULL;
3749  }
3750  break;
3751  case ANALOG_EVENT_NOALARM:
3752  analog_set_alarm(i, 0);
3753  ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel);
3754  manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
3755  "Channel: %d\r\n", i->channel);
3756  break;
3757  case ANALOG_EVENT_ALARM:
3758  analog_set_alarm(i, 1);
3760  /* fall thru intentionally */
3761  case ANALOG_EVENT_ONHOOK:
3762  /* Back on hook. Hang up. */
3763  switch (i->sig) {
3764  case ANALOG_SIG_FXOLS:
3765  case ANALOG_SIG_FXOGS:
3766  i->fxsoffhookstate = 0;
3768  /* Fall through */
3769  case ANALOG_SIG_FEATD:
3770  case ANALOG_SIG_FEATDMF:
3771  case ANALOG_SIG_FEATDMF_TA:
3772  case ANALOG_SIG_E911:
3773  case ANALOG_SIG_FGC_CAMA:
3774  case ANALOG_SIG_FGC_CAMAMF:
3775  case ANALOG_SIG_FEATB:
3776  case ANALOG_SIG_EM:
3777  case ANALOG_SIG_EM_E1:
3778  case ANALOG_SIG_EMWINK:
3779  case ANALOG_SIG_SF_FEATD:
3780  case ANALOG_SIG_SF_FEATDMF:
3781  case ANALOG_SIG_SF_FEATB:
3782  case ANALOG_SIG_SF:
3783  case ANALOG_SIG_SFWINK:
3784  case ANALOG_SIG_FXSLS:
3785  case ANALOG_SIG_FXSGS:
3786  case ANALOG_SIG_FXSKS:
3788  res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
3789  analog_on_hook(i);
3790  break;
3791  case ANALOG_SIG_FXOKS:
3792  i->fxsoffhookstate = 0;
3795  /* Diddle the battery for the zhone */
3796 #ifdef ZHONE_HACK
3797  analog_off_hook(i);
3798  usleep(1);
3799 #endif
3800  res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
3801  analog_on_hook(i);
3802  break;
3803  default:
3804  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);
3805  res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
3806  return NULL;
3807  }
3808  break;
3809  case ANALOG_EVENT_POLARITY:
3810  switch (i->sig) {
3811  case ANALOG_SIG_FXSLS:
3812  case ANALOG_SIG_FXSKS:
3813  case ANALOG_SIG_FXSGS:
3814  /* We have already got a PR before the channel was
3815  created, but it wasn't handled. We need polarity
3816  to be REV for remote hangup detection to work.
3817  At least in Spain */
3818  if (i->hanguponpolarityswitch) {
3819  i->polarity = POLARITY_REV;
3820  }
3822  i->polarity = POLARITY_REV;
3823  ast_verb(2, "Starting post polarity "
3824  "CID detection on channel %d\n",
3825  i->channel);
3827  i->ss_astchan = chan;
3828  if (!chan) {
3829  ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
3830  } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
3831  ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
3832  ast_hangup(chan);
3833  }
3834  }
3835  break;
3836  default:
3837  ast_log(LOG_WARNING, "handle_init_event detected "
3838  "polarity reversal on non-FXO (ANALOG_SIG_FXS) "
3839  "interface %d\n", i->channel);
3840  break;
3841  }
3842  break;
3843  case ANALOG_EVENT_DTMFCID:
3844  switch (i->sig) {
3845  case ANALOG_SIG_FXSLS:
3846  case ANALOG_SIG_FXSKS:
3847  case ANALOG_SIG_FXSGS:
3849  ast_verb(2, "Starting DTMF CID detection on channel %d\n",
3850  i->channel);
3852  i->ss_astchan = chan;
3853  if (!chan) {
3854  ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
3855  } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
3856  ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
3857  ast_hangup(chan);
3858  }
3859  }
3860  break;
3861  default:
3862  ast_log(LOG_WARNING, "handle_init_event detected "
3863  "dtmfcid generation event on non-FXO (ANALOG_SIG_FXS) "
3864  "interface %d\n", i->channel);
3865  break;
3866  }
3867  break;
3868  case ANALOG_EVENT_REMOVED: /* destroy channel, will actually do so in do_monitor */
3869  ast_log(LOG_NOTICE, "Got ANALOG_EVENT_REMOVED. Destroying channel %d\n",
3870  i->channel);
3871  return i->chan_pvt;
3874  break;
3877  break;
3878  }
3879  return NULL;
3880 }
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
Main Channel structure associated with a channel.
Definition: channel.h:742
#define POLARITY_REV
Definition: sig_analog.c:57
unsigned int immediate
Definition: sig_analog.h:276
#define ast_pthread_create_detached(a, b, c, d)
Definition: utils.h:422
int polarity
Definition: sig_analog.h:330
static int analog_off_hook(struct analog_pvt *p)
Definition: sig_analog.c:592
static int analog_play_tone(struct analog_pvt *p, enum analog_sub sub, enum analog_tone tone)
Definition: sig_analog.c:420
int ringt_base
Definition: sig_analog.h:346
#define LOG_WARNING
Definition: logger.h:144
static int analog_handle_notify_message(struct ast_channel *chan, struct analog_pvt *p, int cid_flags, int neon_mwievent)
Definition: sig_analog.c:1651
static void analog_start_polarityswitch(struct analog_pvt *p)
Definition: sig_analog.c:616
struct ast_channel * ss_astchan
Definition: sig_analog.h:342
#define ast_verb(level,...)
Definition: logger.h:243
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
static void * __analog_ss_thread(void *data)
Definition: sig_analog.c:1739
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:436
const char * analog_sigtype_to_str(enum analog_sigtype sigtype)
Definition: sig_analog.c:120
static int analog_on_hook(struct analog_pvt *p)
Definition: sig_analog.c:511
enum analog_cid_start cid_start
Definition: sig_analog.h:300
static char * analog_event2str(enum analog_event event)
Definition: sig_analog.c:247
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
int errno
static int analog_has_voicemail(struct analog_pvt *p)
Definition: sig_analog.c:659
static int analog_set_echocanceller(struct analog_pvt *p, int enable)
Definition: sig_analog.c:455
unsigned int inalarm
Definition: sig_analog.h:314
int fxsoffhookstate
Definition: sig_analog.h:265
static void analog_cancel_cidspill(struct analog_pvt *p)
Definition: sig_analog.c:961
static void analog_get_and_handle_alarms(struct analog_pvt *p)
Definition: sig_analog.c:1687
unsigned int hanguponpolarityswitch
Definition: sig_analog.h:275
void * chan_pvt
Definition: sig_analog.h:256
static void analog_set_ringtimeout(struct analog_pvt *p, int ringt)
Definition: sig_analog.c:919
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Definition: manager.h:219
enum analog_sigtype sig
Definition: sig_analog.h:254
static void analog_set_alarm(struct analog_pvt *p, int in_alarm)
Definition: sig_analog.c:911
int analog_hangup ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 1270 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_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_bridged_channel(), ast_channel_setoption(), ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, ast_copy_string(), ast_debug, ast_free, 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::channel, analog_pvt::cid_name, analog_pvt::cid_num, analog_pvt::cidrings, analog_pvt::guardtime, analog_pvt::hidecallerid, analog_subchannel::inthreeway, LOG_ERROR, LOG_WARNING, analog_pvt::mohsuggest, ast_channel::name, 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, S_OR, analog_pvt::sig, analog_pvt::subs, and ast_channel::tech_pvt.

Referenced by dahdi_hangup().

1271 {
1272  int res;
1273  int idx, x;
1274 
1275  ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
1276  if (!ast->tech_pvt) {
1277  ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
1278  return 0;
1279  }
1280 
1281  idx = analog_get_index(ast, p, 1);
1282 
1283  x = 0;
1284  if (p->origcid_num) {
1285  ast_copy_string(p->cid_num, p->origcid_num, sizeof(p->cid_num));
1286  ast_free(p->origcid_num);
1287  p->origcid_num = NULL;
1288  }
1289  if (p->origcid_name) {
1290  ast_copy_string(p->cid_name, p->origcid_name, sizeof(p->cid_name));
1291  ast_free(p->origcid_name);
1292  p->origcid_name = NULL;
1293  }
1294 
1296 
1297  ast_debug(1, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
1299  if (idx > -1) {
1300  /* Real channel, do some fixup */
1301  p->subs[idx].owner = NULL;
1302  p->polarity = POLARITY_IDLE;
1303  analog_set_linear_mode(p, idx, 0);
1304  switch (idx) {
1305  case ANALOG_SUB_REAL:
1307  ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
1309  /* We had flipped over to answer a callwait and now it's gone */
1310  ast_debug(1, "We were flipped over to the callwait, moving back and unowning.\n");
1311  /* Move to the call-wait, but un-own us until they flip back. */
1314  analog_set_new_owner(p, NULL);
1315  } else {
1316  /* The three way hung up, but we still have a call wait */
1317  ast_debug(1, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
1320  if (p->subs[ANALOG_SUB_REAL].inthreeway) {
1321  /* This was part of a three way call. Immediately make way for
1322  another call */
1323  ast_debug(1, "Call was complete, setting owner to former third call\n");
1326  } else {
1327  /* This call hasn't been completed yet... Set owner to NULL */
1328  ast_debug(1, "Call was incomplete, setting owner to NULL\n");
1329  analog_set_new_owner(p, NULL);
1330  }
1331  }
1332  } else if (p->subs[ANALOG_SUB_CALLWAIT].allocd) {
1333  /* Need to hold the lock for real-call, private, and call-waiting call */
1335  if (!p->subs[ANALOG_SUB_CALLWAIT].owner) {
1336  /* The call waiting call dissappeared. */
1337  analog_set_new_owner(p, NULL);
1338  break;
1339  }
1340 
1341  /* Move to the call-wait and switch back to them. */
1345  if (p->owner->_state != AST_STATE_UP) {
1347  }
1350  }
1351  /* Unlock the call-waiting call that we swapped to real-call. */
1353  } else if (p->subs[ANALOG_SUB_THREEWAY].allocd) {
1356  if (p->subs[ANALOG_SUB_REAL].inthreeway) {
1357  /* This was part of a three way call. Immediately make way for
1358  another call */
1359  ast_debug(1, "Call was complete, setting owner to former third call\n");
1362  } else {
1363  /* This call hasn't been completed yet... Set owner to NULL */
1364  ast_debug(1, "Call was incomplete, setting owner to NULL\n");
1365  analog_set_new_owner(p, NULL);
1366  }
1367  }
1368  break;
1369  case ANALOG_SUB_CALLWAIT:
1370  /* Ditch the holding callwait call, and immediately make it available */
1372  /* Need to hold the lock for call-waiting call, private, and 3-way call */
1374 
1375  /* This is actually part of a three way, placed on hold. Place the third part
1376  on music on hold now */
1379  S_OR(p->mohsuggest, NULL),
1380  !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
1381  }
1383  /* Make it the call wait now */
1386  if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
1387  /* Unlock the 3-way call that we swapped to call-waiting call. */
1389  }
1390  } else {
1392  }
1393  break;
1394  case ANALOG_SUB_THREEWAY:
1395  /* Need to hold the lock for 3-way call, private, and call-waiting call */
1398  /* The other party of the three way call is currently in a call-wait state.
1399  Start music on hold for them, and take the main guy out of the third call */
1403  S_OR(p->mohsuggest, NULL),
1404  !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
1405  }
1406  }
1407  if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
1409  }
1411  /* If this was part of a three way call index, let us make
1412  another three way call */
1414  break;
1415  default:
1416  /*
1417  * Should never happen.
1418  * This wasn't any sort of call, so how are we an index?
1419  */
1420  ast_log(LOG_ERROR, "Index found but not any type of call?\n");
1421  break;
1422  }
1423  }
1424 
1426  analog_set_new_owner(p, NULL);
1427  analog_set_ringtimeout(p, 0);
1429  analog_set_pulsedial(p, 0);
1430  analog_set_outgoing(p, 0);
1431  p->onhooktime = time(NULL);
1432  p->cidrings = 1;
1433 
1434  /* Perform low level hangup if no owner left */
1435  res = analog_on_hook(p);
1436  if (res < 0) {
1437  ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name);
1438  }
1439  switch (p->sig) {
1440  case ANALOG_SIG_FXOGS:
1441  case ANALOG_SIG_FXOLS:
1442  case ANALOG_SIG_FXOKS:
1443  /* If they're off hook, try playing congestion */
1444  if (analog_is_off_hook(p)) {
1447  } else {
1449  }
1450  break;
1451  case ANALOG_SIG_FXSGS:
1452  case ANALOG_SIG_FXSLS:
1453  case ANALOG_SIG_FXSKS:
1454  /* Make sure we're not made available for at least two seconds assuming
1455  we were actually used for an inbound or outbound call. */
1456  if (ast->_state != AST_STATE_RESERVED) {
1457  time(&p->guardtime);
1458  p->guardtime += 2;
1459  }
1460  break;
1461  default:
1463  break;
1464  }
1465 
1467 
1468  x = 0;
1469  ast_channel_setoption(ast,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0);
1470  ast_channel_setoption(ast,AST_OPTION_TDD,&x,sizeof(char),0);
1471  p->callwaitcas = 0;
1474  analog_set_dialing(p, 0);
1475  analog_update_conf(p);
1477  }
1478 
1480 
1481  ast_verb(3, "Hanging up on '%s'\n", ast->name);
1482 
1483  return 0;
1484 }
char cid_name[AST_MAX_EXTENSION]
Definition: sig_analog.h:303
#define POLARITY_IDLE
Definition: sig_analog.c:56
#define analog_get_index(ast, p, nullok)
Definition: sig_analog.c:389
static int analog_unalloc_sub(struct analog_pvt *p, enum analog_sub x)
Definition: sig_analog.c:363
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
Definition: channel.c:1601
int polarity
Definition: sig_analog.h:330
void * tech_pvt
Definition: channel.h:744
static int analog_set_linear_mode(struct analog_pvt *p, enum analog_sub sub, int linear_mode)
Definition: sig_analog.c:986
char mohsuggest[MAX_MUSICCLASS]
Definition: sig_analog.h:301
static int analog_play_tone(struct analog_pvt *p, enum analog_sub sub, enum analog_tone tone)
Definition: sig_analog.c:420
#define LOG_WARNING
Definition: logger.h:144
static void analog_lock_sub_owner(struct analog_pvt *pvt, enum analog_sub sub_idx)
Definition: sig_analog.c:571
struct ast_channel * owner
Definition: sig_analog.h:245
#define AST_OPTION_TDD
Definition: frame.h:445
time_t guardtime
Definition: sig_analog.h:333
#define AST_OPTION_TONE_VERIFY
Definition: frame.h:441
static void analog_all_subchannels_hungup(struct analog_pvt *p)
Definition: sig_analog.c:535
unsigned int allocd
Definition: sig_analog.h:249
unsigned int hidecallerid
Definition: sig_analog.h:312
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:7795
static void analog_set_outgoing(struct analog_pvt *p, int is_outgoing)
Definition: sig_analog.c:519
static void analog_hangup_polarityswitch(struct analog_pvt *p)
Definition: sig_analog.c:629
#define ast_verb(level,...)
Definition: logger.h:243
struct ast_channel * owner
Definition: sig_analog.h:260
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
int onhooktime
Definition: sig_analog.h:264
static void analog_swap_subs(struct analog_pvt *p, enum analog_sub a, enum analog_sub b)
Definition: sig_analog.c:330
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static int analog_stop_callwait(struct analog_pvt *p)
Definition: sig_analog.c:870
char cid_num[AST_MAX_EXTENSION]
Definition: sig_analog.h:302
static void analog_set_inthreeway(struct analog_pvt *p, enum analog_sub sub, int inthreeway)
Definition: sig_analog.c:995
static int analog_on_hook(struct analog_pvt *p)
Definition: sig_analog.c:511
#define LOG_ERROR
Definition: logger.h:155
enum ast_channel_state _state
Definition: channel.h:839
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
unsigned int inthreeway
Definition: sig_analog.h:247
char * origcid_num
Definition: sig_analog.h:337
#define ast_channel_unlock(chan)
Definition: channel.h:2467
#define ast_free(a)
Definition: astmm.h:97
static int analog_is_off_hook(struct analog_pvt *p)
Definition: sig_analog.c:471
static void analog_set_confirmanswer(struct analog_pvt *p, int flag)
Definition: sig_analog.c:944
char * origcid_name
Definition: sig_analog.h:338
unsigned int permhidecallerid
Definition: sig_analog.h:278
static void analog_set_callwaiting(struct analog_pvt *p, int callwaiting_enable)
Definition: sig_analog.c:888
static void analog_set_pulsedial(struct analog_pvt *p, int flag)
Definition: sig_analog.c:978
int cidrings
Definition: sig_analog.h:328
static int analog_set_echocanceller(struct analog_pvt *p, int enable)
Definition: sig_analog.c:455
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
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:1608
static void analog_set_new_owner(struct analog_pvt *p, struct ast_channel *new_owner)
Definition: sig_analog.c:428
unsigned int callwaitcas
TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
Definition: sig_analog.h:321
static int analog_update_conf(struct analog_pvt *p)
Definition: sig_analog.c:756
struct analog_subchannel subs[3]
Definition: sig_analog.h:262
static void analog_set_ringtimeout(struct analog_pvt *p, int ringt)
Definition: sig_analog.c:919
static void analog_set_dialing(struct analog_pvt *p, int is_dialing)
Definition: sig_analog.c:903
static int analog_dsp_set_digitmode(struct analog_pvt *p, enum analog_dsp_digitmode mode)
Definition: sig_analog.c:636
enum analog_sigtype sig
Definition: sig_analog.h:254
unsigned int permcallwaiting
Definition: sig_analog.h:277
struct analog_pvt* analog_new ( enum analog_sigtype  signallingtype,
struct analog_callback c,
void *  private_data 
)

Definition at line 3883 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().

3884 {
3885  struct analog_pvt *p;
3886 
3887  p = ast_calloc(1, sizeof(*p));
3888  if (!p) {
3889  return p;
3890  }
3891 
3892  p->calls = c;
3894  p->sig = signallingtype;
3895  p->chan_pvt = private_data;
3896 
3897  /* Some defaults for values */
3900  /* Sub real is assumed to always be alloc'd */
3901  p->subs[ANALOG_SUB_REAL].allocd = 1;
3902 
3903  return p;
3904 }
int cid_signalling
Definition: sig_analog.h:297
#define CID_SIG_BELL
Definition: callerid.h:59
unsigned int allocd
Definition: sig_analog.h:249
enum analog_cid_start cid_start
Definition: sig_analog.h:300
#define ast_calloc(a, b)
Definition: astmm.h:82
struct analog_callback * calls
Definition: sig_analog.h:258
enum analog_sigtype outsigmod
Definition: sig_analog.h:295
struct analog_subchannel subs[3]
Definition: sig_analog.h:262
void * chan_pvt
Definition: sig_analog.h:256
enum analog_sigtype sig
Definition: sig_analog.h:254
struct ast_channel* analog_request ( struct analog_pvt p,
int *  callwait,
const struct ast_channel requestor 
)

Definition at line 783 of file sig_analog.c.

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, and analog_pvt::owner.

Referenced by dahdi_request().

784 {
785  struct ast_channel *ast;
786 
787  ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
788  *callwait = (p->owner != NULL);
789 
790  if (p->owner) {
792  ast_log(LOG_ERROR, "Unable to alloc subchannel\n");
793  return NULL;
794  }
795  }
796 
797  analog_set_outgoing(p, 1);
799  p->owner ? ANALOG_SUB_CALLWAIT : ANALOG_SUB_REAL, requestor);
800  if (!ast) {
801  analog_set_outgoing(p, 0);
802  }
803  return ast;
804 }
Main Channel structure associated with a channel.
Definition: channel.h:742
static void analog_set_outgoing(struct analog_pvt *p, int is_outgoing)
Definition: sig_analog.c:519
struct ast_channel * owner
Definition: sig_analog.h:260
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
static int analog_alloc_sub(struct analog_pvt *p, enum analog_sub x)
Definition: sig_analog.c:350
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:436
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
const char* analog_sigtype_to_str ( enum analog_sigtype  sigtype)

Definition at line 120 of file sig_analog.c.

References ARRAY_LEN, and sigtypes.

Referenced by __analog_ss_thread(), and analog_handle_init_event().

121 {
122  int i;
123 
124  for (i = 0; i < ARRAY_LEN(sigtypes); i++) {
125  if (sigtype == sigtypes[i].sigtype) {
126  return sigtypes[i].name;
127  }
128  }
129 
130  return "Unknown";
131 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
enum analog_sigtype sigtype
Definition: sig_analog.c:66
static struct @118 sigtypes[]
int analog_ss_thread_start ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 2644 of file sig_analog.c.

References __analog_ss_thread(), and ast_pthread_create_detached.

Referenced by mwi_thread().

2645 {
2646  pthread_t threadid;
2647 
2648  return ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, p);
2649 }
#define ast_pthread_create_detached(a, b, c, d)
Definition: utils.h:422
static void * __analog_ss_thread(void *data)
Definition: sig_analog.c:1739
enum analog_cid_start analog_str_to_cidstart ( const char *  value)

Definition at line 216 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.

217 {
218  if (!strcasecmp(value, "ring")) {
219  return ANALOG_CID_START_RING;
220  } else if (!strcasecmp(value, "polarity")) {
222  } else if (!strcasecmp(value, "polarity_in")) {
224  } else if (!strcasecmp(value, "dtmf")) {
226  }
227 
228  return 0;
229 }
int value
Definition: syslog.c:39
unsigned int analog_str_to_cidtype ( const char *  name)

Definition at line 133 of file sig_analog.c.

References ARRAY_LEN, and cidtypes.

134 {
135  int i;
136 
137  for (i = 0; i < ARRAY_LEN(cidtypes); i++) {
138  if (!strcasecmp(cidtypes[i].name, name)) {
139  return cidtypes[i].cid_type;
140  }
141  }
142 
143  return 0;
144 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct @119 cidtypes[]
static const char name[]
enum analog_sigtype analog_str_to_sigtype ( const char *  name)

Definition at line 107 of file sig_analog.c.

References ARRAY_LEN, and sigtypes.

108 {
109  int i;
110 
111  for (i = 0; i < ARRAY_LEN(sigtypes); i++) {
112  if (!strcasecmp(sigtypes[i].name, name)) {
113  return sigtypes[i].sigtype;
114  }
115  }
116 
117  return 0;
118 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static const char name[]
static struct @118 sigtypes[]