Signed-off-by: Marek Lindner lindner_marek@yahoo.de --- main.c | 15 ++++++++++++++- man/batctl.8 | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c index a1e6f4d..7f6d1a3 100644 --- a/main.c +++ b/main.c @@ -36,9 +36,11 @@ #include "tcpdump.h" #include "bisect.h" #include "vis.h" +#include "functions.h" #include <err.h>
char mesh_dfl_iface[] = "bat0"; +char module_ver_path[] = "/sys/module/batman_adv/version";
void print_usage(void) { printf("Usage: batctl [options] commands \n"); @@ -96,7 +98,18 @@ int main(int argc, char **argv) goto err;
if (strcmp(argv[1], "-v") == 0) { - printf("batctl %s\n", SOURCE_VERSION); + printf("batctl %s [batman-adv: ", SOURCE_VERSION); + + ret = read_file("", module_ver_path, USE_READ_BUFF | SILENCE_ERRORS, 0, 0); + if ((line_ptr) && (line_ptr[strlen(line_ptr) - 1] == '\n')) + line_ptr[strlen(line_ptr) - 1] = '\0'; + + if (ret == EXIT_SUCCESS) + printf("%s]\n", line_ptr); + else + printf("module not loaded]\n"); + + free(line_ptr); exit(EXIT_SUCCESS); }
diff --git a/man/batctl.8 b/man/batctl.8 index b0c6fc6..928c7e3 100644 --- a/man/batctl.8 +++ b/man/batctl.8 @@ -51,7 +51,7 @@ protocol. .br -h print general batctl help .br --v print batctl version +-v print batctl version and batman-adv version (if the module is loaded) .br .TP .I \fBcommands:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de --- functions.h | 2 +- sys.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/functions.h b/functions.h index 90fc831..7e9f68c 100644 --- a/functions.h +++ b/functions.h @@ -40,7 +40,7 @@ int write_file(char *dir, char *fname, char *arg1, char *arg2); extern char *line_ptr;
enum { - SINGLE_READ = 0x00, + NO_FLAGS = 0x00, CONT_READ = 0x01, CLR_CONT_READ = 0x02, USE_BAT_HOSTS = 0x04, diff --git a/sys.c b/sys.c index 4f2b2c5..14fc577 100644 --- a/sys.c +++ b/sys.c @@ -79,7 +79,7 @@ static int print_interfaces(char *mesh_iface)
while ((iface_dir = readdir(iface_base_dir)) != NULL) { snprintf(path_buff, PATH_BUFF_LEN, SYS_MESH_IFACE_FMT, iface_dir->d_name); - res = read_file("", path_buff, SINGLE_READ | USE_READ_BUFF | SILENCE_ERRORS, 0, 0); + res = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS, 0, 0); if (res != EXIT_SUCCESS) continue;
@@ -96,7 +96,7 @@ static int print_interfaces(char *mesh_iface) line_ptr = NULL;
snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, iface_dir->d_name); - res = read_file("", path_buff, SINGLE_READ | USE_READ_BUFF | SILENCE_ERRORS, 0, 0); + res = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS, 0, 0); if (res != EXIT_SUCCESS) { printf("<error reading status>\n"); continue; @@ -204,7 +204,7 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv) goto out; }
- res = read_file(path_buff, SYS_LOG_LEVEL, SINGLE_READ | USE_READ_BUFF, 0, 0); + res = read_file(path_buff, SYS_LOG_LEVEL, USE_READ_BUFF, 0, 0);
if (res != EXIT_SUCCESS) goto out; @@ -300,7 +300,7 @@ int handle_sys_setting(char *mesh_iface, int argc, char **argv, snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
if (argc == 1) { - res = read_file(path_buff, file_path, SINGLE_READ, 0, 0); + res = read_file(path_buff, file_path, NO_FLAGS, 0, 0); goto out; }
@@ -355,7 +355,7 @@ int handle_gw_setting(char *mesh_iface, int argc, char **argv) snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
if (argc == 1) { - res = read_file(path_buff, SYS_GW_MODE, SINGLE_READ | USE_READ_BUFF, 0, 0); + res = read_file(path_buff, SYS_GW_MODE, USE_READ_BUFF, 0, 0);
if (res != EXIT_SUCCESS) goto out; @@ -375,10 +375,10 @@ int handle_gw_setting(char *mesh_iface, int argc, char **argv)
switch (gw_mode) { case GW_MODE_CLIENT: - res = read_file(path_buff, SYS_GW_SEL, SINGLE_READ | USE_READ_BUFF, 0, 0); + res = read_file(path_buff, SYS_GW_SEL, USE_READ_BUFF, 0, 0); break; case GW_MODE_SERVER: - res = read_file(path_buff, SYS_GW_BW, SINGLE_READ | USE_READ_BUFF, 0, 0); + res = read_file(path_buff, SYS_GW_BW, USE_READ_BUFF, 0, 0); break; default: printf("off\n");
On Sunday, November 06, 2011 20:10:00 Marek Lindner wrote:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
functions.h | 2 +- sys.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
Applied in revision d0b1a5a.
Regards, Marek
On Sunday, November 06, 2011 20:09:59 Marek Lindner wrote:
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
main.c | 15 ++++++++++++++- man/batctl.8 | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-)
Applied in revision dbc4a8c.
Regards, Marek
b.a.t.m.a.n@lists.open-mesh.org