Mon Mar 19 11:30:28 2012

Asterisk developer's documentation


isdn_lib.h

Go to the documentation of this file.
00001 /*
00002  * Chan_Misdn -- Channel Driver for Asterisk
00003  *
00004  * Interface to mISDN
00005  *
00006  * Copyright (C) 2004, Christian Richter
00007  *
00008  * Christian Richter <crich@beronet.com>
00009  *
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License
00012  */
00013 
00014 /*! \file
00015  * \brief Interface to mISDN
00016  *
00017  * \author Christian Richter <crich@beronet.com>
00018  */
00019 
00020 #ifndef TE_LIB
00021 #define TE_LIB
00022 
00023 #include <mISDNuser/suppserv.h>
00024 
00025 /** For initialization usage **/
00026 /* typedef int ie_nothing_t ;*/
00027 /** end of init usage **/
00028 
00029 
00030 /*
00031  * uncomment the following to make chan_misdn create
00032  * record files in /tmp/misdn-{rx|tx}-PortChannel format
00033  * */
00034 
00035 /*#define MISDN_SAVE_DATA*/
00036 
00037 #ifdef WITH_BEROEC
00038 typedef int beroec_t;
00039 
00040 
00041 enum beroec_type {
00042    BEROEC_FULLBAND=0,
00043    BEROEC_SUBBAND,
00044    BEROEC_FASTSUBBAND
00045 };
00046 
00047 void beroec_init(void);
00048 void beroec_exit(void);
00049 beroec_t *beroec_new(int tail, enum beroec_type type, int anti_howl,
00050            int tonedisable, int zerocoeff, int adapt, int nlp);
00051 
00052 void beroec_destroy(beroec_t *ec);
00053 int beroec_cancel_alaw_chunk(beroec_t *ec,
00054    char *send,
00055    char *receive,
00056    int len);
00057 
00058 int beroec_version(void);
00059 #endif
00060 
00061 
00062 
00063 enum tone_e {
00064    TONE_NONE=0,
00065    TONE_DIAL,
00066    TONE_ALERTING,
00067    TONE_FAR_ALERTING,
00068    TONE_BUSY,
00069    TONE_HANGUP,
00070    TONE_CUSTOM,
00071    TONE_FILE
00072 };
00073 
00074 
00075 
00076 #define MAX_BCHANS 31
00077 
00078 enum bchannel_state {
00079    BCHAN_CLEANED=0,
00080    BCHAN_EMPTY,
00081    BCHAN_SETUP,
00082    BCHAN_SETUPED,
00083    BCHAN_ACTIVE,
00084    BCHAN_ACTIVATED,
00085    BCHAN_BRIDGE,
00086    BCHAN_BRIDGED,
00087    BCHAN_RELEASE,
00088    BCHAN_RELEASED,
00089    BCHAN_CLEAN,
00090    BCHAN_CLEAN_REQUEST,
00091    BCHAN_ERROR
00092 };
00093 
00094 
00095 enum misdn_err_e {
00096    ENOCHAN=1
00097 };
00098 
00099 enum mISDN_NUMBER_PLAN {
00100    NUMPLAN_UNKNOWN = 0x0,
00101    NUMPLAN_ISDN = 0x1,     /* ISDN/Telephony numbering plan E.164 */
00102    NUMPLAN_DATA = 0x3,     /* Data numbering plan X.121 */
00103    NUMPLAN_TELEX = 0x4, /* Telex numbering plan F.69 */
00104    NUMPLAN_NATIONAL = 0x8,
00105    NUMPLAN_PRIVATE = 0x9
00106 };
00107 
00108 enum mISDN_NUMBER_TYPE {
00109    NUMTYPE_UNKNOWN = 0x0,
00110    NUMTYPE_INTERNATIONAL = 0x1,
00111    NUMTYPE_NATIONAL = 0x2,
00112    NUMTYPE_NETWORK_SPECIFIC = 0x3,
00113    NUMTYPE_SUBSCRIBER = 0x4,
00114    NUMTYPE_ABBREVIATED = 0x5
00115 };
00116 
00117 enum event_response_e {
00118    RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE,
00119    RESPONSE_IGNORE_SETUP,
00120    RESPONSE_RELEASE_SETUP,
00121    RESPONSE_ERR,
00122    RESPONSE_OK
00123 };
00124 
00125 
00126 enum event_e {
00127    EVENT_NOTHING,
00128    EVENT_TONE_GENERATE,
00129    EVENT_BCHAN_DATA,
00130    EVENT_BCHAN_ACTIVATED,
00131    EVENT_BCHAN_ERROR,
00132    EVENT_CLEANUP,
00133    EVENT_PROCEEDING,
00134    EVENT_PROGRESS,
00135    EVENT_SETUP,
00136    EVENT_REGISTER,
00137    EVENT_ALERTING,
00138    EVENT_CONNECT,
00139    EVENT_SETUP_ACKNOWLEDGE,
00140    EVENT_CONNECT_ACKNOWLEDGE ,
00141    EVENT_USER_INFORMATION,
00142    EVENT_SUSPEND_REJECT,
00143    EVENT_RESUME_REJECT,
00144    EVENT_HOLD,
00145    EVENT_SUSPEND,
00146    EVENT_RESUME,
00147    EVENT_HOLD_ACKNOWLEDGE,
00148    EVENT_SUSPEND_ACKNOWLEDGE,
00149    EVENT_RESUME_ACKNOWLEDGE,
00150    EVENT_HOLD_REJECT,
00151    EVENT_RETRIEVE,
00152    EVENT_RETRIEVE_ACKNOWLEDGE,
00153    EVENT_RETRIEVE_REJECT,
00154    EVENT_DISCONNECT,
00155    EVENT_RESTART,
00156    EVENT_RELEASE,
00157    EVENT_RELEASE_COMPLETE,
00158    EVENT_FACILITY,
00159    EVENT_NOTIFY,
00160    EVENT_STATUS_ENQUIRY,
00161    EVENT_INFORMATION,
00162    EVENT_STATUS,
00163    EVENT_TIMEOUT,
00164    EVENT_DTMF_TONE,
00165    EVENT_NEW_L3ID,
00166    EVENT_NEW_BC,
00167    EVENT_PORT_ALARM,
00168    EVENT_NEW_CHANNEL,
00169    EVENT_UNKNOWN
00170 };
00171 
00172 
00173 enum ie_name_e {
00174    IE_DUMMY,
00175    IE_LAST
00176 };
00177 
00178 enum { /* bearer capability */
00179    INFO_CAPABILITY_SPEECH=0,
00180    INFO_CAPABILITY_AUDIO_3_1K=0x10 ,
00181    INFO_CAPABILITY_AUDIO_7K=0x11 ,
00182    INFO_CAPABILITY_VIDEO =0x18,
00183    INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8,
00184    INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09,
00185    INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES
00186 };
00187 
00188 enum { /* progress indicators */
00189    INFO_PI_CALL_NOT_E2E_ISDN =0x01,
00190    INFO_PI_CALLED_NOT_ISDN =0x02,
00191    INFO_PI_CALLER_NOT_ISDN =0x03,
00192    INFO_PI_CALLER_RETURNED_TO_ISDN =0x04,
00193    INFO_PI_INBAND_AVAILABLE =0x08,
00194    INFO_PI_DELAY_AT_INTERF =0x0a,
00195    INFO_PI_INTERWORKING_WITH_PUBLIC =0x10,
00196    INFO_PI_INTERWORKING_NO_RELEASE =0x11,
00197    INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12,
00198    INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13
00199 };
00200 
00201 /*!
00202  * \brief Q.931 encoded redirecting reason
00203  */
00204 enum mISDN_REDIRECTING_REASON {
00205    mISDN_REDIRECTING_REASON_UNKNOWN = 0x0,
00206    /*! Call forwarding busy or called DTE busy */
00207    mISDN_REDIRECTING_REASON_CALL_FWD_BUSY = 0x1,
00208    /*! Call forwarding no reply */
00209    mISDN_REDIRECTING_REASON_NO_REPLY = 0x2,
00210    /*! Call deflection */
00211    mISDN_REDIRECTING_REASON_DEFLECTION = 0x4,
00212    /*! Called DTE out of order */
00213    mISDN_REDIRECTING_REASON_OUT_OF_ORDER = 0x9,
00214    /*! Call forwarding by the called DTE */
00215    mISDN_REDIRECTING_REASON_CALL_FWD_DTE = 0xA,
00216    /*! Call forwarding unconditional or systematic call redirection */
00217    mISDN_REDIRECTING_REASON_CALL_FWD = 0xF
00218 };
00219 
00220 /*!
00221  * \brief Notification description code enumeration
00222  */
00223 enum mISDN_NOTIFY_CODE {
00224    mISDN_NOTIFY_CODE_INVALID = -1,
00225    /*! Call is placed on hold (Q.931) */
00226    mISDN_NOTIFY_CODE_USER_SUSPEND = 0x00,
00227    /*! Call is taken off of hold (Q.931) */
00228    mISDN_NOTIFY_CODE_USER_RESUME = 0x01,
00229    /*! Call is diverting (EN 300 207-1 Section 7.2.1) */
00230    mISDN_NOTIFY_CODE_CALL_IS_DIVERTING = 0x7B,
00231    /*! Call diversion is enabled (cfu, cfb, cfnr) (EN 300 207-1 Section 7.2.1) */
00232    mISDN_NOTIFY_CODE_DIVERSION_ACTIVATED = 0x68,
00233    /*! Call transfer, alerting (EN 300 369-1 Section 7.2) */
00234    mISDN_NOTIFY_CODE_CALL_TRANSFER_ALERTING = 0x69,
00235    /*! Call transfer, active(answered) (EN 300 369-1 Section 7.2) */
00236    mISDN_NOTIFY_CODE_CALL_TRANSFER_ACTIVE = 0x6A,
00237 };
00238 
00239 enum { /*CODECS*/
00240    INFO_CODEC_ULAW=2,
00241    INFO_CODEC_ALAW=3
00242 };
00243 
00244 
00245 enum layer_e {
00246    L3,
00247    L2,
00248    L1,
00249    UNKNOWN
00250 };
00251 
00252 /*! Maximum phone number (address) length plus null terminator */
00253 #define MISDN_MAX_NUMBER_LEN     (31 + 1)
00254 
00255 /*! Maximum name length plus null terminator (From ECMA-164) */
00256 #define MISDN_MAX_NAME_LEN       (50 + 1)
00257 
00258 /*! Maximum subaddress length plus null terminator */
00259 #define MISDN_MAX_SUBADDRESS_LEN (23 + 1)
00260 
00261 /*! Maximum keypad facility content length plus null terminator */
00262 #define MISDN_MAX_KEYPAD_LEN     (31 + 1)
00263 
00264 /*! \brief Dialed/Called information struct */
00265 struct misdn_party_dialing {
00266    /*! \brief Type-of-number in ISDN terms for the dialed/called number */
00267    enum mISDN_NUMBER_TYPE number_type;
00268 
00269    /*! \brief Type-of-number numbering plan. */
00270    enum mISDN_NUMBER_PLAN number_plan;
00271 
00272    /*! \brief Dialed/Called Phone Number (Address) */
00273    char number[MISDN_MAX_NUMBER_LEN];
00274 
00275    /*! \brief Dialed/Called Subaddress number */
00276    char subaddress[MISDN_MAX_SUBADDRESS_LEN];
00277 };
00278 
00279 /*! \brief Connected-Line/Calling/Redirecting ID info struct */
00280 struct misdn_party_id {
00281    /*! \brief Number presentation restriction code
00282     * 0=Allowed, 1=Restricted, 2=Unavailable
00283     */
00284    int presentation;
00285 
00286    /*! \brief Number screening code
00287     * 0=Unscreened, 1=Passed Screen, 2=Failed Screen, 3=Network Number
00288     */
00289    int screening;
00290 
00291    /*! \brief Type-of-number in ISDN terms for the number */
00292    enum mISDN_NUMBER_TYPE number_type;
00293 
00294    /*! \brief Type-of-number numbering plan. */
00295    enum mISDN_NUMBER_PLAN number_plan;
00296 
00297    /*! \brief Subscriber Name
00298     * \note The name is currently obtained from Asterisk for
00299     * potential use in display ie's since basic ISDN does
00300     * not support names directly.
00301     */
00302    char name[MISDN_MAX_NAME_LEN];
00303 
00304    /*! \brief Phone number (Address) */
00305    char number[MISDN_MAX_NUMBER_LEN];
00306 
00307    /*! \brief Subaddress number */
00308    char subaddress[MISDN_MAX_SUBADDRESS_LEN];
00309 };
00310 
00311 /*! \brief Redirecting information struct */
00312 struct misdn_party_redirecting {
00313    /*! \brief Who is redirecting the call (Sent to the party the call is redirected toward) */
00314    struct misdn_party_id from;
00315 
00316    /*! \brief Where the call is being redirected toward (Sent to the calling party) */
00317    struct misdn_party_id to;
00318 
00319    /*! \brief Reason a call is being redirected (Q.931 field value) */
00320    enum mISDN_REDIRECTING_REASON reason;
00321 
00322    /*! \brief Number of times the call has been redirected */
00323    int count;
00324 
00325    /*! \brief TRUE if the redirecting.to information has changed */
00326    int to_changed;
00327 };
00328 
00329 
00330 /*! \brief B channel control structure */
00331 struct misdn_bchannel {
00332    /*! \brief B channel send locking structure */
00333    struct send_lock *send_lock;
00334 
00335 #if defined(AST_MISDN_ENHANCEMENTS)
00336    /*! \brief The BC, HLC (optional) and LLC (optional) contents from the SETUP message. */
00337    struct Q931_Bc_Hlc_Llc setup_bc_hlc_llc;
00338 #endif   /* defined(AST_MISDN_ENHANCEMENTS) */
00339 
00340    /*!
00341     * \brief Dialed/Called information struct
00342     * \note The number_type element is set to "dialplan" in /etc/asterisk/misdn.conf for outgoing calls
00343     */
00344    struct misdn_party_dialing dialed;
00345 
00346    /*! \brief Originating/Caller ID information struct
00347     * \note The number_type element can be set to "localdialplan" in /etc/asterisk/misdn.conf for outgoing calls
00348     * \note The number element can be set to "callerid" in /etc/asterisk/misdn.conf for outgoing calls
00349     */
00350    struct misdn_party_id caller;
00351 
00352    /*! \brief  Incoming Caller ID string tag for special purpose
00353     * \note The element can be set to "incoming_cid_tag" in /etc/asterisk/misdn.conf for incoming calls
00354     */
00355    char incoming_cid_tag[MISDN_MAX_NAME_LEN];
00356 
00357    /*! \brief Connected-Party/Connected-Line ID information struct
00358     * \note The number_type element can be set to "cpndialplan" in /etc/asterisk/misdn.conf for outgoing calls
00359     */
00360    struct misdn_party_id connected;
00361 
00362    /*! \brief Redirecting information struct (Where a call diversion or transfer was invoked)
00363     * \note The redirecting subaddress is not defined in Q.931 so it is not used.
00364     */
00365    struct misdn_party_redirecting redirecting;
00366 
00367    /*! \brief TRUE if this is a dummy BC record */
00368    int dummy;
00369 
00370    /*! \brief TRUE if NT side of protocol (TE otherwise) */
00371    int nt;
00372 
00373    /*! \brief TRUE if ISDN-PRI (ISDN-BRI otherwise) */
00374    int pri;
00375 
00376    /*! \brief Logical Layer 1 port associated with this B channel */
00377    int port;
00378 
00379    /** init stuff **/
00380    /*! \brief B Channel mISDN driver stack ID */
00381    int b_stid;
00382 
00383    /* int b_addr; */
00384 
00385    /*! \brief B Channel mISDN driver layer ID from mISDN_new_layer() */
00386    int layer_id;
00387 
00388    /*! \brief B channel layer; set to 3 or 4 */
00389    int layer;
00390 
00391    /* state stuff */
00392    /*! \brief TRUE if DISCONNECT needs to be sent to clear a call */
00393    int need_disconnect;
00394 
00395    /*! \brief TRUE if RELEASE needs to be sent to clear a call */
00396    int need_release;
00397 
00398    /*! \brief TRUE if RELEASE_COMPLETE needs to be sent to clear a call */
00399    int need_release_complete;
00400 
00401    /*! \brief TRUE if allocate higher B channels first */
00402    int dec;
00403 
00404    /* var stuff */
00405    /*! \brief Layer 3 process ID */
00406    int l3_id;
00407 
00408    /*! \brief B channel process ID (1-5000) */
00409    int pid;
00410 
00411    /*! \brief Not used. Saved mISDN stack CONNECT_t ces value */
00412    int ces;
00413 
00414    /*! \brief B channel to restart if received a RESTART message */
00415    int restart_channel;
00416 
00417    /*! \brief Assigned B channel number B1, B2... 0 if not assigned */
00418    int channel;
00419 
00420    /*! \brief TRUE if the B channel number is preselected */
00421    int channel_preselected;
00422 
00423    /*! \brief TRUE if the B channel is allocated from the REGISTER pool */
00424    int is_register_pool;
00425 
00426    /*! \brief TRUE if B channel record is in use */
00427    int in_use;
00428 
00429    /*! \brief Time when empty_bc() last called on this record */
00430    struct timeval last_used;
00431 
00432    /*! \brief TRUE if call waiting */
00433    int cw;
00434 
00435    /*! \brief B Channel mISDN driver layer ID from mISDN_get_layerid() */
00436    int addr;
00437 
00438    /*! \brief B channel speech sample data buffer */
00439    char *bframe;
00440 
00441    /*! \brief B channel speech sample data buffer size */
00442    int bframe_len;
00443    int time_usec; /* Not used */
00444 
00445    /*! \brief Not used. Contents are setup but not used. */
00446    void *astbuf;
00447 
00448    /*! \brief TRUE if the TE side should choose the B channel to use
00449     * \note This value is user configurable in /etc/asterisk/misdn.conf
00450     */
00451    int te_choose_channel;
00452 
00453    /*! \brief TRUE if the call progress indicators can indicate an inband audio message for the user to listen to
00454     * \note This value is user configurable in /etc/asterisk/misdn.conf
00455     */
00456    int early_bconnect;
00457 
00458    /*! \brief Last decoded DTMF digit from mISDN driver */
00459    int dtmf;
00460 
00461    /*! \brief TRUE if we should produce DTMF tones ourselves
00462     * \note This value is user configurable in /etc/asterisk/misdn.conf
00463     */
00464    int send_dtmf;
00465 
00466    /*! \brief TRUE if we send SETUP_ACKNOWLEDGE on incoming calls anyway (instead of PROCEEDING).
00467     *
00468     * This requests additional INFORMATION messages, so we can
00469     * wait for digits without issues.
00470     * \note This value is user configurable in /etc/asterisk/misdn.conf
00471     */
00472    int need_more_infos;
00473 
00474    /*! \brief TRUE if all digits necessary to complete the call are available.
00475     * No more INFORMATION messages are needed.
00476     */
00477    int sending_complete;
00478 
00479 
00480    /*! \brief TRUE if we will not use jollys dsp */
00481    int nodsp;
00482 
00483    /*! \brief TRUE if we will not use the jitter buffer system */
00484    int nojitter;
00485 
00486    /*! \brief Progress Indicator IE coding standard field.
00487     * \note Collected from the incoming messages but not used.
00488     */
00489    int progress_coding;
00490 
00491    /*! \brief Progress Indicator IE location field.
00492     * \note Collected from the incoming messages but not used.
00493     */
00494    int progress_location;
00495 
00496    /*! \brief Progress Indicator IE progress description field.
00497     * Used to determine if there is an inband audio message present.
00498     */
00499    int progress_indicator;
00500 
00501 #if defined(AST_MISDN_ENHANCEMENTS)
00502    /*!
00503     * \brief TRUE if waiting for DivertingLegInformation3 to queue redirecting update.
00504     */
00505    int div_leg_3_rx_wanted;
00506 
00507    /*!
00508     * \brief TRUE if a DivertingLegInformation3 needs to be sent with CONNECT.
00509     */
00510    int div_leg_3_tx_pending;
00511 #endif   /* defined(AST_MISDN_ENHANCEMENTS) */
00512 
00513    /*! \brief Inbound FACILITY message function type and contents */
00514    struct FacParm fac_in;
00515 
00516    /*! \brief Outbound FACILITY message function type and contents.
00517     * \note Filled in by misdn facility commands before FACILITY message sent.
00518     */
00519    struct FacParm fac_out;
00520 
00521    /* storing the current AOCD info here */
00522    enum FacFunction AOCDtype;
00523    union {
00524       struct FacAOCDCurrency currency;
00525       struct FacAOCDChargingUnit chargingUnit;
00526    } AOCD;
00527    /*! \brief TRUE if AOCDtype and AOCD data are ready to export to Asterisk */
00528    int AOCD_need_export;
00529 
00530    /*! \brief Event waiting for Layer 1 to come up */
00531    enum event_e evq;
00532 
00533    /*** CRYPTING STUFF ***/
00534    int crypt;     /* Initialized, Not used */
00535    int curprx;    /* Initialized, Not used */
00536    int curptx;    /* Initialized, Not used */
00537 
00538    /*! \brief Blowfish encryption key string (secret) */
00539    char crypt_key[255];
00540 
00541    int crypt_state;  /* Not used */
00542    /*** CRYPTING STUFF END***/
00543 
00544    /*! \brief Seems to have been intended for something to do with the jitter buffer.
00545     * \note Used as a boolean.  Only initialized to 0 and referenced in a couple places
00546     */
00547    int active;
00548    int upset;  /* Not used */
00549 
00550    /*! \brief TRUE if tone generator allowed to start */
00551    int generate_tone;
00552 
00553    /*! \brief Number of tone samples to generate */
00554    int tone_cnt;
00555 
00556    /*! \brief Current B Channel state */
00557    enum bchannel_state bc_state;
00558 
00559    /*! \brief This is used as a pending bridge join request for when bc_state becomes BCHAN_ACTIVATED */
00560    enum bchannel_state next_bc_state;
00561 
00562    /*! \brief Bridging conference ID */
00563    int conf_id;
00564 
00565    /*! \brief TRUE if this channel is on hold */
00566    int holded;
00567 
00568    /*! \brief TRUE if this channel is on the misdn_stack->holding list
00569     * \note If TRUE this implies that the structure is also malloced.
00570     */
00571    int stack_holder;
00572 
00573    /*!
00574     * \brief Put a display ie in the CONNECT message
00575     * \details
00576     * Put a display ie in the CONNECT message containing the following
00577     * information if it is available (nt port only):
00578     * 0 - Do not put the connected line information in the display ie.
00579     * 1 - Put the available connected line name in the display ie.
00580     * 2 - Put the available connected line number in the display ie.
00581     * 3 - Put the available connected line name and number in the display ie.
00582     */
00583    int display_connected;
00584 
00585    /*!
00586     * \brief Put a display ie in the SETUP message
00587     * \details
00588     * Put a display ie in the SETUP message containing the following
00589     * information if it is available (nt port only):
00590     * 0 - Do not put the caller information in the display ie.
00591     * 1 - Put the available caller name in the display ie.
00592     * 2 - Put the available caller number in the display ie.
00593     * 3 - Put the available caller name and number in the display ie.
00594     */
00595    int display_setup;
00596 
00597    /*!
00598     * \brief Select what to do with outgoing COLP information.
00599     * \details
00600     * 0 - pass (Send out COLP information unaltered.)
00601     * 1 - restricted (Force COLP to restricted on all outgoing COLP information.)
00602     * 2 - block (Do not send COLP information.)
00603     */
00604    int outgoing_colp;
00605 
00606    /*! \brief User set presentation restriction code
00607     * 0=Allowed, 1=Restricted, 2=Unavailable
00608     * \note It is settable by the misdn_set_opt() application.
00609     */
00610    int presentation;
00611 
00612    /*! \brief TRUE if the user set the presentation restriction code */
00613    int set_presentation;
00614 
00615    /*! \brief Notification indicator ie description code */
00616    enum mISDN_NOTIFY_CODE notify_description_code;
00617 
00618    /*! \brief SETUP message bearer capability field code value */
00619    int capability;
00620 
00621    /*! \brief Companding ALaw/uLaw encoding (INFO_CODEC_ALAW / INFO_CODEC_ULAW) */
00622    int law;
00623 
00624    /* V110 Stuff */
00625    /*! \brief Q.931 Bearer Capability IE Information Transfer Rate field. Initialized to 0x10 (64kbit). Altered by incoming SETUP messages. */
00626    int rate;
00627 
00628    /*! \brief Q.931 Bearer Capability IE Transfer Mode field. Initialized to 0 (Circuit). Altered by incoming SETUP messages. */
00629    int mode;
00630 
00631    /*! \brief Q.931 Bearer Capability IE User Information Layer 1 Protocol field code.
00632     * \note Collected from the incoming SETUP message but not used.
00633     */
00634    int user1;
00635 
00636    /*! \brief Q.931 Bearer Capability IE Layer 1 User Rate field.
00637     * \note Collected from the incoming SETUP message and exported to Asterisk variable MISDN_URATE.
00638     */
00639    int urate;
00640 
00641    /*! \brief TRUE if call made in digital HDLC mode
00642     * \note This value is user configurable in /etc/asterisk/misdn.conf.
00643     * It is also settable by the misdn_set_opt() application.
00644     */
00645    int hdlc;
00646    /* V110 */
00647 
00648    /*! \brief Display message that can be displayed by the user phone.
00649     * \note Maximum displayable length is 34 or 82 octets.
00650     * It is also settable by the misdn_set_opt() application.
00651     */
00652    char display[84];
00653 
00654    /*! \brief Q.931 Keypad Facility IE contents
00655     * \note Contents exported and imported to Asterisk variable MISDN_KEYPAD
00656     */
00657    char keypad[MISDN_MAX_KEYPAD_LEN];
00658 
00659    /*! \brief Current overlap dialing digits to/from INFORMATION messages */
00660    char info_dad[MISDN_MAX_NUMBER_LEN];
00661 
00662    /*! \brief Collected digits to go into info_dad[] while waiting for a SETUP_ACKNOWLEDGE to come in. */
00663    char infos_pending[MISDN_MAX_NUMBER_LEN];
00664 
00665 /*    unsigned char info_keypad[MISDN_MAX_KEYPAD_LEN]; */
00666 /*    unsigned char clisub[24]; */
00667 /*    unsigned char cldsub[24]; */
00668 
00669    /*! \brief User-User information string.
00670     * \note Contents exported and imported to Asterisk variable MISDN_USERUSER
00671     * \note We only support ASCII strings (IA5 characters).
00672     */
00673    char uu[256];
00674 
00675    /*! \brief User-User information string length in uu[] */
00676    int uulen;
00677 
00678    /*! \brief Q.931 Cause for disconnection code (received)
00679     * \note Need to use the AST_CAUSE_xxx code definitions in causes.h
00680     */
00681    int cause;
00682 
00683    /*! \brief Q.931 Cause for disconnection code (sent)
00684     * \note Need to use the AST_CAUSE_xxx code definitions in causes.h
00685     * \note -1 is used to suppress including the cause code in the RELEASE message.
00686     */
00687    int out_cause;
00688 
00689    /* struct misdn_bchannel hold_bc; */
00690 
00691    /** list stuf **/
00692 
00693 #ifdef MISDN_1_2
00694    /*! \brief The configuration string for the mISDN dsp pipeline in /etc/asterisk/misdn.conf. */
00695    char pipeline[128];
00696 #else
00697    /*! \brief TRUE if the echo cancellor is enabled */
00698    int ec_enable;
00699 
00700    /*! \brief Number of taps in the echo cancellor when enabled.
00701     * \note This value is user configurable in /etc/asterisk/misdn.conf (echocancel)
00702     */
00703    int ec_deftaps;
00704 #endif
00705 
00706    /*! \brief TRUE if the channel was allocated from the available B channels */
00707    int channel_found;
00708 
00709    /*! \brief Who originated the call (ORG_AST, ORG_MISDN)
00710     * \note Set but not used when the misdn_set_opt() application enables echo cancellation.
00711     */
00712    int orig;
00713 
00714    /*! \brief Tx gain setting (range -8 to 8)
00715     * \note This value is user configurable in /etc/asterisk/misdn.conf.
00716     * It is also settable by the misdn_set_opt() application.
00717     */
00718    int txgain;
00719 
00720    /*! \brief Rx gain setting (range -8 to 8)
00721     * \note This value is user configurable in /etc/asterisk/misdn.conf.
00722     * It is also settable by the misdn_set_opt() application.
00723     */
00724    int rxgain;
00725 
00726    /*! \brief Next node in the misdn_stack.holding list */
00727    struct misdn_bchannel *next;
00728 };
00729 
00730 
00731 extern enum event_response_e (*cb_event) (enum event_e event, struct misdn_bchannel *bc, void *user_data);
00732 
00733 extern void (*cb_log) (int level, int port, char *tmpl, ...)
00734    __attribute__ ((format (printf, 3, 4)));
00735 
00736 extern int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
00737 
00738 struct misdn_lib_iface {
00739    enum event_response_e (*cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data);
00740    void (*cb_log)(int level, int port, char *tmpl, ...)
00741       __attribute__ ((format (printf, 3, 4)));
00742    int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
00743 };
00744 
00745 /***** USER IFACE **********/
00746 
00747 void misdn_lib_nt_keepcalls(int kc);
00748 
00749 void misdn_lib_nt_debug_init( int flags, char *file );
00750 
00751 int misdn_lib_init(char *portlist, struct misdn_lib_iface* iface, void *user_data);
00752 int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event );
00753 void misdn_lib_destroy(void);
00754 
00755 void misdn_lib_isdn_l1watcher(int port);
00756 
00757 void misdn_lib_log_ies(struct misdn_bchannel *bc);
00758 
00759 char *manager_isdn_get_info(enum event_e event);
00760 
00761 struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, int dec);
00762 #if defined(AST_MISDN_ENHANCEMENTS)
00763 struct misdn_bchannel *misdn_lib_get_register_bc(int port);
00764 #endif   /* defined(AST_MISDN_ENHANCEMENTS) */
00765 
00766 void manager_bchannel_activate(struct misdn_bchannel *bc);
00767 void manager_bchannel_deactivate(struct misdn_bchannel * bc);
00768 
00769 int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len);
00770 
00771 void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2);
00772 
00773 void isdn_lib_update_rxgain (struct misdn_bchannel *bc);
00774 void isdn_lib_update_txgain (struct misdn_bchannel *bc);
00775 void isdn_lib_update_ec (struct misdn_bchannel *bc);
00776 void isdn_lib_stop_dtmf (struct misdn_bchannel *bc);
00777 
00778 int misdn_lib_port_restart(int port);
00779 int misdn_lib_pid_restart(int pid);
00780 int misdn_lib_send_restart(int port, int channel);
00781 
00782 int misdn_lib_get_port_info(int port);
00783 
00784 int misdn_lib_is_port_blocked(int port);
00785 int misdn_lib_port_block(int port);
00786 int misdn_lib_port_unblock(int port);
00787 
00788 int misdn_lib_port_is_pri(int port);
00789 int misdn_lib_port_is_nt(int port);
00790 
00791 int misdn_lib_port_up(int port, int notcheck);
00792 
00793 int misdn_lib_get_port_down(int port);
00794 
00795 int misdn_lib_get_port_up (int port) ;
00796 
00797 int misdn_lib_maxports_get(void) ;
00798 
00799 struct misdn_bchannel *misdn_lib_find_held_bc(int port, int l3_id);
00800 void misdn_lib_release(struct misdn_bchannel *bc);
00801 
00802 int misdn_cap_is_speech(int cap);
00803 int misdn_inband_avail(struct misdn_bchannel *bc);
00804 
00805 void manager_ec_enable(struct misdn_bchannel *bc);
00806 void manager_ec_disable(struct misdn_bchannel *bc);
00807 
00808 void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone);
00809 
00810 void get_show_stack_details(int port, char *buf);
00811 
00812 
00813 void misdn_lib_tone_generator_start(struct misdn_bchannel *bc);
00814 void misdn_lib_tone_generator_stop(struct misdn_bchannel *bc);
00815 
00816 
00817 void misdn_lib_setup_bc(struct misdn_bchannel *bc);
00818 
00819 void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
00820 void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
00821 
00822 void misdn_lib_echo(struct misdn_bchannel *bc, int onoff);
00823 
00824 int misdn_lib_is_ptp(int port);
00825 int misdn_lib_get_maxchans(int port);
00826 
00827 void misdn_lib_reinit_nt_stack(int port);
00828 
00829 #define PRI_TRANS_CAP_SPEECH                                    0x0
00830 #define PRI_TRANS_CAP_DIGITAL                                   0x08
00831 #define PRI_TRANS_CAP_RESTRICTED_DIGITAL                        0x09
00832 #define PRI_TRANS_CAP_3_1K_AUDIO                                0x10
00833 #define PRI_TRANS_CAP_7K_AUDIO                                  0x11
00834 
00835 
00836 
00837 char *bc_state2str(enum bchannel_state state);
00838 void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state);
00839 
00840 void misdn_dump_chanlist(void);
00841 
00842 void misdn_make_dummy(struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel);
00843 
00844 
00845 #endif   /* TE_LIB */

Generated on Mon Mar 19 11:30:28 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7