Asterisk - The Open Source Telephony Project GIT-master-545c459
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
sig_analog.h File Reference

Interface header for analog signaling module. More...

#include "asterisk/channel.h"
#include "asterisk/frame.h"
#include "asterisk/smdi.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
 

Macros

#define ANALOG_FIRST_DIGIT_TIMEOUT   16000
 Default time (ms) to detect first digit.
 
#define ANALOG_INTER_DIGIT_TIMEOUT   8000
 Default time (ms) to detect following digits.
 
#define ANALOG_MATCH_DIGIT_TIMEOUT   3000
 Default time (ms) to wait, in case of ambiguous match.
 
#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_dialmode { ANALOG_DIALMODE_BOTH = 0 , ANALOG_DIALMODE_PULSE , ANALOG_DIALMODE_DTMF , ANALOG_DIALMODE_NONE }
 
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, const char *rdest, int timeout)
 
int analog_callwaiting_deluxe (struct analog_pvt *p, int option)
 
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_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, 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)
 

Variables

struct analog_callback analog_callbacks
 

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

◆ ANALOG_FIRST_DIGIT_TIMEOUT

#define ANALOG_FIRST_DIGIT_TIMEOUT   16000

Default time (ms) to detect first digit.

Definition at line 38 of file sig_analog.h.

◆ ANALOG_INTER_DIGIT_TIMEOUT

#define ANALOG_INTER_DIGIT_TIMEOUT   8000

Default time (ms) to detect following digits.

Definition at line 40 of file sig_analog.h.

◆ ANALOG_MATCH_DIGIT_TIMEOUT

#define ANALOG_MATCH_DIGIT_TIMEOUT   3000

Default time (ms) to wait, in case of ambiguous match.

Definition at line 42 of file sig_analog.h.

◆ ANALOG_MAX_CID

#define ANALOG_MAX_CID   300

Definition at line 33 of file sig_analog.h.

◆ ANALOG_SMDI_MD_WAIT_TIMEOUT

#define ANALOG_SMDI_MD_WAIT_TIMEOUT   1500 /* 1.5 seconds */

Definition at line 32 of file sig_analog.h.

◆ READ_SIZE

#define READ_SIZE   160

Definition at line 34 of file sig_analog.h.

◆ RING_PATTERNS

#define RING_PATTERNS   3

Definition at line 35 of file sig_analog.h.

Enumeration Type Documentation

◆ analog_cid_start

Enumerator
ANALOG_CID_START_POLARITY 
ANALOG_CID_START_POLARITY_IN 
ANALOG_CID_START_RING 
ANALOG_CID_START_DTMF_NOALERT 

Definition at line 126 of file sig_analog.h.

126 {
131};
@ ANALOG_CID_START_RING
Definition sig_analog.h:129
@ ANALOG_CID_START_DTMF_NOALERT
Definition sig_analog.h:130
@ ANALOG_CID_START_POLARITY
Definition sig_analog.h:127
@ ANALOG_CID_START_POLARITY_IN
Definition sig_analog.h:128

◆ analog_dialmode

Enumerator
ANALOG_DIALMODE_BOTH 
ANALOG_DIALMODE_PULSE 
ANALOG_DIALMODE_DTMF 
ANALOG_DIALMODE_NONE 

Definition at line 119 of file sig_analog.h.

119 {
124};
@ ANALOG_DIALMODE_DTMF
Definition sig_analog.h:122
@ ANALOG_DIALMODE_PULSE
Definition sig_analog.h:121
@ ANALOG_DIALMODE_NONE
Definition sig_analog.h:123
@ ANALOG_DIALMODE_BOTH
Definition sig_analog.h:120

◆ analog_dsp_digitmode

Enumerator
ANALOG_DIGITMODE_DTMF 
ANALOG_DIGITMODE_MF 

Definition at line 114 of file sig_analog.h.

114 {
117};
@ ANALOG_DIGITMODE_DTMF
Definition sig_analog.h:115
@ ANALOG_DIGITMODE_MF
Definition sig_analog.h:116

◆ analog_event

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

79 {
101 ANALOG_EVENT_ERROR, /* not a DAHDI event */
102 ANALOG_EVENT_DTMFCID, /* not a DAHDI event */
103 ANALOG_EVENT_PULSEDIGIT = (1 << 16),
104 ANALOG_EVENT_DTMFDOWN = (1 << 17),
105 ANALOG_EVENT_DTMFUP = (1 << 18),
106};
@ ANALOG_EVENT_NONE
Definition sig_analog.h:80
@ ANALOG_EVENT_HOOKCOMPLETE
Definition sig_analog.h:89
@ ANALOG_EVENT_DTMFDOWN
Definition sig_analog.h:104
@ ANALOG_EVENT_RINGEROFF
Definition sig_analog.h:88
@ ANALOG_EVENT_PULSE_START
Definition sig_analog.h:90
@ ANALOG_EVENT_DTMFCID
Definition sig_analog.h:102
@ ANALOG_EVENT_TX_CED_DETECTED
Definition sig_analog.h:97
@ ANALOG_EVENT_NEONMWI_ACTIVE
Definition sig_analog.h:95
@ ANALOG_EVENT_RINGBEGIN
Definition sig_analog.h:92
@ ANALOG_EVENT_ONHOOK
Definition sig_analog.h:81
@ ANALOG_EVENT_EC_DISABLED
Definition sig_analog.h:93
@ ANALOG_EVENT_WINKFLASH
Definition sig_analog.h:83
@ ANALOG_EVENT_ERROR
Definition sig_analog.h:101
@ ANALOG_EVENT_PULSEDIGIT
Definition sig_analog.h:103
@ ANALOG_EVENT_RINGERON
Definition sig_analog.h:87
@ ANALOG_EVENT_RX_CED_DETECTED
Definition sig_analog.h:98
@ ANALOG_EVENT_ALARM
Definition sig_analog.h:84
@ ANALOG_EVENT_DIALCOMPLETE
Definition sig_analog.h:86
@ ANALOG_EVENT_EC_NLP_ENABLED
Definition sig_analog.h:100
@ ANALOG_EVENT_POLARITY
Definition sig_analog.h:91
@ ANALOG_EVENT_NEONMWI_INACTIVE
Definition sig_analog.h:96
@ ANALOG_EVENT_DTMFUP
Definition sig_analog.h:105
@ ANALOG_EVENT_EC_NLP_DISABLED
Definition sig_analog.h:99
@ ANALOG_EVENT_RINGOFFHOOK
Definition sig_analog.h:82
@ ANALOG_EVENT_REMOVED
Definition sig_analog.h:94
@ ANALOG_EVENT_NOALARM
Definition sig_analog.h:85

◆ analog_sigtype

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

45 {
46 ANALOG_SIG_NONE = -1,
68};
@ ANALOG_SIG_FEATD
Definition sig_analog.h:56
@ ANALOG_SIG_FEATDMF_TA
Definition sig_analog.h:66
@ ANALOG_SIG_FGC_CAMAMF
Definition sig_analog.h:60
@ ANALOG_SIG_FXOLS
Definition sig_analog.h:47
@ ANALOG_SIG_FEATDMF
Definition sig_analog.h:57
@ ANALOG_SIG_EM_E1
Definition sig_analog.h:55
@ ANALOG_SIG_EMWINK
Definition sig_analog.h:53
@ ANALOG_SIG_FXOKS
Definition sig_analog.h:48
@ ANALOG_SIG_SF
Definition sig_analog.h:63
@ ANALOG_SIG_FGC_CAMA
Definition sig_analog.h:59
@ ANALOG_SIG_FXSLS
Definition sig_analog.h:50
@ ANALOG_SIG_EM
Definition sig_analog.h:54
@ ANALOG_SIG_FXOGS
Definition sig_analog.h:49
@ ANALOG_SIG_SF_FEATB
Definition sig_analog.h:67
@ ANALOG_SIG_NONE
Definition sig_analog.h:46
@ ANALOG_SIG_FXSGS
Definition sig_analog.h:52
@ ANALOG_SIG_SF_FEATDMF
Definition sig_analog.h:65
@ ANALOG_SIG_SFWINK
Definition sig_analog.h:62
@ ANALOG_SIG_E911
Definition sig_analog.h:58
@ ANALOG_SIG_FEATB
Definition sig_analog.h:61
@ ANALOG_SIG_SF_FEATD
Definition sig_analog.h:64
@ ANALOG_SIG_FXSKS
Definition sig_analog.h:51

◆ analog_sub

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

108 {
109 ANALOG_SUB_REAL = 0, /*!< Active call */
110 ANALOG_SUB_CALLWAIT, /*!< Call-Waiting call on hold */
111 ANALOG_SUB_THREEWAY, /*!< Three-way call */
112};
@ ANALOG_SUB_THREEWAY
Definition sig_analog.h:111
@ ANALOG_SUB_REAL
Definition sig_analog.h:109
@ ANALOG_SUB_CALLWAIT
Definition sig_analog.h:110

◆ analog_tone

Enumerator
ANALOG_TONE_RINGTONE 
ANALOG_TONE_STUTTER 
ANALOG_TONE_CONGESTION 
ANALOG_TONE_DIALTONE 
ANALOG_TONE_DIALRECALL 
ANALOG_TONE_INFO 

Definition at line 70 of file sig_analog.h.

70 {
77};
@ ANALOG_TONE_CONGESTION
Definition sig_analog.h:73
@ ANALOG_TONE_INFO
Definition sig_analog.h:76
@ ANALOG_TONE_DIALTONE
Definition sig_analog.h:74
@ ANALOG_TONE_DIALRECALL
Definition sig_analog.h:75
@ ANALOG_TONE_STUTTER
Definition sig_analog.h:72
@ ANALOG_TONE_RINGTONE
Definition sig_analog.h:71

◆ dialop

enum dialop
Enumerator
ANALOG_DIAL_OP_REPLACE 

Definition at line 133 of file sig_analog.h.

133 {
135};
@ ANALOG_DIAL_OP_REPLACE
Definition sig_analog.h:134

