Fixed vlan bug, gotta rewrite that section soon
authoradvielsack@gmail.com <advielsack@gmail.com@11042eb7-4a36-49e9-8ab2-01d26d512705>
Mon, 9 Jan 2012 16:59:04 +0000 (16:59 +0000)
committeradvielsack@gmail.com <advielsack@gmail.com@11042eb7-4a36-49e9-8ab2-01d26d512705>
Mon, 9 Jan 2012 16:59:04 +0000 (16:59 +0000)
git-svn-id: http://gsconf.googlecode.com/svn/trunk@7 11042eb7-4a36-49e9-8ab2-01d26d512705

gs105e.c
shell_vlan.c

index a5b9aa60300345753050f02d0d3bcd3000ae9fae..5f3ed44e166844716d715d77489d9b48e7f2f377 100644 (file)
--- a/gs105e.c
+++ b/gs105e.c
@@ -241,10 +241,10 @@ int gs105e__receive(void) {
         unsigned int slLen;
         
         
-//        if (len > 0) 
-//                hexDump(data, len);
+        if (len > 0) 
+                hexDump(data, len);
         if (len == -1) {
-//                printf("Received No or Invalid Packet\n");
+                printf("Received No or Invalid Packet\n");
                 return -1;
         }
         if (memcmp(&data[8], myMac, 6) | data[0] != 0x01 | (!(data[1] == 0x02 | data[1] == 0x04))) {
@@ -412,25 +412,42 @@ void addDiscoveredDevice(int id) {
         if (ddev == NULL) {
                 ddev = (struct gs105e_discovered *)malloc(sizeof(struct gs105e_discovered));
                 gs105e_devs = ddev;
+                ddev->next = NULL;
         }else {
                 while (ddev != NULL) {
-                        if (memcmp(ddev->mac, settings.mac, 6))
+                        if (memcmp(ddev->mac, settings.mac, 6)) {
+                                ddev = ddev->next;
                                 continue;
-                        ddev = ddev->next;
+                        }
+                        
+                        break;
                 }
+                
         }
         
         if (ddev == NULL) {
-                struct gs105e_discovered * ddev = gs105e_devs;
+                
+                ddev = gs105e_devs;
                 gs105e_devs = (struct gs105e_discovered *)malloc(sizeof(struct gs105e_discovered));
+                printf("%p\n", gs105e_devs);
+                printf("%p\n", ddev);
                 gs105e_devs->next = ddev;
                 ddev = gs105e_devs;
+                printf("%p\n", ddev);
+                
         }        
-        ddev->name = settings.name;
+        
+        printf("%p\n", ddev);
+        ddev->name = (char *)realloc(ddev->name, sizeof(char) * strlen(settings.name));
+        printf("DEBUG 1\n");
+        memcpy(ddev->name, settings.name, strlen(settings.name) + 1);
         memcpy(ddev->mac, settings.mac, 6);
+        
         memcpy(ddev->ip, settings.ip, 4);
         memcpy(ddev->gateway, settings.gateway, 4);
-        ddev->model = settings.model;
+        ddev->model = (char *)malloc(sizeof(char) * strlen(settings.model));
+        memcpy(ddev->model, settings.model, strlen(settings.model) + 1);
+        
         ddev->id = id;
         
 }
@@ -458,7 +475,9 @@ int gs105e_discover(void) {
         gs105e_query ();
         gs105e_query ();
         while (gs105e__receive() == 0) {
+                printf("DEGUB DEVICE DISCOVERED\n");
                 addDiscoveredDevice(n + 1);
+                
                 n++;
         }
         return n;
index 80dfcb102254c3e27e2043b1c266d1026a7321f8..85bb2763dce2008e89bd5d4537a292fbe5596403 100644 (file)
@@ -100,13 +100,13 @@ void shell_vlan(char ** argv, int elem) {
                         printf("Invalid Port ID\n");
                         return;
                 }         
-                
+                o = m;
                 m  = (0x80 >> ((m & 0xFF) - 1))  | (int)vl->members;
-                
+                printf("%i  %i\n", (int)vl->tag, (unsigned int)(~((unsigned char)m)));
                 if (strncmp(argv[4], "T", 1) == 0) {
-                        o = (int)vl->tag | m;
+                        o = (int)vl->tag | (0x80 >> ((o & 0xFF) - 1));
                 }else if (strncmp(argv[4], "U", 1) == 0) {
-                        o = (int)vl->tag &(~((char)m));
+                        o = (int)vl->tag &(~((0x80 >> ((o & 0xFF) - 1))));
                 }
                 password();
                 printError(gs105e_setVlanMembers(n, m, o));