00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TE_LIB
00021 #define TE_LIB
00022
00023 #include <mISDNuser/suppserv.h>
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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
00100 enum mISDN_NUMBER_PLAN {
00101 NUMPLAN_UNINITIALIZED=-1,
00102 NUMPLAN_INTERNATIONAL=0x1,
00103 NUMPLAN_NATIONAL=0x2,
00104 NUMPLAN_SUBSCRIBER=0x4,
00105 NUMPLAN_UNKNOWN=0x0
00106 };
00107
00108
00109 enum event_response_e {
00110 RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE,
00111 RESPONSE_IGNORE_SETUP,
00112 RESPONSE_RELEASE_SETUP,
00113 RESPONSE_ERR,
00114 RESPONSE_OK
00115 };
00116
00117
00118 enum event_e {
00119 EVENT_NOTHING,
00120 EVENT_TONE_GENERATE,
00121 EVENT_BCHAN_DATA,
00122 EVENT_BCHAN_ACTIVATED,
00123 EVENT_BCHAN_ERROR,
00124 EVENT_CLEANUP,
00125 EVENT_PROCEEDING,
00126 EVENT_PROGRESS,
00127 EVENT_SETUP,
00128 EVENT_ALERTING,
00129 EVENT_CONNECT,
00130 EVENT_SETUP_ACKNOWLEDGE,
00131 EVENT_CONNECT_ACKNOWLEDGE ,
00132 EVENT_USER_INFORMATION,
00133 EVENT_SUSPEND_REJECT,
00134 EVENT_RESUME_REJECT,
00135 EVENT_HOLD,
00136 EVENT_SUSPEND,
00137 EVENT_RESUME,
00138 EVENT_HOLD_ACKNOWLEDGE,
00139 EVENT_SUSPEND_ACKNOWLEDGE,
00140 EVENT_RESUME_ACKNOWLEDGE,
00141 EVENT_HOLD_REJECT,
00142 EVENT_RETRIEVE,
00143 EVENT_RETRIEVE_ACKNOWLEDGE,
00144 EVENT_RETRIEVE_REJECT,
00145 EVENT_DISCONNECT,
00146 EVENT_RESTART,
00147 EVENT_RELEASE,
00148 EVENT_RELEASE_COMPLETE,
00149 EVENT_FACILITY,
00150 EVENT_NOTIFY,
00151 EVENT_STATUS_ENQUIRY,
00152 EVENT_INFORMATION,
00153 EVENT_STATUS,
00154 EVENT_TIMEOUT,
00155 EVENT_DTMF_TONE,
00156 EVENT_NEW_L3ID,
00157 EVENT_NEW_BC,
00158 EVENT_PORT_ALARM,
00159 EVENT_NEW_CHANNEL,
00160 EVENT_UNKNOWN
00161 };
00162
00163
00164 enum ie_name_e {
00165 IE_DUMMY,
00166 IE_LAST
00167 };
00168
00169 enum {
00170 INFO_CAPABILITY_SPEECH=0,
00171 INFO_CAPABILITY_AUDIO_3_1K=0x10 ,
00172 INFO_CAPABILITY_AUDIO_7K=0x11 ,
00173 INFO_CAPABILITY_VIDEO =0x18,
00174 INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8,
00175 INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09,
00176 INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES
00177 };
00178
00179 enum {
00180 INFO_PI_CALL_NOT_E2E_ISDN =0x01,
00181 INFO_PI_CALLED_NOT_ISDN =0x02,
00182 INFO_PI_CALLER_NOT_ISDN =0x03,
00183 INFO_PI_CALLER_RETURNED_TO_ISDN =0x04,
00184 INFO_PI_INBAND_AVAILABLE =0x08,
00185 INFO_PI_DELAY_AT_INTERF =0x0a,
00186 INFO_PI_INTERWORKING_WITH_PUBLIC =0x10,
00187 INFO_PI_INTERWORKING_NO_RELEASE =0x11,
00188 INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12,
00189 INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13
00190 };
00191
00192 enum {
00193 INFO_CODEC_ULAW=2,
00194 INFO_CODEC_ALAW=3
00195 };
00196
00197
00198 enum layer_e {
00199 L3,
00200 L2,
00201 L1,
00202 UNKNOWN
00203 };
00204
00205
00206
00207 struct misdn_bchannel {
00208 struct send_lock *send_lock;
00209
00210 int dummy;
00211
00212 int nt;
00213 int pri;
00214
00215 int port;
00216
00217 int b_stid;
00218
00219 int layer_id;
00220
00221 int layer;
00222
00223
00224 int need_disconnect;
00225 int need_release;
00226 int need_release_complete;
00227
00228 int dec;
00229
00230 int l3_id;
00231 int pid;
00232 int ces;
00233
00234 int restart_channel;
00235 int channel;
00236 int channel_preselected;
00237
00238 int in_use;
00239 struct timeval last_used;
00240 int cw;
00241 int addr;
00242
00243 char * bframe;
00244 int bframe_len;
00245 int time_usec;
00246
00247
00248 void *astbuf;
00249
00250 void *misdnbuf;
00251
00252 int te_choose_channel;
00253 int early_bconnect;
00254
00255
00256 int dtmf;
00257 int send_dtmf;
00258
00259
00260 int need_more_infos;
00261
00262
00263 int sending_complete;
00264
00265
00266
00267 int nodsp;
00268
00269
00270 int nojitter;
00271
00272 enum mISDN_NUMBER_PLAN dnumplan;
00273 enum mISDN_NUMBER_PLAN rnumplan;
00274 enum mISDN_NUMBER_PLAN onumplan;
00275 enum mISDN_NUMBER_PLAN cpnnumplan;
00276
00277 int progress_coding;
00278 int progress_location;
00279 int progress_indicator;
00280
00281 struct FacParm fac_in;
00282 struct FacParm fac_out;
00283
00284
00285 enum FacFunction AOCDtype;
00286 union {
00287 struct FacAOCDCurrency currency;
00288 struct FacAOCDChargingUnit chargingUnit;
00289 } AOCD;
00290 int AOCD_need_export;
00291
00292 enum event_e evq;
00293
00294
00295
00296 int crypt;
00297 int curprx;
00298 int curptx;
00299 char crypt_key[255];
00300
00301 int crypt_state;
00302
00303
00304
00305
00306
00307
00308 int active;
00309 int upset;
00310
00311 int generate_tone;
00312 int tone_cnt;
00313
00314 enum bchannel_state bc_state;
00315 enum bchannel_state next_bc_state;
00316
00317 int conf_id;
00318
00319 int holded;
00320 int stack_holder;
00321
00322 int pres;
00323 int screen;
00324
00325 int capability;
00326 int law;
00327
00328 int rate;
00329 int mode;
00330
00331 int user1;
00332 int urate;
00333 int hdlc;
00334
00335
00336 char display[84];
00337 char msn[32];
00338 char oad[32];
00339 char rad[32];
00340 char dad[32];
00341 char cad[32];
00342 char orig_dad[32];
00343 char keypad[32];
00344
00345 char info_dad[64];
00346 char infos_pending[64];
00347
00348
00349
00350
00351
00352 char uu[256];
00353 int uulen;
00354
00355 int cause;
00356 int out_cause;
00357
00358
00359
00360
00361
00362 #ifdef MISDN_1_2
00363 char pipeline[128];
00364 #else
00365 int ec_enable;
00366 int ec_deftaps;
00367 #endif
00368
00369 int channel_found;
00370
00371 int orig;
00372
00373 int txgain;
00374 int rxgain;
00375
00376 struct misdn_bchannel *next;
00377 };
00378
00379
00380 enum event_response_e (*cb_event) (enum event_e event, struct misdn_bchannel *bc, void *user_data);
00381 void (*cb_log) (int level, int port, char *tmpl, ...)
00382 __attribute__ ((format (printf, 3, 4)));
00383 int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
00384
00385 struct misdn_lib_iface {
00386 enum event_response_e (*cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data);
00387 void (*cb_log)(int level, int port, char *tmpl, ...)
00388 __attribute__ ((format (printf, 3, 4)));
00389 int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
00390 };
00391
00392
00393
00394 void misdn_lib_nt_keepcalls(int kc);
00395
00396 void misdn_lib_nt_debug_init( int flags, char *file );
00397
00398 int misdn_lib_init(char *portlist, struct misdn_lib_iface* iface, void *user_data);
00399 int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event );
00400 void misdn_lib_destroy(void);
00401
00402 void misdn_lib_isdn_l1watcher(int port);
00403
00404 void misdn_lib_log_ies(struct misdn_bchannel *bc);
00405
00406 char *manager_isdn_get_info(enum event_e event);
00407
00408 void misdn_lib_transfer(struct misdn_bchannel* holded_bc);
00409
00410 struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout, int dec);
00411
00412 void manager_bchannel_activate(struct misdn_bchannel *bc);
00413 void manager_bchannel_deactivate(struct misdn_bchannel * bc);
00414
00415 int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len);
00416
00417 void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2);
00418
00419 void isdn_lib_update_rxgain (struct misdn_bchannel *bc);
00420 void isdn_lib_update_txgain (struct misdn_bchannel *bc);
00421 void isdn_lib_update_ec (struct misdn_bchannel *bc);
00422 void isdn_lib_stop_dtmf (struct misdn_bchannel *bc);
00423
00424 int misdn_lib_port_restart(int port);
00425 int misdn_lib_pid_restart(int pid);
00426 int misdn_lib_send_restart(int port, int channel);
00427
00428 int misdn_lib_get_port_info(int port);
00429
00430 int misdn_lib_is_port_blocked(int port);
00431 int misdn_lib_port_block(int port);
00432 int misdn_lib_port_unblock(int port);
00433
00434 int misdn_lib_port_is_pri(int port);
00435 int misdn_lib_port_is_nt(int port);
00436
00437 int misdn_lib_port_up(int port, int notcheck);
00438
00439 int misdn_lib_get_port_down(int port);
00440
00441 int misdn_lib_get_port_up (int port) ;
00442
00443 int misdn_lib_maxports_get(void) ;
00444
00445 void misdn_lib_release(struct misdn_bchannel *bc);
00446
00447 int misdn_cap_is_speech(int cap);
00448 int misdn_inband_avail(struct misdn_bchannel *bc);
00449
00450 void manager_ec_enable(struct misdn_bchannel *bc);
00451 void manager_ec_disable(struct misdn_bchannel *bc);
00452
00453 void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone);
00454
00455 void get_show_stack_details(int port, char *buf);
00456
00457
00458 void misdn_lib_tone_generator_start(struct misdn_bchannel *bc);
00459 void misdn_lib_tone_generator_stop(struct misdn_bchannel *bc);
00460
00461
00462 void misdn_lib_setup_bc(struct misdn_bchannel *bc);
00463
00464 void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
00465 void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
00466
00467 void misdn_lib_echo(struct misdn_bchannel *bc, int onoff);
00468
00469 int misdn_lib_is_ptp(int port);
00470 int misdn_lib_get_maxchans(int port);
00471
00472 void misdn_lib_reinit_nt_stack(int port);
00473
00474 #define PRI_TRANS_CAP_SPEECH 0x0
00475 #define PRI_TRANS_CAP_DIGITAL 0x08
00476 #define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09
00477 #define PRI_TRANS_CAP_3_1K_AUDIO 0x10
00478 #define PRI_TRANS_CAP_7K_AUDIO 0x11
00479
00480
00481
00482 char *bc_state2str(enum bchannel_state state);
00483 void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state);
00484
00485 void misdn_dump_chanlist(void);
00486
00487 void misdn_make_dummy(struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel);
00488
00489
00490 #endif