Hi,
I need to display the number of all nodes/clients as well as all neighbor nodes/clients.
This would be easy if batctl would be able to output the respective
list of mac addresses (batctl ... | wc -l).
I've started writing a patch as part of a feature request:
http://www.open-mesh.org/issues/203
But the problem is how to get the respective output form the debug tables.
I have been reading the docs, but have not been able
to understand the necessary information needed, no offense:
http://www.open-mesh.org/projects/batman-adv/wiki/Understand-your-batman-ad…
Some explanation beforehand:
Clients are computers not running batman-adv,
represented by the MAC address of its network interface.
Nodes are computers running batman-adv,
represented by the MAC address of its primary interface.
List of all nodes:
Get all MACs from the 'Originator' column of the originator table
List of all neighbor nodes:
Get all MACs from the 'Nexthop' column of the originator table
and make it a unique list.
List of all clients:
Get all MACs of the 'Client' column of the transtable_local table
when it starts with a '*' character.
List of all neighbor clients:
Get all MACs of the 'Client' column of the transtable_global table
when it starts with a '*' character and when the nodes own originator
MAC (of the primary interface?) is also in the 'Originator' column.
I do not think this approach is correct, yet.
Maybe someone can drop some hints.
thanks,
mwarning
The socket is still using one file descriptor of the process when the
connection fails. This fd leak is non-problematic in the current client process
code because the client would be closed in this situation anyway and therefore
the socket would be closed when the process is stopped. But people using this
as example code may not stop the process on this error. The unclosed and unused
sockets would accumulate and the process would hit the limit for open file
descriptors.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
gpsd/alfred-gpsd.c | 2 ++
unix_sock.c | 2 ++
vis/vis.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/gpsd/alfred-gpsd.c b/gpsd/alfred-gpsd.c
index d736ad1..4bc18ae 100644
--- a/gpsd/alfred-gpsd.c
+++ b/gpsd/alfred-gpsd.c
@@ -40,6 +40,8 @@ static int alfred_open_sock(struct globals *globals)
if (connect(globals->unix_sock, (struct sockaddr *)&addr,
sizeof(addr)) < 0) {
+ close(globals->unix_sock);
+ globals->unix_sock = -1;
perror("can't connect to unix socket");
return -1;
}
diff --git a/unix_sock.c b/unix_sock.c
index 8a99327..693b55d 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -84,6 +84,8 @@ int unix_sock_open_client(struct globals *globals)
if (connect(globals->unix_sock, (struct sockaddr *)&addr,
sizeof(addr)) < 0) {
+ close(globals->unix_sock);
+ globals->unix_sock = -1;
perror("can't connect to unix socket");
return -1;
}
diff --git a/vis/vis.c b/vis/vis.c
index 3dd5c8c..1916ea3 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -173,6 +173,8 @@ static int alfred_open_sock(struct globals *globals)
if (connect(globals->unix_sock, (struct sockaddr *)&addr,
sizeof(addr)) < 0) {
+ close(globals->unix_sock);
+ globals->unix_sock = -1;
perror("can't connect to unix socket");
return -1;
}
--
2.1.4