Sun Jun 12 16:37:47 2011

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 #ifndef TE_LIB
00015 #define TE_LIB
00016 
00017 #include <mISDNuser/suppserv.h>
00018 
00019 /** For initialization usage **/
00020 /* typedef int ie_nothing_t ;*/
00021 /** end of init usage **/
00022 
00023 
00024 /* 
00025  * uncomment the following to make chan_misdn create
00026  * record files in /tmp/misdn-{rx|tx}-PortChannel format 
00027  * */
00028 
00029 /*#define MISDN_SAVE_DATA*/
00030 
00031 #ifdef WITH_BEROEC
00032 typedef int beroec_t;
00033 
00034 
00035 enum beroec_type {
00036    BEROEC_FULLBAND=0,
00037    BEROEC_SUBBAND,
00038    BEROEC_FASTSUBBAND
00039 };
00040 
00041 void beroec_init(void);
00042 void beroec_exit(void);
00043 beroec_t *beroec_new(int tail, enum beroec_type type, int anti_howl,
00044            int tonedisable, int zerocoeff, int adapt, int nlp);
00045 
00046 void beroec_destroy(beroec_t *ec);
00047 int beroec_cancel_alaw_chunk(beroec_t *ec, 
00048    char *send, 
00049    char *receive , 
00050    int len);
00051 
00052 int beroec_version(void);
00053 #endif
00054 
00055 
00056 
00057 enum tone_e {
00058    TONE_NONE=0,
00059    TONE_DIAL,
00060    TONE_ALERTING,
00061    TONE_FAR_ALERTING,
00062    TONE_BUSY,
00063    TONE_HANGUP,
00064    TONE_CUSTOM,
00065    TONE_FILE
00066 };
00067 
00068 
00069 
00070 #define MAX_BCHANS 31
00071 
00072 enum bchannel_state {
00073    BCHAN_CLEANED=0,
00074    BCHAN_EMPTY,
00075    BCHAN_SETUP,
00076    BCHAN_SETUPED,
00077    BCHAN_ACTIVE,
00078    BCHAN_ACTIVATED,
00079    BCHAN_BRIDGE,
00080    BCHAN_BRIDGED,
00081    BCHAN_RELEASE,
00082    BCHAN_RELEASED,
00083    BCHAN_CLEAN,
00084    BCHAN_CLEAN_REQUEST,
00085    BCHAN_ERROR
00086 };
00087 
00088 
00089 enum misdn_err_e {
00090    ENOCHAN=1
00091 };
00092 
00093 
00094 enum mISDN_NUMBER_PLAN {
00095    NUMPLAN_UNINITIALIZED=-1,
00096    NUMPLAN_INTERNATIONAL=0x1,
00097    NUMPLAN_NATIONAL=0x2,
00098    NUMPLAN_SUBSCRIBER=0x4,
00099    NUMPLAN_UNKNOWN=0x0
00100 }; 
00101 
00102 
00103 enum event_response_e {
00104    RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE,
00105    RESPONSE_IGNORE_SETUP,
00106    RESPONSE_RELEASE_SETUP,
00107    RESPONSE_ERR,
00108    RESPONSE_OK
00109 };
00110 
00111 
00112 enum event_e {
00113    EVENT_NOTHING,
00114    EVENT_TONE_GENERATE,
00115    EVENT_BCHAN_DATA,
00116    EVENT_BCHAN_ACTIVATED,
00117    EVENT_BCHAN_ERROR,
00118    EVENT_CLEANUP,
00119    EVENT_PROCEEDING,
00120    EVENT_PROGRESS,
00121    EVENT_SETUP,
00122    EVENT_ALERTING,
00123    EVENT_CONNECT,
00124    EVENT_SETUP_ACKNOWLEDGE,
00125    EVENT_CONNECT_ACKNOWLEDGE ,
00126    EVENT_USER_INFORMATION,
00127    EVENT_SUSPEND_REJECT,
00128    EVENT_RESUME_REJECT,
00129    EVENT_HOLD,
00130    EVENT_SUSPEND,
00131    EVENT_RESUME,
00132    EVENT_HOLD_ACKNOWLEDGE,
00133    EVENT_SUSPEND_ACKNOWLEDGE,
00134    EVENT_RESUME_ACKNOWLEDGE,
00135    EVENT_HOLD_REJECT,
00136    EVENT_RETRIEVE,
00137    EVENT_RETRIEVE_ACKNOWLEDGE,
00138    EVENT_RETRIEVE_REJECT,
00139    EVENT_DISCONNECT,
00140    EVENT_RESTART,
00141    EVENT_RELEASE,
00142    EVENT_RELEASE_COMPLETE,
00143    EVENT_FACILITY,
00144    EVENT_NOTIFY,
00145    EVENT_STATUS_ENQUIRY,
00146    EVENT_INFORMATION,
00147    EVENT_STATUS,
00148    EVENT_TIMEOUT,
00149    EVENT_DTMF_TONE,
00150    EVENT_NEW_L3ID,
00151    EVENT_NEW_BC,
00152    EVENT_PORT_ALARM,
00153    EVENT_NEW_CHANNEL,
00154    EVENT_UNKNOWN
00155 }; 
00156 
00157 
00158 enum ie_name_e {
00159    IE_DUMMY,
00160    IE_LAST
00161 };
00162 
00163 enum { /* bearer capability */
00164    INFO_CAPABILITY_SPEECH=0,
00165    INFO_CAPABILITY_AUDIO_3_1K=0x10 ,
00166    INFO_CAPABILITY_AUDIO_7K=0x11 ,
00167    INFO_CAPABILITY_VIDEO =0x18,
00168    INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8,
00169    INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09,
00170    INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES
00171 };
00172 
00173 enum { /* progress indicators */
00174    INFO_PI_CALL_NOT_E2E_ISDN =0x01,
00175    INFO_PI_CALLED_NOT_ISDN =0x02,
00176    INFO_PI_CALLER_NOT_ISDN =0x03,
00177    INFO_PI_CALLER_RETURNED_TO_ISDN =0x04,
00178    INFO_PI_INBAND_AVAILABLE =0x08,
00179    INFO_PI_DELAY_AT_INTERF =0x0a,
00180    INFO_PI_INTERWORKING_WITH_PUBLIC =0x10,
00181    INFO_PI_INTERWORKING_NO_RELEASE =0x11,
00182    INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12,
00183    INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13
00184 };
00185 
00186 enum { /*CODECS*/
00187    INFO_CODEC_ULAW=2,
00188    INFO_CODEC_ALAW=3
00189 }; 
00190 
00191 
00192 enum layer_e {
00193    L3,
00194    L2,
00195    L1,
00196    UNKNOWN
00197 }; 
00198 
00199 
00200 
00201 struct misdn_bchannel {
00202    struct send_lock *send_lock;
00203 
00204    int dummy;
00205 
00206    int nt;
00207    int pri;
00208 
00209    int port;
00210    /** init stuff **/
00211    int b_stid;
00212    /* int b_addr; */
00213    int layer_id;
00214 
00215    int layer;
00216    
00217    /*state stuff*/
00218    int need_disconnect;
00219    int need_release;
00220    int need_release_complete;
00221 
00222    int dec;
00223    /** var stuff**/
00224    int l3_id;
00225    int pid;
00226    int ces;
00227 
00228    int restart_channel;
00229    int channel;
00230    int channel_preselected;
00231    
00232    int in_use;
00233    struct timeval last_used;
00234    int cw;
00235    int addr;
00236 
00237    char * bframe;
00238    int bframe_len;
00239    int time_usec;
00240    
00241    
00242    void *astbuf;
00243 
00244    void *misdnbuf;
00245 
00246    int te_choose_channel;
00247    int early_bconnect;
00248    
00249    /* dtmf digit */
00250    int dtmf;
00251    int send_dtmf;
00252 
00253    /* get setup ack */
00254    int need_more_infos;
00255 
00256    /* may there be more infos ?*/
00257    int sending_complete;
00258 
00259 
00260    /* wether we should use jollys dsp or not */
00261    int nodsp;
00262    
00263    /* wether we should use our jitter buf system or not */
00264    int nojitter;
00265    
00266    enum mISDN_NUMBER_PLAN dnumplan;
00267    enum mISDN_NUMBER_PLAN rnumplan;
00268    enum mISDN_NUMBER_PLAN onumplan;
00269    enum mISDN_NUMBER_PLAN cpnnumplan;
00270 
00271    int progress_coding;
00272    int progress_location;
00273    int progress_indicator;
00274 
00275    struct FacParm fac_in;
00276    struct FacParm fac_out;
00277 
00278    /* storing the current AOCD info here */
00279    enum FacFunction AOCDtype;
00280    union {
00281       struct FacAOCDCurrency currency;
00282       struct FacAOCDChargingUnit chargingUnit;
00283    } AOCD;
00284    
00285    enum event_e evq;
00286    
00287    /*** CRYPTING STUFF ***/
00288    
00289    int crypt;
00290    int curprx;
00291    int curptx; 
00292    char crypt_key[255];
00293   
00294    int crypt_state;
00295     
00296    /*char ast_dtmf_buf[255];
00297      char misdn_dtmf_buf[255]; */
00298   
00299    /*** CRYPTING STUFF END***/
00300   
00301    int active;
00302    int upset;
00303 
00304    int generate_tone;
00305    int tone_cnt;
00306  
00307    enum bchannel_state bc_state;
00308    enum bchannel_state next_bc_state;
00309 
00310    int conf_id;
00311    
00312    int holded;
00313    int stack_holder;
00314 
00315    int pres;
00316    int screen;
00317    
00318    int capability;
00319    int law;
00320    /** V110 Stuff **/
00321    int rate;
00322    int mode;
00323 
00324    int user1;
00325    int urate;
00326    int hdlc;
00327    /* V110 */
00328   
00329    char display[84];
00330    char msn[32];
00331    char oad[32];
00332    char rad[32];
00333    char dad[32];
00334    char cad[32];
00335    char orig_dad[32];
00336    char keypad[32];
00337 
00338    char info_dad[64];
00339    char infos_pending[64];
00340 
00341 /*    unsigned char info_keypad[32]; */
00342 /*    unsigned char clisub[24]; */
00343 /*    unsigned char cldsub[24]; */
00344 
00345    char uu[256];
00346    int uulen;
00347   
00348    int cause;
00349    int out_cause;
00350   
00351    /* struct misdn_bchannel hold_bc; */
00352   
00353    /** list stuf **/
00354 
00355 #ifdef MISDN_1_2
00356    char pipeline[128];
00357 #else
00358    int ec_enable;
00359    int ec_deftaps;
00360 #endif
00361    
00362    int channel_found;
00363    
00364    int orig;
00365 
00366    int txgain;
00367    int rxgain;
00368   
00369    struct misdn_bchannel *next;
00370 };
00371 
00372 
00373 enum event_response_e (*cb_event) (enum event_e event, struct misdn_bchannel *bc, void *user_data);
00374 void (*cb_log) (int level, int port, char *tmpl, ...);
00375 int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
00376 
00377 struct misdn_lib_iface {
00378    enum event_response_e (*cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data);
00379    void (*cb_log)(int level, int port, char *tmpl, ...);
00380    int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
00381 };
00382 
00383 /***** USER IFACE **********/
00384 
00385 void misdn_lib_nt_keepcalls(int kc);
00386 
00387 void misdn_lib_nt_debug_init( int flags, char *file );
00388 
00389 int misdn_lib_init(char *portlist, struct misdn_lib_iface* iface, void *user_data);
00390 int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event );
00391 void misdn_lib_destroy(void);
00392 
00393 void misdn_lib_isdn_l1watcher(int port);
00394 
00395 void misdn_lib_log_ies(struct misdn_bchannel *bc);
00396 
00397 char *manager_isdn_get_info(enum event_e event);
00398 
00399 void misdn_lib_transfer(struct misdn_bchannel* holded_bc);
00400 
00401 struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, int dec);
00402 
00403 void manager_bchannel_activate(struct misdn_bchannel *bc);
00404 void manager_bchannel_deactivate(struct misdn_bchannel * bc);
00405 
00406 int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len);
00407 
00408 void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2);
00409 
00410 void isdn_lib_update_rxgain (struct misdn_bchannel *bc);
00411 void isdn_lib_update_txgain (struct misdn_bchannel *bc);
00412 void isdn_lib_update_ec (struct misdn_bchannel *bc);
00413 void isdn_lib_stop_dtmf (struct misdn_bchannel *bc);
00414 
00415 int misdn_lib_port_restart(int port);
00416 int misdn_lib_pid_restart(int pid);
00417 int misdn_lib_send_restart(int port, int channel);
00418 
00419 int misdn_lib_get_port_info(int port);
00420 
00421 int misdn_lib_is_port_blocked(int port);
00422 int misdn_lib_port_block(int port);
00423 int misdn_lib_port_unblock(int port);
00424 
00425 int misdn_lib_port_is_pri(int port);
00426 
00427 int misdn_lib_port_up(int port, int notcheck);
00428 
00429 int misdn_lib_get_port_down(int port);
00430 
00431 int misdn_lib_get_port_up (int port) ;
00432      
00433 int misdn_lib_maxports_get(void) ;
00434 
00435 void misdn_lib_release(struct misdn_bchannel *bc);
00436 
00437 int misdn_cap_is_speech(int cap);
00438 int misdn_inband_avail(struct misdn_bchannel *bc);
00439 
00440 void manager_ec_enable(struct misdn_bchannel *bc);
00441 void manager_ec_disable(struct misdn_bchannel *bc);
00442 
00443 void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone);
00444 
00445 void get_show_stack_details(int port, char *buf);
00446 
00447 
00448 void misdn_lib_tone_generator_start(struct misdn_bchannel *bc);
00449 void misdn_lib_tone_generator_stop(struct misdn_bchannel *bc);
00450 
00451 
00452 void misdn_lib_setup_bc(struct misdn_bchannel *bc);
00453 
00454 void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
00455 void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
00456 
00457 void misdn_lib_echo(struct misdn_bchannel *bc, int onoff);
00458 
00459 int misdn_lib_is_ptp(int port);
00460 int misdn_lib_get_maxchans(int port);
00461 
00462 void misdn_lib_reinit_nt_stack(int port);
00463 
00464 #define PRI_TRANS_CAP_SPEECH                                    0x0
00465 #define PRI_TRANS_CAP_DIGITAL                                   0x08
00466 #define PRI_TRANS_CAP_RESTRICTED_DIGITAL                        0x09
00467 #define PRI_TRANS_CAP_3_1K_AUDIO                                0x10
00468 #define PRI_TRANS_CAP_7K_AUDIO                                  0x11
00469 
00470 
00471 
00472 char *bc_state2str(enum bchannel_state state);
00473 void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state);
00474 
00475 void misdn_dump_chanlist(void);
00476 
00477 #endif

Generated on Sun Jun 12 16:37:47 2011 for Asterisk - the Open Source PBX by  doxygen 1.5.6