On Tuesday 09 October 2012 00:10:56 Dominic Follett-Smith wrote:
Hi
[1] I am using batmand, I have added the following field to the orig_node struct in batman.h:
char * mac_addr;
This doesn't makes sense when you allocate a static 30 byte array.
[2] In get_orig_node() in originator.c:
orig_node->mac_addr = (char *)malloc(30 * sizeof(char)); memset(orig_node->mac_addr, 0, 30);
This is horrible code.
[3] Problem: When I update this field in isbidirectional() in batman.c:
There is no such function.
memcpy(orig_neigh_node->mac_addr, mac_addr_1, strlen(mac_addr_1));
This is even more horrible.
it updates the field fine, but it does not persist, that is to say that after receiving another OGM from the same station, orig_neigh_node->mac_addr is empty. I dont understand why this should be happening.
May it be related with the memset in get_orig_node? It is hard to find problems in the code without seeing the code.
Please use "watch" in gdb to break whenever the field is written (and therefore reset to 0). And check that you really get the same originator when you search in the hash (and not that the item couldn't be found for some reasons in the hash and had to be reallocated).
Kind regards, Sven