fixed a certain 64bit segfault
[asterisk/asterisk.git] / channels / misdn / isdn_lib.c
index b7b78f6..8605bff 100644 (file)
@@ -1138,7 +1138,7 @@ struct misdn_stack* stack_init( int midev, int port, int ptp )
                if (!stack->nt) {
                        /*assume L1 is up, we'll get DEACTIVATES soon, for non
                         * up L1s*/
-                       stack->l1link=1;
+                       stack->l1link=0;
                }
 
                misdn_lib_get_short_status(stack);
@@ -2037,7 +2037,8 @@ int handle_bchan(msg_t *msg)
                                
                                int i=cb_event( EVENT_BCHAN_DATA, bc, glob_mgr->user_data);
                                if (i<0) {
-                                       clean_up_bc(bc);
+                                       cb_log(2,stack->port,"cb_event returned <0\n");
+                                       /*clean_up_bc(bc);*/
                                }
                        }
                }
@@ -2319,6 +2320,7 @@ int handle_mgmt(msg_t *msg)
        
        switch(frm->prim) {
        case MGR_SHORTSTATUS | INDICATION:
+       case MGR_SHORTSTATUS | CONFIRM:
                cb_log(2, 0, "MGMT: Short status dinfo %x\n",frm->dinfo);
                
                switch (frm->dinfo) {
@@ -2341,12 +2343,13 @@ int handle_mgmt(msg_t *msg)
                case SSTATUS_L2_ESTABLISHED:
                        cb_log(1, stack->port, "MGMT: SSTATUS: L2_ESTABLISH \n");
                        stack->l2link=1;
+                       if ( !stack->ptp && !stack->nt )
+                               stack->l1link=2;
                        break;
                        
                case SSTATUS_L2_RELEASED:
                        cb_log(1, stack->port, "MGMT: SSTATUS: L2_RELEASED \n");
                        stack->l2link=0;
-                       stack->l1link=2;
                        break;
                }
                
@@ -3245,7 +3248,7 @@ int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len)
  */
 void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
 {
-       unsigned char buffer[mISDN_HEADER_LEN+sizeof(int)+sizeof(int)];
+       unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(long)];
        iframe_t *ctrl = (iframe_t *)buffer; /* preload data */
        unsigned long *d = (unsigned long *)&ctrl->data.p;
        struct misdn_stack *stack=get_stack_by_bc(bc);
@@ -3264,7 +3267,7 @@ void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
  */
 void manager_ph_control_block(struct misdn_bchannel *bc, int c1, void *c2, int c2_len)
 {
-       unsigned char buffer[mISDN_HEADER_LEN+sizeof(int)+c2_len];
+       unsigned char buffer[mISDN_HEADER_LEN+sizeof(long)+c2_len];
        iframe_t *ctrl = (iframe_t *)buffer;
        unsigned long *d = (unsigned long *)&ctrl->data.p;
        struct misdn_stack *stack=get_stack_by_bc(bc);