From 99594a1f0718bf17c986cc730420f989f759fadb Mon Sep 17 00:00:00 2001 From: "advielsack@gmail.com" Date: Mon, 9 Jan 2012 16:59:04 +0000 Subject: [PATCH] Fixed vlan bug, gotta rewrite that section soon git-svn-id: http://gsconf.googlecode.com/svn/trunk@7 11042eb7-4a36-49e9-8ab2-01d26d512705 --- gs105e.c | 35 +++++++++++++++++++++++++++-------- shell_vlan.c | 8 ++++---- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gs105e.c b/gs105e.c index a5b9aa6..5f3ed44 100644 --- 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; diff --git a/shell_vlan.c b/shell_vlan.c index 80dfcb1..85bb276 100644 --- a/shell_vlan.c +++ b/shell_vlan.c @@ -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)); -- 2.39.5