Function Documentation

◆ analog_answer()

int analog_answer ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 1510 of file sig_analog.c.

1511{
1512 int res = 0;
1513 int idx;
1514 int oldstate = ast_channel_state(ast);
1515
1516 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
1518 idx = analog_get_index(ast, p, 1);
1519 if (idx < 0) {
1520 idx = ANALOG_SUB_REAL;
1521 }
1522 switch (p->sig) {
1523 case ANALOG_SIG_FXSLS:
1524 case ANALOG_SIG_FXSGS:
1525 case ANALOG_SIG_FXSKS:
1527 /* Fall through */
1528 case ANALOG_SIG_EM:
1529 case ANALOG_SIG_EM_E1:
1530 case ANALOG_SIG_EMWINK:
1531 case ANALOG_SIG_FEATD:
1532 case ANALOG_SIG_FEATDMF:
1534 case ANALOG_SIG_E911:
1537 case ANALOG_SIG_FEATB:
1538 case ANALOG_SIG_SF:
1539 case ANALOG_SIG_SFWINK:
1543 case ANALOG_SIG_FXOLS:
1544 case ANALOG_SIG_FXOGS:
1545 case ANALOG_SIG_FXOKS:
1546 /* Pick up the line */
1547 ast_debug(1, "Took %s off hook\n", ast_channel_name(ast));
1548 if (p->hanguponpolarityswitch) {
1549 gettimeofday(&p->polaritydelaytv, NULL);
1550 }
1551 res = analog_off_hook(p);
1552 analog_play_tone(p, idx, -1);
1553 analog_set_dialing(p, 0);
1554 if ((idx == ANALOG_SUB_REAL) && p->subs[ANALOG_SUB_THREEWAY].inthreeway) {
1555 if (oldstate == AST_STATE_RINGING) {
1556 ast_debug(1, "Finally swapping real and threeway\n");
1560 }
1561 }
1562
1563 switch (p->sig) {
1564 case ANALOG_SIG_FXSLS:
1565 case ANALOG_SIG_FXSKS:
1566 case ANALOG_SIG_FXSGS:
1569 break;
1570 case ANALOG_SIG_FXOLS:
1571 case ANALOG_SIG_FXOKS:
1572 case ANALOG_SIG_FXOGS:
1574 break;
1575 default:
1576 break;
1577 }
1578 break;
1579 default:
1580 ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
1581 res = -1;
1582 break;
1583 }
1585 return res;
1586}
#define ast_log
Definition astobj2.c:42
const char * ast_channel_name(const struct ast_channel *chan)
ast_channel_state
ast_channel states
@ AST_STATE_RINGING
@ AST_STATE_UP
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition channel.c:7422
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
#define NULL
Definition resample.c:96
static void analog_set_new_owner(struct analog_pvt *p, struct ast_channel *new_owner)
Definition sig_analog.c:456
static int analog_train_echocanceller(struct analog_pvt *p)
Definition sig_analog.c:491
static void analog_set_dialing(struct analog_pvt *p, int is_dialing)
Definition sig_analog.c:915
static void analog_set_ringtimeout(struct analog_pvt *p, int ringt)
Definition sig_analog.c:931
#define analog_get_index(ast, p, nullok)
Definition sig_analog.c:417
static void analog_answer_polarityswitch(struct analog_pvt *p)
Definition sig_analog.c:655
static int analog_off_hook(struct analog_pvt *p)
Definition sig_analog.c:625
static int analog_play_tone(struct analog_pvt *p, enum analog_sub sub, enum analog_tone tone)
Definition sig_analog.c:448
static int analog_set_echocanceller(struct analog_pvt *p, int enable)
Definition sig_analog.c:483
static void analog_swap_subs(struct analog_pvt *p, enum analog_sub a, enum analog_sub b)
Definition sig_analog.c:352
struct timeval polaritydelaytv
Definition sig_analog.h:371
unsigned int hanguponpolarityswitch
Definition sig_analog.h:297
enum analog_sigtype sig
Definition sig_analog.h:273
struct analog_subchannel subs[3]
Definition sig_analog.h:279
unsigned int inthreeway
Definition sig_analog.h:266
struct ast_channel * owner
Definition sig_analog.h:264

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

Referenced by dahdi_answer().

◆ analog_available()

int analog_available ( struct analog_pvt p)

Definition at line 803 of file sig_analog.c.

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

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

Referenced by available().

◆ analog_call()

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

Definition at line 1010 of file sig_analog.c.

