www.usr.com/support/gpl/USR9113_release1.0.tar.gz
[bcm963xx.git] / userapps / opensource / atm2684 / pvc2684ctl / pvc2684d.c
index 6222499..c2168fe 100755 (executable)
@@ -211,8 +211,13 @@ int assign_vcc(struct sockaddr_atmpvc addr, int nas_idx, int encap, int bufsize,
 
 void do_add(int cli_fd, struct be_msg *rmsg, struct ucred *cli_cred)
 {
-  static struct be_group *group = &group_head;
-  static struct be_vc *prev_vc = NULL;
+
+  //brcm begin: static pointers of prev_vc,group has problems when delete is called in between adds
+  //  static struct be_group *group = &group_head;
+  //  static struct be_vc *prev_vc = NULL;
+  struct be_group *group = &group_head;
+  struct be_vc *prev_vc = NULL;
+  //brcm end
   static char curr_groupname[MAX_GROUPNAME_LEN] = {};
   static pid_t curr_cli_pid = 0;
 
@@ -333,13 +338,18 @@ void do_add(int cli_fd, struct be_msg *rmsg, struct ucred *cli_cred)
      which is non-constant. My intent is to keep most of the state 
      variables local to this function.
   */
-
-  if(!group->head)
+  if(!group->head) {
     group->head = new_vc;
-  else if(prev_vc) 
-    prev_vc->next = new_vc;
+  }
+  else {
+    for(prev_vc = group->head; prev_vc->next != NULL; prev_vc=prev_vc->next) ;
 
-  prev_vc       = new_vc;
+    if(prev_vc) {
+    prev_vc->next = new_vc;
+    }
+  }
+  //brcm this has a problem if the VCC in the list is deleted
+  //prev_vc       = new_vc;
   
   smsg.msgtype = OK;
   if( send(cli_fd, &smsg, sizeof(smsg), 0) < 0 )