[asterisk-commits] crichter: branch 1.2 r40306 - in /branches/1.2:
channels/ channels/misdn/ con...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Aug 17 14:57:20 MST 2006
Author: crichter
Date: Thu Aug 17 16:57:19 2006
New Revision: 40306
URL: http://svn.digium.com/view/asterisk?rev=40306&view=rev
Log:
This rather small ;-) commit merges the changes from my team branch 0.3.0 into t
he 1.2 branch.
These changes include the new mISDN mqueue interface which makes it possible to
compile chan_misdn against the current cvs version of mISDN/mISDNuser.
These changes also contain various additions and numerous bugfixes to chan_misdn
.
Each change is documented in the commit logs in the team/crichter/0.3.0 branch.
Added:
branches/1.2/channels/misdn/fac.c (with props)
branches/1.2/channels/misdn/fac.h (with props)
Removed:
branches/1.2/channels/misdn/mISDN.patch
branches/1.2/channels/misdn/portinfo.c
Modified:
branches/1.2/channels/Makefile
branches/1.2/channels/chan_misdn.c
branches/1.2/channels/chan_misdn_config.c
branches/1.2/channels/misdn/Makefile
branches/1.2/channels/misdn/chan_misdn_config.h
branches/1.2/channels/misdn/ie.c
branches/1.2/channels/misdn/isdn_lib.c
branches/1.2/channels/misdn/isdn_lib.h
branches/1.2/channels/misdn/isdn_lib_intern.h
branches/1.2/channels/misdn/isdn_msg_parser.c
branches/1.2/configs/misdn.conf.sample
branches/1.2/doc/README.misdn
Modified: branches/1.2/channels/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/Makefile?rev=40306&r1=40305&r2=40306&view=diff
==============================================================================
--- branches/1.2/channels/Makefile (original)
+++ branches/1.2/channels/Makefile Thu Aug 17 16:57:19 2006
@@ -81,9 +81,9 @@
CHANNEL_LIBS+=chan_h323.so
endif
-ifneq ($(wildcard misdn/chan_misdn_lib.a),)
+ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/mISDNuser/mISDNlib.h),)
CHANNEL_LIBS+=chan_misdn.so
- CFLAGS+=-Imisdn
+ CFLAGS+=-Imisdn
endif
CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
@@ -234,11 +234,17 @@
$(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
endif
-chan_misdn.so: chan_misdn.o chan_misdn_config.o misdn/chan_misdn_lib.a
- $(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lmISDN -lisdnnet
-
-chan_misdn.o: chan_misdn.c
- $(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.2.1\" -c $< -o $@
+misdn/chan_misdn_lib.a:
+ make -C misdn
+
+chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a
+ $(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN
+
+chan_misdn.o: chan_misdn.c
+ $(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.3.0\" -c $< -o $@
+
+misdn_config.o: misdn_config.c misdn/chan_misdn_config.h
+ $(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.3.0\" -c $< -o $@
#chan_modem.so : chan_modem.o
# $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
Modified: branches/1.2/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_misdn.c?rev=40306&r1=40305&r2=40306&view=diff
==============================================================================
--- branches/1.2/channels/chan_misdn.c (original)
+++ branches/1.2/channels/chan_misdn.c Thu Aug 17 16:57:19 2006
@@ -59,16 +59,47 @@
#include <asterisk/app.h>
#include <asterisk/features.h>
-#include "chan_misdn_config.h"
-#include "isdn_lib.h"
-
-ast_mutex_t release_lock_mutex;
-
-#define release_lock ast_mutex_lock(&release_lock_mutex)
-#define release_unlock ast_mutex_unlock(&release_lock_mutex)
+#include <chan_misdn_config.h>
+#include <isdn_lib.h>
+
+char global_tracefile[BUFFERSIZE+1];
+
+
+struct misdn_jb{
+ int size;
+ int upper_threshold;
+ char *samples, *ok;
+ int wp,rp;
+ int state_empty;
+ int state_full;
+ int state_buffer;
+ int bytes_wrote;
+ ast_mutex_t mutexjb;
+};
+
+
+
+/* allocates the jb-structure and initialise the elements*/
+struct misdn_jb *misdn_jb_init(int size, int upper_threshold);
+
+/* frees the data and destroys the given jitterbuffer struct */
+void misdn_jb_destroy(struct misdn_jb *jb);
+
+/* fills the jitterbuffer with len data returns < 0 if there was an
+error (bufferoverun). */
+int misdn_jb_fill(struct misdn_jb *jb, const char *data, int len);
+
+/* gets len bytes out of the jitterbuffer if available, else only the
+available data is returned and the return value indicates the number
+of data. */
+int misdn_jb_empty(struct misdn_jb *jb, char *data, int len);
+
+
/* BEGIN: chan_misdn.h */
+
+
enum misdn_chan_state {
MISDN_NOTHING, /*!< at beginning */
@@ -76,11 +107,15 @@
MISDN_EXTCANTMATCH, /*!< when asterisk couldnt match our ext */
MISDN_DIALING, /*!< when pbx_start */
MISDN_PROGRESS, /*!< we got a progress */
+ MISDN_PROCEEDING, /*!< we got a progress */
MISDN_CALLING, /*!< when misdn_call is called */
MISDN_CALLING_ACKNOWLEDGE, /*!< when we get SETUP_ACK */
MISDN_ALERTING, /*!< when Alerting */
MISDN_BUSY, /*!< when BUSY */
MISDN_CONNECTED, /*!< when connected */
+ MISDN_PRECONNECTED, /*!< when connected */
+ MISDN_DISCONNECTED, /*!< when connected */
+ MISDN_RELEASED, /*!< when connected */
MISDN_BRIDGED, /*!< when bridged */
MISDN_CLEANING, /*!< when hangup from * but we were connected before */
MISDN_HUNGUP_FROM_MISDN, /*!< when DISCONNECT/RELEASE/REL_COMP cam from misdn */
@@ -98,12 +133,23 @@
ast_mutex_t lock;
+ char allowed_bearers[BUFFERSIZE+1];
+
enum misdn_chan_state state;
- int holded;
+ int need_queue_hangup;
+ int need_hangup;
+ int need_busy;
+
int orginator;
int norxtone;
int notxtone;
+
+ int toggle_ec;
+
+ int incoming_early_audio;
+
+ int ignore_dtmf;
int pipe[2];
char ast_rd_buf[4096];
@@ -113,23 +159,45 @@
int faxhandled;
int ast_dsp;
+
+ int jb_len;
+ int jb_upper_threshold;
+ struct misdn_jb *jb;
struct ast_dsp *dsp;
struct ast_trans_pvt *trans;
struct ast_channel * ast;
+
+ int dummy;
struct misdn_bchannel *bc;
struct misdn_bchannel *holded_bc;
unsigned int l3id;
int addr;
+
+ char context[BUFFERSIZE];
+
+ int zero_read_cnt;
+ int dropped_frame_cnt;
+
+ int far_alerting;
+ int other_pid;
+ struct chan_list *other_ch;
+
+ const struct tone_zone_sound *ts;
struct chan_list *peer;
struct chan_list *next;
struct chan_list *prev;
struct chan_list *first;
};
+
+
+
+void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch);
+void import_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch);
struct robin_list {
char *group;
@@ -140,13 +208,19 @@
};
static struct robin_list *robin = NULL;
+
+
+struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame *frame);
+
+
+
static inline void free_robin_list_r (struct robin_list *r)
{
- if (r) {
- if (r->next) free_robin_list_r(r->next);
- if (r->group) free(r->group);
- free(r);
- }
+ if (r) {
+ if (r->next) free_robin_list_r(r->next);
+ if (r->group) free(r->group);
+ free(r);
+ }
}
static void free_robin_list ( void )
@@ -155,7 +229,7 @@
robin = NULL;
}
-struct robin_list* get_robin_position (char *group)
+static struct robin_list* get_robin_position (char *group)
{
struct robin_list *iter = robin;
for (; iter; iter = iter->next) {
@@ -173,8 +247,11 @@
return robin;
}
-struct ast_channel *misdn_new(struct chan_list *cl, int state, char * name, char * context, char *exten, char *callerid, int format, int port, int c);
-void send_digit_to_chan(struct chan_list *cl, char digit );
+
+static void chan_misdn_log(int level, int port, char *tmpl, ...);
+
+static struct ast_channel *misdn_new(struct chan_list *cl, int state, char *exten, char *callerid, int format, int port, int c);
+static void send_digit_to_chan(struct chan_list *cl, char digit );
#define AST_CID_P(ast) ast->cid.cid_num
@@ -184,48 +261,50 @@
#define MISDN_ASTERISK_TECH_PVT(ast) ast->tech_pvt
#define MISDN_ASTERISK_PVT(ast) 1
-#define MISDN_ASTERISK_TYPE(ast) ast->tech->type
-
-/* END: chan_misdn.h */
#include <asterisk/strings.h>
/* #define MISDN_DEBUG 1 */
-static char *desc = "Channel driver for mISDN Support (Bri/Pri)";
-static char *type = "mISDN";
-
-int tracing = 0 ;
+static char *desc = "Channel driver for mISDN Support (Bri/Pri)";
+static const char misdn_type[] = "mISDN";
+
+static int tracing = 0 ;
static int usecnt=0;
-char **misdn_key_vector=NULL;
-int misdn_key_vector_size=0;
+static char **misdn_key_vector=NULL;
+static int misdn_key_vector_size=0;
/* Only alaw and mulaw is allowed for now */
static int prefformat = AST_FORMAT_ALAW ; /* AST_FORMAT_SLINEAR ; AST_FORMAT_ULAW | */
static ast_mutex_t usecnt_lock;
-int *misdn_debug;
-int *misdn_debug_only;
-int max_ports;
+static int *misdn_debug;
+static int *misdn_debug_only;
+static int max_ports;
struct chan_list dummy_cl;
struct chan_list *cl_te=NULL;
ast_mutex_t cl_te_lock;
-enum event_response_e
+static enum event_response_e
cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data);
-void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc);
-
-void cl_queue_chan(struct chan_list **list, struct chan_list *chan);
-void cl_dequeue_chan(struct chan_list **list, struct chan_list *chan);
-struct chan_list *find_chan_by_bc(struct chan_list *list, struct misdn_bchannel *bc);
-void chan_misdn_log(int level, int port, char *tmpl, ...);
-void chan_misdn_trace_call(struct ast_channel *chan, int debug, char *tmpl, ...);
+static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc, struct chan_list *ch);
+
+static void cl_queue_chan(struct chan_list **list, struct chan_list *chan);
+static void cl_dequeue_chan(struct chan_list **list, struct chan_list *chan);
+static struct chan_list *find_chan_by_bc(struct chan_list *list, struct misdn_bchannel *bc);
+static struct chan_list *find_chan_by_pid(struct chan_list *list, int pid);
+
+
+
+static int dialtone_indicate(struct chan_list *cl);
+static int hanguptone_indicate(struct chan_list *cl);
+static int stop_indicate(struct chan_list *cl);
static int start_bc_tones(struct chan_list *cl);
static int stop_bc_tones(struct chan_list *cl);
@@ -234,6 +313,10 @@
static int misdn_set_opt_exec(struct ast_channel *chan, void *data);
static int misdn_facility_exec(struct ast_channel *chan, void *data);
+int chan_misdn_jb_empty(struct misdn_bchannel *bc, char *buf, int len);
+
+static int update_ec_config(struct misdn_bchannel *bc);
+
/*************** Helpers *****************/
static struct chan_list * get_chan_by_ast(struct ast_channel *ast)
@@ -258,25 +341,21 @@
return NULL;
}
-static char* tone2str(struct misdn_bchannel *bc)
-{
- static struct {
- char name[16];
- enum tone_e tone;
- } *tone, tone_buf[] = {
- {"NOTONE",TONE_NONE},
- {"DIAL",TONE_DIAL},
- {"BUSY",TONE_BUSY},
- {"ALERT",TONE_ALERTING},
- {"",TONE_NONE}
- };
-
-
- for (tone=&tone_buf[0]; tone->name[0]; tone++) {
- if (tone->tone == bc->tone) return tone->name;
- }
- return NULL;
-}
+
+
+struct allowed_bearers {
+ int cap;
+ int val;
+ char *name;
+};
+
+struct allowed_bearers allowed_bearers_array[]={
+ {INFO_CAPABILITY_SPEECH,1,"speech"},
+ {INFO_CAPABILITY_AUDIO_3_1K,2,"3_1khz"},
+ {INFO_CAPABILITY_DIGITAL_UNRESTRICTED,4,"digital_unrestricted"},
+ {INFO_CAPABILITY_DIGITAL_RESTRICTED,8,"digital_restriced"},
+ {INFO_CAPABILITY_VIDEO,16,"video"}
+};
static char *bearer2str(int cap) {
static char *bearers[]={
@@ -284,6 +363,7 @@
"Audio 3.1k",
"Unres Digital",
"Res Digital",
+ "Video",
"Unknown Bearer"
};
@@ -300,9 +380,30 @@
case INFO_CAPABILITY_DIGITAL_RESTRICTED:
return bearers[3];
break;
- default:
+ case INFO_CAPABILITY_VIDEO:
return bearers[4];
break;
+ default:
+ return bearers[5];
+ break;
+ }
+}
+
+
+static void print_facility( struct misdn_bchannel *bc)
+{
+ switch (bc->fac_type) {
+ case FACILITY_CALLDEFLECT:
+ chan_misdn_log(2,bc->port," --> calldeflect: %s\n",
+ bc->fac.calldeflect_nr);
+ break;
+ case FACILITY_CENTREX:
+ chan_misdn_log(2,bc->port," --> centrex: %s\n",
+ bc->fac.cnip);
+ break;
+ default:
+ chan_misdn_log(2,bc->port," --> unknown\n");
+
}
}
@@ -322,7 +423,7 @@
}
/*************** Helpers END *************/
-void send_digit_to_chan(struct chan_list *cl, char digit )
+static void send_digit_to_chan(struct chan_list *cl, char digit )
{
static const char* dtmf_tones[] = {
"!941+1336/100,!0/100", /* 0 */
@@ -416,16 +517,15 @@
return 0;
}
-
static int misdn_set_crypt_debug(int fd, int argc, char *argv[])
{
- if (argc != 5 )return RESULT_SHOWUSAGE;
+ if (argc != 5) return RESULT_SHOWUSAGE;
return 0;
}
-static int misdn_restart_port (int fd, int argc, char *argv[])
+static int misdn_port_block(int fd, int argc, char *argv[])
{
int port;
@@ -434,21 +534,64 @@
port = atoi(argv[3]);
- misdn_lib_port_restart(port);
+ misdn_lib_port_block(port);
return 0;
}
-static int misdn_port_up (int fd, int argc, char *argv[])
+static int misdn_port_unblock(int fd, int argc, char *argv[])
{
int port;
-
+
if (argc != 4)
return RESULT_SHOWUSAGE;
-
+
port = atoi(argv[3]);
+
+ misdn_lib_port_unblock(port);
+
+ return 0;
+}
+
+
+static int misdn_restart_port (int fd, int argc, char *argv[])
+{
+ int port;
+
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+
+ port = atoi(argv[3]);
+
+ misdn_lib_port_restart(port);
+
+ return 0;
+}
+
+static int misdn_port_up (int fd, int argc, char *argv[])
+{
+ int port;
+
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+
+ port = atoi(argv[3]);
misdn_lib_get_port_up(port);
+
+ return 0;
+}
+
+static int misdn_port_down (int fd, int argc, char *argv[])
+{
+ int port;
+
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+
+ port = atoi(argv[3]);
+
+ misdn_lib_get_port_down(port);
return 0;
}
@@ -470,12 +613,12 @@
if (argc == 3 || onlyport == 0) {
ast_cli(fd,"Misdn General-Config: \n");
- ast_cli(fd," -> VERSION: " CHAN_MISDN_VERSION "\n");
-
+ ast_cli(fd," -> Version: chan_misdn-" CHAN_MISDN_VERSION "\n");
for (elem = MISDN_GEN_FIRST + 1, linebreak = 1; elem < MISDN_GEN_LAST; elem++, linebreak++) {
misdn_cfg_get_config_string( 0, elem, buffer, BUFFERSIZE);
ast_cli(fd, "%-36s%s", buffer, !(linebreak % 2) ? "\n" : "");
}
+ ast_cli(fd, "\n");
}
if (onlyport < 0) {
@@ -505,23 +648,26 @@
return 0;
}
-
-
struct state_struct {
enum misdn_chan_state state;
char txt[255] ;
} ;
-struct state_struct state_array[] = {
+static struct state_struct state_array[] = {
{MISDN_NOTHING,"NOTHING"}, /* at beginning */
{MISDN_WAITING4DIGS,"WAITING4DIGS"}, /* when waiting for infos */
{MISDN_EXTCANTMATCH,"EXTCANTMATCH"}, /* when asterisk couldnt match our ext */
{MISDN_DIALING,"DIALING"}, /* when pbx_start */
{MISDN_PROGRESS,"PROGRESS"}, /* when pbx_start */
+ {MISDN_PROCEEDING,"PROCEEDING"}, /* when pbx_start */
{MISDN_CALLING,"CALLING"}, /* when misdn_call is called */
+ {MISDN_CALLING_ACKNOWLEDGE,"CALLING_ACKNOWLEDGE"}, /* when misdn_call is called */
{MISDN_ALERTING,"ALERTING"}, /* when Alerting */
{MISDN_BUSY,"BUSY"}, /* when BUSY */
{MISDN_CONNECTED,"CONNECTED"}, /* when connected */
+ {MISDN_PRECONNECTED,"PRECONNECTED"}, /* when connected */
+ {MISDN_DISCONNECTED,"DISCONNECTED"}, /* when connected */
+ {MISDN_RELEASED,"RELEASED"}, /* when connected */
{MISDN_BRIDGED,"BRIDGED"}, /* when bridged */
{MISDN_CLEANING,"CLEANING"}, /* when hangup from * but we were connected before */
{MISDN_HUNGUP_FROM_MISDN,"HUNGUP_FROM_MISDN"}, /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
@@ -531,45 +677,44 @@
/* misdn_hangup */
};
-
-
-
-char *misdn_get_ch_state(struct chan_list *p)
+static char *misdn_get_ch_state(struct chan_list *p)
{
int i;
+ static char state[8];
+
if( !p) return NULL;
for (i=0; i< sizeof(state_array)/sizeof(struct state_struct); i++) {
if ( state_array[i].state == p->state) return state_array[i].txt;
}
-
- return NULL;
-}
-
-static int misdn_reload (int fd, int argc, char *argv[])
+
+ sprintf(state,"%d",p->state) ;
+
+ return state;
+}
+
+
+
+void reload_config(void)
{
int i, cfg_debug;
- ast_cli(fd, "Reloading mISDN Config\n");
- chan_misdn_log(0, 0, "Dynamic Crypting Activation is not support during reload at the moment\n");
-
free_robin_list();
-
misdn_cfg_reload();
-
- {
- char tempbuf[BUFFERSIZE];
- misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, tempbuf, BUFFERSIZE);
- if (strlen(tempbuf))
- tracing = 1;
- }
-
+ misdn_cfg_update_ptp();
+ misdn_cfg_get( 0, MISDN_GEN_TRACEFILE, global_tracefile, BUFFERSIZE);
misdn_cfg_get( 0, MISDN_GEN_DEBUG, &cfg_debug, sizeof(int));
+
for (i = 0; i <= max_ports; i++) {
misdn_debug[i] = cfg_debug;
misdn_debug_only[i] = 0;
}
-
+}
+
+static int misdn_reload (int fd, int argc, char *argv[])
+{
+ ast_cli(fd, "Reloading mISDN Config\n");
+ reload_config();
return 0;
}
@@ -577,12 +722,14 @@
{
struct ast_channel *ast=help->ast;
ast_cli(fd,
- "* Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s ctx:%s state:%s\n",
+ "* Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s rad:%s ctx:%s state:%s\n",
+
bc->pid, bc->port, bc->channel,
bc->nt?"NT":"TE",
help->orginator == ORG_AST?"*":"I",
ast?ast->exten:NULL,
ast?AST_CID_P(ast):NULL,
+ bc->rad,
ast?ast->context:NULL,
misdn_get_ch_state(help)
);
@@ -593,9 +740,9 @@
" --> ch_addr: %x\n"
" --> bc_addr: %x\n"
" --> bc_l3id: %x\n"
- " --> tone: %s\n"
" --> display: %s\n"
" --> activated: %d\n"
+ " --> state: %s\n"
" --> capability: %s\n"
" --> echo_cancel: %d\n"
" --> notone : rx %d tx:%d\n"
@@ -605,18 +752,18 @@
help->addr,
bc->addr,
bc?bc->l3_id:-1,
- tone2str(bc),
bc->display,
bc->active,
+ bc_state2str(bc->bc_state),
bearer2str(bc->capability),
bc->ec_enable,
+
help->norxtone,help->notxtone,
bc->holded, help->holded_bc?1:0
);
}
-
static int misdn_show_cls (int fd, int argc, char *argv[])
{
@@ -642,8 +789,6 @@
return 0;
}
-
-
static int misdn_show_cl (int fd, int argc, char *argv[])
{
struct chan_list *help=cl_te;
@@ -680,13 +825,12 @@
return 0;
}
-
-
static int misdn_show_stacks (int fd, int argc, char *argv[])
{
int port;
-
+
ast_cli(fd, "BEGIN STACK_LIST:\n");
+
for (port=misdn_cfg_get_next_port(0); port > 0;
port=misdn_cfg_get_next_port(port)) {
char buf[128];
@@ -745,8 +889,6 @@
return 0;
}
-
-
static int misdn_send_digit (int fd, int argc, char *argv[])
{
@@ -806,9 +948,11 @@
ast_cli(fd, "Toggling EchoCancel %s failed Channel does not exist\n", channame);
return 0;
} else {
- tmp->bc->ec_enable=tmp->bc->ec_enable?0:1;
-
- if (tmp->bc->ec_enable) {
+
+ tmp->toggle_ec=tmp->toggle_ec?0:1;
+
+ if (tmp->toggle_ec) {
+ update_ec_config(tmp->bc);
manager_ec_enable(tmp->bc);
} else {
manager_ec_disable(tmp->bc);
@@ -818,8 +962,6 @@
return 0;
}
-
-
static int misdn_send_display (int fd, int argc, char *argv[])
{
@@ -838,9 +980,7 @@
tmp=get_chan_by_ast_name(channame);
if (tmp && tmp->bc) {
- int l = sizeof(tmp->bc->display);
- strncpy(tmp->bc->display, msg, l);
- tmp->bc->display[l-1] = 0;
+ ast_copy_string(tmp->bc->display, msg, sizeof(tmp->bc->display));
misdn_lib_send_event(tmp->bc, EVENT_INFORMATION);
} else {
ast_cli(fd,"No such channel %s\n",channame);
@@ -850,9 +990,6 @@
return RESULT_SUCCESS ;
}
-
-
-
static char *complete_ch_helper(char *line, char *word, int pos, int state, int rpos)
{
@@ -909,7 +1046,6 @@
complete_ch
};
-
static struct ast_cli_entry cli_send_digit =
{ {"misdn","send","digit", NULL},
misdn_send_digit,
@@ -920,7 +1056,6 @@
complete_ch
};
-
static struct ast_cli_entry cli_toggle_echocancel =
{ {"misdn","toggle","echocancel", NULL},
misdn_toggle_echocancel,
@@ -928,8 +1063,6 @@
"Usage: misdn toggle echocancel <channel>\n",
complete_ch
};
-
-
static struct ast_cli_entry cli_send_display =
{ {"misdn","send","display", NULL},
@@ -941,7 +1074,6 @@
complete_ch
};
-
static struct ast_cli_entry cli_show_config =
{ {"misdn","show","config", NULL},
misdn_show_config,
@@ -949,7 +1081,6 @@
"Usage: misdn show config [port | 0]\n use 0 to only print the general config.\n"
};
-
static struct ast_cli_entry cli_reload =
{ {"misdn","reload", NULL},
misdn_reload,
@@ -963,7 +1094,6 @@
"",
"\n"
};
-
static struct ast_cli_entry cli_show_cls =
{ {"misdn","show","channels", NULL},
@@ -980,6 +1110,19 @@
complete_ch
};
+static struct ast_cli_entry cli_port_block=
+{ {"misdn","port","block", NULL},
+ misdn_port_block,
+ "Blocks the given port",
+ "Usage: misdn port block\n"
+};
+
+static struct ast_cli_entry cli_port_unblock=
+{ {"misdn","port","unblock", NULL},
+ misdn_port_unblock,
+ "Unblocks the given port",
+ "Usage: misdn port unblock\n"
+};
static struct ast_cli_entry cli_restart_port =
@@ -989,7 +1132,6 @@
"Usage: misdn restart port\n"
};
-
static struct ast_cli_entry cli_port_up =
{ {"misdn","port","up", NULL},
misdn_port_up,
@@ -997,6 +1139,14 @@
"Usage: misdn port up <port>\n"
};
+static struct ast_cli_entry cli_port_down =
+{ {"misdn","port","down", NULL},
+ misdn_port_down,
+ "Tries to deacivate the L1 on the given port",
+ "Usage: misdn port down <port>\n"
+};
+
+
static struct ast_cli_entry cli_show_stacks =
{ {"misdn","show","stacks", NULL},
@@ -1011,8 +1161,6 @@
"Shows detailed information for given port",
"Usage: misdn show port <port>\n"
};
-
-
static struct ast_cli_entry cli_set_debug =
{ {"misdn","set","debug", NULL},
@@ -1031,6 +1179,372 @@
/*** CLI END ***/
+static int update_config (struct chan_list *ch, int orig)
+{
+ if (!ch) {
+ ast_log(LOG_WARNING, "Cannot configure without chanlist\n");
+ return -1;
+ }
+
+ struct ast_channel *ast=ch->ast;
+ struct misdn_bchannel *bc=ch->bc;
+ if (! ast || ! bc ) {
+ ast_log(LOG_WARNING, "Cannot configure without ast || bc\n");
+ return -1;
+ }
+
+ int port=bc->port;
+
+ chan_misdn_log(1,port,"update_config: Getting Config\n");
+
+
+ int hdlc=0;
+ misdn_cfg_get( port, MISDN_CFG_HDLC, &hdlc, sizeof(int));
+
+ if (hdlc) {
+ switch (bc->capability) {
+ case INFO_CAPABILITY_DIGITAL_UNRESTRICTED:
+ case INFO_CAPABILITY_DIGITAL_RESTRICTED:
+ chan_misdn_log(1,bc->port," --> CONF HDLC\n");
+ bc->hdlc=1;
+ break;
+ }
+
+ }
+
+
+ int pres, screen;
+
+ misdn_cfg_get( port, MISDN_CFG_PRES, &pres, sizeof(int));
+ misdn_cfg_get( port, MISDN_CFG_SCREEN, &screen, sizeof(int));
+ chan_misdn_log(2,port," --> pres: %d screen: %d\n",pres, screen);
+
+ if ( (pres + screen) < 0 ) {
+
+ chan_misdn_log(2,port," --> pres: %x\n", ast->cid.cid_pres);
+
+ switch (ast->cid.cid_pres & 0x60){
+
+ case AST_PRES_RESTRICTED:
+ bc->pres=1;
+ chan_misdn_log(2, port, " --> PRES: Restricted (0x1)\n");
+ break;
+
+
+ case AST_PRES_UNAVAILABLE:
+ bc->pres=2;
+ chan_misdn_log(2, port, " --> PRES: Unavailable (0x2)\n");
+ break;
+
+ default:
+ bc->pres=0;
+ chan_misdn_log(2, port, " --> PRES: Allowed (0x0)\n");
+ }
+
+ switch (ast->cid.cid_pres & 0x3){
+
+ case AST_PRES_USER_NUMBER_UNSCREENED:
+ bc->screen=0;
+ chan_misdn_log(2, port, " --> SCREEN: Unscreened (0x0)\n");
+ break;
+
+ case AST_PRES_USER_NUMBER_PASSED_SCREEN:
+ bc->screen=1;
+ chan_misdn_log(2, port, " --> SCREEN: Passed Screen (0x1)\n");
+ break;
+ case AST_PRES_USER_NUMBER_FAILED_SCREEN:
+ bc->screen=2;
+ chan_misdn_log(2, port, " --> SCREEN: Failed Screen (0x2)\n");
+ break;
+
+ case AST_PRES_NETWORK_NUMBER:
+ bc->screen=3;
+ chan_misdn_log(2, port, " --> SCREEN: Network Nr. (0x3)\n");
+ break;
+
+ default:
+ bc->screen=0;
+ chan_misdn_log(2, port, " --> SCREEN: Unscreened (0x0)\n");
+ }
+
+
+ } else {
+ bc->screen=screen;
+ bc->pres=pres;
+ }
+
+ return 0;
+
+}
+
+
+
+
+void config_jitterbuffer(struct chan_list *ch)
+{
+ struct misdn_bchannel *bc=ch->bc;
+ int len=ch->jb_len, threshold=ch->jb_upper_threshold;
+
+ chan_misdn_log(5,bc->port, "config_jb: Called\n");
+
+ if ( ! len ) {
+ chan_misdn_log(1,bc->port, "config_jb: Deactivating Jitterbuffer\n");
+ bc->nojitter=1;
+ } else {
+
+ if (len <=100 || len > 8000) {
+ chan_misdn_log(0,bc->port,"config_jb: Jitterbuffer out of Bounds, setting to 1000\n");
+ len=1000;
+ }
+
+ if ( threshold > len ) {
+ chan_misdn_log(0,bc->port,"config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
+ }
+
+ if ( ch->jb) {
+ cb_log(0,bc->port,"config_jb: We've got a Jitterbuffer Already on this port.\n");
+ misdn_jb_destroy(ch->jb);
+ ch->jb=NULL;
+ }
+
+ ch->jb=misdn_jb_init(len, threshold);
+
+ if (!ch->jb )
+ bc->nojitter=1;
+ }
+}
+
+
+void debug_numplan(int port, int numplan, char *type)
+{
+ switch (numplan) {
+ case NUMPLAN_INTERNATIONAL:
+ chan_misdn_log(2, port, " --> %s: International\n",type);
+ break;
+ case NUMPLAN_NATIONAL:
+ chan_misdn_log(2, port, " --> %s: National\n",type);
+ break;
+ case NUMPLAN_SUBSCRIBER:
+ chan_misdn_log(2, port, " --> %s: Subscriber\n",type);
+ break;
+ case NUMPLAN_UNKNOWN:
+ chan_misdn_log(2, port, " --> %s: Unknown\n",type);
+ break;
+ /* Maybe we should cut off the prefix if present ? */
+ default:
+ chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
+ break;
+ }
+}
+
+
+
+
+static int update_ec_config(struct misdn_bchannel *bc)
+{
+ int ec;
+ int port=bc->port;
+
+ misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
+
+ if (ec == 1 ) {
+ bc->ec_enable=1;
+ } else if ( ec > 1 ) {
+ bc->ec_enable=1;
+ bc->ec_deftaps=ec;
+ }
+
+ return 0;
+}
+
+
+static int read_config(struct chan_list *ch, int orig) {
+
+ if (!ch) {
+ ast_log(LOG_WARNING, "Cannot configure without chanlist\n");
+ return -1;
+ }
+
+ struct ast_channel *ast=ch->ast;
+ struct misdn_bchannel *bc=ch->bc;
+ if (! ast || ! bc ) {
+ ast_log(LOG_WARNING, "Cannot configure without ast || bc\n");
+ return -1;
+ }
+
+ int port=bc->port;
+
+ chan_misdn_log(5,port,"read_config: Getting Config\n");
+
+ char lang[BUFFERSIZE+1];
+
+ misdn_cfg_get( port, MISDN_CFG_LANGUAGE, lang, BUFFERSIZE);
+ ast_copy_string(ast->language, lang, sizeof(ast->language));
+
+ char musicclass[BUFFERSIZE+1];
+
+ misdn_cfg_get( port, MISDN_CFG_MUSICCLASS, musicclass, BUFFERSIZE);
+ ast_copy_string(ast->musicclass, musicclass, sizeof(ast->musicclass));
+
+ misdn_cfg_get( port, MISDN_CFG_TXGAIN, &bc->txgain, sizeof(int));
+ misdn_cfg_get( port, MISDN_CFG_RXGAIN, &bc->rxgain, sizeof(int));
+
+ misdn_cfg_get( port, MISDN_CFG_INCOMING_EARLY_AUDIO, &ch->incoming_early_audio, sizeof(int));
+
+ misdn_cfg_get( port, MISDN_CFG_SENDDTMF, &bc->send_dtmf, sizeof(int));
+
+ misdn_cfg_get( port, MISDN_CFG_NEED_MORE_INFOS, &bc->need_more_infos, sizeof(int));
+
+ misdn_cfg_get( port, MISDN_CFG_FAR_ALERTING, &ch->far_alerting, sizeof(int));
+
+ misdn_cfg_get( port, MISDN_CFG_ALLOWED_BEARERS, &ch->allowed_bearers, BUFFERSIZE);
+
+
+ int hdlc=0;
+ misdn_cfg_get( port, MISDN_CFG_HDLC, &hdlc, sizeof(int));
+
+ if (hdlc) {
+ switch (bc->capability) {
+ case INFO_CAPABILITY_DIGITAL_UNRESTRICTED:
+ case INFO_CAPABILITY_DIGITAL_RESTRICTED:
+ chan_misdn_log(1,bc->port," --> CONF HDLC\n");
+ bc->hdlc=1;
+ break;
+ }
+
+ }
+ /*Initialize new Jitterbuffer*/
+ {
+ misdn_cfg_get( port, MISDN_CFG_JITTERBUFFER, &ch->jb_len, sizeof(int));
+ misdn_cfg_get( port, MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, &ch->jb_upper_threshold, sizeof(int));
+
+ config_jitterbuffer(ch);
+ }
+
+ misdn_cfg_get( bc->port, MISDN_CFG_CONTEXT, ch->context, sizeof(ch->context));
+
+ ast_copy_string (ast->context,ch->context,sizeof(ast->context));
+
+ update_ec_config(bc);
+
+ {
+ int eb3;
+
+ misdn_cfg_get( bc->port, MISDN_CFG_EARLY_BCONNECT, &eb3, sizeof(int));
+ bc->early_bconnect=eb3;
+ }
+
+ port=bc->port;
+
+ {
+ char buf[256];
+ ast_group_t pg,cg;
+
+ misdn_cfg_get(port, MISDN_CFG_PICKUPGROUP, &pg, sizeof(pg));
+ misdn_cfg_get(port, MISDN_CFG_CALLGROUP, &cg, sizeof(cg));
+
+ chan_misdn_log(5, port, " --> * CallGrp:%s PickupGrp:%s\n",ast_print_group(buf,sizeof(buf),cg),ast_print_group(buf,sizeof(buf),pg));
+ ast->pickupgroup=pg;
+ ast->callgroup=cg;
+ }
+
+ if ( orig == ORG_AST) {
+ misdn_cfg_get( port, MISDN_CFG_TE_CHOOSE_CHANNEL, &(bc->te_choose_channel), sizeof(int));
+
+ {
+ char callerid[BUFFERSIZE+1];
+ misdn_cfg_get( port, MISDN_CFG_CALLERID, callerid, BUFFERSIZE);
+ if ( ! ast_strlen_zero(callerid) ) {
+ chan_misdn_log(1, port, " --> * Setting Cid to %s\n", callerid);
+ {
+ int l = sizeof(bc->oad);
+ strncpy(bc->oad,callerid, l);
+ bc->oad[l-1] = 0;
+ }
+
+ }
+
+
+ misdn_cfg_get( port, MISDN_CFG_DIALPLAN, &bc->dnumplan, sizeof(int));
+ misdn_cfg_get( port, MISDN_CFG_LOCALDIALPLAN, &bc->onumplan, sizeof(int));
+ misdn_cfg_get( port, MISDN_CFG_CPNDIALPLAN, &bc->cpnnumplan, sizeof(int));
+ debug_numplan(port, bc->dnumplan,"TON");
+ debug_numplan(port, bc->onumplan,"LTON");
+ debug_numplan(port, bc->cpnnumplan,"CTON");
+ }
+
+
+
+ } else { /** ORIGINATOR MISDN **/
+
+ misdn_cfg_get( port, MISDN_CFG_CPNDIALPLAN, &bc->cpnnumplan, sizeof(int));
+ debug_numplan(port, bc->cpnnumplan,"CTON");
+
+ char prefix[BUFFERSIZE+1]="";
+ switch( bc->onumplan ) {
+ case NUMPLAN_INTERNATIONAL:
+ misdn_cfg_get( bc->port, MISDN_CFG_INTERNATPREFIX, prefix, BUFFERSIZE);
+ break;
+
+ case NUMPLAN_NATIONAL:
+ misdn_cfg_get( bc->port, MISDN_CFG_NATPREFIX, prefix, BUFFERSIZE);
+ break;
+ default:
+ break;
+ }
+
+ {
+ int l = strlen(prefix) + strlen(bc->oad);
+ char tmp[l+1];
+ strcpy(tmp,prefix);
+ strcat(tmp,bc->oad);
+ strcpy(bc->oad,tmp);
+ }
+
+ if (!ast_strlen_zero(bc->dad)) {
+ ast_copy_string(bc->orig_dad,bc->dad, sizeof(bc->orig_dad));
+ }
+
+ if ( ast_strlen_zero(bc->dad) && !ast_strlen_zero(bc->keypad)) {
+ ast_copy_string(bc->dad,bc->keypad, sizeof(bc->dad));
+ }
+
+ prefix[0] = 0;
+
+ switch( bc->dnumplan ) {
+ case NUMPLAN_INTERNATIONAL:
+ misdn_cfg_get( bc->port, MISDN_CFG_INTERNATPREFIX, prefix, BUFFERSIZE);
+ break;
+ case NUMPLAN_NATIONAL:
+ misdn_cfg_get( bc->port, MISDN_CFG_NATPREFIX, prefix, BUFFERSIZE);
+ break;
+ default:
+ break;
+ }
+
+ {
+ int l = strlen(prefix) + strlen(bc->dad);
+ char tmp[l+1];
+ strcpy(tmp,prefix);
+ strcat(tmp,bc->dad);
+ strcpy(bc->dad,tmp);
+ }
+
+ if ( strcmp(bc->dad,ast->exten)) {
+ ast_copy_string(ast->exten, bc->dad, sizeof(ast->exten));
+ }
+
+ ast_set_callerid(ast, bc->oad, NULL, bc->oad);
+
+ if ( !ast_strlen_zero(bc->rad) )
+ ast->cid.cid_rdnis=strdup(bc->rad);
+
+ } /* ORIG MISDN END */
+
+ return 0;
+}
+
+
/*****************************/
/*** AST Indications Start ***/
/*****************************/
@@ -1041,9 +1555,8 @@
int r;
struct chan_list *ch=MISDN_ASTERISK_TECH_PVT(ast);
struct misdn_bchannel *newbc;
- char *opts=NULL, *ext=NULL;
+ char *opts=NULL, *ext,*tokb;
char dest_cp[256];
- char *tokb;
{
strncpy(dest_cp,dest,sizeof(dest_cp)-1);
@@ -1056,12 +1569,10 @@
if (ext) {
opts=strtok_r(NULL,"/",&tokb);
} else {
- chan_misdn_log(-1,0,"misdn_call: No Extension given!\n");
+ chan_misdn_log(0,0,"misdn_call: No Extension given!\n");
return -1;
}
}
-
-
}
if (!ast) {
@@ -1076,7 +1587,6 @@
return -1;
}
-
if (!ch) {
ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name);
ast->hangupcause=41;
@@ -1092,182 +1602,14 @@
ast_setstate(ast, AST_STATE_DOWN);
return -1;
}
-
+
port=newbc->port;
-
- ast_copy_string(newbc->dad, ext, sizeof(newbc->dad));
- ast_copy_string(ast->exten, ext, sizeof(ast->exten));
-
- chan_misdn_log(1, 0, "* CALL: %s\n",dest);
+ strncpy(newbc->dad,ext,sizeof( newbc->dad));
+ strncpy(ast->exten,ext,sizeof(ast->exten));
+
+ chan_misdn_log(1, port, "* CALL: %s\n",dest);
chan_misdn_log(1, port, " --> * dad:%s tech:%s ctx:%s\n",ast->exten,ast->name, ast->context);
-
- {
- char context[BUFFERSIZE];
-
- misdn_cfg_get( port, MISDN_CFG_CONTEXT, context, sizeof(ast->context));
- {
- int l = sizeof(ast->context);
- strncpy(ast->context,context, l);
- ast->context[l-1] = 0;
- }
- chan_misdn_log(2, port, " --> * Setting Context to %s\n",context);
- misdn_cfg_get( port, MISDN_CFG_LANGUAGE, ast->language, BUFFERSIZE);
-
- misdn_cfg_get( port, MISDN_CFG_TXGAIN, &newbc->txgain, sizeof(int));
- misdn_cfg_get( port, MISDN_CFG_RXGAIN, &newbc->rxgain, sizeof(int));
-
- misdn_cfg_get( port, MISDN_CFG_TE_CHOOSE_CHANNEL, &(newbc->te_choose_channel), sizeof(int));
-
-
- {
- char callerid[BUFFERSIZE];
- misdn_cfg_get( port, MISDN_CFG_CALLERID, callerid, BUFFERSIZE);
- if ( ! ast_strlen_zero(callerid) ) {
- chan_misdn_log(1, port, " --> * Setting Cid to %s\n", callerid);
- {
- int l = sizeof(newbc->oad);
- strncpy(newbc->oad,callerid, l);
- newbc->oad[l-1] = 0;
- }
- }
-
-
- misdn_cfg_get( port, MISDN_CFG_DIALPLAN, &newbc->dnumplan, sizeof(int));
- switch (newbc->dnumplan) {
- case NUMPLAN_INTERNATIONAL:
- chan_misdn_log(2, port, " --> TON: International\n");
- break;
- case NUMPLAN_NATIONAL:
- chan_misdn_log(2, port, " --> TON: National\n");
- break;
- case NUMPLAN_SUBSCRIBER:
- chan_misdn_log(2, port, " --> TON: Subscriber\n");
- break;
- case NUMPLAN_UNKNOWN:
- chan_misdn_log(2, port, " --> TON: Unknown\n");
- break;
- /* Maybe we should cut off the prefix if present ? */
- default:
- chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
- break;
- }
-
-
- misdn_cfg_get( port, MISDN_CFG_LOCALDIALPLAN, &newbc->onumplan, sizeof(int));
- switch (newbc->onumplan) {
- case NUMPLAN_INTERNATIONAL:
- chan_misdn_log(2, port, " --> TON: International\n");
- break;
- case NUMPLAN_NATIONAL:
- chan_misdn_log(2, port, " --> TON: National\n");
- break;
- case NUMPLAN_SUBSCRIBER:
- chan_misdn_log(2, port, " --> TON: Subscriber\n");
- break;
- case NUMPLAN_UNKNOWN:
- chan_misdn_log(2, port, " --> TON: Unknown\n");
- break;
- /* Maybe we should cut off the prefix if present ? */
- default:
- chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
- break;
- }
- }
-
-
-
-
- {
- int eb3;
-
- misdn_cfg_get( port, MISDN_CFG_EARLY_BCONNECT, &eb3, sizeof(int));
- newbc->early_bconnect=eb3;
-
- }
-
-
-
- /* Will be overridden by asterisk in head! */
- {
- int pres;
-
- misdn_cfg_get( port, MISDN_CFG_PRES, &pres, sizeof(int));
- newbc->pres=pres?0:1;
-
- }
-
- int def_callingpres;
- misdn_cfg_get( port, MISDN_CFG_USE_CALLINGPRES, &def_callingpres, sizeof(int));
- if ( def_callingpres) {
-
- switch (ast->cid.cid_pres & 0x60){
-
- case AST_PRES_RESTRICTED:
- chan_misdn_log(2, port, " --> PRES: Restricted (0x1)\n");
- newbc->pres=1;
- break;
-
-
- case AST_PRES_UNAVAILABLE:
- chan_misdn_log(2, port, " --> PRES: Unavailable (0x2)\n");
- newbc->pres=2;
- break;
-
- default:
- chan_misdn_log(2, port, " --> PRES: Allowed (0x0)\n");
- newbc->pres=0;
- }
-
- switch (ast->cid.cid_pres & 0x3){
-
- case AST_PRES_USER_NUMBER_UNSCREENED:
- chan_misdn_log(2, port, " --> SCREEN: Unscreened (0x0)\n");
- newbc->screen=0;
- break;
-
- case AST_PRES_USER_NUMBER_PASSED_SCREEN:
- chan_misdn_log(2, port, " --> SCREEN: Passed Screen (0x1)\n");
- newbc->screen=1;
- break;
- case AST_PRES_USER_NUMBER_FAILED_SCREEN:
- chan_misdn_log(2, port, " --> SCREEN: Failed Screen (0x2)\n");
- newbc->screen=2;
- break;
-
- case AST_PRES_NETWORK_NUMBER:
- chan_misdn_log(2, port, " --> SCREEN: Network Nr. (0x3)\n");
- newbc->screen=3;
- break;
-
- default:
- chan_misdn_log(2, port, " --> SCREEN: Unscreened (0x0)\n");
- newbc->screen=0;
- }
- }
-
-
- {
- int ec, ectr;
-
- misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
-
- misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
- if (ec == 1 ) {
- newbc->ec_enable=1;
- } else if ( ec > 1 ) {
- newbc->ec_enable=1;
- newbc->ec_deftaps=ec;
- }
-
-
- if (ectr>=0) {
- newbc->ec_training=ectr;
- }
-
- }
-
- }
chan_misdn_log(3, port, " --> * adding2newbc ext %s\n",ast->exten);
if (ast->exten) {
@@ -1278,6 +1620,7 @@
newbc->rad[0]=0;
chan_misdn_log(3, port, " --> * adding2newbc callerid %s\n",AST_CID_P(ast));
if (ast_strlen_zero(newbc->oad) && AST_CID_P(ast) ) {
+
if (AST_CID_P(ast)) {
int l = sizeof(newbc->oad);
strncpy(newbc->oad,AST_CID_P(ast), l);
@@ -1288,14 +1631,7 @@
{
struct chan_list *ch=MISDN_ASTERISK_TECH_PVT(ast);
if (!ch) { ast_verbose("No chan_list in misdn_call"); return -1;}
- ch->bc = newbc;
- ch->orginator=ORG_AST;
- ch->ast = ast;
-
- MISDN_ASTERISK_TECH_PVT(ast) = ch ;
-
-
-
+
newbc->capability=ast->transfercapability;
pbx_builtin_setvar_helper(ast,"TRANSFERCAPABILITY",ast_transfercapability2str(newbc->capability));
if ( ast->transfercapability == INFO_CAPABILITY_DIGITAL_UNRESTRICTED) {
@@ -1303,17 +1639,19 @@
}
+ /* update screening and presentation */
+ update_config(ch,ORG_AST);
+
+ /* fill in some ies from channel vary*/
+ import_ch(ast, newbc, ch);
+
/* Finally The Options Override Everything */
if (opts)
misdn_set_opt_exec(ast,opts);
else
- chan_misdn_log(1,0,"NO OPTS GIVEN\n");
-
-
- cl_queue_chan(&cl_te, ch) ;
+ chan_misdn_log(2,port,"NO OPTS GIVEN\n");
+
ch->state=MISDN_CALLING;
-
- chan_misdn_trace_call(ast,1,"*->I: EVENT_CALL\n" );
r=misdn_lib_send_event( newbc, EVENT_SETUP );
@@ -1332,21 +1670,20 @@
chan_misdn_log(1, port, " --> * SEND: State Dialing pid:%d\n",newbc?newbc->pid:1);
ast_setstate(ast, AST_STATE_DIALING);
-
ast->hangupcause=16;
+
+ if (newbc->nt) stop_bc_tones(ch);
+
return 0;
}
-int misdn_answer(struct ast_channel *ast)
+static int misdn_answer(struct ast_channel *ast)
{
struct chan_list *p;
- if (!ast || ! MISDN_ASTERISK_PVT(ast)) return -1;
- p = MISDN_ASTERISK_TECH_PVT(ast) ;
-
- chan_misdn_trace_call(ast,1,"*->I: EVENT_ANSWER\n");
+ if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast)) ) return -1;
chan_misdn_log(1, p? (p->bc? p->bc->port : 0) : 0, "* ANSWER:\n");
@@ -1362,7 +1699,7 @@
}
{
- char *tmp_key = pbx_builtin_getvar_helper(p->ast, "CRYPT_KEY");
+ const char *tmp_key = pbx_builtin_getvar_helper(p->ast, "CRYPT_KEY");
if (tmp_key ) {
chan_misdn_log(1, p->bc->port, " --> Connection will be BF crypted\n");
@@ -1378,27 +1715,35 @@
}
{
- char *async=pbx_builtin_getvar_helper(ast, "MISDN_DIGITAL_TRANS");
- if (async) {
+ const char *nodsp=pbx_builtin_getvar_helper(ast, "MISDN_DIGITAL_TRANS");
+ if (nodsp) {
chan_misdn_log(1, p->bc->port, " --> Connection is transparent digital\n");
- p->bc->async=1;
+ p->bc->nodsp=1;
+ p->bc->hdlc=0;
+ p->bc->nojitter=1;
}
}
p->state = MISDN_CONNECTED;
+ misdn_lib_echo(p->bc,0);
+ stop_indicate(p);
+
+ if ( ast_strlen_zero(p->bc->cad) ) {
+ chan_misdn_log(2,p->bc->port," --> empty cad using dad\n");
+ ast_copy_string(p->bc->cad,p->bc->dad,sizeof(p->bc->cad));
+ }
+
misdn_lib_send_event( p->bc, EVENT_CONNECT);
start_bc_tones(p);
return 0;
}
-int misdn_digit(struct ast_channel *ast, char digit )
+static int misdn_digit(struct ast_channel *ast, char digit )
{
struct chan_list *p;
- if (!ast || ! MISDN_ASTERISK_PVT(ast)) return -1;
- p = MISDN_ASTERISK_TECH_PVT(ast) ;
-
[... 13084 lines stripped ...]
More information about the asterisk-commits
mailing list