1011{
1012 int res, idx, mysig;
1013 char *c, *n, *l;
1014 char dest[256]; /* must be same length as p->dialdest */
1015
1016 ast_debug(1, "CALLING CID_NAME: %s CID_NUM:: %s\n",
1017 S_COR(ast_channel_connected(ast)->id.name.valid, ast_channel_connected(ast)->id.name.str, ""),
1018 S_COR(ast_channel_connected(ast)->id.number.valid, ast_channel_connected(ast)->id.number.str, ""));
1019
1020 ast_copy_string(dest, rdest, sizeof(dest));
1021 ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest));
1022
1023 if ((ast_channel_state(ast) == AST_STATE_BUSY)) {
1025 return 0;
1026 }
1027
1029 ast_log(LOG_WARNING, "analog_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
1030 return -1;
1031 }
1032
1033 p->dialednone = 0;
1034 analog_set_outgoing(p, 1);
1035
1036 mysig = p->sig;
1037 if (p->outsigmod > -1) {
1038 mysig = p->outsigmod;
1039 }
1040
1041 switch (mysig) {
1042 case ANALOG_SIG_FXOLS:
1043 case ANALOG_SIG_FXOGS:
1044 case ANALOG_SIG_FXOKS:
1045 if (p->owner == ast) {
1046 /* Normal ring, on hook */
1047
1048 /* Don't send audio while on hook, until the call is answered */
1049 analog_set_dialing(p, 1);
1050 analog_set_cadence(p, ast); /* and set p->cidrings */
1051
1052 /* nick@dccinc.com 4/3/03 mods to allow for deferred dialing */
1053 c = strchr(dest, '/');
1054 if (c) {
1055 c++;
1056 }
1057 if (c && (strlen(c) < p->stripmsd)) {
1058 ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
1059 c = NULL;
1060 }
1061 if (c && (strlen(c) > sizeof(p->dop.dialstr) - 3 /* "Tw\0" */)) {
1062 ast_log(LOG_WARNING, "Number '%s' is longer than %d bytes\n", c, (int)sizeof(p->dop.dialstr) - 2);
1063 c = NULL;
1064 }
1065 if (c) {
1067 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
1068 ast_debug(1, "FXO: setup deferred dialstring: %s\n", c);
1069 } else {
1070 p->dop.dialstr[0] = '\0';
1071 }
1072
1073 if (analog_ring(p)) {
1074 ast_log(LOG_WARNING, "Unable to ring phone: %s\n", strerror(errno));
1075 return -1;
1076 }
1077 analog_set_dialing(p, 1);
1078 } else {
1079 /* Call waiting call */
1080 if (ast_channel_connected(ast)->id.number.valid && ast_channel_connected(ast)->id.number.str) {
1082 } else {
1083 p->callwait_num[0] = '\0';
1084 }
1085 if (ast_channel_connected(ast)->id.name.valid && ast_channel_connected(ast)->id.name.str) {
1087 } else {
1088 p->callwait_name[0] = '\0';
1089 }
1090
1091 /* Call waiting tone instead */
1092 if (analog_callwait(p)) {
1093 return -1;
1094 }
1095 /* Make ring-back */
1097 ast_log(LOG_WARNING, "Unable to generate call-wait ring-back on channel %s\n", ast_channel_name(ast));
1098 }
1099
1100 }
1101
1102 /* Name and Number */
1105 if (l) {
1106 ast_copy_string(p->lastcid_num, l, sizeof(p->lastcid_num));
1107 } else {
1108 p->lastcid_num[0] = '\0';
1109 }
1110 if (n) {
1111 ast_copy_string(p->lastcid_name, n, sizeof(p->lastcid_name));
1112 } else {
1113 p->lastcid_name[0] = '\0';
1114 }
1115
1116 if (p->use_callerid) {
1117 const char *qual_var;
1118
1119 /* Caller ID Name and Number */
1120 p->caller.id.name.str = p->lastcid_name;
1121 p->caller.id.number.str = p->lastcid_num;
1126
1127 /* Redirecting Reason */
1129
1130 /* Call Qualifier */
1131 ast_channel_lock(ast);
1132 /* XXX In the future, we may want to make this a CALLERID or CHANNEL property and fetch it from there. */
1133 qual_var = pbx_builtin_getvar_helper(ast, "CALL_QUALIFIER");
1134 p->call_qualifier = ast_true(qual_var) ? 1 : 0;
1135 ast_channel_unlock(ast);
1136 }
1137
1139 idx = analog_get_index(ast, p, 0);
1140 if (idx > -1) {
1141 struct ast_cc_config_params *cc_params;
1142
1143 /* This is where the initial ringing frame is queued for an analog call.
1144 * As such, this is a great time to offer CCNR to the caller if it's available.
1145 */
1146 cc_params = ast_channel_get_cc_config_params(p->subs[idx].owner);
1147 if (cc_params) {
1148 switch (ast_get_cc_monitor_policy(cc_params)) {
1150 break;
1156 break;
1157 }
1158 }
1160 }
1161 break;
1162 case ANALOG_SIG_FXSLS:
1163 case ANALOG_SIG_FXSGS:
1164 case ANALOG_SIG_FXSKS:
1166 ast_debug(1, "Ignore possible polarity reversal on line seizure\n");
1168 }
1169 /* fall through */
1170 case ANALOG_SIG_EMWINK:
1171 case ANALOG_SIG_EM:
1172 case ANALOG_SIG_EM_E1:
1173 case ANALOG_SIG_FEATD:
1174 case ANALOG_SIG_FEATDMF:
1175 case ANALOG_SIG_E911:
1178 case ANALOG_SIG_FEATB:
1179 case ANALOG_SIG_SFWINK:
1180 case ANALOG_SIG_SF:
1185 c = strchr(dest, '/');
1186 if (c) {
1187 c++;
1188 } else {
1189 c = "";
1190 }
1191 if (strlen(c) < p->stripmsd) {
1192 ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
1193 return -1;
1194 }
1195 res = analog_start(p);
1196 if (res < 0) {
1197 if (errno != EINPROGRESS) {
1198 return -1;
1199 }
1200 }
1201 ast_debug(1, "Dialing '%s'\n", c);
1203
1204 c += p->stripmsd;
1205
1206 switch (mysig) {
1207 case ANALOG_SIG_FEATD:
1209 if (l) {
1210 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T*%s*%s*", l, c);
1211 } else {
1212 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T**%s*", c);
1213 }
1214 break;
1215 case ANALOG_SIG_FEATDMF:
1217 if (l) {
1218 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*00%s#*%s#", l, c);
1219 } else {
1220 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*02#*%s#", c);
1221 }
1222 break;
1224 {
1225 const char *cic = "", *ozz = "";
1226
1227 /* If you have to go through a Tandem Access point you need to use this */
1228#ifndef STANDALONE
1229 ozz = pbx_builtin_getvar_helper(p->owner, "FEATDMF_OZZ");
1230 if (!ozz) {
1231 ozz = analog_defaultozz;
1232 }
1233 cic = pbx_builtin_getvar_helper(p->owner, "FEATDMF_CIC");
1234 if (!cic) {
1235 cic = analog_defaultcic;
1236 }
1237#endif
1238 if (!ozz || !cic) {
1239 ast_log(LOG_WARNING, "Unable to dial channel of type feature group D MF tandem access without CIC or OZZ set\n");
1240 return -1;
1241 }
1242 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s%s#", ozz, cic);
1243 snprintf(p->finaldial, sizeof(p->finaldial), "M*%s#", c);
1244 p->whichwink = 0;
1245 }
1246 break;
1247 case ANALOG_SIG_E911:
1248 ast_copy_string(p->dop.dialstr, "M*911#", sizeof(p->dop.dialstr));
1249 break;
1251 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%s", c);
1252 break;
1254 case ANALOG_SIG_FEATB:
1255 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%s#", c);
1256 break;
1257 default:
1258 if (p->pulse) {
1259 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "P%sw", c);
1260 } else {
1261 snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "T%sw", c);
1262 }
1263 break;
1264 }
1265
1266 if (p->echotraining && (strlen(p->dop.dialstr) > 4)) {
1267 memset(p->echorest, 'w', sizeof(p->echorest) - 1);
1268 strcpy(p->echorest + (p->echotraining / 400) + 1, p->dop.dialstr + strlen(p->dop.dialstr) - 2);
1269 p->echorest[sizeof(p->echorest) - 1] = '\0';
1270 p->echobreak = 1;
1271 p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0';
1272 } else {
1273 p->echobreak = 0;
1274 }
1276 if (!res) {
1277 if (analog_dial_digits(p, ANALOG_SUB_REAL, &p->dop)) {
1278 analog_on_hook(p);
1279 return -1;
1280 }
1281 } else {
1282 ast_debug(1, "Deferring dialing...\n");
1283 }
1284 analog_set_dialing(p, 1);
1285 if (ast_strlen_zero(c)) {
1286 p->dialednone = 1;
1287 }
1289 break;
1290 default:
1291 ast_debug(1, "not yet implemented\n");
1292 return -1;
1293 }
1294 return 0;
1295}
#define AST_CC_GENERIC_MONITOR_TYPE
Definition ccss.h:455
@ AST_CC_CCNR
Definition ccss.h:38
@ AST_CC_MONITOR_NEVER
Definition ccss.h:76
@ AST_CC_MONITOR_ALWAYS
Definition ccss.h:87
@ AST_CC_MONITOR_NATIVE
Definition ccss.h:78
@ AST_CC_MONITOR_GENERIC
Definition ccss.h:83
enum ast_cc_monitor_policies ast_get_cc_monitor_policy(struct ast_cc_config_params *config)
Get the cc_monitor_policy.
Definition ccss.c:900
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:4206
#define ast_channel_lock(chan)
Definition channel.h:2983
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition channel.c:1289
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
struct ast_cc_config_params * ast_channel_get_cc_config_params(struct ast_channel *chan)
Get the CCSS parameters from a channel.
Definition channel.c:10650
#define ast_channel_unlock(chan)
Definition channel.h:2984
@ AST_STATE_DOWN
@ AST_STATE_BUSY
@ AST_STATE_DIALING
@ AST_STATE_RESERVED
@ AST_CONTROL_RINGING
int errno
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
static const char * analog_get_orig_dialstring(struct analog_pvt *p)
Definition sig_analog.c:190
static char analog_defaultozz[64]
Definition sig_analog.c:66
static int analog_callwait(struct analog_pvt *p)
Definition sig_analog.c:891
static void analog_set_outgoing(struct analog_pvt *p, int is_outgoing)
Definition sig_analog.c:547
static char analog_defaultcic[64]
Definition sig_analog.c:65
static int analog_dial_digits(struct analog_pvt *p, enum analog_sub sub, struct analog_dialoperation *dop)
Definition sig_analog.c:531
static int analog_ring(struct analog_pvt *p)
Definition sig_analog.c:507
static void analog_set_cadence(struct analog_pvt *p, struct ast_channel *chan)
Definition sig_analog.c:908
const char * name
Definition sig_analog.c:70
static int analog_on_hook(struct analog_pvt *p)
Definition sig_analog.c:539
static int analog_start(struct analog_pvt *p)
Definition sig_analog.c:523
static void analog_set_waitingfordt(struct analog_pvt *p, struct ast_channel *ast)
Definition sig_analog.c:939
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition utils.c:2233
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition strings.h:87
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition strings.h:425
char dialdest[256]
Definition sig_analog.h:372
struct analog_dialoperation dop
Definition sig_analog.h:280
int redirecting_reason
Definition sig_analog.h:366
enum analog_sigtype outsigmod
Definition sig_analog.h:323
unsigned int answeronpolarityswitch
Definition sig_analog.h:291
unsigned int pulse
Definition sig_analog.h:305
int echotraining
Definition sig_analog.h:325
char callwait_num[AST_MAX_EXTENSION]
Definition sig_analog.h:360
unsigned int echobreak
Definition sig_analog.h:341
char lastcid_name[AST_MAX_EXTENSION]
Definition sig_analog.h:363
unsigned int dialednone
Definition sig_analog.h:338
unsigned int call_qualifier
Definition sig_analog.h:358
char echorest[20]
Definition sig_analog.h:369
char lastcid_num[AST_MAX_EXTENSION]
Definition sig_analog.h:362
char finaldial[64]
Definition sig_analog.h:376
unsigned int use_callerid
Definition sig_analog.h:310
char callwait_name[AST_MAX_EXTENSION]
Definition sig_analog.h:361
struct ast_party_caller caller
Definition sig_analog.h:365
struct ast_party_id id
Caller party ID.
Definition channel.h:422
struct ast_party_id id
Connected party ID.
Definition channel.h:460
struct ast_party_name name
Subscriber name.
Definition channel.h:342
struct ast_party_number number
Subscriber phone number.
Definition channel.h:344
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition channel.h:279
unsigned char valid
TRUE if the name information is valid/present.
Definition channel.h:281
char * str
Subscriber name (Malloced)
Definition channel.h:266
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition channel.h:297
unsigned char valid
TRUE if the number information is valid/present.
Definition channel.h:299
char * str
Subscriber phone number (Malloced)
Definition channel.h:293
int code
enum AST_REDIRECTING_REASON value for redirection
Definition channel.h:512
struct ast_party_redirecting_reason reason
Reason for the redirection.
Definition channel.h:544
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition channel.h:529
Number structure.
static struct test_val c
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition time.h:159

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

Referenced by dahdi_call().

◆ analog_callwaiting_deluxe()

int analog_callwaiting_deluxe ( struct analog_pvt p,
int  option 
)

Definition at line 1639 of file sig_analog.c.

