Asterisk - The Open Source Telephony Project GIT-master-3dae2cf
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. More...
 
#define ANALOG_INTER_DIGIT_TIMEOUT   8000
 Default time (ms) to detect following digits. More...
 
#define ANALOG_MATCH_DIGIT_TIMEOUT   3000
 Default time (ms) to wait, in case of ambiguous match. More...
 
#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)
 
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, 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 1490 of file sig_analog.c.

1491{
1492 int res = 0;
1493 int idx;
1494 int oldstate = ast_channel_state(ast);
1495
1496 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
1498 idx = analog_get_index(ast, p, 1);
1499 if (idx < 0) {
1500 idx = ANALOG_SUB_REAL;
1501 }
1502 switch (p->sig) {
1503 case ANALOG_SIG_FXSLS:
1504 case ANALOG_SIG_FXSGS:
1505 case ANALOG_SIG_FXSKS:
1507 /* Fall through */
1508 case ANALOG_SIG_EM:
1509 case ANALOG_SIG_EM_E1:
1510 case ANALOG_SIG_EMWINK:
1511 case ANALOG_SIG_FEATD:
1512 case ANALOG_SIG_FEATDMF:
1514 case ANALOG_SIG_E911:
1517 case ANALOG_SIG_FEATB:
1518 case ANALOG_SIG_SF:
1519 case ANALOG_SIG_SFWINK:
1523 case ANALOG_SIG_FXOLS:
1524 case ANALOG_SIG_FXOGS:
1525 case ANALOG_SIG_FXOKS:
1526 /* Pick up the line */
1527 ast_debug(1, "Took %s off hook\n", ast_channel_name(ast));
1528 if (p->hanguponpolarityswitch) {
1529 gettimeofday(&p->polaritydelaytv, NULL);
1530 }
1531 res = analog_off_hook(p);
1532 analog_play_tone(p, idx, -1);
1533 analog_set_dialing(p, 0);
1534 if ((idx == ANALOG_SUB_REAL) && p->subs[ANALOG_SUB_THREEWAY].inthreeway) {
1535 if (oldstate == AST_STATE_RINGING) {
1536 ast_debug(1, "Finally swapping real and threeway\n");
1540 }
1541 }
1542
1543 switch (p->sig) {
1544 case ANALOG_SIG_FXSLS:
1545 case ANALOG_SIG_FXSKS:
1546 case ANALOG_SIG_FXSGS:
1549 break;
1550 case ANALOG_SIG_FXOLS:
1551 case ANALOG_SIG_FXOKS:
1552 case ANALOG_SIG_FXOGS:
1554 break;
1555 default:
1556 break;
1557 }
1558 break;
1559 default:
1560 ast_log(LOG_WARNING, "Don't know how to answer signalling %d (channel %d)\n", p->sig, p->channel);
1561 res = -1;
1562 break;
1563 }
1565 return res;
1566}
#define ast_log
Definition: astobj2.c:42
const char * ast_channel_name(const struct ast_channel *chan)
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_RINGING
Definition: channelstate.h:41
@ AST_STATE_UP
Definition: channelstate.h:42
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7408
#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:446
static int analog_train_echocanceller(struct analog_pvt *p)
Definition: sig_analog.c:481
static void analog_set_dialing(struct analog_pvt *p, int is_dialing)
Definition: sig_analog.c:895
static void analog_set_ringtimeout(struct analog_pvt *p, int ringt)
Definition: sig_analog.c:911
#define analog_get_index(ast, p, nullok)
Definition: sig_analog.c:407
static void analog_answer_polarityswitch(struct analog_pvt *p)
Definition: sig_analog.c:645
static int analog_off_hook(struct analog_pvt *p)
Definition: sig_analog.c:615
static int analog_play_tone(struct analog_pvt *p, enum analog_sub sub, enum analog_tone tone)
Definition: sig_analog.c:438
static int analog_set_echocanceller(struct analog_pvt *p, int enable)
Definition: sig_analog.c:473
static void analog_swap_subs(struct analog_pvt *p, enum analog_sub a, enum analog_sub b)
Definition: sig_analog.c:348
struct timeval polaritydelaytv
Definition: sig_analog.h:361
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 793 of file sig_analog.c.

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

