chan_dahdi.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2013 Digium, Inc.
00005  *
00006  * Richard Mudgett <rmudgett@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*!
00020  * \file
00021  * \brief DAHDI internal API definitions.
00022  *
00023  * \author Richard Mudgett <rmudgett@digium.com>
00024  *
00025  * See Also:
00026  * \arg \ref AstCREDITS
00027  */
00028 
00029 #ifndef _ASTERISK_CHAN_DAHDI_H
00030 #define _ASTERISK_CHAN_DAHDI_H
00031 
00032 #if defined(HAVE_OPENR2)
00033 #include <openr2.h>
00034 #endif   /* defined(HAVE_OPENR2) */
00035 
00036 #include <dahdi/user.h>
00037 #include <dahdi/tonezone.h>
00038 
00039 #include "asterisk/channel.h"
00040 #include "asterisk/dsp.h"
00041 #include "asterisk/app.h"
00042 
00043 #if defined(__cplusplus) || defined(c_plusplus)
00044 extern "C" {
00045 #endif
00046 
00047 /* ------------------------------------------------------------------- */
00048 
00049 #if defined(HAVE_PRI)
00050 struct sig_pri_span;
00051 #endif   /* defined(HAVE_PRI) */
00052 #if defined(HAVE_SS7)
00053 struct sig_ss7_linkset;
00054 #endif   /* defined(HAVE_SS7) */
00055 
00056 #define SUB_REAL     0        /*!< Active call */
00057 #define SUB_CALLWAIT 1        /*!< Call-Waiting call on hold */
00058 #define SUB_THREEWAY 2        /*!< Three-way call */
00059 
00060 
00061 struct distRingData {
00062    int ring[3];
00063    int range;
00064 };
00065 struct ringContextData {
00066    char contextData[AST_MAX_CONTEXT];
00067 };
00068 struct dahdi_distRings {
00069    struct distRingData ringnum[3];
00070    struct ringContextData ringContext[3];
00071 };
00072 
00073 
00074 extern const char * const subnames[];
00075 
00076 struct dahdi_subchannel {
00077    int dfd;
00078    struct ast_channel *owner;
00079    int chan;
00080    short buffer[AST_FRIENDLY_OFFSET/2 + READ_SIZE];
00081    struct ast_frame f;     /*!< One frame for each channel.  How did this ever work before? */
00082    unsigned int needringing:1;
00083    unsigned int needbusy:1;
00084    unsigned int needcongestion:1;
00085    unsigned int needanswer:1;
00086    unsigned int needflash:1;
00087    unsigned int needhold:1;
00088    unsigned int needunhold:1;
00089    unsigned int linear:1;
00090    unsigned int inthreeway:1;
00091    struct dahdi_confinfo curconf;
00092 };
00093 
00094 #define MAX_SLAVES   4
00095 
00096 /* States for sending MWI message
00097  * First three states are required for send Ring Pulse Alert Signal
00098  */
00099 typedef enum {
00100    MWI_SEND_NULL = 0,
00101    MWI_SEND_SA,
00102    MWI_SEND_SA_WAIT,
00103    MWI_SEND_PAUSE,
00104    MWI_SEND_SPILL,
00105    MWI_SEND_CLEANUP,
00106    MWI_SEND_DONE,
00107 } mwisend_states;
00108 
00109 struct mwisend_info {
00110    struct timeval pause;
00111    mwisend_states mwisend_current;
00112 };
00113 
00114 /*! Specify the lists dahdi_pvt can be put in. */
00115 enum DAHDI_IFLIST {
00116    DAHDI_IFLIST_NONE,   /*!< The dahdi_pvt is not in any list. */
00117    DAHDI_IFLIST_MAIN,   /*!< The dahdi_pvt is in the main interface list */
00118 #if defined(HAVE_PRI)
00119    DAHDI_IFLIST_NO_B_CHAN, /*!< The dahdi_pvt is in a no B channel interface list */
00120 #endif   /* defined(HAVE_PRI) */
00121 };
00122 
00123 struct dahdi_pvt {
00124    ast_mutex_t lock;             /*!< Channel private lock. */
00125    struct callerid_state *cs;
00126    struct ast_channel *owner;       /*!< Our current active owner (if applicable) */
00127                      /*!< Up to three channels can be associated with this call */
00128 
00129    struct dahdi_subchannel sub_unused;    /*!< Just a safety precaution */
00130    struct dahdi_subchannel subs[3];       /*!< Sub-channels */
00131    struct dahdi_confinfo saveconf;        /*!< Saved conference info */
00132 
00133    struct dahdi_pvt *slaves[MAX_SLAVES];     /*!< Slave to us (follows our conferencing) */
00134    struct dahdi_pvt *master;           /*!< Master to us (we follow their conferencing) */
00135    int inconference;          /*!< If our real should be in the conference */
00136 
00137    int bufsize;                /*!< Size of the buffers */
00138    int buf_no;             /*!< Number of buffers */
00139    int buf_policy;            /*!< Buffer policy */
00140    int faxbuf_no;              /*!< Number of Fax buffers */
00141    int faxbuf_policy;          /*!< Fax buffer policy */
00142    int sig;             /*!< Signalling style */
00143    /*!
00144     * \brief Nonzero if the signaling type is sent over a radio.
00145     * \note Set to a couple of nonzero values but it is only tested like a boolean.
00146     */
00147    int radio;
00148    int outsigmod;             /*!< Outbound Signalling style (modifier) */
00149    int oprmode;               /*!< "Operator Services" mode */
00150    struct dahdi_pvt *oprpeer;          /*!< "Operator Services" peer tech_pvt ptr */
00151    /*! \brief Hardware Rx gain set by chan_dahdi.conf */
00152    float hwrxgain;
00153    /*! \brief Hardware Tx gain set by chan_dahdi.conf */
00154    float hwtxgain;
00155    /*! \brief Amount of gain to increase during caller id */
00156    float cid_rxgain;
00157    /*! \brief Software Rx gain set by chan_dahdi.conf */
00158    float rxgain;
00159    /*! \brief Software Tx gain set by chan_dahdi.conf */
00160    float txgain;
00161 
00162    float txdrc; /*!< Dynamic Range Compression factor. a number between 1 and 6ish */
00163    float rxdrc;
00164 
00165    int tonezone;              /*!< tone zone for this chan, or -1 for default */
00166    enum DAHDI_IFLIST which_iflist;  /*!< Which interface list is this structure listed? */
00167    struct dahdi_pvt *next;          /*!< Next channel in list */
00168    struct dahdi_pvt *prev;          /*!< Prev channel in list */
00169 
00170    /* flags */
00171 
00172    /*!
00173     * \brief TRUE if ADSI (Analog Display Services Interface) available
00174     * \note Set from the "adsi" value read in from chan_dahdi.conf
00175     */
00176    unsigned int adsi:1;
00177    /*!
00178     * \brief TRUE if we can use a polarity reversal to mark when an outgoing
00179     * call is answered by the remote party.
00180     * \note Set from the "answeronpolarityswitch" value read in from chan_dahdi.conf
00181     */
00182    unsigned int answeronpolarityswitch:1;
00183    /*!
00184     * \brief TRUE if busy detection is enabled.
00185     * (Listens for the beep-beep busy pattern.)
00186     * \note Set from the "busydetect" value read in from chan_dahdi.conf
00187     */
00188    unsigned int busydetect:1;
00189    /*!
00190     * \brief TRUE if call return is enabled.
00191     * (*69, if your dialplan doesn't catch this first)
00192     * \note Set from the "callreturn" value read in from chan_dahdi.conf
00193     */
00194    unsigned int callreturn:1;
00195    /*!
00196     * \brief TRUE if busy extensions will hear the call-waiting tone
00197     * and can use hook-flash to switch between callers.
00198     * \note Can be disabled by dialing *70.
00199     * \note Initialized with the "callwaiting" value read in from chan_dahdi.conf
00200     */
00201    unsigned int callwaiting:1;
00202    /*!
00203     * \brief TRUE if send caller ID for Call Waiting
00204     * \note Set from the "callwaitingcallerid" value read in from chan_dahdi.conf
00205     */
00206    unsigned int callwaitingcallerid:1;
00207    /*!
00208     * \brief TRUE if support for call forwarding enabled.
00209     * Dial *72 to enable call forwarding.
00210     * Dial *73 to disable call forwarding.
00211     * \note Set from the "cancallforward" value read in from chan_dahdi.conf
00212     */
00213    unsigned int cancallforward:1;
00214    /*!
00215     * \brief TRUE if support for call parking is enabled.
00216     * \note Set from the "canpark" value read in from chan_dahdi.conf
00217     */
00218    unsigned int canpark:1;
00219    /*! \brief TRUE if to wait for a DTMF digit to confirm answer */
00220    unsigned int confirmanswer:1;
00221    /*!
00222     * \brief TRUE if the channel is to be destroyed on hangup.
00223     * (Used by pseudo channels.)
00224     */
00225    unsigned int destroy:1;
00226    unsigned int didtdd:1;           /*!< flag to say its done it once */
00227    /*! \brief TRUE if analog type line dialed no digits in Dial() */
00228    unsigned int dialednone:1;
00229    /*!
00230     * \brief TRUE if in the process of dialing digits or sending something.
00231     * \note This is used as a receive squelch for ISDN until connected.
00232     */
00233    unsigned int dialing:1;
00234    /*! \brief TRUE if the transfer capability of the call is digital. */
00235    unsigned int digital:1;
00236    /*! \brief TRUE if Do-Not-Disturb is enabled, present only for non sig_analog */
00237    unsigned int dnd:1;
00238    /*! \brief XXX BOOLEAN Purpose??? */
00239    unsigned int echobreak:1;
00240    /*!
00241     * \brief TRUE if echo cancellation enabled when bridged.
00242     * \note Initialized with the "echocancelwhenbridged" value read in from chan_dahdi.conf
00243     * \note Disabled if the echo canceller is not setup.
00244     */
00245    unsigned int echocanbridged:1;
00246    /*! \brief TRUE if echo cancellation is turned on. */
00247    unsigned int echocanon:1;
00248    /*! \brief TRUE if a fax tone has already been handled. */
00249    unsigned int faxhandled:1;
00250    /*! TRUE if dynamic faxbuffers are configured for use, default is OFF */
00251    unsigned int usefaxbuffers:1;
00252    /*! TRUE while buffer configuration override is in use */
00253    unsigned int bufferoverrideinuse:1;
00254    /*! \brief TRUE if over a radio and dahdi_read() has been called. */
00255    unsigned int firstradio:1;
00256    /*!
00257     * \brief TRUE if the call will be considered "hung up" on a polarity reversal.
00258     * \note Set from the "hanguponpolarityswitch" value read in from chan_dahdi.conf
00259     */
00260    unsigned int hanguponpolarityswitch:1;
00261    /*! \brief TRUE if DTMF detection needs to be done by hardware. */
00262    unsigned int hardwaredtmf:1;
00263    /*!
00264     * \brief TRUE if the outgoing caller ID is blocked/hidden.
00265     * \note Caller ID can be disabled by dialing *67.
00266     * \note Caller ID can be enabled by dialing *82.
00267     * \note Initialized with the "hidecallerid" value read in from chan_dahdi.conf
00268     */
00269    unsigned int hidecallerid:1;
00270    /*!
00271     * \brief TRUE if hide just the name not the number for legacy PBX use.
00272     * \note Only applies to PRI channels.
00273     * \note Set from the "hidecalleridname" value read in from chan_dahdi.conf
00274     */
00275    unsigned int hidecalleridname:1;
00276    /*! \brief TRUE if DTMF detection is disabled. */
00277    unsigned int ignoredtmf:1;
00278    /*!
00279     * \brief TRUE if the channel should be answered immediately
00280     * without attempting to gather any digits.
00281     * \note Set from the "immediate" value read in from chan_dahdi.conf
00282     */
00283    unsigned int immediate:1;
00284    /*! \brief TRUE if in an alarm condition. */
00285    unsigned int inalarm:1;
00286    /*! \brief TRUE if TDD in MATE mode */
00287    unsigned int mate:1;
00288    /*! \brief TRUE if we originated the call leg. */
00289    unsigned int outgoing:1;
00290    /*!
00291     * \brief TRUE if busy extensions will hear the call-waiting tone
00292     * and can use hook-flash to switch between callers.
00293     * \note Set from the "callwaiting" value read in from chan_dahdi.conf
00294     */
00295    unsigned int permcallwaiting:1;
00296    /*!
00297     * \brief TRUE if the outgoing caller ID is blocked/restricted/hidden.
00298     * \note Set from the "hidecallerid" value read in from chan_dahdi.conf
00299     */
00300    unsigned int permhidecallerid:1;
00301    /*!
00302     * \brief TRUE if PRI congestion/busy indications are sent out-of-band.
00303     * \note Set from the "priindication" value read in from chan_dahdi.conf
00304     */
00305    unsigned int priindication_oob:1;
00306    /*!
00307     * \brief TRUE if PRI B channels are always exclusively selected.
00308     * \note Set from the "priexclusive" value read in from chan_dahdi.conf
00309     */
00310    unsigned int priexclusive:1;
00311    /*!
00312     * \brief TRUE if we will pulse dial.
00313     * \note Set from the "pulsedial" value read in from chan_dahdi.conf
00314     */
00315    unsigned int pulse:1;
00316    /*! \brief TRUE if a pulsed digit was detected. (Pulse dial phone detected) */
00317    unsigned int pulsedial:1;
00318    unsigned int restartpending:1;      /*!< flag to ensure counted only once for restart */
00319    /*!
00320     * \brief TRUE if caller ID is restricted.
00321     * \note Set but not used.  Should be deleted.  Redundant with permhidecallerid.
00322     * \note Set from the "restrictcid" value read in from chan_dahdi.conf
00323     */
00324    unsigned int restrictcid:1;
00325    /*!
00326     * \brief TRUE if three way calling is enabled
00327     * \note Set from the "threewaycalling" value read in from chan_dahdi.conf
00328     */
00329    unsigned int threewaycalling:1;
00330    /*!
00331     * \brief TRUE if call transfer is enabled
00332     * \note For FXS ports (either direct analog or over T1/E1):
00333     *   Support flash-hook call transfer
00334     * \note For digital ports using ISDN PRI protocols:
00335     *   Support switch-side transfer (called 2BCT, RLT or other names)
00336     * \note Set from the "transfer" value read in from chan_dahdi.conf
00337     */
00338    unsigned int transfer:1;
00339    /*!
00340     * \brief TRUE if caller ID is used on this channel.
00341     * \note PRI and SS7 spans will save caller ID from the networking peer.
00342     * \note FXS ports will generate the caller ID spill.
00343     * \note FXO ports will listen for the caller ID spill.
00344     * \note Set from the "usecallerid" value read in from chan_dahdi.conf
00345     */
00346    unsigned int use_callerid:1;
00347    /*!
00348     * \brief TRUE if we will use the calling presentation setting
00349     * from the Asterisk channel for outgoing calls.
00350     * \note Only applies to PRI and SS7 channels.
00351     * \note Set from the "usecallingpres" value read in from chan_dahdi.conf
00352     */
00353    unsigned int use_callingpres:1;
00354    /*!
00355     * \brief TRUE if distinctive rings are to be detected.
00356     * \note For FXO lines
00357     * \note Set indirectly from the "usedistinctiveringdetection" value read in from chan_dahdi.conf
00358     */
00359    unsigned int usedistinctiveringdetection:1;
00360    /*!
00361     * \brief TRUE if we should use the callerid from incoming call on dahdi transfer.
00362     * \note Set from the "useincomingcalleridondahditransfer" value read in from chan_dahdi.conf
00363     */
00364    unsigned int dahditrcallerid:1;
00365    /*!
00366     * \brief TRUE if allowed to flash-transfer to busy channels.
00367     * \note Set from the "transfertobusy" value read in from chan_dahdi.conf
00368     */
00369    unsigned int transfertobusy:1;
00370    /*!
00371     * \brief TRUE if the FXO port monitors for neon type MWI indications from the other end.
00372     * \note Set if the "mwimonitor" value read in contains "neon" from chan_dahdi.conf
00373     */
00374    unsigned int mwimonitor_neon:1;
00375    /*!
00376     * \brief TRUE if the FXO port monitors for fsk type MWI indications from the other end.
00377     * \note Set if the "mwimonitor" value read in contains "fsk" from chan_dahdi.conf
00378     */
00379    unsigned int mwimonitor_fsk:1;
00380    /*!
00381     * \brief TRUE if the FXO port monitors for rpas precursor to fsk MWI indications from the other end.
00382     * \note RPAS - Ring Pulse Alert Signal
00383     * \note Set if the "mwimonitor" value read in contains "rpas" from chan_dahdi.conf
00384     */
00385    unsigned int mwimonitor_rpas:1;
00386    /*! \brief TRUE if an MWI monitor thread is currently active */
00387    unsigned int mwimonitoractive:1;
00388    /*! \brief TRUE if a MWI message sending thread is active */
00389    unsigned int mwisendactive:1;
00390    /*!
00391     * \brief TRUE if channel is out of reset and ready
00392     * \note Used by SS7.  Otherwise set but not used.
00393     */
00394    unsigned int inservice:1;
00395    /*!
00396     * \brief Bitmask for the channel being locally blocked.
00397     * \note Applies to SS7 and MFCR2 channels.
00398     * \note For MFCR2 only the first bit is used - TRUE if blocked
00399     * \note For SS7 two bits are used
00400     * \note Bit 0 - TRUE if maintenance blocked
00401     * \note Bit 1 - TRUE if hardware blocked
00402     */
00403    unsigned int locallyblocked:2;
00404    /*!
00405     * \brief Bitmask for the channel being remotely blocked. 1 maintenance, 2 blocked in hardware.
00406     * \note Applies to SS7 and MFCR2 channels.
00407     * \note For MFCR2 only the first bit is used - TRUE if blocked
00408     * \note For SS7 two bits are used
00409     * \note Bit 0 - TRUE if maintenance blocked
00410     * \note Bit 1 - TRUE if hardware blocked
00411     */
00412    unsigned int remotelyblocked:2;
00413    /*!
00414     * \brief TRUE if the channel alarms will be managed also as Span ones
00415     * \note Applies to all channels
00416     */
00417    unsigned int manages_span_alarms:1;
00418    /*! \brief TRUE if hardware Rx gain set by Asterisk */
00419    unsigned int hwrxgain_enabled;
00420    /*! \brief TRUE if hardware Tx gain set by Asterisk */
00421    unsigned int hwtxgain_enabled;
00422 
00423 #if defined(HAVE_PRI)
00424    struct sig_pri_span *pri;
00425    int logicalspan;
00426 #endif   /* defined(HAVE_PRI) */
00427    /*!
00428     * \brief TRUE if SMDI (Simplified Message Desk Interface) is enabled
00429     * \note Set from the "usesmdi" value read in from chan_dahdi.conf
00430     */
00431    unsigned int use_smdi:1;
00432    struct mwisend_info mwisend_data;
00433    /*! \brief The SMDI interface to get SMDI messages from. */
00434    struct ast_smdi_interface *smdi_iface;
00435 
00436    /*! \brief Distinctive Ring data */
00437    struct dahdi_distRings drings;
00438 
00439    /*!
00440     * \brief The configured context for incoming calls.
00441     * \note The "context" string read in from chan_dahdi.conf
00442     */
00443    char context[AST_MAX_CONTEXT];
00444    /*!
00445     * \brief A description for the channel configuration
00446     * \note The "description" string read in from chan_dahdi.conf
00447     */
00448    char description[32];
00449    /*!
00450     * \brief Default distinctive ring context.
00451     */
00452    char defcontext[AST_MAX_CONTEXT];
00453    /*! \brief Extension to use in the dialplan. */
00454    char exten[AST_MAX_EXTENSION];
00455    /*!
00456     * \brief Language configured for calls.
00457     * \note The "language" string read in from chan_dahdi.conf
00458     */
00459    char language[MAX_LANGUAGE];
00460    /*!
00461     * \brief The configured music-on-hold class to use for calls.
00462     * \note The "musicclass" or "mohinterpret" or "musiconhold" string read in from chan_dahdi.conf
00463     */
00464    char mohinterpret[MAX_MUSICCLASS];
00465    /*!
00466     * \brief Suggested music-on-hold class for peer channel to use for calls.
00467     * \note The "mohsuggest" string read in from chan_dahdi.conf
00468     */
00469    char mohsuggest[MAX_MUSICCLASS];
00470    char parkinglot[AST_MAX_EXTENSION]; /*!< Parking lot for this channel */
00471 #if defined(HAVE_PRI) || defined(HAVE_SS7)
00472    /*! \brief Automatic Number Identification number (Alternate PRI caller ID number) */
00473    char cid_ani[AST_MAX_EXTENSION];
00474 #endif   /* defined(HAVE_PRI) || defined(HAVE_SS7) */
00475    /*! \brief Automatic Number Identification code from PRI */
00476    int cid_ani2;
00477    /*! \brief Caller ID number from an incoming call. */
00478    char cid_num[AST_MAX_EXTENSION];
00479    /*!
00480     * \brief Caller ID tag from incoming call
00481     * \note the "cid_tag" string read in from chan_dahdi.conf
00482     */
00483    char cid_tag[AST_MAX_EXTENSION];
00484    /*! \brief Caller ID Q.931 TON/NPI field values.  Set by PRI. Zero otherwise. */
00485    int cid_ton;
00486    /*! \brief Caller ID name from an incoming call. */
00487    char cid_name[AST_MAX_EXTENSION];
00488    /*! \brief Caller ID subaddress from an incoming call. */
00489    char cid_subaddr[AST_MAX_EXTENSION];
00490    char *origcid_num;            /*!< malloced original callerid */
00491    char *origcid_name;           /*!< malloced original callerid */
00492    /*! \brief Call waiting number. */
00493    char callwait_num[AST_MAX_EXTENSION];
00494    /*! \brief Call waiting name. */
00495    char callwait_name[AST_MAX_EXTENSION];
00496    /*! \brief Redirecting Directory Number Information Service (RDNIS) number */
00497    char rdnis[AST_MAX_EXTENSION];
00498    /*! \brief Dialed Number Identifier */
00499    char dnid[AST_MAX_EXTENSION];
00500    /*!
00501     * \brief Bitmapped groups this belongs to.
00502     * \note The "group" bitmapped group string read in from chan_dahdi.conf
00503     */
00504    ast_group_t group;
00505    /*! \brief Default call PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW. */
00506    int law_default;
00507    /*! \brief Active PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW */
00508    int law;
00509    int confno;             /*!< Our conference */
00510    int confusers;             /*!< Who is using our conference */
00511    int propconfno;               /*!< Propagated conference number */
00512    /*!
00513     * \brief Bitmapped call groups this belongs to.
00514     * \note The "callgroup" bitmapped group string read in from chan_dahdi.conf
00515     */
00516    ast_group_t callgroup;
00517    /*!
00518     * \brief Bitmapped pickup groups this belongs to.
00519     * \note The "pickupgroup" bitmapped group string read in from chan_dahdi.conf
00520     */
00521    ast_group_t pickupgroup;
00522    /*!
00523     * \brief Named call groups this belongs to.
00524     * \note The "namedcallgroup" string read in from chan_dahdi.conf
00525     */
00526    struct ast_namedgroups *named_callgroups;
00527    /*!
00528     * \brief Named pickup groups this belongs to.
00529     * \note The "namedpickupgroup" string read in from chan_dahdi.conf
00530     */
00531    struct ast_namedgroups *named_pickupgroups;
00532    /*!
00533     * \brief Channel variable list with associated values to set when a channel is created.
00534     * \note The "setvar" strings read in from chan_dahdi.conf
00535     */
00536    struct ast_variable *vars;
00537    int channel;               /*!< Channel Number */
00538    int span;               /*!< Span number */
00539    time_t guardtime;          /*!< Must wait this much time before using for new call */
00540    int cid_signalling;           /*!< CID signalling type bell202 or v23 */
00541    int cid_start;             /*!< CID start indicator, polarity or ring or DTMF without warning event */
00542    int dtmfcid_holdoff_state;    /*!< State indicator that allows for line to settle before checking for dtmf energy */
00543    struct timeval dtmfcid_delay;  /*!< Time value used for allow line to settle */
00544    int callingpres;           /*!< The value of calling presentation that we're going to use when placing a PRI call */
00545    int callwaitingrepeat;           /*!< How many samples to wait before repeating call waiting */
00546    int cidcwexpire;           /*!< When to stop waiting for CID/CW CAS response (In samples) */
00547    int cid_suppress_expire;      /*!< How many samples to suppress after a CID spill. */
00548    /*! \brief Analog caller ID waveform sample buffer */
00549    unsigned char *cidspill;
00550    /*! \brief Position in the cidspill buffer to send out next. */
00551    int cidpos;
00552    /*! \brief Length of the cidspill buffer containing samples. */
00553    int cidlen;
00554    /*! \brief Ring timeout timer?? */
00555    int ringt;
00556    /*!
00557     * \brief Ring timeout base.
00558     * \note Value computed indirectly from "ringtimeout" read in from chan_dahdi.conf
00559     */
00560    int ringt_base;
00561    /*!
00562     * \brief Number of most significant digits/characters to strip from the dialed number.
00563     * \note Feature is deprecated.  Use dialplan logic.
00564     * \note The characters are stripped before the PRI TON/NPI prefix
00565     * characters are processed.
00566     */
00567    int stripmsd;
00568    /*!
00569     * \brief TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
00570     * \note
00571     * After CAS is sent, the call waiting caller id will be sent if the phone
00572     * gives a positive reply.
00573     */
00574    int callwaitcas;
00575    /*! \brief Number of call waiting rings. */
00576    int callwaitrings;
00577    /*! \brief Echo cancel parameters. */
00578    struct {
00579       struct dahdi_echocanparams head;
00580       struct dahdi_echocanparam params[DAHDI_MAX_ECHOCANPARAMS];
00581    } echocancel;
00582    /*!
00583     * \brief Echo training time. 0 = disabled
00584     * \note Set from the "echotraining" value read in from chan_dahdi.conf
00585     */
00586    int echotraining;
00587    /*! \brief Filled with 'w'.  XXX Purpose?? */
00588    char echorest[20];
00589    /*!
00590     * \brief Number of times to see "busy" tone before hanging up.
00591     * \note Set from the "busycount" value read in from chan_dahdi.conf
00592     */
00593    int busycount;
00594    /*!
00595     * \brief Busy cadence pattern description.
00596     * \note Set from the "busypattern" value read from chan_dahdi.conf
00597     */
00598    struct ast_dsp_busy_pattern busy_cadence;
00599    /*!
00600     * \brief Bitmapped call progress detection flags. CALLPROGRESS_xxx values.
00601     * \note Bits set from the "callprogress" and "faxdetect" values read in from chan_dahdi.conf
00602     */
00603    int callprogress;
00604    /*!
00605     * \brief Number of milliseconds to wait for dialtone.
00606     * \note Set from the "waitfordialtone" value read in from chan_dahdi.conf
00607     */
00608    int waitfordialtone;
00609    /*!
00610     * \brief Number of frames to watch for dialtone in incoming calls
00611     * \note Set from the "dialtone_detect" value read in from chan_dahdi.conf
00612     */
00613    int dialtone_detect;
00614    int dialtone_scanning_time_elapsed; /*!< Amount of audio scanned for dialtone, in frames */
00615    struct timeval waitingfordt;        /*!< Time we started waiting for dialtone */
00616    struct timeval flashtime;        /*!< Last flash-hook time */
00617    /*! \brief Opaque DSP configuration structure. */
00618    struct ast_dsp *dsp;
00619    /*! \brief DAHDI dial operation command struct for ioctl() call. */
00620    struct dahdi_dialoperation dop;
00621    int whichwink;             /*!< SIG_FEATDMF_TA Which wink are we on? */
00622    /*! \brief Second part of SIG_FEATDMF_TA wink operation. */
00623    char finaldial[64];
00624    char accountcode[AST_MAX_ACCOUNT_CODE];      /*!< Account code */
00625    int amaflags;              /*!< AMA Flags */
00626    struct tdd_state *tdd;           /*!< TDD flag */
00627    /*! \brief Accumulated call forwarding number. */
00628    char call_forward[AST_MAX_EXTENSION];
00629    /*!
00630     * \brief Voice mailbox location.
00631     * \note Set from the "mailbox" string read in from chan_dahdi.conf
00632     */
00633    char mailbox[AST_MAX_MAILBOX_UNIQUEID];
00634    /*! \brief Opaque event subscription parameters for message waiting indication support. */
00635    struct stasis_subscription *mwi_event_sub;
00636    /*! \brief Delayed dialing for E911.  Overlap digits for ISDN. */
00637    char dialdest[256];
00638 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI
00639    struct dahdi_vmwi_info mwisend_setting;            /*!< Which VMWI methods to use */
00640    unsigned int mwisend_fsk: 1;     /*! Variable for enabling FSK MWI handling in chan_dahdi */
00641    unsigned int mwisend_rpas:1;     /*! Variable for enabling Ring Pulse Alert before MWI FSK Spill */
00642 #endif
00643    int distinctivering;          /*!< Which distinctivering to use */
00644    int dtmfrelax;             /*!< whether to run in relaxed DTMF mode */
00645    /*! \brief Holding place for event injected from outside normal operation. */
00646    int fake_event;
00647    /*!
00648     * \brief Minimal time period (ms) between the answer polarity
00649     * switch and hangup polarity switch.
00650     */
00651    int polarityonanswerdelay;
00652    /*! \brief Start delay time if polarityonanswerdelay is nonzero. */
00653    struct timeval polaritydelaytv;
00654    /*!
00655     * \brief Send caller ID on FXS after this many rings. Set to 1 for US.
00656     * \note Set from the "sendcalleridafter" value read in from chan_dahdi.conf
00657     */
00658    int sendcalleridafter;
00659    /*! \brief Current line interface polarity. POLARITY_IDLE, POLARITY_REV */
00660    int polarity;
00661    /*! \brief DSP feature flags: DSP_FEATURE_xxx */
00662    int dsp_features;
00663 #if defined(HAVE_SS7)
00664    /*! \brief SS7 control parameters */
00665    struct sig_ss7_linkset *ss7;
00666 #endif   /* defined(HAVE_SS7) */
00667 #if defined(HAVE_OPENR2)
00668    struct dahdi_mfcr2 *mfcr2;
00669    openr2_chan_t *r2chan;
00670    openr2_calling_party_category_t mfcr2_recvd_category;
00671    openr2_calling_party_category_t mfcr2_category;
00672    int mfcr2_dnis_index;
00673    int mfcr2_ani_index;
00674    int mfcr2call:1;
00675    int mfcr2_answer_pending:1;
00676    int mfcr2_charge_calls:1;
00677    int mfcr2_allow_collect_calls:1;
00678    int mfcr2_forced_release:1;
00679    int mfcr2_dnis_matched:1;
00680    int mfcr2_call_accepted:1;
00681    int mfcr2_accept_on_offer:1;
00682    int mfcr2_progress_sent:1;
00683 #endif   /* defined(HAVE_OPENR2) */
00684    /*! \brief DTMF digit in progress.  0 when no digit in progress. */
00685    char begindigit;
00686    /*! \brief TRUE if confrence is muted. */
00687    int muting;
00688    void *sig_pvt;
00689    struct ast_cc_config_params *cc_params;
00690    /* DAHDI channel names may differ greatly from the
00691     * string that was provided to an app such as Dial. We
00692     * need to save the original string passed to dahdi_request
00693     * for call completion purposes. This way, we can replicate
00694     * the original dialed string later.
00695     */
00696    char dialstring[AST_CHANNEL_NAME];
00697 };
00698 
00699 
00700 /* Analog signaling */
00701 #define SIG_EM          DAHDI_SIG_EM
00702 #define SIG_EMWINK      (0x0100000 | DAHDI_SIG_EM)
00703 #define SIG_FEATD       (0x0200000 | DAHDI_SIG_EM)
00704 #define SIG_FEATDMF     (0x0400000 | DAHDI_SIG_EM)
00705 #define SIG_FEATB       (0x0800000 | DAHDI_SIG_EM)
00706 #define SIG_E911        (0x1000000 | DAHDI_SIG_EM)
00707 #define SIG_FEATDMF_TA  (0x2000000 | DAHDI_SIG_EM)
00708 #define SIG_FGC_CAMA    (0x4000000 | DAHDI_SIG_EM)
00709 #define SIG_FGC_CAMAMF  (0x8000000 | DAHDI_SIG_EM)
00710 #define SIG_FXSLS       DAHDI_SIG_FXSLS
00711 #define SIG_FXSGS       DAHDI_SIG_FXSGS
00712 #define SIG_FXSKS       DAHDI_SIG_FXSKS
00713 #define SIG_FXOLS       DAHDI_SIG_FXOLS
00714 #define SIG_FXOGS       DAHDI_SIG_FXOGS
00715 #define SIG_FXOKS       DAHDI_SIG_FXOKS
00716 #define SIG_SF          DAHDI_SIG_SF
00717 #define SIG_SFWINK      (0x0100000 | DAHDI_SIG_SF)
00718 #define SIG_SF_FEATD    (0x0200000 | DAHDI_SIG_SF)
00719 #define SIG_SF_FEATDMF  (0x0400000 | DAHDI_SIG_SF)
00720 #define SIG_SF_FEATB    (0x0800000 | DAHDI_SIG_SF)
00721 #define SIG_EM_E1       DAHDI_SIG_EM_E1
00722 
00723 /* PRI signaling */
00724 #define SIG_PRI         DAHDI_SIG_CLEAR
00725 #define SIG_BRI         (0x2000000 | DAHDI_SIG_CLEAR)
00726 #define SIG_BRI_PTMP    (0X4000000 | DAHDI_SIG_CLEAR)
00727 
00728 /* SS7 signaling */
00729 #define SIG_SS7         (0x1000000 | DAHDI_SIG_CLEAR)
00730 
00731 /* MFC/R2 signaling */
00732 #define SIG_MFCR2       DAHDI_SIG_CAS
00733 
00734 
00735 #define SIG_PRI_LIB_HANDLE_CASES \
00736    SIG_PRI:                \
00737    case SIG_BRI:              \
00738    case SIG_BRI_PTMP
00739 
00740 /*!
00741  * \internal
00742  * \brief Determine if sig_pri handles the signaling.
00743  * \since 1.8
00744  *
00745  * \param signaling Signaling to determine if is for sig_pri.
00746  *
00747  * \return TRUE if the signaling is for sig_pri.
00748  */
00749 static inline int dahdi_sig_pri_lib_handles(int signaling)
00750 {
00751    int handles;
00752 
00753    switch (signaling) {
00754    case SIG_PRI_LIB_HANDLE_CASES:
00755       handles = 1;
00756       break;
00757    default:
00758       handles = 0;
00759       break;
00760    }
00761 
00762    return handles;
00763 }
00764 
00765 static inline int dahdi_analog_lib_handles(int signalling, int radio, int oprmode)
00766 {
00767    switch (signalling) {
00768    case SIG_FXOLS:
00769    case SIG_FXOGS:
00770    case SIG_FXOKS:
00771    case SIG_FXSLS:
00772    case SIG_FXSGS:
00773    case SIG_FXSKS:
00774    case SIG_EMWINK:
00775    case SIG_EM:
00776    case SIG_EM_E1:
00777    case SIG_FEATD:
00778    case SIG_FEATDMF:
00779    case SIG_E911:
00780    case SIG_FGC_CAMA:
00781    case SIG_FGC_CAMAMF:
00782    case SIG_FEATB:
00783    case SIG_SFWINK:
00784    case SIG_SF:
00785    case SIG_SF_FEATD:
00786    case SIG_SF_FEATDMF:
00787    case SIG_FEATDMF_TA:
00788    case SIG_SF_FEATB:
00789       break;
00790    default:
00791       /* The rest of the function should cover the remainder of signalling types */
00792       return 0;
00793    }
00794 
00795    if (radio) {
00796       return 0;
00797    }
00798 
00799    if (oprmode) {
00800       return 0;
00801    }
00802 
00803    return 1;
00804 }
00805 
00806 #define dahdi_get_index(ast, p, nullok)   _dahdi_get_index(ast, p, nullok, __PRETTY_FUNCTION__, __LINE__)
00807 int _dahdi_get_index(struct ast_channel *ast, struct dahdi_pvt *p, int nullok, const char *fname, unsigned long line);
00808 
00809 void dahdi_dtmf_detect_disable(struct dahdi_pvt *p);
00810 void dahdi_dtmf_detect_enable(struct dahdi_pvt *p);
00811 
00812 void dahdi_ec_enable(struct dahdi_pvt *p);
00813 void dahdi_ec_disable(struct dahdi_pvt *p);
00814 
00815 void dahdi_conf_update(struct dahdi_pvt *p);
00816 void dahdi_master_slave_link(struct dahdi_pvt *slave, struct dahdi_pvt *master);
00817 void dahdi_master_slave_unlink(struct dahdi_pvt *slave, struct dahdi_pvt *master, int needlock);
00818 
00819 /* ------------------------------------------------------------------- */
00820 
00821 #if defined(__cplusplus) || defined(c_plusplus)
00822 }
00823 #endif
00824 
00825 #endif   /* _ASTERISK_CHAN_DAHDI_H */

Generated on Thu Apr 16 06:27:20 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6