1640{
1641 const char *announce_var;
1642 char announcement[PATH_MAX];
1643
1644 ast_debug(1, "Handling Call Waiting on channel %d with option %c: treatment %s\n", p->channel, option, callwaiting_deluxe_optname(option));
1645
1646 if (!p->subs[ANALOG_SUB_CALLWAIT].owner) {
1647 /* This can happen if the caller hook flashes and the call waiting hangs up before the CWD timer expires (1 second) */
1648 ast_debug(1, "Call waiting call disappeared before it could be handled?\n");
1649 return -1;
1650 }
1651
1653 if (!p->subs[ANALOG_SUB_CALLWAIT].owner) {
1654 ast_log(LOG_WARNING, "Whoa, the call-waiting call disappeared.\n");
1655 return -1;
1656 }
1657
1658 /* Note that when p->callwaitingdeluxepending, dahdi_write will drop incoming frames to the channel,
1659 * since the user shouldn't hear anything after flashing until either a DTMF has been received
1660 * or it's been a second and the decision is made automatically. */
1661
1662 switch (option) {
1663 case CWD_CONFERENCE:
1664 /* We should never have a call waiting if we have a 3-way anyways, but check just in case,
1665 * there better be no existing SUB_THREEWAY since we're going to make one (and then swap the call wait to it) */
1666 if (p->subs[ANALOG_SUB_THREEWAY].owner) {
1668 ast_log(LOG_ERROR, "Already have a 3-way call on channel %d, can't conference!\n", p->channel);
1669 return -1;
1670 }
1671
1672 /* To conference the incoming call, swap it from SUB_CALLWAIT to SUB_THREEWAY,
1673 * and then the existing 3-way logic will ensure that flashing again will drop the call waiting */
1677
1678 ast_verb(3, "Building conference call with %s and %s\n", ast_channel_name(p->subs[ANALOG_SUB_THREEWAY].owner), ast_channel_name(p->subs[ANALOG_SUB_REAL].owner));
1681
1685 /* Stop the ringing on the call wait channel (yeah, apparently this is how it's done) */
1688 }
1690
1691 ast_channel_unlock(p->subs[ANALOG_SUB_THREEWAY].owner); /* Unlock what was originally SUB_CALLWAIT */
1692 break;
1693 case CWD_HOLD: /* The CI-7112 Visual Director sends "HOLD" for "Play hold message" rather than "ANNOUNCEMENT". For default behavior, nothing is actually sent. */
1694 case CWD_ANNOUNCEMENT:
1695 /* We can't just call ast_streamfile here, this thread isn't responsible for media on the call waiting channel.
1696 * Indicate to the dialing channel in app_dial that it needs to play media.
1697 *
1698 * This is a lot easier than other ways of trying to send early media to the channel
1699 * (such as every call from the core to dahdi_read, sending the channel one frame of the audio file, etc.)
1700 */
1701
1702 /* There's not a particularly good stock audio prompt to use here. The Pat Fleet library has some better
1703 * ones but we want one that is also in the default Allison Smith library. "One moment please" works okay.
1704 * Check if a variable containing the prompt to use was specified on the call waiting channel, and
1705 * fall back to a reasonable default if not. */
1706
1707 /* The SUB_CALLWAIT channel is already locked here, no need to lock and unlock to get the variable. */
1708 announce_var = pbx_builtin_getvar_helper(p->subs[ANALOG_SUB_CALLWAIT].owner, "CALLWAITDELUXEANNOUNCEMENT");
1709 ast_copy_string(announcement, S_OR(announce_var, "one-moment-please"), sizeof(announcement));
1710 ast_debug(2, "Call Waiting Deluxe announcement for %s: %s\n", ast_channel_name(p->subs[ANALOG_SUB_CALLWAIT].owner), announcement);
1712 /* Tell app_dial what file to play. */
1713 ast_queue_control_data(p->subs[ANALOG_SUB_CALLWAIT].owner, AST_CONTROL_PLAYBACK_BEGIN, announcement, strlen(announcement) + 1);
1714 /* Unlike all the other options, the call waiting is still active with this option,
1715 * so we don't call analog_stop_callwait(p)
1716 * The call waiting will continue to be here, and at some later point the user can flash again and choose a finalizing option
1717 * (or even queue the announcement again... and again... and again...)
1718 */
1719 break;
1720 case CWD_FORWARD:
1721 /* Go away, call waiting, call again some other day... */
1723 /* Can't use p->call_forward exten because that's for *72 forwarding, and sig_analog doesn't
1724 * have a Busy/Don't Answer call forwarding exten internally, so let the dialplan deal with it.
1725 * by sending the call to the 'f' extension.
1726 */
1727 ast_channel_call_forward_set(p->subs[ANALOG_SUB_CALLWAIT].owner, "f");
1729 /* app_dial already has a verbose message for forwarding, so we don't really need one here also since that does the job */
1730 break;
1731 case CWD_DROP:
1732 /* Fall through: logic is identical to hold, except we drop the original call right after we swap. */
1733 default:
1734 /* Swap to call-wait, same as with the non-deluxe call waiting handling. */
1738 ast_debug(1, "Making %s the new owner\n", ast_channel_name(p->owner));
1742 }
1744
1745 if (option == CWD_DROP) {
1746 /* Disconnect the previous call (the original call is now the SUB_CALLWAIT since we swapped above) */
1748 ast_verb(3, "Dropping original call and swapping to call waiting on %s\n", ast_channel_name(p->subs[ANALOG_SUB_REAL].owner));
1749 } else {
1750 /* Start music on hold if appropriate */
1753 }
1754 ast_verb(3, "Holding original call and swapping to call waiting on %s\n", ast_channel_name(p->subs[ANALOG_SUB_REAL].owner));
1755 }
1756
1757 /* Stop ringing on the incoming call */
1760
1761 /* Unlock the call-waiting call that we swapped to real-call. */
1763 }
1765 return 0;
1766}
#define PATH_MAX
Definition asterisk.h:40
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition channel.c:1182
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:1296
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Definition channel.c:1274
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
Definition channel.c:1249
@ AST_CONTROL_PLAYBACK_BEGIN
@ AST_CONTROL_ANSWER
#define LOG_ERROR
#define ast_verb(level,...)
static int analog_alloc_sub(struct analog_pvt *p, enum analog_sub x)
Definition sig_analog.c:372
static int analog_update_conf(struct analog_pvt *p)
Definition sig_analog.c:753
@ CWD_DROP
@ CWD_FORWARD
@ CWD_HOLD
@ CWD_CONFERENCE
@ CWD_ANNOUNCEMENT
static int analog_unalloc_sub(struct analog_pvt *p, enum analog_sub x)
Definition sig_analog.c:385
static void analog_lock_sub_owner(struct analog_pvt *pvt, enum analog_sub sub_idx)
Definition sig_analog.c:609
static int analog_stop_callwait(struct analog_pvt *p)
Definition sig_analog.c:872
static void analog_set_inthreeway(struct analog_pvt *p, enum analog_sub sub, int inthreeway)
static const char * callwaiting_deluxe_optname(int option)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition strings.h:80
char mohsuggest[MAX_MUSICCLASS]
Definition sig_analog.h:330

References analog_alloc_sub(), analog_lock_sub_owner(), analog_play_tone(), analog_set_inthreeway(), analog_set_new_owner(), analog_stop_callwait(), ANALOG_SUB_CALLWAIT, ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY, analog_swap_subs(), analog_unalloc_sub(), analog_update_conf(), ast_channel_name(), ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_PLAYBACK_BEGIN, ast_copy_string(), ast_debug, ast_log, ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_queue_hold(), ast_queue_unhold(), ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, ast_verb, callwaiting_deluxe_optname(), analog_pvt::channel, CWD_ANNOUNCEMENT, CWD_CONFERENCE, CWD_DROP, CWD_FORWARD, CWD_HOLD, analog_subchannel::inthreeway, LOG_ERROR, LOG_WARNING, analog_pvt::mohsuggest, analog_subchannel::owner, analog_pvt::owner, PATH_MAX, pbx_builtin_getvar_helper(), S_OR, and analog_pvt::subs.

Referenced by analog_handle_dtmf(), and dahdi_write().

◆ analog_cidstart_to_str()

const char * analog_cidstart_to_str ( enum analog_cid_start  cid_start)

Definition at line 253 of file sig_analog.c.

254{
255 switch (cid_start) {
257 return "Ring";
259 return "Polarity";
261 return "Polarity_In";
263 return "DTMF";
264 }
265
266 return "Unknown";
267}

References ANALOG_CID_START_DTMF_NOALERT, ANALOG_CID_START_POLARITY, ANALOG_CID_START_POLARITY_IN, and ANALOG_CID_START_RING.

◆ analog_cidtype_to_str()

const char * analog_cidtype_to_str ( unsigned int  cid_type)

Definition at line 153 of file sig_analog.c.

154{
155 int i;
156
157 for (i = 0; i < ARRAY_LEN(cidtypes); i++) {
158 if (cid_type == cidtypes[i].cid_type) {
159 return cidtypes[i].name;
160 }
161 }
162
163 return "Unknown";
164}
static const struct @147 cidtypes[]
unsigned int cid_type
Definition sig_analog.c:96
#define ARRAY_LEN(a)
Definition utils.h:706

References ARRAY_LEN, cid_type, and cidtypes.

◆ analog_config_complete()

int analog_config_complete ( struct analog_pvt p)

Definition at line 4425 of file sig_analog.c.

4426{
4427 /* No call waiting on non FXS channels */
4428 if (!IS_FXO_SIG(p)) {
4429 p->permcallwaiting = 0;
4430 }
4431
4433
4434 return 0;
4435}
static void analog_set_callwaiting(struct analog_pvt *p, int callwaiting_enable)
Definition sig_analog.c:900
unsigned int permcallwaiting
Definition sig_analog.h:301

References analog_set_callwaiting(), IS_FXO_SIG, and analog_pvt::permcallwaiting.

Referenced by mkintf().

◆ analog_delete()

void analog_delete ( struct analog_pvt doomed)

Delete the analog private structure.

Since
1.8
Parameters
doomedAnalog private structure to delete.

Definition at line 4420 of file sig_analog.c.

4421{
4422 ast_free(doomed);
4423}
#define ast_free(a)
Definition astmm.h:180

References ast_free.

Referenced by destroy_dahdi_pvt().

◆ analog_dnd()

int analog_dnd ( struct analog_pvt p,
int  flag 
)

Definition at line 4481 of file sig_analog.c.

4482{
4483 if (flag == -1) {
4484 return p->dnd;
4485 }
4486
4487 p->dnd = flag;
4488
4489 ast_verb(3, "%s DND on channel %d\n",
4490 flag ? "Enabled" : "Disabled",
4491 p->channel);
4492 analog_publish_dnd_state(p->channel, flag ? "enabled" : "disabled");
4493
4494 return 0;
4495}
long int flag
Definition f2c.h:83
static void analog_publish_dnd_state(int channel, const char *status)

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

Referenced by __analog_ss_thread(), dahdi_dnd(), and dahdichan_write_property().

◆ analog_exception()

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

Definition at line 3988 of file sig_analog.c.

