]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
automerge commit
authorAutomerge script <automerge@asterisk.org>
Wed, 4 Oct 2006 16:05:59 +0000 (16:05 +0000)
committerAutomerge script <automerge@asterisk.org>
Wed, 4 Oct 2006 16:05:59 +0000 (16:05 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@44351 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_macro.c
channels/chan_misdn.c
channels/misdn/chan_misdn_config.h
channels/misdn/isdn_lib.c
channels/misdn/isdn_lib.h
channels/misdn_config.c
configs/misdn.conf.sample

index ede17ccf71be5b53098b4c2fed530d8a332d10bd..44d3d06105e33946e59b36c0678c69284d7af911 100644 (file)
@@ -60,7 +60,13 @@ static char *descrip =
 "If you Goto out of the Macro context, the Macro will terminate and control\n"
 "will be returned at the location of the Goto.\n"
 "If ${MACRO_OFFSET} is set at termination, Macro will attempt to continue\n"
-"at priority MACRO_OFFSET + N + 1 if such a step exists, and N + 1 otherwise.\n";
+"at priority MACRO_OFFSET + N + 1 if such a step exists, and N + 1 otherwise.\n"
+"WARNING: Because of the way Macro is implemented (it executes the priorities\n"
+"         contained within it via sub-engine), and a fixed per-thread\n"
+"         memory stack allowance, macros are limited to 7 levels\n"
+"         of nesting (macro calling macro calling macro, etc.); It\n"
+"         may be possible that stack-intensive applications in deeply nested\n"
+"         macros could cause asterisk to crash earlier than this limit.\n";
 
 static char *if_descrip =
 "  MacroIf(<expr>?macroname_a[|arg1][:macroname_b[|arg1]])\n"
index dc6c87982adb724b19883affcbaa51cebb35d86a..de116768291f40f08822c90589923115ac21d05b 100644 (file)
@@ -2560,7 +2560,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
                                                
                                                
                                                if ( port_up>0 )        {
-                                                       newbc = misdn_lib_get_free_bc(port, robin_channel);
+                                                       newbc = misdn_lib_get_free_bc(port, robin_channel,0);
                                                        if (newbc) {
                                                                chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
                                                                if (port_up)
@@ -2594,7 +2594,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
                                        chan_misdn_log(4, port, "portup:%d\n", port_up);
                                        
                                        if ( port_up>0 ) {
-                                               newbc = misdn_lib_get_free_bc(port, 0);
+                                               newbc = misdn_lib_get_free_bc(port, 0, 0);
                                                if (newbc)
                                                        break;
                                        }
@@ -2605,7 +2605,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
        } else {
                if (channel)
                        chan_misdn_log(1, port," --> preselected_channel: %d\n",channel);
-               newbc = misdn_lib_get_free_bc(port, channel);
+               newbc = misdn_lib_get_free_bc(port, channel, 0);
        }
        
        if (!newbc) {
@@ -3316,6 +3316,12 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                
                if (ch->state == MISDN_WAITING4DIGS ) {
                        /*  Ok, incomplete Setup, waiting till extension exists */
+
+                       if (ast_strlen_zero(bc->info_dad) && ! ast_strlen_zero(bc->keypad)) {
+                               chan_misdn_log(1, bc->port, " --> using keypad as info\n");
+                               strcpy(bc->info_dad,bc->keypad);
+                       }
+
                        {
                                int l = sizeof(bc->dad);
                                strncat(bc->dad,bc->info_dad, l);
@@ -3428,6 +3434,14 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
                return RESPONSE_IGNORE_SETUP; /*  Ignore MSNs which are not in our List */
        }
        
+       if (bc->cw) {
+               chan_misdn_log(0, bc->port, " --> Call Waiting on PMP sending RELEASE_COMPLETE\n");
+               int cause;
+               misdn_cfg_get( bc->port, MISDN_CFG_REJECT_CAUSE, &cause, sizeof(cause));
+               bc->out_cause=cause?cause:16;
+               return RESPONSE_RELEASE_SETUP;
+       }
+
        print_bearer(bc);
     
        {
index 58fca2c8b3affc23e50e24fdc3a7475cdef0e98c..24c6a1feaa1ec0d4dcb22b9ec0da0730940759b6 100644 (file)
@@ -29,6 +29,7 @@ enum misdn_cfg_elements {
        MISDN_CFG_TXGAIN,              /* int */
        MISDN_CFG_TE_CHOOSE_CHANNEL,   /* int (bool) */
        MISDN_CFG_PMP_L1_CHECK,        /* int (bool) */
+       MISDN_CFG_REJECT_CAUSE,         /* int */
        MISDN_CFG_ALARM_BLOCK,        /* int (bool) */
        MISDN_CFG_HDLC,                /* int (bool) */
        MISDN_CFG_CONTEXT,             /* char[] */
index bc019f5bb1147dff943e65ea231c42cbaf78e726..c0fdf31d8d37e39595f84e86223256f7cde0fb87 100644 (file)
@@ -94,7 +94,7 @@ struct misdn_stack* get_stack_by_bc(struct misdn_bchannel *bc)
        
        for ( ; stack; stack=stack->next) {
                int i;
-               for (i=0; i <stack->b_num; i++) {
+               for (i=0; i <=stack->b_num; i++) {
                        if ( bc->port == stack->port) return stack;
                }
        }
@@ -408,7 +408,7 @@ void dump_chan_list(struct misdn_stack *stack)
 {
        int i;
 
-       for (i=0; i <stack->b_num; i++) {
+       for (i=0; i <stack->b_num; i++) {
                cb_log(6, stack->port, "Idx:%d stack->cchan:%d Chan:%d\n",i,stack->channels[i], i+1);
        }
 }
@@ -523,6 +523,7 @@ void empty_bc(struct misdn_bchannel *bc)
        
 
        bc->in_use= 0;
+       bc->cw= 0;
 
        bc->channel = 0;
 
@@ -655,7 +656,7 @@ void clear_l3(struct misdn_stack *stack)
 {
        int i;
 
-       for (i=0; i<stack->b_num; i++) {
+       for (i=0; i<=stack->b_num; i++) {
                if (global_state == MISDN_INITIALIZED)  {
                        cb_event(EVENT_CLEANUP, &stack->bc[i], NULL); 
                        empty_chan_in_stack(stack,i+1);
@@ -1148,7 +1149,7 @@ struct misdn_stack* stack_init( int midev, int port, int ptp )
        stack->d_stid = stinf->id;
        stack->b_num = stinf->childcnt;
 
-       for (i=0; i<stinf->childcnt; i++)
+       for (i=0; i<=stinf->childcnt; i++)
                stack->b_stids[i] = stinf->child[i];
   
        switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK) {
@@ -1353,7 +1354,7 @@ struct misdn_stack * find_stack_by_mgr(manager_t* mgr_nt)
 struct misdn_bchannel *find_bc_by_masked_l3id(struct misdn_stack *stack, unsigned long l3id, unsigned long mask)
 {
        int i;
-       for (i=0; i<stack->b_num; i++) {
+       for (i=0; i<=stack->b_num; i++) {
                if ( (stack->bc[i].l3_id & mask)  ==  (l3id & mask)) return &stack->bc[i] ;
        }
        return stack_holder_find(stack,l3id);
@@ -1363,7 +1364,7 @@ struct misdn_bchannel *find_bc_by_masked_l3id(struct misdn_stack *stack, unsigne
 struct misdn_bchannel *find_bc_by_l3id(struct misdn_stack *stack, unsigned long l3id)
 {
        int i;
-       for (i=0; i<stack->b_num; i++) {
+       for (i=0; i<=stack->b_num; i++) {
                if (stack->bc[i].l3_id == l3id) return &stack->bc[i] ;
        }
        return stack_holder_find(stack,l3id);
@@ -1372,7 +1373,7 @@ struct misdn_bchannel *find_bc_by_l3id(struct misdn_stack *stack, unsigned long
 struct misdn_bchannel *find_bc_holded(struct misdn_stack *stack)
 {
        int i;
-       for (i=0; i<stack->b_num; i++) {
+       for (i=0; i<=stack->b_num; i++) {
                if (stack->bc[i].holded ) return &stack->bc[i] ;
        }
        return NULL;
@@ -1387,7 +1388,7 @@ struct misdn_bchannel *find_bc_by_addr(unsigned long addr)
        for (stack=glob_mgr->stack_list;
             stack;
             stack=stack->next) {
-               for (i=0; i< stack->b_num; i++) {
+               for (i=0; i<=stack->b_num; i++) {
                        if ( (stack->bc[i].addr&STACK_ID_MASK)==(addr&STACK_ID_MASK) ||  stack->bc[i].layer_id== addr ) {
                                return &stack->bc[i];
                        }
@@ -1405,7 +1406,7 @@ struct misdn_bchannel *find_bc_by_confid(unsigned long confid)
        for (stack=glob_mgr->stack_list;
             stack;
             stack=stack->next) {
-               for (i=0; i< stack->b_num; i++) {
+               for (i=0; i<=stack->b_num; i++) {
                        if ( stack->bc[i].conf_id==confid ) {
                                return &stack->bc[i];
                        }
@@ -1422,7 +1423,7 @@ struct misdn_bchannel *find_bc_by_channel(int port, int channel)
 
        if (!stack) return NULL;        
        
-       for (i=0; i< stack->b_num; i++) {
+       for (i=0; i<=stack->b_num; i++) {
                if ( stack->bc[i].channel== channel ) {
                        return &stack->bc[i];
                }
@@ -1512,7 +1513,7 @@ int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_t *frm)
 int handle_new_process(struct misdn_stack *stack, iframe_t *frm)
 {
   
-       struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0);
+       struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1);
        
        
        if (!bc) {
@@ -1532,8 +1533,9 @@ int handle_cr ( struct misdn_stack *stack, iframe_t *frm)
        switch (frm->prim) {
        case CC_NEW_CR|INDICATION:
                cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
-               if (handle_new_process(stack, frm) <0) 
+               if (handle_new_process(stack, frm) <0) {
                        return -1;
+               }
                return 1;
        case CC_NEW_CR|CONFIRM:
                return 1;
@@ -2177,6 +2179,30 @@ static int do_tone(struct misdn_bchannel *bc, int len)
 }
 
 
+#ifdef MISDN_SAVE_DATA
+static void misdn_save_data(int id, char *p1, int l1, char *p2, int l2) 
+{
+       char n1[32],n2[32];
+
+       sprintf(n1,"/tmp/misdn-rx-%d.raw",id);
+       sprintf(n2,"/tmp/misdn-tx-%d.raw",id);
+
+       FILE *rx=fopen(n1,"a+"); 
+       FILE *tx=fopen(n2,"a+");
+
+       if (!rx || !tx) {
+               cb_log(0,0,"Couldn't open files: %s\n",strerror(errno));
+               return ;
+       }
+       
+       fwrite(p1,1,l1,rx);
+       fwrite(p2,1,l2,tx);
+       
+       fclose(rx);
+       fclose(tx);
+
+}
+#endif
 
 void misdn_tx_jitter(struct misdn_bchannel *bc, int len)
 {
@@ -2188,6 +2214,9 @@ void misdn_tx_jitter(struct misdn_bchannel *bc, int len)
        jlen=cb_jb_empty(bc,data,len);
        
        if (jlen) {
+#ifdef MISDN_SAVE_DATA
+               misdn_save_data((bc->port*100+bc->channel), data, jlen, bc->bframe, bc->bframe_len);
+#endif
                flip_buf_bits( data, jlen);
                
                if (jlen < len) {
@@ -2202,7 +2231,7 @@ void misdn_tx_jitter(struct misdn_bchannel *bc, int len)
                
                txfrm->len =jlen;
                cb_log(9, bc->port, "Transmitting %d samples 2 misdn\n", txfrm->len);
-               
+
                r=mISDN_write( glob_mgr->midev, buf, txfrm->len + mISDN_HEADER_LEN, 8000 );
        } else {
 #define MISDN_GEN_SILENCE
@@ -2548,6 +2577,8 @@ int handle_frm(msg_t *msg)
 
                if (ret<0) {
                        cb_log(3,stack?stack->port:0,"handle_frm: handle_cr <0 prim:%x addr:%x\n", frm->prim, frm->addr);
+
+
                }
 
                if(ret) {
@@ -2582,8 +2613,9 @@ int handle_frm(msg_t *msg)
                                        break;
                                case RESPONSE_IGNORE_SETUP:
                                        /* I think we should send CC_RELEASE_CR, but am not sure*/
-
                                        bc->out_cause=16;
+                               
+                               case RESPONSE_RELEASE_SETUP:
                                        misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
                                        if (bc->channel>0)
                                                empty_chan_in_stack(stack, bc->channel);
@@ -2646,7 +2678,7 @@ int handle_l1(msg_t *msg)
                        free_msg(msg);
                }
                
-               for (i=0;i<stack->b_num; i++) {
+               for (i=0;i<=stack->b_num; i++) {
                        if (stack->bc[i].evq != EVENT_NOTHING) {
                                cb_log(4, stack->port, "Fireing Queued Event %s because L1 got up\n", isdn_get_info(msgs_g, stack->bc[i].evq, 0));
                                misdn_lib_send_event(&stack->bc[i],stack->bc[i].evq);
@@ -2670,7 +2702,7 @@ int handle_l1(msg_t *msg)
        case PH_DEACTIVATE | INDICATION:
                cb_log (3, stack->port, "L1: PH L1Link Down! \n");
                
-               for (i=0; i<stack->b_num; i++) {
+               for (i=0; i<=stack->b_num; i++) {
                        if (global_state == MISDN_INITIALIZED)  {
                                cb_event(EVENT_CLEANUP, &stack->bc[i], glob_mgr->user_data);
                        }
@@ -2977,7 +3009,7 @@ struct misdn_bchannel *manager_find_bc_by_pid(int pid)
        for (stack=glob_mgr->stack_list;
             stack;
             stack=stack->next) {
-               for (i=0; i<stack->b_num; i++)
+               for (i=0; i<=stack->b_num; i++)
                        if (stack->bc[i].pid == pid) return &stack->bc[i];
        }
   
@@ -3012,7 +3044,7 @@ void prepare_bc(struct misdn_bchannel*bc, int channel)
 #endif
 }
 
-struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel)
+struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout)
 {
        struct misdn_stack *stack;
        int i;
@@ -3043,8 +3075,14 @@ struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel)
                                        return NULL;
                                }
                        }
-                       for (i = 0; i < stack->b_num; i++) {
+
+                       int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num;
+                       for (i = 0; i <maxnum; i++) {
                                if (!stack->bc[i].in_use) {
+                                       /* 3. channel on bri means CW*/
+                                       if (!stack->pri && i==stack->b_num)
+                                               stack->bc[i].cw=1;
+
                                        prepare_bc(&stack->bc[i], channel);
                                        return &stack->bc[i];
                                }
@@ -3751,7 +3789,7 @@ int misdn_lib_init(char *portlist, struct misdn_lib_iface *iface, void *user_dat
                        first=0;
                        {
                                int i;
-                               for(i=0;i<stack->b_num; i++) {
+                               for(i=0;i<=stack->b_num; i++) {
                                        int r;
                                        if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) {
                                                cb_log(0, port, "Got Err @ init_bc :%d\n",r);
@@ -3773,7 +3811,7 @@ int misdn_lib_init(char *portlist, struct misdn_lib_iface *iface, void *user_dat
 
                        {
                                int i;
-                               for(i=0;i<stack->b_num; i++) {
+                               for(i=0;i<=stack->b_num; i++) {
                                        int r;
                                        if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "",1 ))<0) {
                                                cb_log(0, port, "Got Err @ init_bc :%d\n",r);
@@ -3808,7 +3846,7 @@ void misdn_lib_destroy()
        int i;
   
        for ( help=glob_mgr->stack_list; help; help=help->next ) {
-               for(i=0;i<help->b_num; i++) {
+               for(i=0;i<=help->b_num; i++) {
                        char buf[1024];
                        mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
                        help->bc[i].addr = 0;
index ea9cbafcb3075b5ec01fe2d8a0722347924e7e27..dcd41c26fd37e6ed65cc16fb575de2a4fcb64172 100644 (file)
 /* typedef int ie_nothing_t ;*/
 /** end of init usage **/
 
+
+/* 
+ * uncomment the following to make chan_misdn create
+ * record files in /tmp/misdn-{rx|tx}-PortChannel format 
+ * */
+
+/*#define MISDN_SAVE_DATA*/
+
 #ifdef WITH_BEROEC
 typedef int beroec_t;
 
@@ -94,6 +102,7 @@ enum mISDN_NUMBER_PLAN {
 enum event_response_e {
        RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE,
        RESPONSE_IGNORE_SETUP,
+       RESPONSE_RELEASE_SETUP,
        RESPONSE_ERR,
        RESPONSE_OK
 };
@@ -228,6 +237,7 @@ struct misdn_bchannel {
        int channel_preselected;
        
        int in_use;
+       int cw;
        int addr;
 
        unsigned char * bframe;
@@ -391,7 +401,7 @@ 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);
+struct misdn_bchannel* misdn_lib_get_free_bc(int port, int channel, int inout);
 
 void manager_bchannel_activate(struct misdn_bchannel *bc);
 void manager_bchannel_deactivate(struct misdn_bchannel * bc);
index 7c019dca0a66cb56bda163f38fb03cd38a6bd4db..e02cd14763bb3a7bcbc18c63693350925886ae3b 100644 (file)
@@ -90,6 +90,7 @@ static const struct misdn_cfg_spec port_spec[] = {
        { "te_choose_channel", MISDN_CFG_TE_CHOOSE_CHANNEL, MISDN_CTYPE_BOOL, "no", NONE },
        { "far_alerting", MISDN_CFG_FAR_ALERTING, MISDN_CTYPE_BOOL, "no", NONE },
        { "pmp_l1_check", MISDN_CFG_PMP_L1_CHECK, MISDN_CTYPE_BOOL, "yes", NONE },
+       { "reject_cause", MISDN_CFG_REJECT_CAUSE, MISDN_CTYPE_INT, "21", NONE },
        { "block_on_alarm", MISDN_CFG_ALARM_BLOCK, MISDN_CTYPE_BOOL, "yes", NONE },
        { "hdlc", MISDN_CFG_HDLC, MISDN_CTYPE_BOOL, "no", NONE },
        { "context", MISDN_CFG_CONTEXT, MISDN_CTYPE_STR, "default", NONE },
index e33dd77235effbba0a400c3ebeef456321eeaa6f..27d9b05c4b36319902be02975d6ede2b34a9f1f2 100644 (file)
@@ -187,6 +187,17 @@ te_choose_channel=no
 ;
 pmp_l1_check=yes
 
+
+
+;
+; in PMP this option defines which cause should be sent out to 
+; the 3. caller. chan_misdn does not support callwaiting on TE
+; PMP side. This allows to modify the RELEASE_COMPLETE cause 
+; at least.
+;
+reject_cause=16
+
+
 ;
 ; Send Setup_Acknowledge on incoming calls anyway (instead of PROCEEDING), 
 ; this requests additional Infos, so we can waitfordigits