[svn-commits] branch crichter/1.2-mqueued - r8484 in
/team/crichter/1.2-mqueued: channels/ ...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Mon Jan 23 09:50:38 MST 2006
Author: crichter
Date: Mon Jan 23 10:50:27 2006
New Revision: 8484
URL: http://svn.digium.com/view/asterisk?rev=8484&view=rev
Log:
merged source from 0.3.0
Added:
team/crichter/1.2-mqueued/channels/misdn/fac.c
team/crichter/1.2-mqueued/channels/misdn/fac.h
Removed:
team/crichter/1.2-mqueued/channels/misdn/mISDN.patch
team/crichter/1.2-mqueued/channels/misdn/mISDNuser.patch
Modified:
team/crichter/1.2-mqueued/channels/Makefile
team/crichter/1.2-mqueued/channels/chan_misdn.c
team/crichter/1.2-mqueued/channels/chan_misdn_config.c
team/crichter/1.2-mqueued/channels/misdn/Makefile
team/crichter/1.2-mqueued/channels/misdn/chan_misdn_config.h
team/crichter/1.2-mqueued/channels/misdn/ie.c
team/crichter/1.2-mqueued/channels/misdn/isdn_lib.c
team/crichter/1.2-mqueued/channels/misdn/isdn_lib.h
team/crichter/1.2-mqueued/channels/misdn/isdn_lib_intern.h
team/crichter/1.2-mqueued/channels/misdn/isdn_msg_parser.c
team/crichter/1.2-mqueued/configs/misdn.conf.sample
team/crichter/1.2-mqueued/doc/README.misdn
Modified: team/crichter/1.2-mqueued/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/1.2-mqueued/channels/Makefile?rev=8484&r1=8483&r2=8484&view=diff
==============================================================================
--- team/crichter/1.2-mqueued/channels/Makefile (original)
+++ team/crichter/1.2-mqueued/channels/Makefile Mon Jan 23 10:50:27 2006
@@ -235,10 +235,10 @@
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
+ $(CC) -shared -Xlinker -x -L/usr/lib -o $@ $^ -lisdnnet -lmISDN
chan_misdn.o: chan_misdn.c
- $(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.2.1\" -c $< -o $@
+ $(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.3.0\" -c $< -o $@
#chan_modem.so : chan_modem.o
# $(CC) -rdynamic -shared -Xlinker -x -o $@ $<
Modified: team/crichter/1.2-mqueued/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/1.2-mqueued/channels/chan_misdn.c?rev=8484&r1=8483&r2=8484&view=diff
==============================================================================
--- team/crichter/1.2-mqueued/channels/chan_misdn.c (original)
+++ team/crichter/1.2-mqueued/channels/chan_misdn.c Mon Jan 23 10:50:27 2006
@@ -68,7 +68,50 @@
#define release_unlock ast_mutex_unlock(&release_lock_mutex)
+char global_tracefile[BUFFERSIZE];
+
+
+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 tone_e {
+ TONE_NONE=0,
+ TONE_DIAL,
+ TONE_ALERTING,
+ TONE_BUSY,
+ TONE_CUSTOM,
+ TONE_FILE
+};
+
enum misdn_chan_state {
MISDN_NOTHING, /*!< at beginning */
@@ -113,6 +156,8 @@
int faxhandled;
int ast_dsp;
+
+ struct misdn_jb *jb;
struct ast_dsp *dsp;
struct ast_trans_pvt *trans;
@@ -124,6 +169,10 @@
unsigned int l3id;
int addr;
+
+ char context[BUFFERSIZE];
+
+ const struct tone_zone_sound *ts;
struct chan_list *peer;
struct chan_list *next;
@@ -142,11 +191,11 @@
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 +204,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 +222,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
@@ -186,46 +238,47 @@
#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 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);
+
+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 int tone_indicate( struct chan_list *cl, enum tone_e tone);
static int start_bc_tones(struct chan_list *cl);
static int stop_bc_tones(struct chan_list *cl);
@@ -234,6 +287,8 @@
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);
+
/*************** Helpers *****************/
static struct chan_list * get_chan_by_ast(struct ast_channel *ast)
@@ -258,25 +313,6 @@
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;
-}
static char *bearer2str(int cap) {
static char *bearers[]={
@@ -306,6 +342,24 @@
}
}
+
+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");
+
+ }
+}
+
static void print_bearer(struct misdn_bchannel *bc)
{
@@ -322,7 +376,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,10 +470,9 @@
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;
}
@@ -470,12 +523,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,14 +558,12 @@
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 */
@@ -531,10 +582,7 @@
/* misdn_hangup */
};
-
-
-
-char *misdn_get_ch_state(struct chan_list *p)
+static char *misdn_get_ch_state(struct chan_list *p)
{
int i;
if( !p) return NULL;
@@ -551,19 +599,16 @@
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");
+ chan_misdn_log(-1, 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;
@@ -578,6 +623,7 @@
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",
+
bc->pid, bc->port, bc->channel,
bc->nt?"NT":"TE",
help->orginator == ORG_AST?"*":"I",
@@ -593,7 +639,6 @@
" --> ch_addr: %x\n"
" --> bc_addr: %x\n"
" --> bc_l3id: %x\n"
- " --> tone: %s\n"
" --> display: %s\n"
" --> activated: %d\n"
" --> capability: %s\n"
@@ -605,7 +650,6 @@
help->addr,
bc->addr,
bc?bc->l3_id:-1,
- tone2str(bc),
bc->display,
bc->active,
@@ -616,7 +660,6 @@
);
}
-
static int misdn_show_cls (int fd, int argc, char *argv[])
{
@@ -642,8 +685,6 @@
return 0;
}
-
-
static int misdn_show_cl (int fd, int argc, char *argv[])
{
struct chan_list *help=cl_te;
@@ -680,13 +721,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 +785,6 @@
return 0;
}
-
-
static int misdn_send_digit (int fd, int argc, char *argv[])
{
@@ -819,8 +857,6 @@
return 0;
}
-
-
static int misdn_send_display (int fd, int argc, char *argv[])
{
char *channame;
@@ -851,9 +887,6 @@
return RESULT_SUCCESS ;
}
-
-
-
static char *complete_ch_helper(char *line, char *word, int pos, int state, int rpos)
{
struct ast_channel *c;
@@ -909,7 +942,6 @@
complete_ch
};
-
static struct ast_cli_entry cli_send_digit =
{ {"misdn","send","digit", NULL},
misdn_send_digit,
@@ -920,7 +952,6 @@
complete_ch
};
-
static struct ast_cli_entry cli_toggle_echocancel =
{ {"misdn","toggle","echocancel", NULL},
misdn_toggle_echocancel,
@@ -928,8 +959,6 @@
"Usage: misdn toggle echocancel <channel>\n",
complete_ch
};
-
-
static struct ast_cli_entry cli_send_display =
{ {"misdn","send","display", NULL},
@@ -941,7 +970,6 @@
complete_ch
};
-
static struct ast_cli_entry cli_show_config =
{ {"misdn","show","config", NULL},
misdn_show_config,
@@ -949,7 +977,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 +990,6 @@
"",
"\n"
};
-
static struct ast_cli_entry cli_show_cls =
{ {"misdn","show","channels", NULL},
@@ -989,7 +1015,6 @@
"Usage: misdn restart port\n"
};
-
static struct ast_cli_entry cli_port_up =
{ {"misdn","port","up", NULL},
misdn_port_up,
@@ -997,7 +1022,6 @@
"Usage: misdn port up <port>\n"
};
-
static struct ast_cli_entry cli_show_stacks =
{ {"misdn","show","stacks", NULL},
misdn_show_stacks,
@@ -1011,8 +1035,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,110 +1053,164 @@
/*** CLI END ***/
-/*****************************/
-/*** AST Indications Start ***/
-/*****************************/
-
-static int misdn_call(struct ast_channel *ast, char *dest, int timeout)
-{
- int port=0;
- int r;
- struct chan_list *ch=MISDN_ASTERISK_TECH_PVT(ast);
- struct misdn_bchannel *newbc;
- char *opts=NULL, *ext=NULL;
- char dest_cp[256];
- char *tokb;
-
+
+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(1,port,"read_config: Getting Config\n");
+
+ char lang[BUFFERSIZE];
+
+
+ misdn_cfg_get( port, MISDN_CFG_LANGUAGE, lang, BUFFERSIZE);
+ ast_copy_string(ast->language, lang, sizeof(ast->language));
+ ast->language[sizeof(ast->language)]=0;
+
+
+ char musicclass[BUFFERSIZE];
+
+ misdn_cfg_get( port, MISDN_CFG_MUSICCLASS, musicclass, BUFFERSIZE);
+ ast_copy_string(ast->musicclass, musicclass, sizeof(ast->musicclass));
+ ast->musicclass[sizeof(ast->musicclass)]=0;
+
+
+ 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_SENDDTMF, &bc->send_dtmf, sizeof(int));
+
+
+ /*Initialize new Jitterbuffer*/
{
- strncpy(dest_cp,dest,sizeof(dest_cp)-1);
- dest_cp[sizeof(dest_cp)]=0;
-
- ext=strtok_r(dest_cp,"/",&tokb);
-
- if (ext) {
- ext=strtok_r(NULL,"/",&tokb);
- if (ext) {
- opts=strtok_r(NULL,"/",&tokb);
- } else {
- chan_misdn_log(-1,0,"misdn_call: No Extension given!\n");
- return -1;
- }
- }
-
-
- }
-
- if (!ast) {
- ast_log(LOG_WARNING, " --> ! misdn_call called on ast_channel *ast where ast == NULL\n");
- return -1;
- }
-
- if (((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) || !dest ) {
- ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name);
- ast->hangupcause=41;
- ast_setstate(ast, AST_STATE_DOWN);
- 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;
- ast_setstate(ast, AST_STATE_DOWN);
- return -1;
- }
-
- newbc=ch->bc;
-
- if (!newbc) {
- ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name);
- ast->hangupcause=41;
- 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);
-
- chan_misdn_log(1, port, " --> * dad:%s tech:%s ctx:%s\n",ast->exten,ast->name, ast->context);
+ int jb_len,jb_upper_threshold;
+ misdn_cfg_get( port, MISDN_CFG_JITTERBUFFER, &jb_len, sizeof(int));
+ misdn_cfg_get( port, MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, &jb_upper_threshold, sizeof(int));
+
+ if ( ! jb_len ) {
+ chan_misdn_log(1,bc->port, "read_config: Deactivating Jitterbuffer\n");
+ bc->nojitter=1;
+ } else {
+
+ if (jb_len <=100 || jb_len > 8000) {
+ chan_misdn_log(-1,bc->port,"read_config: Jitterbuffer out of Bounds, setting to 1000\n");
+ jb_len=1000;
+ }
+
+ if ( jb_upper_threshold > jb_len ) {
+ chan_misdn_log(-1,bc->port,"read_config: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
+ }
+
+
+ if ( ch->jb) {
+ cb_log(0,bc->port,"read_config: We've got a Jitterbuffer Already on this port.\n");
+ misdn_jb_destroy(ch->jb);
+ ch->jb=NULL;
+ }
+
+ ch->jb=misdn_jb_init(jb_len, jb_upper_threshold);
+ }
+ }
+
+ misdn_cfg_get( bc->port, MISDN_CFG_CONTEXT, ch->context, sizeof(ch->context));
+
+ strncpy(ast->context,ch->context,sizeof(ast->context)-1);
{
- 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));
-
-
+ 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 ) {
+ bc->ec_enable=1;
+ } else if ( ec > 1 ) {
+ bc->ec_enable=1;
+ bc->ec_deftaps=ec;
+ }
+
+ if ( ectr >= 0 ) {
+ bc->ec_training=ectr;
+ }
+ }
+
+
+ {
+ 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(2, 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];
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;
+ int l = sizeof(bc->oad);
+ strncpy(bc->oad,callerid, l);
+ bc->oad[l-1] = 0;
}
- }
-
-
- misdn_cfg_get( port, MISDN_CFG_DIALPLAN, &newbc->dnumplan, sizeof(int));
- switch (newbc->dnumplan) {
+
+ }
+
+
+ misdn_cfg_get( port, MISDN_CFG_DIALPLAN, &bc->dnumplan, sizeof(int));
+ switch (bc->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, &bc->onumplan, sizeof(int));
+ switch (bc->onumplan) {
case NUMPLAN_INTERNATIONAL:
chan_misdn_log(2, port, " --> TON: International\n");
break;
@@ -1152,122 +1228,241 @@
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;
+ int pres, screen;
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){
+ misdn_cfg_get( port, MISDN_CFG_SCREEN, &screen, sizeof(int));
+ chan_misdn_log(2,port," --> pres: %d screen: %d\n",pres);
+
+ if ( (pres + screen) < 0 ) {
+
+ switch (ast->cid.cid_pres & 0x60){
- case AST_PRES_RESTRICTED:
- chan_misdn_log(2, port, " --> PRES: Restricted (0x1)\n");
- newbc->pres=1;
+ 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;
+ }
+ }
+
+
+
+ } else { /** ORIGINATOR MISDN **/
+
+ char prefix[BUFFERSIZE]="";
+ 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;
+
+
+ case NUMPLAN_SUBSCRIBER:
+ /* dunno what to do here ? */
+ break;
+
+ case NUMPLAN_UNKNOWN:
+ 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)) {
+ strncpy(bc->orig_dad,bc->dad, sizeof(bc->orig_dad));
+ bc->orig_dad[sizeof(bc->orig_dad)-1] = 0;
+ }
+
+ if ( ast_strlen_zero(bc->dad) && !ast_strlen_zero(bc->keypad)) {
+ strncpy(bc->dad,bc->keypad, sizeof(bc->dad));
+ bc->dad[sizeof(bc->dad)-1] = 0;
+ }
+ 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;
- 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;
- }
- }
-
+ case NUMPLAN_SUBSCRIBER:
+ /* dunno what to do here ? */
+ break;
+
+ case NUMPLAN_UNKNOWN:
+ break;
+ default:
+ break;
+ }
{
- 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;
- }
-
- }
-
- }
+ 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));
+ }
+ if ( ast->cid.cid_num && strcmp(ast->cid.cid_num, bc->oad)) {
+ free(ast->cid.cid_num);
+ ast->cid.cid_num=NULL;
+
+ }
+ if ( !ast->cid.cid_num) {
+ ast->cid.cid_num=strdup(bc->oad);
+ }
+
+ pbx_builtin_setvar_helper(ch->ast,"REDIRECTING_NUMBER",bc->rad);
+ }
+
+ return 0;
+}
+
+
+/*****************************/
+/*** AST Indications Start ***/
+/*****************************/
+
+static int misdn_call(struct ast_channel *ast, char *dest, int timeout)
+{
+ int port=0;
+ int r;
+ struct chan_list *ch=MISDN_ASTERISK_TECH_PVT(ast);
+ struct misdn_bchannel *newbc;
+ char *opts=NULL, *ext,*tokb;
+ char dest_cp[256];
+ struct ast_channel *bridged;
+
+ if ( (bridged=ast_bridged_channel(ast)) ) {
+ chan_misdn_log(0,0,"Our Bridged Partner is %s\n",bridged->tech->type);
+ } else {
+ chan_misdn_log(0,0,"No Bridged Partner\n");
+ }
+
+ {
+ strncpy(dest_cp,dest,sizeof(dest_cp)-1);
+ dest_cp[sizeof(dest_cp)]=0;
+
+ ext=strtok_r(dest_cp,"/",&tokb);
+
+ if (ext) {
+ ext=strtok_r(NULL,"/",&tokb);
+ if (ext) {
+ opts=strtok_r(NULL,"/",&tokb);
+ } else {
+ chan_misdn_log(-1,0,"misdn_call: No Extension given!\n");
+ return -1;
+ }
+
+ }
+
+
+ }
+
+ if (!ast) {
+ ast_log(LOG_WARNING, " --> ! misdn_call called on ast_channel *ast where ast == NULL\n");
+ return -1;
+ }
+
+ if (((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) || !dest ) {
+ ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name);
+ ast->hangupcause=41;
+ ast_setstate(ast, AST_STATE_DOWN);
+ 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;
+ ast_setstate(ast, AST_STATE_DOWN);
+ return -1;
+ }
+
+ newbc=ch->bc;
+
+ if (!newbc) {
+ ast_log(LOG_WARNING, " --> ! misdn_call called on %s, neither down nor reserved (or dest==NULL)\n", ast->name);
+ ast->hangupcause=41;
+ ast_setstate(ast, AST_STATE_DOWN);
+ return -1;
+ }
+
+ port=newbc->port;
+ strncpy(newbc->dad,ext,sizeof( newbc->dad));
+ strncpy(ast->exten,ext,sizeof(ast->exten));
+
+
+ chan_misdn_log(1, 0, "* CALL: %s\n",dest);
+
+ chan_misdn_log(1, port, " --> * dad:%s tech:%s ctx:%s\n",ast->exten,ast->name, ast->context);
+
+
chan_misdn_log(3, port, " --> * adding2newbc ext %s\n",ast->exten);
if (ast->exten) {
@@ -1278,6 +1473,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,21 +1484,14 @@
{
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) {
chan_misdn_log(2, port, " --> * Call with flag Digital\n");
}
-
+
/* Finally The Options Override Everything */
if (opts)
misdn_set_opt_exec(ast,opts);
@@ -1310,10 +1499,9 @@
chan_misdn_log(1,0,"NO OPTS GIVEN\n");
- cl_queue_chan(&cl_te, ch) ;
+
ch->state=MISDN_CALLING;
- chan_misdn_trace_call(ast,1,"*->I: EVENT_CALL\n" );
r=misdn_lib_send_event( newbc, EVENT_SETUP );
@@ -1338,15 +1526,12 @@
}
-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 +1547,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,10 +1563,12 @@
}
{
- 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;
}
}
@@ -1392,13 +1579,11 @@
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) ;
-
+ if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast))) return -1;
struct misdn_bchannel *bc=p->bc;
chan_misdn_log(1, bc?bc->port:0, "* IND : Digit %c\n",digit);
@@ -1452,12 +1637,11 @@
}
-int misdn_fixup(struct ast_channel *oldast, struct ast_channel *ast)
+static int misdn_fixup(struct ast_channel *oldast, struct ast_channel *ast)
{
struct chan_list *p;
- if (!ast || ! MISDN_ASTERISK_PVT(ast)) return -1;
- p = MISDN_ASTERISK_TECH_PVT(ast) ;
+ if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast) )) return -1;
chan_misdn_log(1, p->bc?p->bc->port:0, "* IND: Got Fixup State:%s Holded:%d L3id:%x\n", misdn_get_ch_state(p), p->holded, p->l3id);
@@ -1468,29 +1652,16 @@
}
-int misdn_transfer (struct ast_channel *ast, char *dest)
+
+static int misdn_indication(struct ast_channel *ast, int cond)
{
struct chan_list *p;
-
- if (!ast || ! MISDN_ASTERISK_PVT(ast)) return -1;
- p = MISDN_ASTERISK_TECH_PVT(ast) ;
-
- chan_misdn_log(1, p->bc?p->bc->port:0, "* IND : Got Transfer %s\n",dest);
- return 0;
-}
-
-
-
-int misdn_indication(struct ast_channel *ast, int cond)
-{
- struct chan_list *p;
-
-
- if (!ast || ! MISDN_ASTERISK_PVT(ast)) {
+
+
+ if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast))) {
ast_log(LOG_WARNING, "Returnded -1 in misdn_indication\n");
return -1;
}
- p = MISDN_ASTERISK_TECH_PVT(ast) ;
if (!p->bc ) {
chan_misdn_log(1, 0, "* IND : Indication from %s\n",ast->exten);
@@ -1509,31 +1680,33 @@
p->bc->out_cause=17;
if (p->state != MISDN_CONNECTED) {
misdn_lib_send_event( p->bc, EVENT_DISCONNECT);
- manager_send_tone(p->bc, TONE_BUSY);
+ tone_indicate(p, TONE_BUSY);
} else {
- chan_misdn_log(0, p->bc->port, " --> !! Got Busy in Connected State !?! port:%d ast:%s\n",
- p->bc->port, ast->name);
+
+ chan_misdn_log(-1, p->bc->port, " --> !! Got Busy in Connected State !?! ast:%s\n", ast->name);
}
break;
case AST_CONTROL_RING:
chan_misdn_log(1, p->bc->port, " --> * IND :\tring pid:%d\n",p->bc?p->bc->pid:-1);
break;
case AST_CONTROL_RINGING:
- if ( p->state == MISDN_ALERTING) {
- chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d but I ws Ringing before, so ignoreing it\n",p->bc?p->bc->pid:-1);
- break;
- }
- p->state=MISDN_ALERTING;
-
- chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d\n",p->bc?p->bc->pid:-1);
-
- misdn_lib_send_event( p->bc, EVENT_ALERTING);
-
- manager_send_tone(p->bc, TONE_ALERTING);
- chan_misdn_log(1, p->bc->port, " --> * SEND: State Ring pid:%d\n",p->bc?p->bc->pid:-1);
- ast_setstate(ast,AST_STATE_RINGING);
- break;
-
+ switch (p->state) {
+ case MISDN_ALERTING:
+ chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d but I was Ringing before, so ignoreing it\n",p->bc?p->bc->pid:-1);
+ break;
+ case MISDN_CONNECTED:
+ chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d but Connected, so just send TONE_ALERTING without state changes \n",p->bc?p->bc->pid:-1);
+ tone_indicate(p, TONE_ALERTING);
+ break;
+ default:
+ p->state=MISDN_ALERTING;
+ chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d\n",p->bc?p->bc->pid:-1);
+ misdn_lib_send_event( p->bc, EVENT_ALERTING);
+ tone_indicate(p, TONE_ALERTING);
+ chan_misdn_log(1, p->bc->port, " --> * SEND: State Ring pid:%d\n",p->bc?p->bc->pid:-1);
+ ast_setstate(ast,AST_STATE_RINGING);
+ }
+ break;
case AST_CONTROL_ANSWER:
chan_misdn_log(1, p->bc->port, " --> * IND :\tanswer pid:%d\n",p->bc?p->bc->pid:-1);
break;
@@ -1549,24 +1722,28 @@
case AST_CONTROL_PROGRESS:
chan_misdn_log(1, p->bc->port, " --> * IND :\tprogress pid:%d\n",p->bc?p->bc->pid:-1);
break;
+ case AST_CONTROL_PROCEEDING:
+ chan_misdn_log(1, p->bc->port, " --> * IND :\tproceeding pid:%d\n",p->bc?p->bc->pid:-1);
+ break;
case AST_CONTROL_CONGESTION:
chan_misdn_log(1, p->bc->port, " --> * IND :\tcongestion pid:%d\n",p->bc?p->bc->pid:-1);
p->bc->out_cause=42;
if (p->state != MISDN_CONNECTED) {
start_bc_tones(p);
- //misdn_lib_send_event( p->bc, EVENT_RELEASE_COMPLETE);
misdn_lib_send_event( p->bc, EVENT_RELEASE);
} else {
misdn_lib_send_event( p->bc, EVENT_DISCONNECT);
}
+
if (p->bc->nt) {
- manager_send_tone(p->bc, TONE_BUSY);
+ tone_indicate(p, TONE_BUSY);
}
break;
case -1 :
chan_misdn_log(1, p->bc->port, " --> * IND :\t-1! pid:%d\n",p->bc?p->bc->pid:-1);
break;
+
case AST_CONTROL_HOLD:
chan_misdn_log(1, p->bc->port, " --> *\tHOLD pid:%d\n",p->bc?p->bc->pid:-1);
break;
@@ -1580,7 +1757,7 @@
return 0;
}
-int misdn_hangup(struct ast_channel *ast)
+static int misdn_hangup(struct ast_channel *ast)
{
struct chan_list *p;
struct misdn_bchannel *bc=NULL;
@@ -1589,7 +1766,6 @@
release_lock;
- chan_misdn_trace_call(ast,1,"*->I: EVENT_HANGUP cause=%d\n",ast->hangupcause);
ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name);
@@ -1611,6 +1787,8 @@
MISDN_ASTERISK_TECH_PVT(ast)=NULL;
p->ast=NULL;
+ bc=p->bc;
+
if (ast->_state == AST_STATE_RESERVED) {
/* between request and call */
MISDN_ASTERISK_TECH_PVT(ast)=NULL;
@@ -1618,8 +1796,9 @@
cl_dequeue_chan(&cl_te, p);
free(p);
-
- misdn_lib_release(bc);
+
+ if (bc)
+ misdn_lib_release(bc);
return 0;
}
@@ -1629,12 +1808,8 @@
release_unlock;
-
-
-
-
{
- char *varcause=NULL;
+ const char *varcause=NULL;
bc->cause=ast->hangupcause?ast->hangupcause:16;
if ( (varcause=pbx_builtin_getvar_helper(ast, "HANGUPCAUSE")) ||
@@ -1656,7 +1831,7 @@
case MISDN_HOLDED:
case MISDN_DIALING:
start_bc_tones(p);
- manager_send_tone(bc, TONE_BUSY);
+ tone_indicate(p, TONE_BUSY);
p->state=MISDN_CLEANING;
misdn_lib_send_event( bc, EVENT_RELEASE_COMPLETE);
@@ -1667,7 +1842,7 @@
chan_misdn_log(2, bc->port, " --> * State Alerting\n");
if (p->orginator != ORG_AST)
- manager_send_tone(bc, TONE_BUSY);
+ tone_indicate(p, TONE_BUSY);
p->state=MISDN_CLEANING;
misdn_lib_send_event( bc, EVENT_DISCONNECT);
@@ -1676,7 +1851,7 @@
/* Alerting or Disconect */
chan_misdn_log(2, bc->port, " --> * State Connected\n");
start_bc_tones(p);
- manager_send_tone(bc, TONE_BUSY);
+ tone_indicate(p, TONE_BUSY);
misdn_lib_send_event( bc, EVENT_DISCONNECT);
p->state=MISDN_CLEANING; /* MISDN_HUNGUP_FROM_AST; */
@@ -1695,6 +1870,7 @@
break;
default:
/* Alerting or Disconect */
+
if (bc->nt)
misdn_lib_send_event(bc, EVENT_RELEASE);
else
@@ -1709,7 +1885,7 @@
return 0;
}
-struct ast_frame *misdn_read(struct ast_channel *ast)
+static struct ast_frame *misdn_read(struct ast_channel *ast)
{
struct chan_list *tmp;
@@ -1740,38 +1916,48 @@
tmp->frame.src = NULL;
tmp->frame.data = tmp->ast_rd_buf ;
- chan_misdn_trace_call(tmp->ast,3,"*->I: EVENT_READ len=%d\n",len);
return &tmp->frame;
}
-int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
-{
- struct chan_list *p;
+
+
+
+static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
+{
+ struct chan_list *ch;
int i = 0;
- if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast)) ) return -1;
-
- if (!p->bc ) {
+ if (!ast || ! (ch=MISDN_ASTERISK_TECH_PVT(ast)) ) return -1;
+
+ if (!ch->bc ) {
ast_log(LOG_WARNING, "private but no bc\n");
return -1;
}
- if (p->bc->tone != TONE_NONE)
- manager_send_tone(p->bc,TONE_NONE);
-
-
- if (p->holded ) {
- chan_misdn_log(5, p->bc->port, "misdn_write: Returning because holded\n");
+ /*if (ch->bc->tone != TONE_NONE)
+ tone_indicate(ch,TONE_NONE); */
+
+
+ if (ch->holded ) {
+ chan_misdn_log(5, ch->bc->port, "misdn_write: Returning because holded\n");
return 0;
}
- if (p->notxtone) {
- chan_misdn_log(5, p->bc->port, "misdn_write: Returning because notxone\n");
+ if (ch->notxtone) {
+ chan_misdn_log(5, ch->bc->port, "misdn_write: Returning because notxone\n");
return 0;
}
+
+
+ if ( !frame->subclass) {
+ chan_misdn_log(0, ch->bc->port, "misdn_write: * prods us\n");
+ return 0;
+ }
if ( !(frame->subclass & prefformat)) {
- chan_misdn_log(0, p->bc->port, "Got Unsupported Frame with Format:%d\n", frame->subclass);
+
[... 8177 lines stripped ...]
More information about the svn-commits
mailing list