3989{
3990 int res;
3991 int idx;
3992 struct ast_frame *f;
3993
3994 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
3995
3996 idx = analog_get_index(ast, p, 1);
3997 if (idx < 0) {
3998 idx = ANALOG_SUB_REAL;
3999 }
4000
4001 p->subs[idx].f.frametype = AST_FRAME_NULL;
4002 p->subs[idx].f.datalen = 0;
4003 p->subs[idx].f.samples = 0;
4004 p->subs[idx].f.mallocd = 0;
4005 p->subs[idx].f.offset = 0;
4006 p->subs[idx].f.subclass.integer = 0;
4007 p->subs[idx].f.delivery = ast_tv(0,0);
4008 p->subs[idx].f.src = "dahdi_exception";
4009 p->subs[idx].f.data.ptr = NULL;
4010
4011 if (!p->owner) {
4012 /* If nobody owns us, absorb the event appropriately, otherwise
4013 we loop indefinitely. This occurs when, during call waiting, the
4014 other end hangs up our channel so that it no longer exists, but we
4015 have neither FLASH'd nor ONHOOK'd to signify our desire to
4016 change to the other channel. */
4017 res = analog_get_event(p);
4018
4019 /* Switch to real if there is one and this isn't something really silly... */
4020 if ((res != ANALOG_EVENT_RINGEROFF) && (res != ANALOG_EVENT_RINGERON) &&
4021 (res != ANALOG_EVENT_HOOKCOMPLETE)) {
4022 ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
4024 if (p->owner && ast != p->owner) {
4025 /*
4026 * Could this even happen?
4027 * Possible deadlock because we do not have the real-call lock.
4028 */
4029 ast_log(LOG_WARNING, "Event %s on %s is not restored owner %s\n",
4031 }
4032 if (p->owner) {
4034 }
4035 }
4036 switch (res) {
4039 if (p->owner) {
4040 ast_verb(3, "Channel %s still has call, ringing phone\n", ast_channel_name(p->owner));
4041 analog_ring(p);
4043 } else {
4044 ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
4045 analog_event2str(res));
4046 }
4048 break;
4051 analog_off_hook(p);
4052 if (p->owner && (ast_channel_state(p->owner) == AST_STATE_RINGING)) {
4054 analog_set_dialing(p, 0);
4055 }
4056 break;
4060 /* Do nothing */
4061 break;
4063 gettimeofday(&p->flashtime, NULL);
4064 if (p->owner) {
4065 ast_verb(3, "Channel %d flashed to other channel %s\n", p->channel, ast_channel_name(p->owner));
4067 /* Answer if necessary */
4070 }
4073 } else {
4074 ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
4075 analog_event2str(res));
4076 }
4078 break;
4079 default:
4080 ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", analog_event2str(res));
4081 break;
4082 }
4083 f = &p->subs[idx].f;
4084 return f;
4085 }
4086 ast_debug(1, "Exception on %d, channel %d\n", ast_channel_fd(ast, 0), p->channel);
4087 /* If it's not us, return NULL immediately */
4088 if (ast != p->owner) {
4089 ast_log(LOG_WARNING, "We're %s, not %s\n", ast_channel_name(ast), ast_channel_name(p->owner));
4090 f = &p->subs[idx].f;
4091 return f;
4092 }
4093
4094 f = __analog_handle_event(p, ast);
4095 if (!f) {
4096 const char *name = ast_strdupa(ast_channel_name(ast));
4097
4098 /* Tell the CDR this DAHDI device hung up */
4100 ast_channel_unlock(ast);
4101 ast_set_hangupsource(ast, name, 0);
4102 ast_channel_lock(ast);
4104 }
4105 return f;
4106}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
int ast_channel_fd(const struct ast_channel *chan, int which)
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
Definition channel.c:2498
static void analog_unlock_private(struct analog_pvt *p)
Definition sig_analog.c:570
static struct ast_frame * __analog_handle_event(struct analog_pvt *p, struct ast_channel *ast)
static char * analog_event2str(enum analog_event event)
Definition sig_analog.c:269
static void analog_lock_private(struct analog_pvt *p)
Definition sig_analog.c:577
static int analog_get_event(struct analog_pvt *p)
Definition sig_analog.c:198
struct timeval flashtime
Definition sig_analog.h:374
struct ast_frame f
Definition sig_analog.h:265
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
struct timeval delivery
enum ast_frame_type frametype
union ast_frame::@237 data
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Definition time.h:235

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

Referenced by dahdi_exception(), and dahdi_read().

◆ analog_fixup()

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

Definition at line 4443 of file sig_analog.c.

4444{
4445 struct analog_pvt *new_pvt = newp;
4446 int x;
4447 ast_debug(1, "New owner for channel %d is %s\n", new_pvt->channel, ast_channel_name(newchan));
4448 if (new_pvt->owner == oldchan) {
4449 analog_set_new_owner(new_pvt, newchan);
4450 }
4451 for (x = 0; x < 3; x++) {
4452 if (new_pvt->subs[x].owner == oldchan) {
4453 new_pvt->subs[x].owner = newchan;
4454 }
4455 }
4456
4457 analog_update_conf(new_pvt);
4458 return 0;
4459}

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

Referenced by dahdi_fixup().

◆ analog_free()

void analog_free ( struct analog_pvt p)

Definition at line 4437 of file sig_analog.c.

4438{
4439 ast_free(p);
4440}

References ast_free.

◆ analog_handle_dtmf()

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

Definition at line 1768 of file sig_analog.c.

1769{
1770 struct ast_frame *f = *dest;
1771
1772 ast_debug(1, "%s DTMF digit: 0x%02X '%c' on %s\n",
1773 f->frametype == AST_FRAME_DTMF_BEGIN ? "Begin" : "End",
1774 (unsigned)f->subclass.integer, f->subclass.integer, ast_channel_name(ast));
1775
1777 if (f->frametype == AST_FRAME_DTMF_END) {
1778 ast_debug(1, "Confirm answer on %s!\n", ast_channel_name(ast));
1779 /* Upon receiving a DTMF digit, consider this an answer confirmation instead
1780 of a DTMF digit */
1783 /* Reset confirmanswer so DTMF's will behave properly for the duration of the call */
1785 } else {
1786 p->subs[idx].f.frametype = AST_FRAME_NULL;
1787 p->subs[idx].f.subclass.integer = 0;
1788 }
1789 *dest = &p->subs[idx].f;
1790 } else if (p->callwaitcas) {
1791 if (f->frametype == AST_FRAME_DTMF_END) {
1792 if ((f->subclass.integer == 'A') || (f->subclass.integer == 'D')) {
1793 ast_debug(1, "Got some DTMF, but it's for the CAS\n");
1794 p->caller.id.name.str = p->callwait_name;
1796 analog_send_callerid(p, 1, &p->caller);
1797 }
1798 if (analog_handles_digit(f)) {
1799 p->callwaitcas = 0;
1800 }
1801 }
1802 p->subs[idx].f.frametype = AST_FRAME_NULL;
1803 p->subs[idx].f.subclass.integer = 0;
1804 *dest = &p->subs[idx].f;
1805 } else if (p->callwaitingdeluxepending) {
1806 if (f->frametype == AST_FRAME_DTMF_END) {
1807 unsigned int mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime);
1809
1810 /* This is the case where a user explicitly took action (made a decision)
1811 * for Call Waiting Deluxe.
1812 * Because we already handled the hook flash, if the user doesn't do
1813 * anything within a second, then we still need to eventually take
1814 * the default action (swap) for the call waiting.
1815 *
1816 * dahdi_write will also drop audio if callwaitingdeluxepending is set HIGH,
1817 * and also check if flashtime hits 1000, in which case it will set the flag LOW and then take the
1818 * default action, e.g. analog_callwaiting_deluxe(p, 0);
1819 */
1820
1821 /* Slightly less than 1000, so there's no chance of a race condition
1822 * between do_monitor when it sees flashtime hitting 1000 and us. */
1823 if (mssinceflash > 990) {
1824 /* This was more than a second ago, clear the flag and process normally. */
1825 /* Because another thread has to monitor channels with pending CWDs,
1826 * in theory, we shouldn't need to check this here. */
1827 ast_debug(1, "It's been %u ms since the last flash, this is not a Call Waiting Deluxe DTMF\n", mssinceflash);
1828 analog_cb_handle_dtmf(p, ast, idx, dest);
1829 return;
1830 }
1831 /* Okay, actually do something now. */
1832 switch (f->subclass.integer) {
1833 case CWD_CONFERENCE:
1834 case CWD_HOLD:
1835 case CWD_DROP:
1836 case CWD_ANNOUNCEMENT:
1837 case CWD_FORWARD:
1838 ast_debug(1, "Got some DTMF, but it's for Call Waiting Deluxe: %c\n", f->subclass.integer);
1840 break;
1841 default:
1842 ast_log(LOG_WARNING, "Invalid Call Waiting Deluxe option (%c), using default\n", f->subclass.integer);
1844 }
1845 }
1846 p->subs[idx].f.frametype = AST_FRAME_NULL;
1847 p->subs[idx].f.subclass.integer = 0;
1848 *dest = &p->subs[idx].f;
1849 } else {
1850 analog_cb_handle_dtmf(p, ast, idx, dest);
1851 }
1852}
@ AST_FRAME_DTMF_END
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_CONTROL
INT32 integer
Definition lpc10.h:80
static int analog_send_callerid(struct analog_pvt *p, int cwcid, struct ast_party_caller *caller)
Definition sig_analog.c:395
static void analog_set_confirmanswer(struct analog_pvt *p, int flag)
Definition sig_analog.c:955
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:677
int analog_callwaiting_deluxe(struct analog_pvt *p, int option)
static int analog_handles_digit(struct ast_frame *f)
static int analog_check_confirmanswer(struct analog_pvt *p)
Definition sig_analog.c:962
unsigned int callwaitingdeluxepending
TRUE if a Call Waiting Deluxe action is currently pending.
Definition sig_analog.h:356
unsigned int callwaitcas
TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
Definition sig_analog.h:351
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition time.h:107

References analog_callwaiting_deluxe(), analog_cb_handle_dtmf(), analog_check_confirmanswer(), analog_handles_digit(), analog_send_callerid(), analog_set_confirmanswer(), ast_channel_name(), AST_CONTROL_ANSWER, ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_NULL, ast_log, ast_tvdiff_ms(), ast_tvnow(), analog_pvt::caller, analog_pvt::callwait_name, analog_pvt::callwait_num, analog_pvt::callwaitcas, analog_pvt::callwaitingdeluxepending, CWD_ANNOUNCEMENT, CWD_CONFERENCE, CWD_DROP, CWD_FORWARD, CWD_HOLD, analog_subchannel::f, analog_pvt::flashtime, ast_frame::frametype, ast_party_caller::id, ast_frame_subclass::integer, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_name::str, ast_party_number::str, ast_frame::subclass, and analog_pvt::subs.