Referenced by available().

◆ analog_call()

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

Definition at line 990 of file sig_analog.c.

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

const char * analog_cidstart_to_str ( enum analog_cid_start  cid_start)

Definition at line 249 of file sig_analog.c.

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

References ANALOG_CID_START_DTMF_NOALERT, ANALOG_CID_START_POLARITY, ANALOG_CID_START_POLARITY_IN, and ANALOG_CID_START_RING.

◆ analog_cidtype_to_str()

const char * analog_cidtype_to_str ( unsigned int  cid_type)

Definition at line 149 of file sig_analog.c.

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

References ARRAY_LEN, cid_type, and cidtypes.

◆ analog_config_complete()

int analog_config_complete ( struct analog_pvt p)

Definition at line 4114 of file sig_analog.c.

4115{
4116 /* No call waiting on non FXS channels */
4117 if ((p->sig != ANALOG_SIG_FXOKS) && (p->sig != ANALOG_SIG_FXOLS) && (p->sig != ANALOG_SIG_FXOGS)) {
4118 p->permcallwaiting = 0;
4119 }
4120
4122
4123 return 0;
4124}
static void analog_set_callwaiting(struct analog_pvt *p, int callwaiting_enable)
Definition: sig_analog.c:880
unsigned int permcallwaiting
Definition: sig_analog.h:300

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

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 4109 of file sig_analog.c.

4110{
4111 ast_free(doomed);
4112}
#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 4170 of file sig_analog.c.

4171{
4172 if (flag == -1) {
4173 return p->dnd;
4174 }
4175
4176 p->dnd = flag;
4177
4178 ast_verb(3, "%s DND on channel %d\n",
4179 flag ? "Enabled" : "Disabled",
4180 p->channel);
4181 analog_publish_dnd_state(p->channel, flag ? "enabled" : "disabled");
4182
4183 return 0;
4184}
long int flag
Definition: f2c.h:83
#define ast_verb(level,...)
static void analog_publish_dnd_state(int channel, const char *status)
Definition: sig_analog.c:4150

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

Referenced by __analog_ss_thread(), and dahdi_dnd().

◆ analog_exception()

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

Definition at line 3678 of file sig_analog.c.

