| 1 |
#ifndef _SIG_ANALOG_H |
| 2 |
#define _SIG_ANALOG_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include "asterisk/channel.h" |
| 29 |
#include "asterisk/frame.h" |
| 30 |
#include "asterisk/smdi.h" |
| 31 |
|
| 32 |
#define ANALOG_SMDI_MD_WAIT_TIMEOUT 1500 |
| 33 |
#define ANALOG_MAX_CID 300 |
| 34 |
#define READ_SIZE 160 |
| 35 |
#define RING_PATTERNS 3 |
| 36 |
|
| 37 |
|
| 38 |
#define ANALOG_FIRST_DIGIT_TIMEOUT 16000 |
| 39 |
|
| 40 |
#define ANALOG_INTER_DIGIT_TIMEOUT 8000 |
| 41 |
|
| 42 |
#define ANALOG_MATCH_DIGIT_TIMEOUT 3000 |
| 43 |
|
| 44 |
|
| 45 |
enum analog_sigtype { |
| 46 |
ANALOG_SIG_NONE = -1, |
| 47 |
ANALOG_SIG_FXOLS = 1, |
| 48 |
ANALOG_SIG_FXOKS, |
| 49 |
ANALOG_SIG_FXOGS, |
| 50 |
ANALOG_SIG_FXSLS, |
| 51 |
ANALOG_SIG_FXSKS, |
| 52 |
ANALOG_SIG_FXSGS, |
| 53 |
ANALOG_SIG_EMWINK, |
| 54 |
ANALOG_SIG_EM, |
| 55 |
ANALOG_SIG_EM_E1, |
| 56 |
ANALOG_SIG_FEATD, |
| 57 |
ANALOG_SIG_FEATDMF, |
| 58 |
ANALOG_SIG_E911, |
| 59 |
ANALOG_SIG_FGC_CAMA, |
| 60 |
ANALOG_SIG_FGC_CAMAMF, |
| 61 |
ANALOG_SIG_FEATB, |
| 62 |
ANALOG_SIG_SFWINK, |
| 63 |
ANALOG_SIG_SF, |
| 64 |
ANALOG_SIG_SF_FEATD, |
| 65 |
ANALOG_SIG_SF_FEATDMF, |
| 66 |
ANALOG_SIG_FEATDMF_TA, |
| 67 |
ANALOG_SIG_SF_FEATB, |
| 68 |
}; |
| 69 |
|
| 70 |
enum analog_tone { |
| 71 |
ANALOG_TONE_RINGTONE = 0, |
| 72 |
ANALOG_TONE_STUTTER, |
| 73 |
ANALOG_TONE_CONGESTION, |
| 74 |
ANALOG_TONE_DIALTONE, |
| 75 |
ANALOG_TONE_DIALRECALL, |
| 76 |
ANALOG_TONE_INFO, |
| 77 |
}; |
| 78 |
|
| 79 |
enum analog_event { |
| 80 |
ANALOG_EVENT_NONE = 0, |
| 81 |
ANALOG_EVENT_ONHOOK, |
| 82 |
ANALOG_EVENT_RINGOFFHOOK, |
| 83 |
ANALOG_EVENT_WINKFLASH, |
| 84 |
ANALOG_EVENT_ALARM, |
| 85 |
ANALOG_EVENT_NOALARM, |
| 86 |
ANALOG_EVENT_DIALCOMPLETE, |
| 87 |
ANALOG_EVENT_RINGERON, |
| 88 |
ANALOG_EVENT_RINGEROFF, |
| 89 |
ANALOG_EVENT_HOOKCOMPLETE, |
| 90 |
ANALOG_EVENT_PULSE_START, |
| 91 |
ANALOG_EVENT_POLARITY, |
| 92 |
ANALOG_EVENT_RINGBEGIN, |
| 93 |
ANALOG_EVENT_EC_DISABLED, |
| 94 |
ANALOG_EVENT_REMOVED, |
| 95 |
ANALOG_EVENT_NEONMWI_ACTIVE, |
| 96 |
ANALOG_EVENT_NEONMWI_INACTIVE, |
| 97 |
ANALOG_EVENT_TX_CED_DETECTED, |
| 98 |
ANALOG_EVENT_RX_CED_DETECTED, |
| 99 |
ANALOG_EVENT_EC_NLP_DISABLED, |
| 100 |
ANALOG_EVENT_EC_NLP_ENABLED, |
| 101 |
ANALOG_EVENT_ERROR, |
| 102 |
ANALOG_EVENT_DTMFCID, |
| 103 |
ANALOG_EVENT_PULSEDIGIT = (1 << 16), |
| 104 |
ANALOG_EVENT_DTMFDOWN = (1 << 17), |
| 105 |
ANALOG_EVENT_DTMFUP = (1 << 18), |
| 106 |
}; |
| 107 |
|
| 108 |
enum analog_sub { |
| 109 |
ANALOG_SUB_REAL = 0, |
| 110 |
ANALOG_SUB_CALLWAIT, |
| 111 |
ANALOG_SUB_THREEWAY, |
| 112 |
}; |
| 113 |
|
| 114 |
enum analog_dsp_digitmode { |
| 115 |
ANALOG_DIGITMODE_DTMF = 1, |
| 116 |
ANALOG_DIGITMODE_MF, |
| 117 |
}; |
| 118 |
|
| 119 |
enum analog_dialmode { |
| 120 |
ANALOG_DIALMODE_BOTH = 0, |
| 121 |
ANALOG_DIALMODE_PULSE, |
| 122 |
ANALOG_DIALMODE_DTMF, |
| 123 |
ANALOG_DIALMODE_NONE, |
| 124 |
}; |
| 125 |
|
| 126 |
enum analog_cid_start { |
| 127 |
ANALOG_CID_START_POLARITY = 1, |
| 128 |
ANALOG_CID_START_POLARITY_IN, |
| 129 |
ANALOG_CID_START_RING, |
| 130 |
ANALOG_CID_START_DTMF_NOALERT, |
| 131 |
}; |
| 132 |
|
| 133 |
enum dialop { |
| 134 |
ANALOG_DIAL_OP_REPLACE = 2, |
| 135 |
}; |
| 136 |
|
| 137 |
|
| 138 |
struct analog_dialoperation { |
| 139 |
enum dialop op; |
| 140 |
char dialstr[256]; |
| 141 |
}; |
| 142 |
|
| 143 |
struct analog_callback { |
| 144 |
|
| 145 |
void (* const unlock_private)(void *pvt); |
| 146 |
|
| 147 |
void (* const lock_private)(void *pvt); |
| 148 |
|
| 149 |
void (* const deadlock_avoidance_private)(void *pvt); |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
void (* const handle_dtmf)(void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest); |
| 155 |
|
| 156 |
int (* const get_event)(void *pvt); |
| 157 |
int (* const wait_event)(void *pvt); |
| 158 |
int (* const is_off_hook)(void *pvt); |
| 159 |
int (* const is_dialing)(void *pvt, enum analog_sub sub); |
| 160 |
|
| 161 |
int (* const start)(void *pvt); |
| 162 |
int (* const ring)(void *pvt); |
| 163 |
int (* const flash)(void *pvt); |
| 164 |
|
| 165 |
int (* const on_hook)(void *pvt); |
| 166 |
|
| 167 |
int (* const off_hook)(void *pvt); |
| 168 |
void (* const set_needringing)(void *pvt, int value); |
| 169 |
|
| 170 |
void (* const set_polarity)(void *pvt, int value); |
| 171 |
|
| 172 |
void (* const start_polarityswitch)(void *pvt); |
| 173 |
|
| 174 |
void (* const answer_polarityswitch)(void *pvt); |
| 175 |
|
| 176 |
void (* const hangup_polarityswitch)(void *pvt); |
| 177 |
|
| 178 |
|
| 179 |
int (* const wink)(void *pvt, enum analog_sub sub); |
| 180 |
int (* const dial_digits)(void *pvt, enum analog_sub sub, struct analog_dialoperation *dop); |
| 181 |
int (* const send_fsk)(void *pvt, struct ast_channel *ast, char *fsk); |
| 182 |
int (* const play_tone)(void *pvt, enum analog_sub sub, enum analog_tone tone); |
| 183 |
|
| 184 |
int (* const set_echocanceller)(void *pvt, int enable); |
| 185 |
int (* const train_echocanceller)(void *pvt); |
| 186 |
int (* const dsp_set_digitmode)(void *pvt, enum analog_dsp_digitmode mode); |
| 187 |
int (* const dsp_reset_and_flush_digits)(void *pvt); |
| 188 |
int (* const send_callerid)(void *pvt, int cwcid, struct ast_party_caller *caller); |
| 189 |
|
| 190 |
int (* const get_callerid)(void *pvt, char *name, char *num, enum analog_event *ev, size_t timeout); |
| 191 |
|
| 192 |
int (* const start_cid_detect)(void *pvt, int cid_signalling); |
| 193 |
|
| 194 |
int (* const stop_cid_detect)(void *pvt); |
| 195 |
|
| 196 |
|
| 197 |
int (* const callwait)(void *pvt); |
| 198 |
|
| 199 |
int (* const stop_callwait)(void *pvt); |
| 200 |
|
| 201 |
|
| 202 |
int (* const allocate_sub)(void *pvt, enum analog_sub sub); |
| 203 |
int (* const unallocate_sub)(void *pvt, enum analog_sub sub); |
| 204 |
|
| 205 |
|
| 206 |
void (* const swap_subs)(void *pvt, enum analog_sub a, struct ast_channel *new_a_owner, enum analog_sub b, struct ast_channel *new_b_owner); |
| 207 |
struct ast_channel * (* const new_ast_channel)(void *pvt, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor); |
| 208 |
|
| 209 |
|
| 210 |
int (* const conf_add)(void *pvt, enum analog_sub sub); |
| 211 |
|
| 212 |
int (* const conf_del)(void *pvt, enum analog_sub sub); |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
int (* const complete_conference_update)(void *pvt, int needconf); |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
void (* const all_subchannels_hungup)(void *pvt); |
| 221 |
|
| 222 |
int (* const has_voicemail)(void *pvt); |
| 223 |
int (* const check_for_conference)(void *pvt); |
| 224 |
void (* const handle_notify_message)(struct ast_channel *chan, void *pvt, int cid_flags, int neon_mwievent); |
| 225 |
|
| 226 |
|
| 227 |
void (* const increase_ss_count)(void); |
| 228 |
void (* const decrease_ss_count)(void); |
| 229 |
|
| 230 |
int (* const distinctive_ring)(struct ast_channel *chan, void *pvt, int idx, int *ringdata); |
| 231 |
|
| 232 |
int (* const set_linear_mode)(void *pvt, enum analog_sub sub, int linear_mode); |
| 233 |
void (* const set_inthreeway)(void *pvt, enum analog_sub sub, int inthreeway); |
| 234 |
void (* const get_and_handle_alarms)(void *pvt); |
| 235 |
void * (* const get_sigpvt_bridged_channel)(struct ast_channel *chan); |
| 236 |
int (* const get_sub_fd)(void *pvt, enum analog_sub sub); |
| 237 |
void (* const set_cadence)(void *pvt, int *cidrings, struct ast_channel *chan); |
| 238 |
void (* const set_alarm)(void *pvt, int in_alarm); |
| 239 |
void (* const set_dialing)(void *pvt, int is_dialing); |
| 240 |
void (* const set_outgoing)(void *pvt, int is_outgoing); |
| 241 |
void (* const set_ringtimeout)(void *pvt, int ringt); |
| 242 |
void (* const set_waitingfordt)(void *pvt, struct ast_channel *ast); |
| 243 |
int (* const check_waitingfordt)(void *pvt); |
| 244 |
void (* const set_confirmanswer)(void *pvt, int flag); |
| 245 |
int (* const check_confirmanswer)(void *pvt); |
| 246 |
void (* const set_callwaiting)(void *pvt, int callwaiting_enable); |
| 247 |
void (* const cancel_cidspill)(void *pvt); |
| 248 |
int (* const confmute)(void *pvt, int mute); |
| 249 |
void (* const set_pulsedial)(void *pvt, int flag); |
| 250 |
void (* const set_new_owner)(void *pvt, struct ast_channel *new_owner); |
| 251 |
|
| 252 |
const char *(* const get_orig_dialstring)(void *pvt); |
| 253 |
int (* const have_progressdetect)(void *pvt); |
| 254 |
int (* const get_firstdigit_timeout)(void *pvt); |
| 255 |
int (* const get_interdigit_timeout)(void *pvt); |
| 256 |
int (* const get_matchdigit_timeout)(void *pvt); |
| 257 |
}; |
| 258 |
|
| 259 |
|
| 260 |
extern struct analog_callback analog_callbacks; |
| 261 |
|
| 262 |
|
| 263 |
struct analog_subchannel { |
| 264 |
struct ast_channel *owner; |
| 265 |
struct ast_frame f; |
| 266 |
unsigned int inthreeway:1; |
| 267 |
|
| 268 |
unsigned int allocd:1; |
| 269 |
}; |
| 270 |
|
| 271 |
struct analog_pvt { |
| 272 |
|
| 273 |
enum analog_sigtype sig; |
| 274 |
|
| 275 |
void *chan_pvt; |
| 276 |
|
| 277 |
struct ast_channel *owner; |
| 278 |
|
| 279 |
struct analog_subchannel subs[3]; |
| 280 |
struct analog_dialoperation dop; |
| 281 |
int onhooktime; |
| 282 |
int fxsoffhookstate; |
| 283 |
|
| 284 |
int msgstate; |
| 285 |
|
| 286 |
|
| 287 |
unsigned int ani_info_digits:8; |
| 288 |
unsigned int ani_timeout:16; |
| 289 |
unsigned int ani_wink_time:16; |
| 290 |
|
| 291 |
unsigned int answeronpolarityswitch:1; |
| 292 |
unsigned int calledsubscriberheld:1; |
| 293 |
unsigned int callreturn:1; |
| 294 |
unsigned int cancallforward:1; |
| 295 |
unsigned int canpark:1; |
| 296 |
unsigned int dahditrcallerid:1; |
| 297 |
unsigned int hanguponpolarityswitch:1; |
| 298 |
unsigned int immediate:1; |
| 299 |
unsigned int immediatering:1; |
| 300 |
unsigned int lastnumredial:1; |
| 301 |
unsigned int permcallwaiting:1; |
| 302 |
unsigned int callwaitingdeluxe:1; |
| 303 |
unsigned int permhidecallerid:1; |
| 304 |
enum analog_dialmode permdialmode; |
| 305 |
unsigned int pulse:1; |
| 306 |
unsigned int threewaycalling:1; |
| 307 |
unsigned int threewaysilenthold:1; |
| 308 |
unsigned int transfer:1; |
| 309 |
unsigned int transfertobusy:1; |
| 310 |
unsigned int use_callerid:1; |
| 311 |
unsigned int usedistinctiveringdetection:1; |
| 312 |
unsigned int callwaitingcallerid:1; |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
unsigned int use_smdi:1; |
| 317 |
|
| 318 |
struct ast_smdi_interface *smdi_iface; |
| 319 |
|
| 320 |
|
| 321 |
int channel; |
| 322 |
|
| 323 |
enum analog_sigtype outsigmod; |
| 324 |
enum analog_dialmode dialmode; |
| 325 |
int echotraining; |
| 326 |
int cid_signalling; |
| 327 |
int polarityonanswerdelay; |
| 328 |
int stripmsd; |
| 329 |
enum analog_cid_start cid_start; |
| 330 |
char mohsuggest[MAX_MUSICCLASS]; |
| 331 |
char cid_num[AST_MAX_EXTENSION]; |
| 332 |
char cid_name[AST_MAX_EXTENSION]; |
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
unsigned int callwaiting:1; |
| 337 |
unsigned int cshactive:1; |
| 338 |
unsigned int dialednone:1; |
| 339 |
unsigned int dialing:1; |
| 340 |
unsigned int dnd:1; |
| 341 |
unsigned int echobreak:1; |
| 342 |
unsigned int hidecallerid:1; |
| 343 |
unsigned int outgoing:1; |
| 344 |
unsigned int inalarm:1; |
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
unsigned int callwaitcas:1; |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
unsigned int callwaitingdeluxepending:1; |
| 357 |
|
| 358 |
unsigned int call_qualifier:1; |
| 359 |
|
| 360 |
char callwait_num[AST_MAX_EXTENSION]; |
| 361 |
char callwait_name[AST_MAX_EXTENSION]; |
| 362 |
char lastcid_num[AST_MAX_EXTENSION]; |
| 363 |
char lastcid_name[AST_MAX_EXTENSION]; |
| 364 |
char lastexten[AST_MAX_EXTENSION]; |
| 365 |
struct ast_party_caller caller; |
| 366 |
int redirecting_reason; |
| 367 |
|
| 368 |
int cidrings; |
| 369 |
char echorest[20]; |
| 370 |
int polarity; |
| 371 |
struct timeval polaritydelaytv; |
| 372 |
char dialdest[256]; |
| 373 |
time_t guardtime; |
| 374 |
struct timeval flashtime; |
| 375 |
int whichwink; |
| 376 |
char finaldial[64]; |
| 377 |
char *origcid_num; |
| 378 |
char *origcid_name; |
| 379 |
char call_forward[AST_MAX_EXTENSION]; |
| 380 |
|
| 381 |
|
| 382 |
struct ast_channel *ss_astchan; |
| 383 |
|
| 384 |
|
| 385 |
int ringt; |
| 386 |
int ringt_base; |
| 387 |
}; |
| 388 |
|
| 389 |
struct analog_pvt *analog_new(enum analog_sigtype signallingtype, void *private_data); |
| 390 |
void analog_delete(struct analog_pvt *doomed); |
| 391 |
|
| 392 |
void analog_free(struct analog_pvt *p); |
| 393 |
|
| 394 |
int analog_call(struct analog_pvt *p, struct ast_channel *ast, const char *rdest, int timeout); |
| 395 |
|
| 396 |
int analog_hangup(struct analog_pvt *p, struct ast_channel *ast); |
| 397 |
|
| 398 |
int analog_answer(struct analog_pvt *p, struct ast_channel *ast); |
| 399 |
|
| 400 |
struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast); |
| 401 |
|
| 402 |
struct ast_channel * analog_request(struct analog_pvt *p, int *callwait, const struct ast_channel *requestor); |
| 403 |
|
| 404 |
int analog_available(struct analog_pvt *p); |
| 405 |
|
| 406 |
void *analog_handle_init_event(struct analog_pvt *i, int event); |
| 407 |
|
| 408 |
int analog_config_complete(struct analog_pvt *p); |
| 409 |
|
| 410 |
int analog_callwaiting_deluxe(struct analog_pvt *p, int option); |
| 411 |
|
| 412 |
void analog_handle_dtmf(struct analog_pvt *p, struct ast_channel *ast, enum analog_sub index, struct ast_frame **dest); |
| 413 |
|
| 414 |
enum analog_cid_start analog_str_to_cidstart(const char *value); |
| 415 |
|
| 416 |
const char *analog_cidstart_to_str(enum analog_cid_start cid_start); |
| 417 |
|
| 418 |
enum analog_sigtype analog_str_to_sigtype(const char *name); |
| 419 |
|
| 420 |
const char *analog_sigtype_to_str(enum analog_sigtype sigtype); |
| 421 |
|
| 422 |
unsigned int analog_str_to_cidtype(const char *name); |
| 423 |
|
| 424 |
const char *analog_cidtype_to_str(unsigned int cid_type); |
| 425 |
|
| 426 |
int analog_ss_thread_start(struct analog_pvt *p, struct ast_channel *ast); |
| 427 |
|
| 428 |
int analog_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, void *newp); |
| 429 |
|
| 430 |
int analog_dnd(struct analog_pvt *p, int flag); |
| 431 |
|
| 432 |
#endif |