Referenced by __analog_handle_event(), and dahdi_read().

◆ analog_handle_init_event()

void * analog_handle_init_event ( struct analog_pvt i,
int  event 
)

Definition at line 4108 of file sig_analog.c.

4109{
4110 int res;
4111 pthread_t threadid;
4112 struct ast_channel *chan;
4113 ast_callid callid = 0;
4114 int callid_created;
4115
4116 ast_debug(1, "channel (%d) - signaling (%d) - event (%s)\n",
4118
4119 /* Handle an event on a given channel for the monitor thread. */
4120 switch (event) {
4123 switch (i->sig) {
4124 case ANALOG_SIG_FXSLS:
4125 case ANALOG_SIG_FXSGS:
4126 case ANALOG_SIG_FXSKS:
4127 if (i->immediate) {
4129 ast_log(LOG_WARNING, "Can't start PBX immediately, must wait for Caller ID / distinctive ring\n");
4130 } else {
4131 /* If we don't care about Caller ID or Distinctive Ring, then there's
4132 * no need to wait for anything before accepting the call, as
4133 * waiting will buy us nothing.
4134 * So if the channel is configured for immediate, actually start immediately
4135 * and get the show on the road as soon as possible. */
4136 ast_debug(1, "Disabling ring timeout (previously %d) to begin handling immediately\n", i->ringt_base);
4138 }
4139 }
4140 break;
4141 default:
4142 break;
4143 }
4144 /* Fall through */
4145 if (!(ISTRUNK(i) && i->immediate && !i->use_callerid && !i->usedistinctiveringdetection)) {
4146 break;
4147 }
4149 if (i->inalarm) {
4150 break;
4151 }
4152 /* Got a ring/answer. What kind of channel are we? */
4153 switch (i->sig) {
4154 case ANALOG_SIG_FXOLS:
4155 case ANALOG_SIG_FXOGS:
4156 case ANALOG_SIG_FXOKS:
4157 res = analog_off_hook(i);
4158 i->fxsoffhookstate = 1;
4159 i->cshactive = 0;
4161 if (res && (errno == EBUSY)) {
4162 break;
4163 }
4164 callid_created = ast_callid_threadstorage_auto(&callid);
4165
4166 /* Cancel VMWI spill */
4168
4169 if (i->immediate) {
4171 /* The channel is immediately up. Start right away */
4172 if (i->immediatering) {
4173 /* Play fake ringing, if we've been told to... */
4175 }
4177 if (!chan) {
4178 ast_log(LOG_WARNING, "Unable to start PBX on channel %d\n", i->channel);
4180 if (res < 0) {
4181 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
4182 }
4183 }
4184 } else {
4185 /* Check for callerid, digits, etc */
4187 i->ss_astchan = chan;
4188 if (chan) {
4189 if (analog_has_voicemail(i)) {
4191 } else {
4193 }
4194 if (res < 0)
4195 ast_log(LOG_WARNING, "Unable to play dialtone on channel %d, do you have defaultzone and loadzone defined?\n", i->channel);
4196
4198 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
4200 if (res < 0) {
4201 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
4202 }
4203 ast_hangup(chan);
4204 }
4205 } else
4206 ast_log(LOG_WARNING, "Unable to create channel\n");
4207 }
4209 break;
4210 case ANALOG_SIG_FXSLS:
4211 case ANALOG_SIG_FXSGS:
4212 case ANALOG_SIG_FXSKS:
4214 /* Fall through */
4215 case ANALOG_SIG_EMWINK:
4216 case ANALOG_SIG_FEATD:
4217 case ANALOG_SIG_FEATDMF:
4219 case ANALOG_SIG_E911:
4222 case ANALOG_SIG_FEATB:
4223 case ANALOG_SIG_EM:
4224 case ANALOG_SIG_EM_E1:
4225 case ANALOG_SIG_SFWINK:
4229 case ANALOG_SIG_SF:
4230 callid_created = ast_callid_threadstorage_auto(&callid);
4231 /* Check for callerid, digits, etc */
4234 } else {
4236 }
4237 i->ss_astchan = chan;
4238 if (!chan) {
4239 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
4240 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
4241 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
4243 if (res < 0) {
4244 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
4245 }
4246 ast_hangup(chan);
4247 }
4249 break;
4250 default:
4251 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);
4253 if (res < 0) {
4254 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
4255 }
4256 return NULL;
4257 }
4258 break;
4260 analog_set_alarm(i, 0);
4262 break;
4263 case ANALOG_EVENT_ALARM:
4264 analog_set_alarm(i, 1);
4266 /* fall thru intentionally */
4268 /* Back on hook. Hang up. */
4269 switch (i->sig) {
4270 case ANALOG_SIG_FXOLS:
4271 case ANALOG_SIG_FXOGS:
4272 i->fxsoffhookstate = 0;
4274 /* Fall through */
4275 case ANALOG_SIG_FEATD:
4276 case ANALOG_SIG_FEATDMF:
4278 case ANALOG_SIG_E911:
4281 case ANALOG_SIG_FEATB:
4282 case ANALOG_SIG_EM:
4283 case ANALOG_SIG_EM_E1:
4284 case ANALOG_SIG_EMWINK:
4288 case ANALOG_SIG_SF:
4289 case ANALOG_SIG_SFWINK:
4290 case ANALOG_SIG_FXSLS:
4291 case ANALOG_SIG_FXSGS:
4292 case ANALOG_SIG_FXSKS:
4294 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
4295 analog_on_hook(i);
4296 break;
4297 case ANALOG_SIG_FXOKS:
4298 i->fxsoffhookstate = 0;
4301 /* Diddle the battery for the zhone */
4302#ifdef ZHONE_HACK
4303 analog_off_hook(i);
4304 usleep(1);
4305#endif
4306 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
4307 analog_on_hook(i);
4308 break;
4309 default:
4310 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);
4311 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
4312 return NULL;
4313 }
4314 break;
4316 switch (i->sig) {
4317 case ANALOG_SIG_FXSLS:
4318 case ANALOG_SIG_FXSKS:
4319 case ANALOG_SIG_FXSGS:
4320 callid_created = ast_callid_threadstorage_auto(&callid);
4321 /* We have already got a PR before the channel was
4322 created, but it wasn't handled. We need polarity
4323 to be REV for remote hangup detection to work.
4324 At least in Spain */
4325 if (i->hanguponpolarityswitch) {
4327 }
4330 ast_verb(2, "Starting post polarity CID detection on channel %d\n",
4331 i->channel);
4333 i->ss_astchan = chan;
4334 if (!chan) {
4335 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
4336 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
4337 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
4338 ast_hangup(chan);
4339 }
4340 }
4342 break;
4343 default:
4345 "handle_init_event detected polarity reversal on non-FXO (ANALOG_SIG_FXS) interface %d\n",
4346 i->channel);
4347 break;
4348 }
4349 break;
4351 switch (i->sig) {
4352 case ANALOG_SIG_FXSLS:
4353 case ANALOG_SIG_FXSKS:
4354 case ANALOG_SIG_FXSGS:
4355 callid_created = ast_callid_threadstorage_auto(&callid);
4357 ast_verb(2, "Starting DTMF CID detection on channel %d\n",
4358 i->channel);
4360 i->ss_astchan = chan;
4361 if (!chan) {
4362 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
4363 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
4364 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
4365 ast_hangup(chan);
4366 }
4367 }
4369 break;
4370 default:
4372 "handle_init_event detected dtmfcid generation event on non-FXO (ANALOG_SIG_FXS) interface %d\n",
4373 i->channel);
4374 break;
4375 }
4376 break;
4377 case ANALOG_EVENT_REMOVED: /* destroy channel, will actually do so in do_monitor */
4378 ast_log(LOG_NOTICE, "Got ANALOG_EVENT_REMOVED. Destroying channel %d\n",
4379 i->channel);
4380 return i->chan_pvt;
4383 break;
4386 break;
4387 }
4388 return NULL;
4389}
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition channel.c:2540
@ AST_STATE_RING
@ AST_STATE_PRERING
void ast_callid_threadstorage_auto_clean(ast_callid callid, int callid_created)
Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was...
Definition logger.c:2367
unsigned int ast_callid
int ast_callid_threadstorage_auto(ast_callid *callid)
Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will b...
Definition logger.c:2345
#define LOG_NOTICE
static void analog_publish_channel_alarm_clear(int channel)
static void analog_set_alarm(struct analog_pvt *p, int in_alarm)
Definition sig_analog.c:923
static int analog_handle_notify_message(struct ast_channel *chan, struct analog_pvt *p, int cid_flags, int neon_mwievent)
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:464
static void * __analog_ss_thread(void *data)
static void analog_get_and_handle_alarms(struct analog_pvt *p)
static int analog_has_voicemail(struct analog_pvt *p)
Definition sig_analog.c:692
#define ISTRUNK(p)
Whether a channel is FXS signaled.
Definition sig_analog.c:108
const char * analog_sigtype_to_str(enum analog_sigtype sigtype)
Definition sig_analog.c:127
static void analog_cancel_cidspill(struct analog_pvt *p)
Definition sig_analog.c:971
#define POLARITY_REV
Definition sig_analog.c:63
static void analog_start_polarityswitch(struct analog_pvt *p)
Definition sig_analog.c:649
unsigned int immediate
Definition sig_analog.h:298
unsigned int immediatering
Definition sig_analog.h:299
void * chan_pvt
Definition sig_analog.h:275
unsigned int usedistinctiveringdetection
Definition sig_analog.h:311
enum analog_cid_start cid_start
Definition sig_analog.h:329
int fxsoffhookstate
Definition sig_analog.h:282
unsigned int inalarm
Definition sig_analog.h:344
struct ast_channel * ss_astchan
Definition sig_analog.h:382
Main Channel structure associated with a channel.
ast_callid callid
#define ast_pthread_create_detached(a, b, c, d)
Definition utils.h:628

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