3679{
3680 int res;
3681 int idx;
3682 struct ast_frame *f;
3683
3684 ast_debug(1, "%s %d\n", __FUNCTION__, p->channel);
3685
3686 idx = analog_get_index(ast, p, 1);
3687 if (idx < 0) {
3688 idx = ANALOG_SUB_REAL;
3689 }
3690
3691 p->subs[idx].f.frametype = AST_FRAME_NULL;
3692 p->subs[idx].f.datalen = 0;
3693 p->subs[idx].f.samples = 0;
3694 p->subs[idx].f.mallocd = 0;
3695 p->subs[idx].f.offset = 0;
3696 p->subs[idx].f.subclass.integer = 0;
3697 p->subs[idx].f.delivery = ast_tv(0,0);
3698 p->subs[idx].f.src = "dahdi_exception";
3699 p->subs[idx].f.data.ptr = NULL;
3700
3701 if (!p->owner) {
3702 /* If nobody owns us, absorb the event appropriately, otherwise
3703 we loop indefinitely. This occurs when, during call waiting, the
3704 other end hangs up our channel so that it no longer exists, but we
3705 have neither FLASH'd nor ONHOOK'd to signify our desire to
3706 change to the other channel. */
3707 res = analog_get_event(p);
3708
3709 /* Switch to real if there is one and this isn't something really silly... */
3710 if ((res != ANALOG_EVENT_RINGEROFF) && (res != ANALOG_EVENT_RINGERON) &&
3711 (res != ANALOG_EVENT_HOOKCOMPLETE)) {
3712 ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
3714 if (p->owner && ast != p->owner) {
3715 /*
3716 * Could this even happen?
3717 * Possible deadlock because we do not have the real-call lock.
3718 */
3719 ast_log(LOG_WARNING, "Event %s on %s is not restored owner %s\n",
3721 }
3722 if (p->owner) {
3724 }
3725 }
3726 switch (res) {
3729 if (p->owner) {
3730 ast_verb(3, "Channel %s still has call, ringing phone\n", ast_channel_name(p->owner));
3731 analog_ring(p);
3733 } else {
3734 ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
3735 analog_event2str(res));
3736 }
3738 break;
3741 analog_off_hook(p);
3742 if (p->owner && (ast_channel_state(p->owner) == AST_STATE_RINGING)) {
3744 analog_set_dialing(p, 0);
3745 }
3746 break;
3750 /* Do nothing */
3751 break;
3753 gettimeofday(&p->flashtime, NULL);
3754 if (p->owner) {
3755 ast_verb(3, "Channel %d flashed to other channel %s\n", p->channel, ast_channel_name(p->owner));
3757 /* Answer if necessary */
3760 }
3763 } else {
3764 ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
3765 analog_event2str(res));
3766 }
3768 break;
3769 default:
3770 ast_log(LOG_WARNING, "Don't know how to absorb event %s\n", analog_event2str(res));
3771 break;
3772 }
3773 f = &p->subs[idx].f;
3774 return f;
3775 }
3776 ast_debug(1, "Exception on %d, channel %d\n", ast_channel_fd(ast, 0), p->channel);
3777 /* If it's not us, return NULL immediately */
3778 if (ast != p->owner) {
3779 ast_log(LOG_WARNING, "We're %s, not %s\n", ast_channel_name(ast), ast_channel_name(p->owner));
3780 f = &p->subs[idx].f;
3781 return f;
3782 }
3783
3784 f = __analog_handle_event(p, ast);
3785 if (!f) {
3786 const char *name = ast_strdupa(ast_channel_name(ast));
3787
3788 /* Tell the CDR this DAHDI device hung up */
3790 ast_channel_unlock(ast);
3791 ast_set_hangupsource(ast, name, 0);
3792 ast_channel_lock(ast);
3794 }
3795 return f;
3796}
#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:2518
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Definition: channel.c:1235
@ AST_FRAME_NULL
@ AST_CONTROL_ANSWER
static int analog_update_conf(struct analog_pvt *p)
Definition: sig_analog.c:743
static void analog_unlock_private(struct analog_pvt *p)
Definition: sig_analog.c:560
static struct ast_frame * __analog_handle_event(struct analog_pvt *p, struct ast_channel *ast)
Definition: sig_analog.c:2778
static char * analog_event2str(enum analog_event event)
Definition: sig_analog.c:265
static void analog_lock_private(struct analog_pvt *p)
Definition: sig_analog.c:567
static int analog_stop_callwait(struct analog_pvt *p)
Definition: sig_analog.c:862
static int analog_get_event(struct analog_pvt *p)
Definition: sig_analog.c:194
struct timeval flashtime
Definition: sig_analog.h:364
struct ast_frame f
Definition: sig_analog.h:265
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
struct timeval delivery
enum ast_frame_type frametype
const char * src
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 4132 of file sig_analog.c.

4133{
4134 struct analog_pvt *new_pvt = newp;
4135 int x;
4136 ast_debug(1, "New owner for channel %d is %s\n", new_pvt->channel, ast_channel_name(newchan));
4137 if (new_pvt->owner == oldchan) {
4138 analog_set_new_owner(new_pvt, newchan);
4139 }
4140 for (x = 0; x < 3; x++) {
4141 if (new_pvt->subs[x].owner == oldchan) {
4142 new_pvt->subs[x].owner = newchan;
4143 }
4144 }
4145
4146 analog_update_conf(new_pvt);
4147 return 0;
4148}

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 4126 of file sig_analog.c.

4127{
4128 ast_free(p);
4129}

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 1593 of file sig_analog.c.

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

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

Referenced by __analog_handle_event(), and dahdi_read().

◆ analog_handle_init_event()

void * analog_handle_init_event ( struct analog_pvt i,
int  event 
)

Definition at line 3798 of file sig_analog.c.

