Fri Aug 17 00:17:20 2018

Asterisk developer's documentation


sig_pri.h

Go to the documentation of this file.
00001 #ifndef _SIG_PRI_H
00002 #define _SIG_PRI_H
00003 /*
00004  * Asterisk -- An open source telephony toolkit.
00005  *
00006  * Copyright (C) 1999 - 2009, Digium, Inc.
00007  *
00008  * Mark Spencer <markster@digium.com>
00009  *
00010  * See http://www.asterisk.org for more information about
00011  * the Asterisk project. Please do not directly contact
00012  * any of the maintainers of this project for assistance;
00013  * the project provides a web site, mailing lists and IRC
00014  * channels for your use.
00015  *
00016  * This program is free software, distributed under the terms of
00017  * the GNU General Public License Version 2. See the LICENSE file
00018  * at the top of the source tree.
00019  */
00020 
00021 /*! \file
00022  *
00023  * \brief Interface header for PRI signaling module
00024  *
00025  * \author Matthew Fredrickson <creslin@digium.com>
00026  */
00027 
00028 #include "asterisk/channel.h"
00029 #include "asterisk/frame.h"
00030 #include "asterisk/event.h"
00031 #include "asterisk/ccss.h"
00032 #include <libpri.h>
00033 #include <dahdi/user.h>
00034 
00035 #if defined(HAVE_PRI_CCSS)
00036 /*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
00037 #define SIG_PRI_DEBUG_NORMAL  \
00038    (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
00039    | PRI_DEBUG_CC)
00040 
00041 /*! PRI debug message flags when intense PRI debugging is turned on at the command line. */
00042 #define SIG_PRI_DEBUG_INTENSE \
00043    (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
00044    | PRI_DEBUG_CC | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP)
00045 
00046 #else
00047 
00048 /*! PRI debug message flags when normal PRI debugging is turned on at the command line. */
00049 #define SIG_PRI_DEBUG_NORMAL  \
00050    (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE)
00051 
00052 /*! PRI debug message flags when intense PRI debugging is turned on at the command line. */
00053 #define SIG_PRI_DEBUG_INTENSE \
00054    (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \
00055    | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP)
00056 #endif   /* !defined(HAVE_PRI_CCSS) */
00057 
00058 #if 0
00059 /*! PRI debug message flags set on initial startup. */
00060 #define SIG_PRI_DEBUG_DEFAULT SIG_PRI_DEBUG_NORMAL
00061 #else
00062 /*! PRI debug message flags set on initial startup. */
00063 #define SIG_PRI_DEBUG_DEFAULT 0
00064 #endif
00065 
00066 #define SIG_PRI_AOC_GRANT_S    (1 << 0)
00067 #define SIG_PRI_AOC_GRANT_D    (1 << 1)
00068 #define SIG_PRI_AOC_GRANT_E    (1 << 2)
00069 
00070 enum sig_pri_tone {
00071    SIG_PRI_TONE_RINGTONE = 0,
00072    SIG_PRI_TONE_STUTTER,
00073    SIG_PRI_TONE_CONGESTION,
00074    SIG_PRI_TONE_DIALTONE,
00075    SIG_PRI_TONE_DIALRECALL,
00076    SIG_PRI_TONE_INFO,
00077    SIG_PRI_TONE_BUSY,
00078 };
00079 
00080 enum sig_pri_law {
00081    SIG_PRI_DEFLAW = 0,
00082    SIG_PRI_ULAW,
00083    SIG_PRI_ALAW
00084 };
00085 
00086 /*! Call establishment life cycle level for simple comparisons. */
00087 enum sig_pri_call_level {
00088    /*! Call does not exist. */
00089    SIG_PRI_CALL_LEVEL_IDLE,
00090    /*! Call is present but has no response yet. (SETUP) */
00091    SIG_PRI_CALL_LEVEL_SETUP,
00092    /*! Call is collecting digits for overlap dialing. (SETUP ACKNOWLEDGE) */
00093    SIG_PRI_CALL_LEVEL_OVERLAP,
00094    /*! Call routing is happening. (PROCEEDING) */
00095    SIG_PRI_CALL_LEVEL_PROCEEDING,
00096    /*! Called party is being alerted of the call. (ALERTING) */
00097    SIG_PRI_CALL_LEVEL_ALERTING,
00098    /*! Call is dialing 'w' deferred digits. (CONNECT) */
00099    SIG_PRI_CALL_LEVEL_DEFER_DIAL,
00100    /*! Call is connected/answered. (CONNECT) */
00101    SIG_PRI_CALL_LEVEL_CONNECT,
00102 };
00103 
00104 enum sig_pri_reset_state {
00105    /*! \brief The channel is not being RESTARTed. */
00106    SIG_PRI_RESET_IDLE,
00107    /*!
00108     * \brief The channel is being RESTARTed.
00109     * \note Waiting for a RESTART ACKNOWLEDGE from the peer.
00110     */
00111    SIG_PRI_RESET_ACTIVE,
00112    /*!
00113     * \brief Peer may not be sending the expected RESTART ACKNOWLEDGE.
00114     *
00115     * \details We have already received a SETUP on this channel.
00116     * If another SETUP comes in on this channel then the peer
00117     * considers this channel useable.  Assume that the peer is
00118     * never going to give us a RESTART ACKNOWLEDGE and assume that
00119     * we have received one.  This is not according to Q.931, but
00120     * some peers occasionally fail to send a RESTART ACKNOWLEDGE.
00121     */
00122    SIG_PRI_RESET_NO_ACK,
00123 };
00124 
00125 struct sig_pri_span;
00126 
00127 struct sig_pri_callback {
00128    /* Unlock the private in the signalling private structure.  This is used for three way calling madness. */
00129    void (* const unlock_private)(void *pvt);
00130    /* Lock the private in the signalling private structure.  ... */
00131    void (* const lock_private)(void *pvt);
00132    /* Function which is called back to handle any other DTMF events that are received.  Called by analog_handle_event.  Why is this
00133     * important to use, instead of just directly using events received before they are passed into the library?  Because sometimes,
00134     * (CWCID) the library absorbs DTMF events received. */
00135    //void (* const handle_dtmf)(void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest);
00136 
00137    //int (* const dial_digits)(void *pvt, enum analog_sub sub, struct analog_dialoperation *dop);
00138    int (* const play_tone)(void *pvt, enum sig_pri_tone tone);
00139 
00140    int (* const set_echocanceller)(void *pvt, int enable);
00141    int (* const train_echocanceller)(void *pvt);
00142    int (* const dsp_reset_and_flush_digits)(void *pvt);
00143 
00144    struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_pri_law law, char *exten, const struct ast_channel *chan);
00145 
00146    void (* const fixup_chans)(void *old_chan, void *new_chan);
00147 
00148    /* Note: Called with PRI lock held */
00149    void (* const handle_dchan_exception)(struct sig_pri_span *pri, int index);
00150    void (* const set_alarm)(void *pvt, int in_alarm);
00151    void (* const set_dialing)(void *pvt, int is_dialing);
00152    void (* const set_digital)(void *pvt, int is_digital);
00153    void (* const set_outgoing)(void *pvt, int is_outgoing);
00154    void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
00155    void (* const set_dnid)(void *pvt, const char *dnid);
00156    void (* const set_rdnis)(void *pvt, const char *rdnis);
00157    void (* const queue_control)(void *pvt, int subclass);
00158    int (* const new_nobch_intf)(struct sig_pri_span *pri);
00159    void (* const init_config)(void *pvt, struct sig_pri_span *pri);
00160    const char *(* const get_orig_dialstring)(void *pvt);
00161    void (* const make_cc_dialstring)(void *pvt, char *buf, size_t buf_size);
00162    void (* const update_span_devstate)(struct sig_pri_span *pri);
00163    void (* const dial_digits)(void *pvt, const char *dial_string);
00164 
00165    void (* const open_media)(void *pvt);
00166 
00167    /*!
00168     * \brief Post an AMI B channel association event.
00169     *
00170     * \param pvt Private structure of the user of this module.
00171     * \param chan Channel associated with the private pointer
00172     *
00173     * \return Nothing
00174     */
00175    void (* const ami_channel_event)(void *pvt, struct ast_channel *chan);
00176 
00177    /*! Reference the parent module. */
00178    void (*module_ref)(void);
00179    /*! Unreference the parent module. */
00180    void (*module_unref)(void);
00181 };
00182 
00183 #define SIG_PRI_NUM_DCHANS    4     /*!< No more than 4 d-channels */
00184 #define SIG_PRI_MAX_CHANNELS  672      /*!< No more than a DS3 per trunk group */
00185 
00186 #define SIG_PRI      DAHDI_SIG_CLEAR
00187 #define SIG_BRI      (0x2000000 | DAHDI_SIG_CLEAR)
00188 #define SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR)
00189 
00190 /* QSIG channel mapping option types */
00191 #define DAHDI_CHAN_MAPPING_PHYSICAL 0
00192 #define DAHDI_CHAN_MAPPING_LOGICAL  1
00193 
00194 /* Overlap dialing option types */
00195 #define DAHDI_OVERLAPDIAL_NONE 0
00196 #define DAHDI_OVERLAPDIAL_OUTGOING 1
00197 #define DAHDI_OVERLAPDIAL_INCOMING 2
00198 #define DAHDI_OVERLAPDIAL_BOTH (DAHDI_OVERLAPDIAL_INCOMING|DAHDI_OVERLAPDIAL_OUTGOING)
00199 
00200 #if defined(HAVE_PRI_SERVICE_MESSAGES)
00201 /*! \brief Persistent Service State */
00202 #define SRVST_DBKEY "service-state"
00203 /*! \brief The out-of-service SERVICE state */
00204 #define SRVST_TYPE_OOS "O"
00205 /*! \brief SRVST_INITIALIZED is used to indicate a channel being out-of-service
00206  *  The SRVST_INITIALIZED is mostly used maintain backwards compatibility but also may
00207  *  mean that the channel has not yet received a RESTART message.  If a channel is
00208  *  out-of-service with this reason a RESTART message will result in the channel
00209  *  being put into service. */
00210 #define SRVST_INITIALIZED 0
00211 /*! \brief SRVST_NEAREND is used to indicate that the near end was put out-of-service */
00212 #define SRVST_NEAREND  (1 << 0)
00213 /*! \brief SRVST_FAREND is used to indicate that the far end was taken out-of-service */
00214 #define SRVST_FAREND   (1 << 1)
00215 /*! \brief SRVST_BOTH is used to indicate that both sides of the channel are out-of-service */
00216 #define SRVST_BOTH (SRVST_NEAREND | SRVST_FAREND)
00217 
00218 /*! \brief The AstDB family */
00219 static const char dahdi_db[] = "dahdi/registry";
00220 #endif   /* defined(HAVE_PRI_SERVICE_MESSAGES) */
00221 
00222 struct sig_pri_chan {
00223    /* Options to be set by user */
00224    unsigned int hidecallerid:1;
00225    unsigned int hidecalleridname:1;      /*!< Hide just the name not the number for legacy PBX use */
00226    unsigned int immediate:1;        /*!< Answer before getting digits? */
00227    unsigned int priexclusive:1;        /*!< Whether or not to override and use exculsive mode for channel selection */
00228    unsigned int priindication_oob:1;
00229    unsigned int use_callerid:1;        /*!< Whether or not to use caller id on this channel */
00230    unsigned int use_callingpres:1;        /*!< Whether to use the callingpres the calling switch sends */
00231    char context[AST_MAX_CONTEXT];
00232    char mohinterpret[MAX_MUSICCLASS];
00233    int stripmsd;
00234    int channel;               /*!< Channel Number or CRV */
00235 
00236    /* Options to be checked by user */
00237    int cid_ani2;                 /*!< Automatic Number Identification number (Alternate PRI caller ID number) */
00238    int cid_ton;               /*!< Type Of Number (TON) */
00239    int callingpres;           /*!< The value of calling presentation that we're going to use when placing a PRI call */
00240    char cid_num[AST_MAX_EXTENSION];
00241    char cid_subaddr[AST_MAX_EXTENSION];
00242    char cid_name[AST_MAX_EXTENSION];
00243    char cid_ani[AST_MAX_EXTENSION];
00244    /*! \brief User tag for party id's sent from this device driver. */
00245    char user_tag[AST_MAX_EXTENSION];
00246    char exten[AST_MAX_EXTENSION];
00247 
00248    /* Internal variables -- Don't touch */
00249    /* Probably will need DS0 number, DS1 number, and a few other things */
00250    char dialdest[256];           /* Queued up digits for overlap dialing.  They will be sent out as information messages when setup ACK is received */
00251 #if defined(HAVE_PRI_SETUP_KEYPAD)
00252    /*! \brief Keypad digits that came in with the SETUP message. */
00253    char keypad_digits[AST_MAX_EXTENSION];
00254 #endif   /* defined(HAVE_PRI_SETUP_KEYPAD) */
00255    /*! 'w' deferred dialing digits. */
00256    char deferred_digits[AST_MAX_EXTENSION];
00257 
00258 #if defined(HAVE_PRI_AOC_EVENTS)
00259    struct pri_subcmd_aoc_e aoc_e;
00260    int aoc_s_request_invoke_id;     /*!< If an AOC-S request was present for the call, this is the invoke_id to use for the response */
00261    unsigned int aoc_s_request_invoke_id_valid:1; /*!< This is set when the AOC-S invoke id is present */
00262    unsigned int waiting_for_aoce:1; /*!< Delaying hangup for AOC-E msg. If this is set and AOC-E is received, continue with hangup before timeout period. */
00263    unsigned int holding_aoce:1;     /*!< received AOC-E msg from asterisk. holding for disconnect/release */
00264 #endif   /* defined(HAVE_PRI_AOC_EVENTS) */
00265    unsigned int inalarm:1;
00266    unsigned int alreadyhungup:1; /*!< TRUE if the call has already gone/hungup */
00267    unsigned int isidlecall:1;    /*!< TRUE if this is an idle call */
00268    unsigned int progress:1;      /*!< TRUE if the call has seen inband-information progress through the network */
00269 
00270    /*!
00271     * \brief TRUE when this channel is allocated.
00272     *
00273     * \details
00274     * Needed to hold an outgoing channel allocation before the
00275     * owner pointer is created.
00276     *
00277     * \note This is one of several items to check to see if a
00278     * channel is available for use.
00279     */
00280    unsigned int allocated:1;
00281    unsigned int outgoing:1;
00282    unsigned int digital:1;
00283    /*! \brief TRUE if this interface has no B channel.  (call hold and call waiting) */
00284    unsigned int no_b_channel:1;
00285 #if defined(HAVE_PRI_CALL_WAITING)
00286    /*! \brief TRUE if this is a call waiting call */
00287    unsigned int is_call_waiting:1;
00288 #endif   /* defined(HAVE_PRI_CALL_WAITING) */
00289 #if defined(HAVE_PRI_SETUP_ACK_INBAND)
00290    /*! TRUE if outgoing SETUP had no called digits */
00291    unsigned int no_dialed_digits:1;
00292 #endif   /* defined(HAVE_PRI_SETUP_ACK_INBAND) */
00293 
00294    struct ast_channel *owner;
00295 
00296    struct sig_pri_span *pri;
00297    q931_call *call;           /*!< opaque libpri call control structure */
00298 
00299    /*! Call establishment life cycle level for simple comparisons. */
00300    enum sig_pri_call_level call_level;
00301    /*! \brief Channel reset/restart state. */
00302    enum sig_pri_reset_state resetting;
00303    int prioffset;             /*!< channel number in span */
00304    int logicalspan;           /*!< logical span number within trunk group */
00305    int mastertrunkgroup;         /*!< what trunk group is our master */
00306 #if defined(HAVE_PRI_SERVICE_MESSAGES)
00307    /*! \brief Active SRVST_DBKEY out-of-service status value. */
00308    unsigned service_status;
00309 #endif   /* defined(HAVE_PRI_SERVICE_MESSAGES) */
00310 
00311    struct sig_pri_callback *calls;
00312    void *chan_pvt;               /*!< Private structure of the user of this module. */
00313 #if defined(HAVE_PRI_REVERSE_CHARGE)
00314    /*!
00315     * \brief Reverse charging indication
00316     * \details
00317     * -1 - No reverse charging,
00318     *  1 - Reverse charging,
00319     * 0,2-7 - Reserved for future use
00320     */
00321    int reverse_charging_indication;
00322 #endif
00323 };
00324 
00325 #if defined(HAVE_PRI_MWI)
00326 /*! Maximum number of mailboxes per span. */
00327 #define SIG_PRI_MAX_MWI_MAILBOXES         8
00328 /*! Typical maximum length of mwi mailbox number */
00329 #define SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN      10 /* digits in number */
00330 /*! Typical maximum length of mwi mailbox context */
00331 #define SIG_PRI_MAX_MWI_CONTEXT_LEN       10
00332 /*!
00333  * \brief Maximum mwi_mailbox string length.
00334  * \details
00335  * max_length = #mailboxes * (mbox_number + '@' + context + ',')
00336  * The last ',' is a null terminator instead.
00337  */
00338 #define SIG_PRI_MAX_MWI_MAILBOX_STR    (SIG_PRI_MAX_MWI_MAILBOXES \
00339    * (SIG_PRI_MAX_MWI_MBOX_NUMBER_LEN + 1 + SIG_PRI_MAX_MWI_CONTEXT_LEN + 1))
00340 
00341 struct sig_pri_mbox {
00342    /*!
00343     * \brief MWI mailbox event subscription.
00344     * \note NULL if mailbox not configured.
00345     */
00346    struct ast_event_sub *sub;
00347    /*! \brief Mailbox number */
00348    const char *number;
00349    /*! \brief Mailbox context. */
00350    const char *context;
00351 };
00352 #endif   /* defined(HAVE_PRI_MWI) */
00353 
00354 struct sig_pri_span {
00355    /* Should be set by user */
00356    struct ast_cc_config_params *cc_params;         /*!< CC config parameters for each new call. */
00357    int   pritimers[PRI_MAX_TIMERS];
00358    int overlapdial;                       /*!< In overlap dialing mode */
00359    int qsigchannelmapping;                   /*!< QSIG channel mapping type */
00360    int discardremoteholdretrieval;              /*!< shall remote hold or remote retrieval notifications be discarded? */
00361    int facilityenable;                       /*!< Enable facility IEs */
00362 #if defined(HAVE_PRI_L2_PERSISTENCE)
00363    /*! Layer 2 persistence option. */
00364    int l2_persistence;
00365 #endif   /* defined(HAVE_PRI_L2_PERSISTENCE) */
00366    int dchan_logical_span[SIG_PRI_NUM_DCHANS];     /*!< Logical offset the DCHAN sits in */
00367    int fds[SIG_PRI_NUM_DCHANS];              /*!< FD's for d-channels */
00368 
00369 #if defined(HAVE_PRI_AOC_EVENTS)
00370    int aoc_passthrough_flag;                 /*!< Represents what AOC messages (S,D,E) are allowed to pass-through */
00371    unsigned int aoce_delayhangup:1;          /*!< defines whether the aoce_delayhangup option is enabled or not */
00372 #endif   /* defined(HAVE_PRI_AOC_EVENTS) */
00373 
00374 #if defined(HAVE_PRI_SERVICE_MESSAGES)
00375    unsigned int enable_service_message_support:1;  /*!< enable SERVICE message support */
00376 #endif   /* defined(HAVE_PRI_SERVICE_MESSAGES) */
00377 #ifdef HAVE_PRI_INBANDDISCONNECT
00378    unsigned int inbanddisconnect:1;          /*!< Should we support inband audio after receiving DISCONNECT? */
00379 #endif
00380 #if defined(HAVE_PRI_CALL_HOLD)
00381    /*! \brief TRUE if held calls are transferred on disconnect. */
00382    unsigned int hold_disconnect_transfer:1;
00383 #endif   /* defined(HAVE_PRI_CALL_HOLD) */
00384    /*!
00385     * \brief TRUE if call transfer is enabled for the span.
00386     * \note Support switch-side transfer (called 2BCT, RLT or other names)
00387     */
00388    unsigned int transfer:1;
00389 #if defined(HAVE_PRI_CALL_WAITING)
00390    /*! \brief TRUE if we will allow incoming ISDN call waiting calls. */
00391    unsigned int allow_call_waiting_calls:1;
00392 #endif   /* defined(HAVE_PRI_CALL_WAITING) */
00393    /*! TRUE if layer 1 alarm status is ignored */
00394    unsigned int layer1_ignored:1;
00395    /*!
00396     * TRUE if a new call's sig_pri_chan.user_tag[] has the MSN
00397     * appended to the initial_user_tag[].
00398     */
00399    unsigned int append_msn_to_user_tag:1;
00400    /*! TRUE if a SETUP ACK message needs to open the audio path. */
00401    unsigned int inband_on_setup_ack:1;
00402    /*! TRUE if a PROCEEDING message needs to unsquelch the received audio. */
00403    unsigned int inband_on_proceeding:1;
00404    int dialplan;                    /*!< Dialing plan */
00405    int localdialplan;                  /*!< Local dialing plan */
00406    char internationalprefix[10];       /*!< country access code ('00' for european dialplans) */
00407    char nationalprefix[10];            /*!< area access code ('0' for european dialplans) */
00408    char localprefix[20];               /*!< area access code + area code ('0'+area code for european dialplans) */
00409    char privateprefix[20];             /*!< for private dialplans */
00410    char unknownprefix[20];             /*!< for unknown dialplans */
00411    long resetinterval;                 /*!< Interval (in seconds) for resetting unused channels */
00412 #if defined(HAVE_PRI_MWI)
00413    /*! \brief Active MWI mailboxes */
00414    struct sig_pri_mbox mbox[SIG_PRI_MAX_MWI_MAILBOXES];
00415    /*!
00416     * \brief Comma separated list of mailboxes to indicate MWI.
00417     * \note Empty if disabled.
00418     * \note Format: mailbox_number[@context]{,mailbox_number[@context]}
00419     * \note String is split apart when span is started.
00420     */
00421    char mwi_mailboxes[SIG_PRI_MAX_MWI_MAILBOX_STR];
00422 #endif   /* defined(HAVE_PRI_MWI) */
00423    /*!
00424     * \brief Initial user tag for party id's sent from this device driver.
00425     * \note String set by config file.
00426     */
00427    char initial_user_tag[AST_MAX_EXTENSION];
00428    char msn_list[AST_MAX_EXTENSION];      /*!< Comma separated list of MSNs to handle.  Empty if disabled. */
00429    char idleext[AST_MAX_EXTENSION];    /*!< Where to idle extra calls */
00430    char idlecontext[AST_MAX_CONTEXT];     /*!< What context to use for idle */
00431    char idledial[AST_MAX_EXTENSION];      /*!< What to dial before dumping */
00432    int minunused;                   /*!< Min # of channels to keep empty */
00433    int minidle;                     /*!< Min # of "idling" calls to keep active */
00434    int nodetype;                    /*!< Node type */
00435    int switchtype;                     /*!< Type of switch to emulate */
00436    int nsf;                      /*!< Network-Specific Facilities */
00437    int trunkgroup;                     /*!< What our trunkgroup is */
00438 #if defined(HAVE_PRI_CCSS)
00439    int cc_ptmp_recall_mode;            /*!< CC PTMP recall mode. globalRecall(0), specificRecall(1) */
00440    int cc_qsig_signaling_link_req;        /*!< CC Q.SIG signaling link retention (Party A) release(0), retain(1), do-not-care(2) */
00441    int cc_qsig_signaling_link_rsp;        /*!< CC Q.SIG signaling link retention (Party B) release(0), retain(1) */
00442 #endif   /* defined(HAVE_PRI_CCSS) */
00443 #if defined(HAVE_PRI_CALL_WAITING)
00444    /*!
00445     * \brief Number of extra outgoing calls to allow on a span before
00446     * considering that span congested.
00447     */
00448    int max_call_waiting_calls;
00449    struct {
00450       int stripmsd;
00451       unsigned int hidecallerid:1;
00452       unsigned int hidecalleridname:1;      /*!< Hide just the name not the number for legacy PBX use */
00453       unsigned int immediate:1;        /*!< Answer before getting digits? */
00454       unsigned int priexclusive:1;        /*!< Whether or not to override and use exculsive mode for channel selection */
00455       unsigned int priindication_oob:1;
00456       unsigned int use_callerid:1;        /*!< Whether or not to use caller id on this channel */
00457       unsigned int use_callingpres:1;        /*!< Whether to use the callingpres the calling switch sends */
00458       char context[AST_MAX_CONTEXT];
00459       char mohinterpret[MAX_MUSICCLASS];
00460    } ch_cfg;
00461 
00462    /*!
00463     * \brief Number of outstanding call waiting calls.
00464     * \note Must be zero to allow new calls from asterisk to
00465     * immediately allocate a B channel.
00466     */
00467    int num_call_waiting_calls;
00468 #endif   /* defined(HAVE_PRI_CALL_WAITING) */
00469    int dchanavail[SIG_PRI_NUM_DCHANS];    /*!< Whether each channel is available */
00470    int debug;                       /*!< set to true if to dump PRI event info */
00471    int span;                        /*!< span number put into user output messages */
00472    int resetting;                   /*!< true if span is being reset/restarted */
00473    int resetpos;                    /*!< current position during a reset (-1 if not started) */
00474    int sig;                      /*!< ISDN signalling type (SIG_PRI, SIG_BRI, SIG_BRI_PTMP, etc...) */
00475    int new_chan_seq;                /*!< New struct ast_channel sequence number */
00476    /*! TRUE if we have already whined about no D channels available. */
00477    unsigned int no_d_channels:1;
00478 
00479    /* Everything after here is internally set */
00480    struct pri *dchans[SIG_PRI_NUM_DCHANS];      /*!< Actual d-channels */
00481    struct pri *pri;                    /*!< Currently active D-channel */
00482    /*!
00483     * List of private structures of the user of this module for no B channel
00484     * interfaces. (hold and call waiting interfaces)
00485     */
00486    void *no_b_chan_iflist;
00487    /*!
00488     * List of private structures of the user of this module for no B channel
00489     * interfaces. (hold and call waiting interfaces)
00490     */
00491    void *no_b_chan_end;
00492    int numchans;                       /*!< Num of channels we represent */
00493    struct sig_pri_chan *pvts[SIG_PRI_MAX_CHANNELS];/*!< Member channel pvt structs */
00494    pthread_t master;                   /*!< Thread of master */
00495    ast_mutex_t lock;                   /*!< libpri access Mutex */
00496    time_t lastreset;                   /*!< time when unused channels were last reset */
00497    struct sig_pri_callback *calls;
00498    /*!
00499     * \brief Congestion device state of the span.
00500     * \details
00501     * AST_DEVICE_NOT_INUSE - Span does not have all B channels in use.
00502     * AST_DEVICE_BUSY - All B channels are in use.
00503     * AST_DEVICE_UNAVAILABLE - Span is in alarm.
00504     * \note
00505     * Device name: \startverbatim DAHDI/I<span>/congestion. \endverbatim
00506     */
00507    int congestion_devstate;
00508 #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER)
00509    /*! \todo An ISDN span threshold device state could be useful in determining how often a span utilization goes over a configurable threshold. */
00510    /*!
00511     * \brief User threshold device state of the span.
00512     * \details
00513     * AST_DEVICE_NOT_INUSE - There are no B channels in use.
00514     * AST_DEVICE_INUSE - The number of B channels in use is less than
00515     *    the configured threshold but not zero.
00516     * AST_DEVICE_BUSY - The number of B channels in use meets or exceeds
00517     *    the configured threshold.
00518     * AST_DEVICE_UNAVAILABLE - Span is in alarm.
00519     * \note
00520     * Device name:  DAHDI/I<span>/threshold
00521     */
00522    int threshold_devstate;
00523    /*!
00524     * \brief Number of B channels in use to consider the span in a busy state.
00525     * \note Setting the threshold to zero is interpreted as all B channels.
00526     */
00527    int user_busy_threshold;
00528 #endif   /* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
00529 };
00530 
00531 void sig_pri_extract_called_num_subaddr(struct sig_pri_chan *p, const char *rdest, char *called, size_t called_buff_size);
00532 int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, int timeout, int layer1);
00533 
00534 int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast);
00535 
00536 int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
00537 
00538 int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast);
00539 
00540 int sig_pri_is_chan_available(struct sig_pri_chan *pvt);
00541 int sig_pri_available(struct sig_pri_chan **pvt, int is_specific_channel);
00542 
00543 void sig_pri_init_pri(struct sig_pri_span *pri);
00544 
00545 /* If return 0, it means this function was able to handle it (pre setup digits).  If non zero, the user of this
00546  * functions should handle it normally (generate inband DTMF) */
00547 int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char digit);
00548 void sig_pri_dial_complete(struct sig_pri_chan *pvt, struct ast_channel *ast);
00549 
00550 void sig_pri_stop_pri(struct sig_pri_span *pri);
00551 int sig_pri_start_pri(struct sig_pri_span *pri);
00552 
00553 void sig_pri_set_alarm(struct sig_pri_chan *p, int in_alarm);
00554 void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm);
00555 
00556 int sig_pri_is_alarm_ignored(struct sig_pri_span *pri);
00557 void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri);
00558 void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri);
00559 
00560 struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor, int transfercapability);
00561 
00562 struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup);
00563 void sig_pri_chan_delete(struct sig_pri_chan *doomed);
00564 
00565 int pri_is_up(struct sig_pri_span *pri);
00566 
00567 void sig_pri_cli_show_channels_header(int fd);
00568 void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri);
00569 void sig_pri_cli_show_spans(int fd, int span, struct sig_pri_span *pri);
00570 
00571 void sig_pri_cli_show_span(int fd, int *dchannels, struct sig_pri_span *pri);
00572 
00573 int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits);
00574 int pri_send_callrerouting_facility_exec(struct sig_pri_chan *p, enum ast_channel_state chanstate, const char *destination, const char *original, const char *reason);
00575 
00576 #if defined(HAVE_PRI_SERVICE_MESSAGES)
00577 int pri_maintenance_bservice(struct pri *pri, struct sig_pri_chan *p, int changestatus);
00578 #endif   /* defined(HAVE_PRI_SERVICE_MESSAGES) */
00579 
00580 void sig_pri_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan);
00581 
00582 int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan);
00583 int sig_pri_cc_agent_start_offer_timer(struct ast_cc_agent *agent);
00584 int sig_pri_cc_agent_stop_offer_timer(struct ast_cc_agent *agent);
00585 void sig_pri_cc_agent_req_rsp(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason);
00586 int sig_pri_cc_agent_status_req(struct ast_cc_agent *agent);
00587 int sig_pri_cc_agent_stop_ringing(struct ast_cc_agent *agent);
00588 int sig_pri_cc_agent_party_b_free(struct ast_cc_agent *agent);
00589 int sig_pri_cc_agent_start_monitoring(struct ast_cc_agent *agent);
00590 int sig_pri_cc_agent_callee_available(struct ast_cc_agent *agent);
00591 void sig_pri_cc_agent_destructor(struct ast_cc_agent *agent);
00592 
00593 int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, int *available_timer_id);
00594 int sig_pri_cc_monitor_suspend(struct ast_cc_monitor *monitor);
00595 int sig_pri_cc_monitor_unsuspend(struct ast_cc_monitor *monitor);
00596 int sig_pri_cc_monitor_status_rsp(struct ast_cc_monitor *monitor, enum ast_device_state devstate);
00597 int sig_pri_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id);
00598 void sig_pri_cc_monitor_destructor(void *monitor_pvt);
00599 
00600 int sig_pri_load(const char *cc_type_name);
00601 void sig_pri_unload(void);
00602 
00603 #endif /* _SIG_PRI_H */

Generated on 17 Aug 2018 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1