Referenced by do_monitor().

◆ analog_hangup()

int analog_hangup ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 1297 of file sig_analog.c.

1298{
1299 int res;
1300 int idx, x;
1301
1302 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
1303 if (!ast_channel_tech_pvt(ast)) {
1304 ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
1305 return 0;
1306 }
1307
1308 idx = analog_get_index(ast, p, 1);
1309
1310 x = 0;
1311 if (p->origcid_num) {
1312 ast_copy_string(p->cid_num, p->origcid_num, sizeof(p->cid_num));
1314 p->origcid_num = NULL;
1315 }
1316 if (p->origcid_name) {
1317 ast_copy_string(p->cid_name, p->origcid_name, sizeof(p->cid_name));
1319 p->origcid_name = NULL;
1320 }
1321
1323
1324 ast_debug(1, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
1326 if (idx > -1) {
1327 /* Real channel, do some fixup */
1328 p->cshactive = 0;
1329 p->subs[idx].owner = NULL;
1331 analog_set_linear_mode(p, idx, 0);
1332 switch (idx) {
1333 case ANALOG_SUB_REAL:
1335 ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
1337 /* We had flipped over to answer a callwait and now it's gone */
1338 ast_debug(1, "We were flipped over to the callwait, moving back and not owning.\n");
1339 /* Move to the call-wait, but un-own us until they flip back. */
1343 } else {
1344 /* The three way hung up, but we still have a call wait */
1345 ast_debug(1, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
1349 /* This was part of a three way call. Immediately make way for
1350 another call */
1351 ast_debug(1, "Call was complete, setting owner to former third call\n");
1354 } else {
1355 /* This call hasn't been completed yet... Set owner to NULL */
1356 ast_debug(1, "Call was incomplete, setting owner to NULL\n");
1358 }
1359 }
1360 } else if (p->subs[ANALOG_SUB_CALLWAIT].allocd) {
1361 /* Need to hold the lock for real-call, private, and call-waiting call */
1363 if (!p->subs[ANALOG_SUB_CALLWAIT].owner) {
1364 /* The call waiting call disappeared. */
1366 break;
1367 }
1368
1369 /* Move to the call-wait and switch back to them. */
1375 }
1377 /* Unlock the call-waiting call that we swapped to real-call. */
1379 } else if (p->subs[ANALOG_SUB_THREEWAY].allocd) {
1383 /* This was part of a three way call. Immediately make way for
1384 another call */
1385 ast_debug(1, "Call was complete, setting owner to former third call\n");
1388 } else {
1389 /* This call hasn't been completed yet... Set owner to NULL */
1390 ast_debug(1, "Call was incomplete, setting owner to NULL\n");
1392 }
1393 }
1394 break;
1396 /* Ditch the holding callwait call, and immediately make it available */
1398 /* Need to hold the lock for call-waiting call, private, and 3-way call */
1400
1401 /* This is actually part of a three way, placed on hold. Place the third part
1402 on music on hold now */
1403 if (p->subs[ANALOG_SUB_THREEWAY].owner) {
1405 }
1407 /* Make it the call wait now */
1410 if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
1411 /* Unlock the 3-way call that we swapped to call-waiting call. */
1413 }
1414 } else {
1416 }
1417 break;
1419 /* Need to hold the lock for 3-way call, private, and call-waiting call */
1422 /* The other party of the three way call is currently in a call-wait state.
1423 Start music on hold for them, and take the main guy out of the third call */
1425 if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
1427 }
1428 }
1429 if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
1431 }
1433 /* If this was part of a three way call index, let us make
1434 another three way call */
1436 break;
1437 default:
1438 /*
1439 * Should never happen.
1440 * This wasn't any sort of call, so how are we an index?
1441 */
1442 ast_log(LOG_ERROR, "Index found but not any type of call?\n");
1443 break;
1444 }
1445 }
1446
1452 analog_set_outgoing(p, 0);
1453 p->onhooktime = time(NULL);
1454 p->cidrings = 1;
1455
1456 /* Perform low level hangup if no owner left */
1457 res = analog_on_hook(p);
1458 if (res < 0) {
1459 ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast_channel_name(ast));
1460 }
1461 switch (p->sig) {
1462 case ANALOG_SIG_FXOGS:
1463 case ANALOG_SIG_FXOLS:
1464 case ANALOG_SIG_FXOKS:
1465 /* If they're off hook, try playing congestion */
1466 if (analog_is_off_hook(p)) {
1469 } else {
1471 }
1472 break;
1473 case ANALOG_SIG_FXSGS:
1474 case ANALOG_SIG_FXSLS:
1475 case ANALOG_SIG_FXSKS:
1476 /* Make sure we're not made available for at least two seconds assuming
1477 we were actually used for an inbound or outbound call. */
1479 time(&p->guardtime);
1480 p->guardtime += 2;
1481 }
1482 break;
1483 default:
1485 break;
1486 }
1487
1489
1490 x = 0;
1491 ast_channel_setoption(ast,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0);
1492 ast_channel_setoption(ast,AST_OPTION_TDD,&x,sizeof(char),0);
1493 p->callwaitcas = 0;
1495 /* In theory, the below is not necessary since we set hidecallerid = permhidecaller when calls start,
1496 * but this ensures the setting is defaulted properly when channels are idle, too. */
1498 analog_set_dialing(p, 0);
1501 }
1502
1504
1505 ast_verb(3, "Hanging up on '%s'\n", ast_channel_name(ast));
1506
1507 return 0;
1508}
void * ast_channel_tech_pvt(const struct ast_channel *chan)
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:7458
#define AST_OPTION_TONE_VERIFY
#define AST_OPTION_TDD
static int analog_set_linear_mode(struct analog_pvt *p, enum analog_sub sub, int linear_mode)
Definition sig_analog.c:993
static void analog_hangup_polarityswitch(struct analog_pvt *p)
Definition sig_analog.c:662
static int analog_dsp_set_digitmode(struct analog_pvt *p, enum analog_dsp_digitmode mode)
Definition sig_analog.c:669
static void analog_set_pulsedial(struct analog_pvt *p, int flag)
Definition sig_analog.c:986
#define POLARITY_IDLE
Definition sig_analog.c:62
static void analog_all_subchannels_hungup(struct analog_pvt *p)
Definition sig_analog.c:563
char cid_num[AST_MAX_EXTENSION]
Definition sig_analog.h:331
unsigned int permhidecallerid
Definition sig_analog.h:303
char * origcid_name
Definition sig_analog.h:378
char * origcid_num
Definition sig_analog.h:377
unsigned int hidecallerid
Definition sig_analog.h:342
char cid_name[AST_MAX_EXTENSION]
Definition sig_analog.h:332

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

Referenced by dahdi_hangup().

◆ analog_new()

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

Definition at line 4392 of file sig_analog.c.

4393{
4394 struct analog_pvt *p;
4395
4396 p = ast_calloc(1, sizeof(*p));
4397 if (!p) {
4398 return p;
4399 }
4400
4402 p->sig = signallingtype;
4403 p->chan_pvt = private_data;
4404
4405 /* Some defaults for values */
4408 /* Sub real is assumed to always be alloc'd */
4409 p->subs[ANALOG_SUB_REAL].allocd = 1;
4410
4411 return p;
4412}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition astmm.h:202
#define CID_SIG_BELL
Definition callerid.h:60
int cid_signalling
Definition sig_analog.h:326

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

Referenced by mkintf().

◆ analog_request()

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

Definition at line 780 of file sig_analog.c.

781{
782 struct ast_channel *ast;
783
784 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
785 *callwait = (p->owner != NULL);
786
787 if (p->owner) {
789 ast_log(LOG_ERROR, "Unable to alloc subchannel\n");
790 return NULL;
791 }
792 }
793
796 p->owner ? ANALOG_SUB_CALLWAIT : ANALOG_SUB_REAL, requestor);
797 if (!ast) {
799 }
800 return ast;
801}

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

Referenced by dahdi_request().

◆ analog_sigtype_to_str()

const char * analog_sigtype_to_str ( enum analog_sigtype  sigtype)

Definition at line 127 of file sig_analog.c.

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

References ARRAY_LEN, sigtype, and sigtypes.

Referenced by __analog_ss_thread(), and analog_handle_init_event().

◆ analog_ss_thread_start()

int analog_ss_thread_start ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 3047 of file sig_analog.c.

3048{
3049 pthread_t threadid;
3050
3051 p->ss_astchan = chan;
3053}

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

Referenced by mwi_thread().

◆ analog_str_to_cidstart()

enum analog_cid_start analog_str_to_cidstart ( const char *  value)

Definition at line 238 of file sig_analog.c.

239{
240 if (!strcasecmp(value, "ring")) {
242 } else if (!strcasecmp(value, "polarity")) {
244 } else if (!strcasecmp(value, "polarity_in")) {
246 } else if (!strcasecmp(value, "dtmf")) {
248 }
249
250 return 0;
251}
int value
Definition syslog.c:37

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

◆ analog_str_to_cidtype()

unsigned int analog_str_to_cidtype ( const char *  name)

Definition at line 140 of file sig_analog.c.

141{
142 int i;
143
144 for (i = 0; i < ARRAY_LEN(cidtypes); i++) {
145 if (!strcasecmp(cidtypes[i].name, name)) {
146 return cidtypes[i].cid_type;
147 }
148 }
149
150 return 0;
151}

References ARRAY_LEN, cidtypes, and name.

◆ analog_str_to_sigtype()

enum analog_sigtype analog_str_to_sigtype ( const char *  name)

Definition at line 114 of file sig_analog.c.

115{
116 int i;
117
118 for (i = 0; i < ARRAY_LEN(sigtypes); i++) {
119 if (!strcasecmp(sigtypes[i].name, name)) {
120 return sigtypes[i].sigtype;
121 }
122 }
123
124 return 0;
125}