3799{
3800 int res;
3801 pthread_t threadid;
3802 struct ast_channel *chan;
3803 ast_callid callid = 0;
3804 int callid_created;
3805
3806 ast_debug(1, "channel (%d) - signaling (%d) - event (%s)\n",
3808
3809 /* Handle an event on a given channel for the monitor thread. */
3810 switch (event) {
3813 switch (i->sig) {
3814 case ANALOG_SIG_FXSLS:
3815 case ANALOG_SIG_FXSGS:
3816 case ANALOG_SIG_FXSKS:
3817 if (i->immediate) {
3819 ast_log(LOG_WARNING, "Can't start PBX immediately, must wait for Caller ID / distinctive ring\n");
3820 } else {
3821 /* If we don't care about Caller ID or Distinctive Ring, then there's
3822 * no need to wait for anything before accepting the call, as
3823 * waiting will buy us nothing.
3824 * So if the channel is configured for immediate, actually start immediately
3825 * and get the show on the road as soon as possible. */
3826 ast_debug(1, "Disabling ring timeout (previously %d) to begin handling immediately\n", i->ringt_base);
3828 }
3829 }
3830 break;
3831 default:
3832 break;
3833 }
3834 /* Fall through */
3835 if (!(ISTRUNK(i) && i->immediate && !i->use_callerid && !i->usedistinctiveringdetection)) {
3836 break;
3837 }
3839 if (i->inalarm) {
3840 break;
3841 }
3842 /* Got a ring/answer. What kind of channel are we? */
3843 switch (i->sig) {
3844 case ANALOG_SIG_FXOLS:
3845 case ANALOG_SIG_FXOGS:
3846 case ANALOG_SIG_FXOKS:
3847 res = analog_off_hook(i);
3848 i->fxsoffhookstate = 1;
3849 i->cshactive = 0;
3850 if (res && (errno == EBUSY)) {
3851 break;
3852 }
3853 callid_created = ast_callid_threadstorage_auto(&callid);
3854
3855 /* Cancel VMWI spill */
3857
3858 if (i->immediate) {
3860 /* The channel is immediately up. Start right away */
3861 if (i->immediatering) {
3862 /* Play fake ringing, if we've been told to... */
3864 }
3866 if (!chan) {
3867 ast_log(LOG_WARNING, "Unable to start PBX on channel %d\n", i->channel);
3869 if (res < 0) {
3870 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3871 }
3872 }
3873 } else {
3874 /* Check for callerid, digits, etc */
3876 i->ss_astchan = chan;
3877 if (chan) {
3878 if (analog_has_voicemail(i)) {
3880 } else {
3882 }
3883 if (res < 0)
3884 ast_log(LOG_WARNING, "Unable to play dialtone on channel %d, do you have defaultzone and loadzone defined?\n", i->channel);
3885
3887 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
3889 if (res < 0) {
3890 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3891 }
3892 ast_hangup(chan);
3893 }
3894 } else
3895 ast_log(LOG_WARNING, "Unable to create channel\n");
3896 }
3898 break;
3899 case ANALOG_SIG_FXSLS:
3900 case ANALOG_SIG_FXSGS:
3901 case ANALOG_SIG_FXSKS:
3903 /* Fall through */
3904 case ANALOG_SIG_EMWINK:
3905 case ANALOG_SIG_FEATD:
3906 case ANALOG_SIG_FEATDMF:
3908 case ANALOG_SIG_E911:
3911 case ANALOG_SIG_FEATB:
3912 case ANALOG_SIG_EM:
3913 case ANALOG_SIG_EM_E1:
3914 case ANALOG_SIG_SFWINK:
3918 case ANALOG_SIG_SF:
3919 callid_created = ast_callid_threadstorage_auto(&callid);
3920 /* Check for callerid, digits, etc */
3923 } else {
3925 }
3926 i->ss_astchan = chan;
3927 if (!chan) {
3928 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
3929 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
3930 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
3932 if (res < 0) {
3933 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3934 }
3935 ast_hangup(chan);
3936 }
3938 break;
3939 default:
3940 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);
3942 if (res < 0) {
3943 ast_log(LOG_WARNING, "Unable to play congestion tone on channel %d\n", i->channel);
3944 }
3945 return NULL;
3946 }
3947 break;
3949 analog_set_alarm(i, 0);
3951 break;
3952 case ANALOG_EVENT_ALARM:
3953 analog_set_alarm(i, 1);
3955 /* fall thru intentionally */
3957 /* Back on hook. Hang up. */
3958 switch (i->sig) {
3959 case ANALOG_SIG_FXOLS:
3960 case ANALOG_SIG_FXOGS:
3961 i->fxsoffhookstate = 0;
3963 /* Fall through */
3964 case ANALOG_SIG_FEATD:
3965 case ANALOG_SIG_FEATDMF:
3967 case ANALOG_SIG_E911:
3970 case ANALOG_SIG_FEATB:
3971 case ANALOG_SIG_EM:
3972 case ANALOG_SIG_EM_E1:
3973 case ANALOG_SIG_EMWINK:
3977 case ANALOG_SIG_SF:
3978 case ANALOG_SIG_SFWINK:
3979 case ANALOG_SIG_FXSLS:
3980 case ANALOG_SIG_FXSGS:
3981 case ANALOG_SIG_FXSKS:
3983 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
3984 analog_on_hook(i);
3985 break;
3986 case ANALOG_SIG_FXOKS:
3987 i->fxsoffhookstate = 0;
3990 /* Diddle the battery for the zhone */
3991#ifdef ZHONE_HACK
3992 analog_off_hook(i);
3993 usleep(1);
3994#endif
3995 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
3996 analog_on_hook(i);
3997 break;
3998 default:
3999 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);
4000 res = analog_play_tone(i, ANALOG_SUB_REAL, -1);
4001 return NULL;
4002 }
4003 break;
4005 switch (i->sig) {
4006 case ANALOG_SIG_FXSLS:
4007 case ANALOG_SIG_FXSKS:
4008 case ANALOG_SIG_FXSGS:
4009 callid_created = ast_callid_threadstorage_auto(&callid);
4010 /* We have already got a PR before the channel was
4011 created, but it wasn't handled. We need polarity
4012 to be REV for remote hangup detection to work.
4013 At least in Spain */
4014 if (i->hanguponpolarityswitch) {
4016 }
4019 ast_verb(2, "Starting post polarity CID detection on channel %d\n",
4020 i->channel);
4022 i->ss_astchan = chan;
4023 if (!chan) {
4024 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
4025 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
4026 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
4027 ast_hangup(chan);
4028 }
4029 }
4031 break;
4032 default:
4034 "handle_init_event detected polarity reversal on non-FXO (ANALOG_SIG_FXS) interface %d\n",
4035 i->channel);
4036 break;
4037 }
4038 break;
4040 switch (i->sig) {
4041 case ANALOG_SIG_FXSLS:
4042 case ANALOG_SIG_FXSKS:
4043 case ANALOG_SIG_FXSGS:
4044 callid_created = ast_callid_threadstorage_auto(&callid);
4046 ast_verb(2, "Starting DTMF CID detection on channel %d\n",
4047 i->channel);
4049 i->ss_astchan = chan;
4050 if (!chan) {
4051 ast_log(LOG_WARNING, "Cannot allocate new structure on channel %d\n", i->channel);
4052 } else if (ast_pthread_create_detached(&threadid, NULL, __analog_ss_thread, i)) {
4053 ast_log(LOG_WARNING, "Unable to start simple switch thread on channel %d\n", i->channel);
4054 ast_hangup(chan);
4055 }
4056 }
4058 break;
4059 default:
4061 "handle_init_event detected dtmfcid generation event on non-FXO (ANALOG_SIG_FXS) interface %d\n",
4062 i->channel);
4063 break;
4064 }
4065 break;
4066 case ANALOG_EVENT_REMOVED: /* destroy channel, will actually do so in do_monitor */
4067 ast_log(LOG_NOTICE, "Got ANALOG_EVENT_REMOVED. Destroying channel %d\n",
4068 i->channel);
4069 return i->chan_pvt;
4072 break;
4075 break;
4076 }
4077 return NULL;
4078}
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2560
@ AST_STATE_RING
Definition: channelstate.h:40
@ AST_STATE_PRERING
Definition: channelstate.h:45
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:2378
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:2356
#define LOG_NOTICE
static void analog_publish_channel_alarm_clear(int channel)
Definition: sig_analog.c:2765
static void analog_set_alarm(struct analog_pvt *p, int in_alarm)
Definition: sig_analog.c:903
static int analog_handle_notify_message(struct ast_channel *chan, struct analog_pvt *p, int cid_flags, int neon_mwievent)
Definition: sig_analog.c:1655
static struct ast_channel * analog_new_ast_channel(struct analog_pvt *p, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
Definition: sig_analog.c:454
static void * __analog_ss_thread(void *data)
Definition: sig_analog.c:1740
static void analog_get_and_handle_alarms(struct analog_pvt *p)
Definition: sig_analog.c:1690
static int analog_has_voicemail(struct analog_pvt *p)
Definition: sig_analog.c:682
#define ISTRUNK(p)
Definition: sig_analog.c:107
const char * analog_sigtype_to_str(enum analog_sigtype sigtype)
Definition: sig_analog.c:123
static void analog_cancel_cidspill(struct analog_pvt *p)
Definition: sig_analog.c:951
#define POLARITY_REV
Definition: sig_analog.c:63
static void analog_start_polarityswitch(struct analog_pvt *p)
Definition: sig_analog.c:639
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:308
enum analog_cid_start cid_start
Definition: sig_analog.h:326
int ringt_base
Definition: sig_analog.h:376
int fxsoffhookstate
Definition: sig_analog.h:282
unsigned int inalarm
Definition: sig_analog.h:341
int polarity
Definition: sig_analog.h:360
struct ast_channel * ss_astchan
Definition: sig_analog.h:372
Main Channel structure associated with a channel.
Definition: astman.c:222
#define ast_pthread_create_detached(a, b, c, d)
Definition: utils.h:588

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

Referenced by do_monitor().

◆ analog_hangup()

int analog_hangup ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 1277 of file sig_analog.c.

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

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 4081 of file sig_analog.c.

4082{
4083 struct analog_pvt *p;
4084
4085 p = ast_calloc(1, sizeof(*p));
4086 if (!p) {
4087 return p;
4088 }
4089
4091 p->sig = signallingtype;
4092 p->chan_pvt = private_data;
4093
4094 /* Some defaults for values */
4097 /* Sub real is assumed to always be alloc'd */
4098 p->subs[ANALOG_SUB_REAL].allocd = 1;
4099
4100 return p;
4101}
#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:323

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 770 of file sig_analog.c.

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

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 123 of file sig_analog.c.

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

References ARRAY_LEN, sigtype, and sigtypes.

Referenced by __analog_ss_thread(), and analog_handle_init_event().

◆ analog_ss_thread_start()

int analog_ss_thread_start ( struct analog_pvt p,
struct ast_channel ast 
)

Definition at line 2757 of file sig_analog.c.

2758{
2759 pthread_t threadid;
2760
2761 p->ss_astchan = chan;
2763}

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 234 of file sig_analog.c.

235{
236 if (!strcasecmp(value, "ring")) {
238 } else if (!strcasecmp(value, "polarity")) {
240 } else if (!strcasecmp(value, "polarity_in")) {
242 } else if (!strcasecmp(value, "dtmf")) {
244 }
245
246 return 0;
247}
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 136 of file sig_analog.c.

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

References ARRAY_LEN, cidtypes, and name.

◆ analog_str_to_sigtype()

enum analog_sigtype analog_str_to_sigtype ( const char *  name)

Definition at line 110 of file sig_analog.c.

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

References ARRAY_LEN, name, and sigtypes.

Variable Documentation

◆ analog_callbacks

struct analog_callback analog_callbacks
extern

Global analog callbacks to the upper layer.

Definition at line 3616 of file chan_dahdi.c.

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().