![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
chan_zap.c File Reference
You need to install libraries before you attempt to compile and install the zaptel channel.
Definition in file chan_zap.c.
#include "asterisk.h"
#include <stdio.h>
#include <string.h>
#include <sys/signal.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <math.h>
#include <ctype.h>
#include "asterisk/zapata.h"
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"
#include "asterisk/file.h"
#include "asterisk/ulaw.h"
#include "asterisk/alaw.h"
#include "asterisk/callerid.h"
#include "asterisk/adsi.h"
#include "asterisk/cli.h"
#include "asterisk/cdr.h"
#include "asterisk/features.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/tdd.h"
#include "asterisk/app.h"
#include "asterisk/dsp.h"
#include "asterisk/astdb.h"
#include "asterisk/manager.h"
#include "asterisk/causes.h"
#include "asterisk/term.h"
#include "asterisk/utils.h"
#include "asterisk/transcap.h"
#include "asterisk/stringfields.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/smdi.h"
#include "asterisk/astobj.h"
Include dependency graph for chan_zap.c:

Go to the source code of this file.
Data Structures | |
| struct | distRingData |
| struct | ringContextData |
| struct | zt_chan_conf |
| Channel configuration from zapata.conf . This struct is used for parsing the [channels] section of zapata.conf. Generally there is a field here for every possible configuration item. More... | |
| struct | zt_distRings |
| struct | zt_pvt |
| struct | zt_subchannel |
Defines | |
| #define | ASCII_BYTES_PER_CHAR 80 |
| #define | AST_LAW(p) (((p)->law == ZT_LAW_ALAW) ? AST_FORMAT_ALAW : AST_FORMAT_ULAW) |
| #define | CALLWAITING_REPEAT_SAMPLES ( (10000 * 8) / READ_SIZE) |
| #define | CALLWAITING_SILENT_SAMPLES ( (300 * 8) / READ_SIZE) |
| #define | CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */) |
| #define | CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */) |
| #define | CHAN_PSEUDO -2 |
| #define | CHANNEL_PSEUDO -12 |
| #define | CIDCW_EXPIRE_SAMPLES ( (500 * 8) / READ_SIZE) |
| #define | CONF_USER_REAL (1 << 0) |
| #define | CONF_USER_THIRDCALL (1 << 1) |
| #define | DCHAN_AVAILABLE (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP) |
| #define | DCHAN_NOTINALARM (1 << 1) |
| #define | DCHAN_PROVISIONED (1 << 0) |
| #define | DCHAN_UP (1 << 2) |
| #define | DEFAULT_CIDRINGS 1 |
| Typically, how many rings before we should send Caller*ID. | |
| #define | DEFAULT_RINGT ( (8000 * 8) / READ_SIZE) |
| #define | END_SILENCE_LEN 400 |
| #define | FORMAT "%-40.40s %-10.10s %-10d %-10d %-10d\n" |
| #define | FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s\n" |
| #define | FORMAT2 "%-40.40s %-10.10s %-10.10s %-10.10s %-10.10s\n" |
| #define | FORMAT2 "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s\n" |
| #define | GET_CHANNEL(p) ((p)->channel) |
| #define | HANGUP 1 |
| #define | HEADER_LEN ((HEADER_MS + TRAILER_MS) * 8) |
| #define | HEADER_MS 50 |
| #define | ISTRUNK(p) |
| #define | MASK_AVAIL (1 << 0) |
| #define | MASK_INUSE (1 << 1) |
| #define | MAX_CHANLIST_LEN 80 |
| #define | MAX_CHANNELS 672 |
| #define | MAX_SLAVES 4 |
| #define | MIN_MS_SINCE_FLASH ( (2000) ) |
| #define | NEED_MFDETECT(p) (((p)->sig == SIG_FEATDMF) || ((p)->sig == SIG_FEATDMF_TA) || ((p)->sig == SIG_E911) || ((p)->sig == SIG_FGC_CAMA) || ((p)->sig == SIG_FGC_CAMAMF) || ((p)->sig == SIG_FEATB)) |
| Signaling types that need to use MF detection should be placed in this macro. | |
| #define | NUM_CADENCE_MAX 25 |
| #define | NUM_DCHANS 4 |
| #define | NUM_SPANS 32 |
| #define | POLARITY_IDLE 0 |
| #define | POLARITY_REV 1 |
| #define | READ_SIZE 160 |
| #define | sig2str zap_sig2str |
| #define | SIG_E911 (0x1000000 | ZT_SIG_EM) |
| #define | SIG_EM ZT_SIG_EM |
| #define | SIG_EM_E1 ZT_SIG_EM_E1 |
| #define | SIG_EMWINK (0x0100000 | ZT_SIG_EM) |
| #define | SIG_FEATB (0x0800000 | ZT_SIG_EM) |
| #define | SIG_FEATD (0x0200000 | ZT_SIG_EM) |
| #define | SIG_FEATDMF (0x0400000 | ZT_SIG_EM) |
| #define | SIG_FEATDMF_TA (0x2000000 | ZT_SIG_EM) |
| #define | SIG_FGC_CAMA (0x4000000 | ZT_SIG_EM) |
| #define | SIG_FGC_CAMAMF (0x8000000 | ZT_SIG_EM) |
| #define | SIG_FXOGS ZT_SIG_FXOGS |
| #define | SIG_FXOKS ZT_SIG_FXOKS |
| #define | SIG_FXOLS ZT_SIG_FXOLS |
| #define | SIG_FXSGS ZT_SIG_FXSGS |
| #define | SIG_FXSKS ZT_SIG_FXSKS |
| #define | SIG_FXSLS ZT_SIG_FXSLS |
| #define | SIG_GR303FXOKS (0x0100000 | ZT_SIG_FXOKS) |
| #define | SIG_GR303FXSKS (0x0100000 | ZT_SIG_FXSKS) |
| #define | SIG_PRI ZT_SIG_CLEAR |
| #define | SIG_SF ZT_SIG_SF |
| #define | SIG_SF_FEATB (0x0800000 | ZT_SIG_SF) |
| #define | SIG_SF_FEATD (0x0200000 | ZT_SIG_SF) |
| #define | SIG_SF_FEATDMF (0x0400000 | ZT_SIG_SF) |
| #define | SIG_SFWINK (0x0100000 | ZT_SIG_SF) |
| #define | SIG_SS7 (0x1000000 | ZT_SIG_CLEAR) |
| #define | SMDI_MD_WAIT_TIMEOUT 1500 |
| #define | SUB_CALLWAIT 1 |
| #define | SUB_REAL 0 |
| #define | SUB_THREEWAY 2 |
| #define | tdesc "Zapata Telephony" |
| #define | TRAILER_MS 5 |
| #define | TRANSFER 0 |
| #define | ZT_EVENT_DTMFDOWN 0 |
| #define | ZT_EVENT_DTMFUP 0 |
Functions | |
| static int | __unload_module (void) |
| static struct ast_frame * | __zt_exception (struct ast_channel *ast) |
| static int | action_transfer (struct mansession *s, const struct message *m) |
| static int | action_transferhangup (struct mansession *s, const struct message *m) |
| static int | action_zapdialoffhook (struct mansession *s, const struct message *m) |
| static int | action_zapdndoff (struct mansession *s, const struct message *m) |
| static int | action_zapdndon (struct mansession *s, const struct message *m) |
| static int | action_zaprestart (struct mansession *s, const struct message *m) |
| static int | action_zapshowchannels (struct mansession *s, const struct message *m) |
| static char * | alarm2str (int alarm) |
| static int | alloc_sub (struct zt_pvt *p, int x) |
| AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, tdesc,.load=load_module,.unload=unload_module,.reload=reload,) | |
| AST_MUTEX_DEFINE_STATIC (monlock) | |
| Protect the monitoring thread, so only one process can kill or start it, and not when it's doing something critical. | |
| AST_MUTEX_DEFINE_STATIC (iflock) | |
| Protect the interface list (of zt_pvt's). | |
| static int | attempt_transfer (struct zt_pvt *p) |
| static int | available (struct zt_pvt *p, int channelmatch, int groupmatch, int *busy, int *channelmatched, int *groupmatched) |
| static int | build_channels (struct zt_chan_conf conf, int iscrv, const char *value, int reload, int lineno, int *found_pseudo) |
| static int | bump_gains (struct zt_pvt *p) |
| static struct zt_pvt * | chandup (struct zt_pvt *src) |
| static int | check_for_conference (struct zt_pvt *p) |
| static int | conf_add (struct zt_pvt *p, struct zt_subchannel *c, int index, int slavechannel) |
| static int | conf_del (struct zt_pvt *p, struct zt_subchannel *c, int index) |
| static int | destroy_channel (struct zt_pvt *prev, struct zt_pvt *cur, int now) |
| static void | destroy_zt_pvt (struct zt_pvt **pvt) |
| static int | digit_to_dtmfindex (char digit) |
| static void | disable_dtmf_detect (struct zt_pvt *p) |
| static void * | do_monitor (void *data) |
| static void | enable_dtmf_detect (struct zt_pvt *p) |
| static char * | event2str (int event) |
| static void | fill_rxgain (struct zt_gains *g, float gain, int law) |
| static void | fill_txgain (struct zt_gains *g, float gain, int law) |
| static struct zt_pvt * | find_channel (int channel) |
| static int | get_alarms (struct zt_pvt *p) |
| static int | handle_init_event (struct zt_pvt *i, int event) |
| static int | handle_zap_show_cadences (int fd, int argc, char *argv[]) |
| static int | has_voicemail (struct zt_pvt *p) |
| static int | isourconf (struct zt_pvt *p, struct zt_subchannel *c) |
| static int | isslavenative (struct zt_pvt *p, struct zt_pvt **out) |
| static int | load_module (void) |
| static struct zt_pvt * | mkintf (int channel, struct zt_chan_conf conf, struct zt_pri *pri, int reloading) |
| static int | my_getsigstr (struct ast_channel *chan, char *str, const char *term, int ms) |
| static int | my_zt_write (struct zt_pvt *p, unsigned char *buf, int len, int index, int linear) |
| static int | process_zap (struct zt_chan_conf *confp, struct ast_variable *v, int reload, int skipchannels) |
| static int | reload (void) |
| static int | reset_conf (struct zt_pvt *p) |
| static int | restart_monitor (void) |
| Start the channel monitor thread. | |
| static int | restore_conference (struct zt_pvt *p) |
| static int | restore_gains (struct zt_pvt *p) |
| static int | save_conference (struct zt_pvt *p) |
| static int | send_callerid (struct zt_pvt *p) |
| static int | send_cwcidspill (struct zt_pvt *p) |
| static int | set_actual_gain (int fd, int chan, float rxgain, float txgain, int law) |
| static int | set_actual_rxgain (int fd, int chan, float gain, int law) |
| static int | set_actual_txgain (int fd, int chan, float gain, int law) |
| static int | setup_zap (int reload) |
| static void * | ss_thread (void *data) |
| static void | swap_subs (struct zt_pvt *p, int a, int b) |
| static int | unalloc_sub (struct zt_pvt *p, int x) |
| static int | unload_module (void) |
| static int | update_conf (struct zt_pvt *p) |
| static void | wakeup_sub (struct zt_pvt *p, int a, void *pri) |
| static int | zap_destroy_channel (int fd, int argc, char **argv) |
| static int | zap_fake_event (struct zt_pvt *p, int mode) |
| static void | zap_queue_frame (struct zt_pvt *p, struct ast_frame *f, void *data) |
| static int | zap_restart (void) |
| static int | zap_restart_cmd (int fd, int argc, char **argv) |
| static int | zap_show_channel (int fd, int argc, char **argv) |
| static int | zap_show_channels (int fd, int argc, char **argv) |
| static int | zap_show_status (int fd, int argc, char *argv[]) |
| static char * | zap_sig2str (int sig) |
| static int | zt_answer (struct ast_channel *ast) |
| static enum ast_bridge_result | zt_bridge (struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms) |
| static int | zt_call (struct ast_channel *ast, char *rdest, int timeout) |
| static int | zt_callwait (struct ast_channel *ast) |
| static struct zt_chan_conf | zt_chan_conf_default (void) |
| static void | zt_close (int fd) |
| static int | zt_confmute (struct zt_pvt *p, int muted) |
| static int | zt_digit_begin (struct ast_channel *ast, char digit) |
| static int | zt_digit_end (struct ast_channel *ast, char digit, unsigned int duration) |
| static void | zt_disable_ec (struct zt_pvt *p) |
| static void | zt_enable_ec (struct zt_pvt *p) |
| static struct ast_frame * | zt_exception (struct ast_channel *ast) |
| static int | zt_fixup (struct ast_channel *oldchan, struct ast_channel *newchan) |
| static int | zt_func_read (struct ast_channel *chan, const char *function, char *data, char *buf, size_t len) |
| static int | zt_get_event (int fd) |
| Avoid the silly zt_getevent which ignores a bunch of events. | |
| static int | zt_get_index (struct ast_channel *ast, struct zt_pvt *p, int nullok) |
| static struct ast_frame * | zt_handle_event (struct ast_channel *ast) |
| static int | zt_hangup (struct ast_channel *ast) |
| static int | zt_indicate (struct ast_channel *chan, int condition, const void *data, size_t datalen) |
| static void | zt_link (struct zt_pvt *slave, struct zt_pvt *master) |
| static struct ast_channel * | zt_new (struct zt_pvt *, int, int, int, int, int) |
| static int | zt_open (char *fn) |
| static struct ast_frame * | zt_read (struct ast_channel *ast) |
| static struct ast_channel * | zt_request (const char *type, int format, void *data, int *cause) |
| static int | zt_ring_phone (struct zt_pvt *p) |
| static int | zt_sendtext (struct ast_channel *c, const char *text) |
| static int | zt_set_hook (int fd, int hs) |
| static int | zt_setlinear (int zfd, int linear) |
| static int | zt_setoption (struct ast_channel *chan, int option, void *data, int datalen) |
| static void | zt_train_ec (struct zt_pvt *p) |
| static void | zt_unlink (struct zt_pvt *slave, struct zt_pvt *master, int needlock) |
| static int | zt_wait_event (int fd) |
| Avoid the silly zt_waitevent which ignores a bunch of events. | |
| static int | zt_wink (struct zt_pvt *p, int index) |
| static int | zt_write (struct ast_channel *ast, struct ast_frame *frame) |
Variables | |
| struct { | |
| int alarm | |
| const char * description | |
| unsigned int event_log:1 | |
| char * ext | |
| char * mtype | |
| char * name | |
| const char * name | |
| rtpPayloadType payloadType | |
| unsigned int queue_log:1 | |
| char * subtype | |
| char * type | |
| int val | |
| } | alarms [] |
| static struct zt_ring_cadence | cadences [NUM_CADENCE_MAX] |
| static int | cidrings [NUM_CADENCE_MAX] |
| cidrings says in which pause to transmit the cid information, where the first pause is 1, the second pause is 2 and so on. | |
| static const char | config [] = "zapata.conf" |
| static struct ast_jb_conf | default_jbconf |
| static char | defaultcic [64] = "" |
| static char | defaultozz [64] = "" |
| static const char | destroy_channel_usage [] |
| static int | distinctiveringaftercid = 0 |
| static struct zt_distRings | drings |
| static char * | events [] |
| static int | firstdigittimeout = 16000 |
| Wait up to 16 seconds for first digit (FXO logic). | |
| static int | gendigittimeout = 8000 |
| How long to wait for following digits (FXO logic). | |
| static struct ast_jb_conf | global_jbconf |
| static int | ifcount = 0 |
| static struct zt_pvt * | ifend |
| static struct zt_pvt * | iflist |
| static char | language [MAX_LANGUAGE] = "" |
| static int | matchdigittimeout = 3000 |
| How long to wait for an extra digit, if there is an ambiguous match. | |
| static pthread_t | monitor_thread = AST_PTHREADT_NULL |
| This is the thread for the monitor which checks for input on the channels which are not currently in use. | |
| static int | num_cadence = 4 |
| static int | numbufs = 4 |
| static char | progzone [10] = "" |
| static int | ringt_base = DEFAULT_RINGT |
| zt_pvt * | round_robin [32] |
| static const char | show_channel_usage [] |
| static const char | show_channels_usage [] |
| static char * | subnames [] |
| static const char | tdesc [] = "Zapata Telephony Driver" |
| static int | usedistinctiveringdetection = 0 |
| static int | user_has_defined_cadences = 0 |
| static struct ast_cli_entry | zap_cli [] |
| static const char | zap_restart_usage [] |
| static char | zap_show_cadences_help [] |
| static const char | zap_show_status_usage [] |
| static const struct ast_channel_tech | zap_tech |
|
|
Referenced by zt_sendtext(). |
|
|
Definition at line 157 of file chan_zap.c. Referenced by send_cwcidspill(), ss_thread(), zt_call(), zt_callwait(), and zt_sendtext(). |
|
|
300 ms Definition at line 292 of file chan_zap.c. Referenced by zt_callwait(). |
|
|
300 ms Definition at line 291 of file chan_zap.c. |
|
|
Definition at line 838 of file chan_zap.c. |
|
|
Definition at line 839 of file chan_zap.c. Referenced by zt_handle_event(). |
|
|
Definition at line 203 of file chan_zap.c. Referenced by enable_dtmf_detect(), mkintf(), zt_new(), and zt_request(). |
|
|
Definition at line 155 of file chan_zap.c. |
|
|
500 ms Definition at line 293 of file chan_zap.c. Referenced by send_callerid(). |
|
|
Definition at line 450 of file chan_zap.c. |
|
|
Definition at line 451 of file chan_zap.c. |
|
|
Definition at line 209 of file chan_zap.c. |
|
|
Definition at line 206 of file chan_zap.c. |
|
|
Definition at line 205 of file chan_zap.c. |
|
|
Definition at line 207 of file chan_zap.c. |
|
|
Typically, how many rings before we should send Caller*ID.
Definition at line 153 of file chan_zap.c. Referenced by zt_chan_conf_default(). |
|
|
Definition at line 295 of file chan_zap.c. |
|
|
Referenced by zt_sendtext(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 764 of file chan_zap.c. |
|
|
Definition at line 11026 of file chan_zap.c. Referenced by action_transferhangup(), and zap_fake_event(). |
|
|
Referenced by zt_sendtext(). |
|
|
Referenced by zt_sendtext(). |
|
|
Value: Definition at line 835 of file chan_zap.c. Referenced by ss_thread(), and zt_indicate(). |
|
|
Channel available for PRI use Definition at line 288 of file chan_zap.c. |
|
|
Channel currently in use Definition at line 289 of file chan_zap.c. |
|
|
The length of the parameters list of 'zapchan'.
Definition at line 11712 of file chan_zap.c. Referenced by process_zap(). |
|
|
No more than a DS3 per trunk group Definition at line 201 of file chan_zap.c. |
|
|
Definition at line 453 of file chan_zap.c. |
|
|
2000 ms Definition at line 294 of file chan_zap.c. Referenced by zt_handle_event(). |
|
|
Signaling types that need to use MF detection should be placed in this macro.
Definition at line 160 of file chan_zap.c. Referenced by ss_thread(). |
|
|
Definition at line 813 of file chan_zap.c. |
|
|
No more than 4 d-channels Definition at line 200 of file chan_zap.c. |
|
|
Definition at line 199 of file chan_zap.c. |
|
|
Definition at line 407 of file chan_zap.c. Referenced by unalloc_sub(), zt_handle_event(), and zt_hangup(). |
|
|
Definition at line 408 of file chan_zap.c. Referenced by handle_init_event(), and zt_handle_event(). |
|
|
Chunk size to read -- we use 20ms chunks to make things happy. Definition at line 286 of file chan_zap.c. Referenced by my_zt_write(), send_cwcidspill(), zt_callwait(), zt_read(), and zt_setoption(). |
|
|
Definition at line 1336 of file chan_zap.c. Referenced by action_zapshowchannels(), handle_init_event(), and zt_handle_event(). |
|
|
Definition at line 178 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 173 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 195 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 174 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 177 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 175 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 176 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 179 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 180 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 181 of file chan_zap.c. Referenced by handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), and zt_handle_event(). |
|
|
Definition at line 186 of file chan_zap.c. Referenced by available(), handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), zt_handle_event(), and zt_hangup(). |
|
|
Definition at line 187 of file chan_zap.c. Referenced by available(), handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), zt_handle_event(), and zt_hangup(). |
|
|
Definition at line 185 of file chan_zap.c. Referenced by available(), handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), zt_handle_event(), and zt_hangup(). |
|
|
Definition at line 183 of file chan_zap.c. Referenced by available(), handle_init_event(), ss_thread(), zap_sig2str(), zt_answer(), zt_call(), zt_handle_event( |