References ARRAY_LEN, name, and sigtypes.

Variable Documentation

◆ analog_callbacks

struct analog_callback analog_callbacks
extern

Global analog callbacks to the upper layer.

Definition at line 3670 of file chan_dahdi.c.

3671{
3672 .play_tone = my_play_tone,
3673 .get_event = my_get_event,
3674 .wait_event = my_wait_event,
3675 .is_off_hook = my_is_off_hook,
3676 .set_echocanceller = my_set_echocanceller,
3677 .ring = my_ring,
3678 .flash = my_flash,
3679 .off_hook = my_off_hook,
3680 .dial_digits = my_dial_digits,
3681 .train_echocanceller = my_train_echocanceller,
3682 .on_hook = my_on_hook,
3683 .is_dialing = my_is_dialing,
3684 .allocate_sub = my_allocate_sub,
3685 .unallocate_sub = my_unallocate_sub,
3686 .swap_subs = my_swap_subchannels,
3687 .has_voicemail = my_has_voicemail,
3688 .check_for_conference = my_check_for_conference,
3689 .conf_add = my_conf_add,
3690 .conf_del = my_conf_del,
3691 .complete_conference_update = my_complete_conference_update,
3692 .start = my_start,
3693 .all_subchannels_hungup = my_all_subchannels_hungup,
3694 .lock_private = my_lock_private,
3695 .unlock_private = my_unlock_private,
3696 .deadlock_avoidance_private = my_deadlock_avoidance_private,
3697 .handle_dtmf = my_handle_dtmf,
3698 .wink = my_wink,
3699 .new_ast_channel = my_new_analog_ast_channel,
3700 .dsp_set_digitmode = my_dsp_set_digitmode,
3701 .dsp_reset_and_flush_digits = my_dsp_reset_and_flush_digits,
3702 .send_callerid = my_send_callerid,
3703 .callwait = my_callwait,
3704 .stop_callwait = my_stop_callwait,
3705 .get_callerid = my_get_callerid,
3706 .start_cid_detect = my_start_cid_detect,
3707 .stop_cid_detect = my_stop_cid_detect,
3708 .handle_notify_message = my_handle_notify_message,
3709 .increase_ss_count = my_increase_ss_count,
3710 .decrease_ss_count = my_decrease_ss_count,
3711 .distinctive_ring = my_distinctive_ring,
3712 .set_linear_mode = my_set_linear_mode,
3713 .set_inthreeway = my_set_inthreeway,
3714 .get_and_handle_alarms = my_get_and_handle_alarms,
3715 .get_sigpvt_bridged_channel = my_get_sigpvt_bridged_channel,
3716 .get_sub_fd = my_get_sub_fd,
3717 .set_cadence = my_set_cadence,
3718 .set_alarm = my_set_alarm,
3719 .set_dialing = my_set_dialing,
3720 .set_outgoing = my_set_outgoing,
3721 .set_ringtimeout = my_set_ringtimeout,
3722 .set_waitingfordt = my_set_waitingfordt,
3723 .check_waitingfordt = my_check_waitingfordt,
3724 .set_confirmanswer = my_set_confirmanswer,
3725 .check_confirmanswer = my_check_confirmanswer,
3726 .set_callwaiting = my_set_callwaiting,
3727 .cancel_cidspill = my_cancel_cidspill,
3728 .confmute = my_confmute,
3729 .set_pulsedial = my_set_pulsedial,
3730 .set_new_owner = my_set_new_owner,
3731 .get_orig_dialstring = my_get_orig_dialstring,
3732 .set_needringing = my_set_needringing,
3733 .set_polarity = my_set_polarity,
3734 .start_polarityswitch = my_start_polarityswitch,
3735 .answer_polarityswitch = my_answer_polarityswitch,
3736 .hangup_polarityswitch = my_hangup_polarityswitch,
3737 .have_progressdetect = my_have_progressdetect,
3738 .get_firstdigit_timeout = my_get_firstdigit_timeout,
3739 .get_matchdigit_timeout = my_get_matchdigit_timeout,
3740 .get_interdigit_timeout = my_get_interdigit_timeout,
3741};
static void my_set_new_owner(void *pvt, struct ast_channel *new_owner)
static void my_set_confirmanswer(void *pvt, int flag)
static int my_callwait(void *pvt)
static int my_check_confirmanswer(void *pvt)
static int my_is_dialing(void *pvt, enum analog_sub sub)
static int my_dial_digits(void *pvt, enum analog_sub sub, struct analog_dialoperation *dop)
static void my_cancel_cidspill(void *pvt)
static int my_set_echocanceller(void *pvt, int enable)
static void my_hangup_polarityswitch(void *pvt)
static int my_stop_cid_detect(void *pvt)
static int my_get_sub_fd(void *pvt, enum analog_sub sub)
static void my_set_needringing(void *pvt, int value)
static void my_unlock_private(void *pvt)
static void my_set_dialing(void *pvt, int is_dialing)
static void my_handle_dtmf(void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest)
static int my_on_hook(void *pvt)
static void my_set_pulsedial(void *pvt, int flag)
static int my_unallocate_sub(void *pvt, enum analog_sub analogsub)
static void my_set_alarm(void *pvt, int in_alarm)
static int my_dsp_set_digitmode(void *pvt, enum analog_dsp_digitmode mode)
static int my_get_event(void *pvt)
static void my_set_callwaiting(void *pvt, int callwaiting_enable)
static int my_is_off_hook(void *pvt)
static int my_check_waitingfordt(void *pvt)
static void my_set_outgoing(void *pvt, int is_outgoing)
static void my_set_inthreeway(void *pvt, enum analog_sub sub, int inthreeway)
static void my_swap_subchannels(void *pvt, enum analog_sub a, struct ast_channel *ast_a, enum analog_sub b, struct ast_channel *ast_b)
static void my_get_and_handle_alarms(void *pvt)
static void my_lock_private(void *pvt)
static int my_stop_callwait(void *pvt)
static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int *ringdata)
static void my_handle_notify_message(struct ast_channel *chan, void *pvt, int cid_flags, int neon_mwievent)
static int my_confmute(void *pvt, int mute)
static int my_send_callerid(void *pvt, int cwcid, struct ast_party_caller *caller)
static void my_decrease_ss_count(void)
static void my_start_polarityswitch(void *pvt)
static int my_wait_event(void *pvt)
static struct ast_channel * my_new_analog_ast_channel(void *pvt, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
static int my_get_callerid(void *pvt, char *namebuf, char *numbuf, enum analog_event *ev, size_t timeout)
static int my_start(void *pvt)
static void my_answer_polarityswitch(void *pvt)
static int my_have_progressdetect(void *pvt)
static int my_train_echocanceller(void *pvt)
static void my_set_polarity(void *pvt, int value)
static int my_set_linear_mode(void *pvt, enum analog_sub sub, int linear_mode)
static void my_all_subchannels_hungup(void *pvt)
static int my_ring(void *pvt)
static int my_start_cid_detect(void *pvt, int cid_signalling)
static int my_complete_conference_update(void *pvt, int needconference)
static void my_set_cadence(void *pvt, int *cid_rings, struct ast_channel *ast)
static void my_increase_ss_count(void)
static int my_play_tone(void *pvt, enum analog_sub sub, enum analog_tone tone)
static int my_wink(void *pvt, enum analog_sub sub)
static int my_conf_add(void *pvt, enum analog_sub sub)
static int my_dsp_reset_and_flush_digits(void *pvt)
static int my_has_voicemail(void *pvt)
static const char * my_get_orig_dialstring(void *pvt)
static int my_conf_del(void *pvt, enum analog_sub sub)
static int my_off_hook(void *pvt)
static int my_allocate_sub(void *pvt, enum analog_sub analogsub)
static void * my_get_sigpvt_bridged_channel(struct ast_channel *chan)
static void my_set_waitingfordt(void *pvt, struct ast_channel *ast)
static int my_check_for_conference(void *pvt)
static int my_flash(void *pvt)
static void my_deadlock_avoidance_private(void *pvt)
static void my_set_ringtimeout(void *pvt, int ringt)

Referenced by analog_all_subchannels_hungup(), analog_alloc_sub(), analog_answer_polarityswitch(), analog_callwait(), analog_cancel_cidspill(), analog_cb_handle_dtmf(), analog_check_confirmanswer(), analog_check_for_conference(), analog_check_waitingfordt(), analog_confmute(), analog_deadlock_avoidance_private(), analog_decrease_ss_count(), analog_dial_digits(), analog_distinctive_ring(), analog_dsp_reset_and_flush_digits(), analog_dsp_set_digitmode(), analog_flash(), analog_get_and_handle_alarms(), analog_get_bridged_channel(), analog_get_callerid(), analog_get_event(), analog_get_orig_dialstring(), analog_get_sub_fd(), analog_handle_notify_message(), analog_hangup_polarityswitch(), analog_has_voicemail(), analog_have_progressdetect(), analog_increase_ss_count(), analog_is_dialing(), analog_is_off_hook(), analog_lock_private(), analog_new_ast_channel(), analog_off_hook(), analog_on_hook(), analog_play_tone(), analog_ring(), analog_send_callerid(), analog_set_alarm(), analog_set_cadence(), analog_set_callwaiting(), analog_set_confirmanswer(), analog_set_dialing(), analog_set_echocanceller(), analog_set_inthreeway(), analog_set_linear_mode(), analog_set_needringing(), analog_set_new_owner(), analog_set_outgoing(), analog_set_pulsedial(), analog_set_ringtimeout(), analog_set_waitingfordt(), analog_start(), analog_start_cid_detect(), analog_start_polarityswitch(), analog_stop_callwait(), analog_stop_cid_detect(), analog_swap_subs(), analog_train_echocanceller(), analog_unalloc_sub(), analog_unlock_private(), analog_update_conf(), analog_wait_event(), and analog_wink().