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

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