2005-10-31 23:30:09 +00:00
|
|
|
/*
|
|
|
|
* Chan_Misdn -- Channel Driver for Asterisk
|
|
|
|
*
|
|
|
|
* Interface to mISDN
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004, Christian Richter
|
|
|
|
*
|
|
|
|
* Christian Richter <crich@beronet.com>
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TE_LIB
|
|
|
|
#define TE_LIB
|
|
|
|
|
2005-12-09 11:01:18 +00:00
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
/** For initialization usage **/
|
|
|
|
/* typedef int ie_nothing_t ;*/
|
|
|
|
/** end of init usage **/
|
|
|
|
|
|
|
|
|
2005-12-09 11:01:18 +00:00
|
|
|
|
2006-06-18 19:09:32 +00:00
|
|
|
enum tone_e {
|
|
|
|
TONE_NONE=0,
|
|
|
|
TONE_DIAL,
|
|
|
|
TONE_ALERTING,
|
|
|
|
TONE_FAR_ALERTING,
|
|
|
|
TONE_BUSY,
|
|
|
|
TONE_HANGUP,
|
|
|
|
TONE_CUSTOM,
|
|
|
|
TONE_FILE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
#define MAX_BCHANS 30
|
|
|
|
|
2006-04-03 19:17:59 +00:00
|
|
|
enum bchannel_state {
|
|
|
|
BCHAN_CLEANED=0,
|
|
|
|
BCHAN_EMPTY,
|
|
|
|
BCHAN_SETUP,
|
|
|
|
BCHAN_SETUPED,
|
|
|
|
BCHAN_ACTIVE,
|
|
|
|
BCHAN_ACTIVATED,
|
|
|
|
BCHAN_BRIDGE,
|
|
|
|
BCHAN_BRIDGED,
|
|
|
|
BCHAN_RELEASE,
|
|
|
|
BCHAN_RELEASED,
|
|
|
|
BCHAN_CLEAN,
|
2006-06-17 10:37:35 +00:00
|
|
|
BCHAN_CLEAN_REQUEST,
|
2006-04-03 19:17:59 +00:00
|
|
|
BCHAN_ERROR
|
2005-10-31 23:30:09 +00:00
|
|
|
};
|
|
|
|
|
2006-04-03 19:17:59 +00:00
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
enum misdn_err_e {
|
|
|
|
ENOCHAN=1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum mISDN_NUMBER_PLAN {
|
|
|
|
NUMPLAN_UNINITIALIZED=-1,
|
|
|
|
NUMPLAN_INTERNATIONAL=0x1,
|
|
|
|
NUMPLAN_NATIONAL=0x2,
|
|
|
|
NUMPLAN_SUBSCRIBER=0x4,
|
|
|
|
NUMPLAN_UNKNOWN=0x0
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum event_response_e {
|
|
|
|
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE,
|
|
|
|
RESPONSE_IGNORE_SETUP,
|
|
|
|
RESPONSE_ERR,
|
|
|
|
RESPONSE_OK
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum event_e {
|
|
|
|
EVENT_NOTHING,
|
2006-02-02 21:15:34 +00:00
|
|
|
EVENT_TONE_GENERATE,
|
2005-10-31 23:30:09 +00:00
|
|
|
EVENT_BCHAN_DATA,
|
2006-02-02 21:15:34 +00:00
|
|
|
EVENT_BCHAN_ACTIVATED,
|
2005-10-31 23:30:09 +00:00
|
|
|
EVENT_CLEANUP,
|
|
|
|
EVENT_PROCEEDING,
|
|
|
|
EVENT_PROGRESS,
|
|
|
|
EVENT_SETUP,
|
|
|
|
EVENT_ALERTING,
|
|
|
|
EVENT_CONNECT,
|
|
|
|
EVENT_SETUP_ACKNOWLEDGE,
|
|
|
|
EVENT_CONNECT_ACKNOWLEDGE ,
|
|
|
|
EVENT_USER_INFORMATION,
|
|
|
|
EVENT_SUSPEND_REJECT,
|
|
|
|
EVENT_RESUME_REJECT,
|
|
|
|
EVENT_HOLD,
|
|
|
|
EVENT_SUSPEND,
|
|
|
|
EVENT_RESUME,
|
|
|
|
EVENT_HOLD_ACKNOWLEDGE,
|
|
|
|
EVENT_SUSPEND_ACKNOWLEDGE,
|
|
|
|
EVENT_RESUME_ACKNOWLEDGE,
|
|
|
|
EVENT_HOLD_REJECT,
|
|
|
|
EVENT_RETRIEVE,
|
|
|
|
EVENT_RETRIEVE_ACKNOWLEDGE,
|
|
|
|
EVENT_RETRIEVE_REJECT,
|
|
|
|
EVENT_DISCONNECT,
|
|
|
|
EVENT_RESTART,
|
|
|
|
EVENT_RELEASE,
|
|
|
|
EVENT_RELEASE_COMPLETE,
|
|
|
|
EVENT_FACILITY,
|
|
|
|
EVENT_NOTIFY,
|
|
|
|
EVENT_STATUS_ENQUIRY,
|
|
|
|
EVENT_INFORMATION,
|
|
|
|
EVENT_STATUS,
|
|
|
|
EVENT_TIMEOUT,
|
|
|
|
EVENT_DTMF_TONE,
|
|
|
|
EVENT_NEW_L3ID,
|
|
|
|
EVENT_NEW_BC,
|
2006-05-24 23:21:03 +00:00
|
|
|
EVENT_NEW_CHANNEL,
|
2005-10-31 23:30:09 +00:00
|
|
|
EVENT_UNKNOWN
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum ie_name_e {
|
|
|
|
IE_DUMMY,
|
|
|
|
IE_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
enum { /* bearer capability */
|
|
|
|
INFO_CAPABILITY_SPEECH=0,
|
|
|
|
INFO_CAPABILITY_AUDIO_3_1K=0x10 ,
|
|
|
|
INFO_CAPABILITY_AUDIO_7K=0x11 ,
|
|
|
|
INFO_CAPABILITY_VIDEO =0x18,
|
|
|
|
INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8,
|
|
|
|
INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09,
|
|
|
|
INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES
|
|
|
|
};
|
|
|
|
|
|
|
|
enum { /* progress indicators */
|
|
|
|
INFO_PI_CALL_NOT_E2E_ISDN =0x01,
|
|
|
|
INFO_PI_CALLED_NOT_ISDN =0x02,
|
|
|
|
INFO_PI_CALLER_NOT_ISDN =0x03,
|
|
|
|
INFO_PI_CALLER_RETURNED_TO_ISDN =0x04,
|
|
|
|
INFO_PI_INBAND_AVAILABLE =0x08,
|
|
|
|
INFO_PI_DELAY_AT_INTERF =0x0a,
|
|
|
|
INFO_PI_INTERWORKING_WITH_PUBLIC =0x10,
|
|
|
|
INFO_PI_INTERWORKING_NO_RELEASE =0x11,
|
|
|
|
INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12,
|
|
|
|
INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13
|
|
|
|
};
|
|
|
|
|
|
|
|
enum { /*CODECS*/
|
|
|
|
INFO_CODEC_ULAW=2,
|
|
|
|
INFO_CODEC_ALAW=3
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum layer_e {
|
|
|
|
L3,
|
|
|
|
L2,
|
|
|
|
L1,
|
|
|
|
UNKNOWN
|
|
|
|
};
|
|
|
|
|
2005-12-09 11:01:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/** FACILITY STUFF **/
|
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
enum facility_type {
|
|
|
|
FACILITY_NONE,
|
2005-12-09 11:01:18 +00:00
|
|
|
FACILITY_CALLDEFLECT=0x91,
|
|
|
|
FACILITY_CENTREX=0x88
|
|
|
|
};
|
|
|
|
|
|
|
|
union facility {
|
|
|
|
char calldeflect_nr[15];
|
|
|
|
char cnip[256];
|
2005-10-31 23:30:09 +00:00
|
|
|
};
|
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
struct misdn_bchannel {
|
2005-11-01 22:04:14 +00:00
|
|
|
|
|
|
|
int nt;
|
|
|
|
int port;
|
2005-10-31 23:30:09 +00:00
|
|
|
/** init stuff **/
|
|
|
|
int b_stid;
|
|
|
|
/* int b_addr; */
|
|
|
|
int layer_id;
|
2005-11-01 22:04:14 +00:00
|
|
|
|
2006-02-02 21:15:34 +00:00
|
|
|
void *ack_hdlc;
|
|
|
|
|
2005-12-09 11:01:18 +00:00
|
|
|
int layer;
|
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
/** var stuff**/
|
|
|
|
int l3_id;
|
|
|
|
int pid;
|
|
|
|
int ces;
|
2006-06-01 12:51:41 +00:00
|
|
|
|
|
|
|
int restart_channel;
|
2005-10-31 23:30:09 +00:00
|
|
|
int channel;
|
|
|
|
int channel_preselected;
|
|
|
|
|
|
|
|
int in_use;
|
|
|
|
int addr;
|
|
|
|
|
|
|
|
unsigned char * bframe;
|
|
|
|
int bframe_len;
|
|
|
|
int time_usec;
|
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
|
|
|
|
void *astbuf;
|
2005-12-09 11:01:18 +00:00
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
void *misdnbuf;
|
|
|
|
|
|
|
|
int te_choose_channel;
|
2005-12-09 11:01:18 +00:00
|
|
|
int early_bconnect;
|
2005-11-01 22:04:14 +00:00
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
/* dtmf digit */
|
|
|
|
int dtmf;
|
|
|
|
int send_dtmf;
|
|
|
|
|
2006-02-02 21:15:34 +00:00
|
|
|
/* get setup ack */
|
|
|
|
int need_more_infos;
|
|
|
|
|
2006-06-01 12:51:41 +00:00
|
|
|
/* may there be more infos ?*/
|
|
|
|
int sending_complete;
|
|
|
|
|
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
/* wether we should use jollys dsp or not */
|
|
|
|
int nodsp;
|
|
|
|
|
|
|
|
/* wether we should use our jitter buf system or not */
|
|
|
|
int nojitter;
|
|
|
|
|
|
|
|
enum mISDN_NUMBER_PLAN dnumplan;
|
|
|
|
enum mISDN_NUMBER_PLAN rnumplan;
|
|
|
|
enum mISDN_NUMBER_PLAN onumplan;
|
2006-03-09 18:01:27 +00:00
|
|
|
enum mISDN_NUMBER_PLAN cpnnumplan;
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
int progress_coding;
|
|
|
|
int progress_location;
|
|
|
|
int progress_indicator;
|
|
|
|
|
2005-12-09 11:01:18 +00:00
|
|
|
enum facility_type fac_type;
|
|
|
|
union facility fac;
|
|
|
|
|
|
|
|
enum facility_type out_fac_type;
|
|
|
|
union facility out_fac;
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
enum event_e evq;
|
|
|
|
|
|
|
|
/*** CRYPTING STUFF ***/
|
|
|
|
|
|
|
|
int crypt;
|
|
|
|
int curprx;
|
|
|
|
int curptx;
|
|
|
|
char crypt_key[255];
|
|
|
|
|
|
|
|
int crypt_state;
|
|
|
|
|
|
|
|
/*char ast_dtmf_buf[255];
|
|
|
|
char misdn_dtmf_buf[255]; */
|
|
|
|
|
|
|
|
/*** CRYPTING STUFF END***/
|
|
|
|
|
|
|
|
int active;
|
|
|
|
int upset;
|
|
|
|
|
2006-02-02 21:15:34 +00:00
|
|
|
int generate_tone;
|
2005-10-31 23:30:09 +00:00
|
|
|
int tone_cnt;
|
2006-04-03 19:17:59 +00:00
|
|
|
|
|
|
|
enum bchannel_state bc_state;
|
|
|
|
enum bchannel_state next_bc_state;
|
2005-10-31 23:30:09 +00:00
|
|
|
|
2006-04-03 19:17:59 +00:00
|
|
|
int conf_id;
|
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
int holded;
|
|
|
|
int stack_holder;
|
2006-04-03 19:17:59 +00:00
|
|
|
|
|
|
|
struct misdn_bchannel *holded_bc;
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
int pres;
|
2005-11-15 20:20:45 +00:00
|
|
|
int screen;
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
int capability;
|
|
|
|
int law;
|
|
|
|
/** V110 Stuff **/
|
|
|
|
int rate;
|
|
|
|
int mode;
|
|
|
|
|
|
|
|
int user1;
|
|
|
|
int urate;
|
2006-02-02 21:15:34 +00:00
|
|
|
int hdlc;
|
2005-10-31 23:30:09 +00:00
|
|
|
/* V110 */
|
|
|
|
|
|
|
|
unsigned char display[84];
|
|
|
|
unsigned char msn[32];
|
|
|
|
unsigned char oad[32];
|
|
|
|
unsigned char rad[32];
|
|
|
|
unsigned char dad[32];
|
2006-04-05 14:51:48 +00:00
|
|
|
unsigned char cad[32];
|
2005-10-31 23:30:09 +00:00
|
|
|
unsigned char orig_dad[32];
|
|
|
|
unsigned char keypad[32];
|
2005-12-09 11:01:18 +00:00
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
unsigned char info_dad[64];
|
|
|
|
unsigned char infos_pending[64];
|
2005-12-09 11:01:18 +00:00
|
|
|
|
|
|
|
/* unsigned char info_keypad[32]; */
|
|
|
|
/* unsigned char clisub[24]; */
|
|
|
|
/* unsigned char cldsub[24]; */
|
|
|
|
/* unsigned char uu[256]; */
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
int cause;
|
|
|
|
int out_cause;
|
|
|
|
|
|
|
|
/* struct misdn_bchannel hold_bc; */
|
|
|
|
|
|
|
|
/** list stuf **/
|
|
|
|
|
|
|
|
int ec_enable;
|
|
|
|
int ec_deftaps;
|
|
|
|
int ec_whenbridged;
|
|
|
|
int ec_training;
|
|
|
|
|
|
|
|
int orig;
|
|
|
|
|
|
|
|
int txgain;
|
|
|
|
int rxgain;
|
|
|
|
|
|
|
|
struct misdn_bchannel *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum event_response_e (*cb_event) (enum event_e event, struct misdn_bchannel *bc, void *user_data);
|
|
|
|
void (*cb_log) (int level, int port, char *tmpl, ...);
|
2005-12-09 11:01:18 +00:00
|
|
|
int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
struct misdn_lib_iface {
|
|
|
|
|
|
|
|
enum event_response_e (*cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data);
|
|
|
|
void (*cb_log)(int level, int port, char *tmpl, ...);
|
2005-12-09 11:01:18 +00:00
|
|
|
int (*cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len);
|
2006-05-23 19:40:16 +00:00
|
|
|
|
|
|
|
int l1watcher_timeout;
|
2005-10-31 23:30:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/***** USER IFACE **********/
|
|
|
|
|
|
|
|
int misdn_lib_init(char *portlist, struct misdn_lib_iface* iface, void *user_data);
|
|
|
|
int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event );
|
|
|
|
void misdn_lib_destroy(void);
|
|
|
|
|
|
|
|
void misdn_lib_log_ies(struct misdn_bchannel *bc);
|
|
|
|
|
|
|
|
char *manager_isdn_get_info(enum event_e event);
|
|
|
|
|
|
|
|
void misdn_lib_transfer(struct misdn_bchannel* holded_bc);
|
|
|
|
|
|
|
|
struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel);
|
|
|
|
|
|
|
|
void manager_bchannel_activate(struct misdn_bchannel *bc);
|
|
|
|
void manager_bchannel_deactivate(struct misdn_bchannel * bc);
|
2005-12-09 11:01:18 +00:00
|
|
|
|
|
|
|
int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len);
|
|
|
|
|
2006-06-01 16:41:07 +00:00
|
|
|
void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2);
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
int misdn_lib_port_restart(int port);
|
|
|
|
int misdn_lib_get_port_info(int port);
|
|
|
|
|
2006-02-15 19:32:45 +00:00
|
|
|
int misdn_lib_port_up(int port, int notcheck);
|
2005-10-31 23:30:09 +00:00
|
|
|
|
2006-03-07 11:16:56 +00:00
|
|
|
int misdn_lib_get_port_down(int port);
|
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
int misdn_lib_get_port_up (int port) ;
|
|
|
|
|
|
|
|
int misdn_lib_maxports_get(void) ;
|
|
|
|
|
|
|
|
void misdn_lib_release(struct misdn_bchannel *bc);
|
|
|
|
|
|
|
|
int misdn_cap_is_speech(int cap);
|
|
|
|
int misdn_inband_avail(struct misdn_bchannel *bc);
|
|
|
|
|
|
|
|
int misdn_lib_send_facility(struct misdn_bchannel *bc, enum facility_type fac, void *data);
|
|
|
|
|
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
void manager_ec_enable(struct misdn_bchannel *bc);
|
|
|
|
void manager_ec_disable(struct misdn_bchannel *bc);
|
2005-10-31 23:30:09 +00:00
|
|
|
|
2006-06-18 19:09:32 +00:00
|
|
|
void misdn_lib_send_tone(struct misdn_bchannel *bc, enum tone_e tone);
|
2005-12-09 11:01:18 +00:00
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
void get_show_stack_details(int port, char *buf);
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
|
2006-02-02 21:15:34 +00:00
|
|
|
void misdn_lib_tone_generator_start(struct misdn_bchannel *bc);
|
|
|
|
void misdn_lib_tone_generator_stop(struct misdn_bchannel *bc);
|
|
|
|
|
|
|
|
|
2005-11-15 20:20:45 +00:00
|
|
|
void misdn_lib_setup_bc(struct misdn_bchannel *bc);
|
2005-10-31 23:30:09 +00:00
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
|
|
|
|
void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2);
|
2005-10-31 23:30:09 +00:00
|
|
|
|
2006-05-05 16:38:15 +00:00
|
|
|
void misdn_lib_echo(struct misdn_bchannel *bc, int onoff);
|
|
|
|
|
2005-11-01 22:04:14 +00:00
|
|
|
int misdn_lib_is_ptp(int port);
|
2006-06-26 17:37:11 +00:00
|
|
|
int misdn_lib_get_maxchans(int port);
|
2005-10-31 23:30:09 +00:00
|
|
|
|
|
|
|
#define PRI_TRANS_CAP_SPEECH 0x0
|
|
|
|
#define PRI_TRANS_CAP_DIGITAL 0x08
|
|
|
|
#define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09
|
|
|
|
#define PRI_TRANS_CAP_3_1K_AUDIO 0x10
|
|
|
|
#define PRI_TRANS_CAP_7K_AUDIO 0x11
|
|
|
|
|
2006-04-03 19:17:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
char *bc_state2str(enum bchannel_state state);
|
|
|
|
void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state);
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-31 23:30:09 +00:00
|
|
|
#endif
|