]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 68631 via svnmerge from
authorChristian Richter <christian.richter@beronet.com>
Mon, 11 Jun 2007 10:29:18 +0000 (10:29 +0000)
committerChristian Richter <christian.richter@beronet.com>
Mon, 11 Jun 2007 10:29:18 +0000 (10:29 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r68631 | crichter | 2007-06-11 11:18:01 +0200 (Mo, 11 Jun 2007) | 1 line

fixed problem that the dummybc chanels had no lock, checking for the lock now. Also fixed the channel restart stuff, we can now specify and restart particular channels too.
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@68644 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_misdn.c
channels/misdn/ie.c
channels/misdn/isdn_lib.c
channels/misdn/isdn_lib.h
channels/misdn/isdn_msg_parser.c

index af093fb75298aa6c8963f970ded6bd77db62ebb5..5157302b7a663ae226cf86f987233ee1fe2f3dad 100644 (file)
@@ -793,7 +793,7 @@ static int misdn_set_crypt_debug(int fd, int argc, char *argv[])
 static int misdn_port_block(int fd, int argc, char *argv[])
 {
        int port;
-  
+
        if (argc != 4)
                return RESULT_SHOWUSAGE;
   
@@ -847,20 +847,6 @@ static int misdn_restart_pid (int fd, int argc, char *argv[])
        return 0;
 }
 
-static int misdn_send_restart(int fd, int argc, char *argv[])
-{
-       int port;
-       
-       if (argc != 4)
-               return RESULT_SHOWUSAGE;
-       port = atoi(argv[3]);
-       misdn_lib_send_restart(port);
-       
-       return 0;
-}
-
 static int misdn_port_up (int fd, int argc, char *argv[])
 {
        int port;
@@ -1280,6 +1266,25 @@ static int misdn_send_cd (int fd, int argc, char *argv[])
        return 0; 
 }
 
+static int misdn_send_restart(int fd, int argc, char *argv[])
+{
+       int port;
+       int channel;
+       
+       if ( (argc < 4) ||  (argc >  5) )
+               return RESULT_SHOWUSAGE;
+  
+       port = atoi(argv[3]);
+
+       if (argc==5) {
+               channel = atoi(argv[4]);
+               misdn_lib_send_restart(port, channel);
+       } else
+               misdn_lib_send_restart(port, -1 );
+       
+       return 0;
+}
+
 static int misdn_send_digit (int fd, int argc, char *argv[])
 {
        char *channame; 
index 32f0b76c2e070fe416e12ec6e4a5a66503f2cb61..4093805b5b463aa146f837784257bbebe8f606a4 100644 (file)
@@ -1402,3 +1402,21 @@ static void dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, ch
 }
 #endif
 
+/* IE_DISPLAY */
+static void enc_ie_restart_ind(unsigned char **ntmode, msg_t *msg, unsigned char rind, int nt, struct misdn_bchannel *bc)
+{
+       unsigned char *p;
+       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
+       /* if (MISDN_IE_DEBG) printf("    display='%s' (len=%d)\n", display, strlen((char *)display)); */
+
+       p = msg_put(msg, 3);
+       if (nt)
+               *ntmode = p+1;
+       else
+               qi->QI_ELEMENT(restart_ind) = p - (unsigned char *)qi - sizeof(Q931_info_t);
+       p[0] = IE_RESTART_IND;
+       p[1] = 1;
+       p[2] = rind;
+
+}
+
index c1fc2332f1bdfcbd2c67c8728cbde3181e2c6ee8..d9632a003f4ac33bab21004d78981d9f440b565b 100644 (file)
@@ -1135,9 +1135,6 @@ int init_bc(struct misdn_stack *stack,  struct misdn_bchannel *bc, int midev, in
                
        }
        
-       
-       
-       
        {
                stack_info_t *stinf;
                ret = mISDN_get_stack_info(midev, stack->port, buff, sizeof(buff));
@@ -3208,13 +3205,15 @@ void misdn_send_unlock(struct misdn_bchannel *bc);
 void misdn_send_lock(struct misdn_bchannel *bc)
 {
        //cb_log(0,bc->port,"Locking bc->pid:%d\n", bc->pid);
-       pthread_mutex_lock(&bc->send_lock->lock);
+       if (bc->send_lock)
+               pthread_mutex_lock(&bc->send_lock->lock);
 }
 
 void misdn_send_unlock(struct misdn_bchannel *bc)
 {
        //cb_log(0,bc->port,"UnLocking bc->pid:%d\n", bc->pid);
-       pthread_mutex_unlock(&bc->send_lock->lock);
+       if (bc->send_lock)
+               pthread_mutex_unlock(&bc->send_lock->lock);
 }
 
 int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
@@ -3654,7 +3653,7 @@ int misdn_lib_pid_restart(int pid)
 }
 
 /*Sends Restart message for every bchnanel*/
-int misdn_lib_send_restart(int port)
+int misdn_lib_send_restart(int port, int channel)
 {
        struct misdn_stack *stack=find_stack_by_port(port);
        cb_log(0, port, "Sending Restarts on this port.\n");
@@ -3665,9 +3664,17 @@ int misdn_lib_send_restart(int port)
        dummybc.l3_id=MISDN_ID_GLOBAL;
        dummybc.nt=stack->nt;
 
+       /*default is all channels*/
        int max=stack->pri?30:2;
-       int i;
-       for (i=1;i<=max;i++) {
+       int i=1;
+       
+       /*if a channel is specified we restart only this one*/
+       if (channel > 0) {
+               i=channel;
+               max=channel;
+       }
+
+       for (;i<=max;i++) {
                dummybc.channel=i;
                cb_log(0, port, "Restarting channel %d\n",i);
                misdn_lib_send_event(&dummybc, EVENT_RESTART);
index a4492729f0652d63e88ec69290dd7cabf0300119..5ad837a2a8f63e4f5a5da6c72cf4d99b3c0d5282 100644 (file)
@@ -415,7 +415,7 @@ void isdn_lib_stop_dtmf (struct misdn_bchannel *bc);
 
 int misdn_lib_port_restart(int port);
 int misdn_lib_pid_restart(int pid);
-int misdn_lib_send_restart(int port);
+int misdn_lib_send_restart(int port, int channel);
 
 int misdn_lib_get_port_info(int port);
 
index d25faf79084cc3fcecae12794ddf0f6de94bd385..8534e4e74a95362f88e5c8cf7c43c478d840cb32 100644 (file)
@@ -839,6 +839,7 @@ static msg_t *build_restart (struct isdn_msg msgs[], struct misdn_bchannel *bc,
        printf("Building RESTART Msg\n"); 
 #endif
        enc_ie_channel_id(&restart->CHANNEL_ID, msg, 1,bc->channel, nt,bc);
+       enc_ie_restart_ind(&restart->RESTART_IND, msg, 0x80, nt, bc);
 
        cb_log(0,bc->port, "Restarting channel %d\n", bc->channel);