Author: marek Date: 2009-12-29 13:02:18 +0000 (Tue, 29 Dec 2009) New Revision: 1514
Modified: trunk/batctl/README trunk/batctl/main.c trunk/batctl/proc.c trunk/batctl/proc.h trunk/batctl/vis.c trunk/batctl/vis.h Log: batctl: adjust vis server/data file path
The kernel module changed the vis data file path which need to be changed in batctl as well. This patch depends on the "splitting /proc vis file into vis_server and vis_data" patch. Also, the vis_server has been added which needs to be supported as well.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
Modified: trunk/batctl/README =================================================================== --- trunk/batctl/README 2009-12-29 13:02:17 UTC (rev 1513) +++ trunk/batctl/README 2009-12-29 13:02:18 UTC (rev 1514) @@ -11,15 +11,15 @@ hosts participating in the virtual switch are completely transparent for all protocols above layer 2. Therefore the common diagnosis tools do not work as expected. To overcome these problems batctl was created. At the moment batctl -contains ping, traceroute, tcpdump and interfaces to the kernel module +contains ping, traceroute, tcpdump and interfaces to the kernel module settings.
How does it work ? ==================
-batctl uses the /dev/batman-adv device provided by the B.A.T.M.A.N. advanced -kernel module to inject custom icmp packets into the data flow. That's why +batctl uses the /dev/batman-adv device provided by the B.A.T.M.A.N. advanced +kernel module to inject custom icmp packets into the data flow. That's why ping and traceroute work almost like their IP based counterparts. Tcpdump was designed because B.A.T.M.A.N. advanced encapsulates all traffic within batman packets, so that the normal tcpdump would not recognize the packets. @@ -30,7 +30,7 @@
This file is simliar to the /etc/hosts file. You can write one MAC address and one host name per line. batctl will analyze the file to find the matching MAC -address to your provided host name. Host names are much easier to remember +address to your provided host name. Host names are much easier to remember than MAC addresses. ;)
@@ -39,9 +39,9 @@
Sends a Layer 2 batman-adv ping to check round trip time and connectivity
-Usage: batctl ping [options] mac|bat-host +Usage: batctl ping [options] mac|bat-host options: - -c ping packet count + -c ping packet count -h print this help -i interval in seconds -t timeout in seconds @@ -60,10 +60,10 @@ batctl traceroute ==================
-Traceroute sends 3 packets to each hop, awaits the answers and prints out the +Traceroute sends 3 packets to each hop, awaits the answers and prints out the response times.
-Usage: batctl traceroute [options] mac|bat-host +Usage: batctl traceroute [options] mac|bat-host
Example:
@@ -121,15 +121,15 @@ =============
Analyzes the logfiles to build a small internal database of all sent sequence -numbers and routing table changes. This database can be used to search for -routing loops (default action), to trace OGMs of a host (use "-t" to -specify the mac address or bat-host name) throughout the network or to -display routing tables of the nodes (use "-r" to specify the mac address or +numbers and routing table changes. This database can be used to search for +routing loops (default action), to trace OGMs of a host (use "-t" to +specify the mac address or bat-host name) throughout the network or to +display routing tables of the nodes (use "-r" to specify the mac address or bat-host name). You can name a specific sequence number or a range using the -"-s" option to limit the output's range. Furthermore you can filter the -output by specifying an originator (use "-o" to specify the mac address or +"-s" option to limit the output's range. Furthermore you can filter the +output by specifying an originator (use "-o" to specify the mac address or bat-host name) to only see data connected to this originator. If "-n" was -given batctl will not replace the mac addresses with bat-host names in the +given batctl will not replace the mac addresses with bat-host names in the output.
Usage: batctl bisect [options] <file1> <file2> .. <fileN> @@ -226,7 +226,7 @@ Example:
$ batctl originators - Originator (#/255) Nexthop [outgoingIF]: Potential nexthops ... [B.A.T.M.A.N. adv 0.2-beta r1457, MainIF/MAC: eth0/fe:fe:00:00:01:01] + Originator (#/255) Nexthop [outgoingIF]: Potential nexthops ... [B.A.T.M.A.N. adv 0.2-beta r1457, MainIF/MAC: eth0/fe:fe:00:00:01:01] fe:fe:00:00:05:01 (223) fe:fe:00:00:02:01 [ eth0]: fe:fe:00:00:03:01 ( 96) fe:fe:00:00:02:01 (223) fe:fe:00:00:04:01 (233) fe:fe:00:00:02:01 [ eth0]: fe:fe:00:00:03:01 (100) fe:fe:00:00:02:01 (233) fe:fe:00:00:02:01 (254) fe:fe:00:00:02:01 [ eth0]: fe:fe:00:00:02:01 (254) fe:fe:00:00:03:01 (100) @@ -241,12 +241,12 @@
display or modify the interface settings
-Usage: batctl interface|if [none|interface] +Usage: batctl interface|if [none|interface]
Example:
$ batctl interface -[ active] eth0 fe:fe:00:00:01:01 +[ active] eth0 fe:fe:00:00:01:01
batctl interval =============== @@ -270,13 +270,13 @@ Example:
$ batctl log -r) -[ 400] Received BATMAN packet via NB: fe:fe:00:00:02:01 IF: eth0 [fe:fe:00:00:01:01] (from OG: fe:fe:00:00:01:01 via prev OG: fe:fe:00:00:01:01 seqno 670, tq 245, TTL 49, V 8, IDF 1) -[ 400] Drop packet: originator packet from myself (via neighbour) -[ 400] Received BATMAN packet via NB: fe:fe:00:00:02:01 IF: eth0 [fe:fe:00:00:01:01] (from OG: fe:fe:00:00:02:01 via prev OG: fe:fe:00:00:02:01 seqno 545, tq 255, TTL 50, V 8, IDF 0) -[ 400] updating last_seqno: old 544, new 545 -[ 400] bidirectional: orig = fe:fe:00:00:02:01 neigh = fe:fe:00:00:02:01 => own_bcast = 64, real recv = 64, local tq: 255, asym_penalty: 255, total tq: 255 -[ 400] update_originator(): Searching and updating originator entry of received packet +r) +[ 400] Received BATMAN packet via NB: fe:fe:00:00:02:01 IF: eth0 [fe:fe:00:00:01:01] (from OG: fe:fe:00:00:01:01 via prev OG: fe:fe:00:00:01:01 seqno 670, tq 245, TTL 49, V 8, IDF 1) +[ 400] Drop packet: originator packet from myself (via neighbour) +[ 400] Received BATMAN packet via NB: fe:fe:00:00:02:01 IF: eth0 [fe:fe:00:00:01:01] (from OG: fe:fe:00:00:02:01 via prev OG: fe:fe:00:00:02:01 seqno 545, tq 255, TTL 50, V 8, IDF 0) +[ 400] updating last_seqno: old 544, new 545 +[ 400] bidirectional: orig = fe:fe:00:00:02:01 neigh = fe:fe:00:00:02:01 => own_bcast = 64, real recv = 64, local tq: 255, asym_penalty: 255, total tq: 255 +[ 400] update_originator(): Searching and updating originator entry of received packet [ 400] Updating existing last-hop neighbour of originator [...]
@@ -285,10 +285,10 @@
display or modify the log level
-Usage: batctl |ll [level] +Usage: batctl |ll [level]
Example: -$ batctl loglevel +$ batctl loglevel [x] critical (0) [x] warnings (1) [x] notices (2) @@ -307,9 +307,9 @@
display the local translation table
-Usage: batctl translocal|tl +Usage: batctl translocal|tl
-Example: +Example:
$ batctl translocal Locally retrieved addresses (from bat0) announced via HNA: @@ -320,32 +320,32 @@
display the global translation table
-Usage: batctl transglobal|tg +Usage: batctl transglobal|tg
Example:
Globally announced HNAs received via the mesh (translation table): - * 16:aa:c4:a2:00:00 via fe:fe:00:00:09:01 - * 5a:32:f9:df:00:00 via fe:fe:00:00:03:01 - * 32:ae:5a:00:00:00 via fe:fe:00:00:04:01 - * 86:88:80:29:00:00 via fe:fe:00:00:08:01 - * 9e:d8:72:f2:00:00 via fe:fe:00:00:02:01 - * 76:84:68:49:00:00 via fe:fe:00:00:05:01 - * 86:4b:b2:d2:00:00 via fe:fe:00:00:07:01 - * ca:a1:5b:e5:00:00 via fe:fe:00:00:06:01 + * 16:aa:c4:a2:00:00 via fe:fe:00:00:09:01 + * 5a:32:f9:df:00:00 via fe:fe:00:00:03:01 + * 32:ae:5a:00:00:00 via fe:fe:00:00:04:01 + * 86:88:80:29:00:00 via fe:fe:00:00:08:01 + * 9e:d8:72:f2:00:00 via fe:fe:00:00:02:01 + * 76:84:68:49:00:00 via fe:fe:00:00:05:01 + * 86:4b:b2:d2:00:00 via fe:fe:00:00:07:01 + * ca:a1:5b:e5:00:00 via fe:fe:00:00:06:01
-batctl visformat +batctl vis_server ================
-display or modify the vis output format +display or modify the status of the VIS server
-Usage: batctl visformat|vf [format] +Usage: batctl vis_server|vs [enable|disable]
-Example: +Example:
-$ batctl visformat -[x] dot_draw -[ ] json +$ batctl vis_server +[x] client mode (server disabled) +[ ] server mode (server enabled)
Modified: trunk/batctl/main.c =================================================================== --- trunk/batctl/main.c 2009-12-29 13:02:17 UTC (rev 1513) +++ trunk/batctl/main.c 2009-12-29 13:02:18 UTC (rev 1514) @@ -48,7 +48,8 @@ printf(" \tlog|l \tread the log produced by the kernel module\n"); printf(" \ttranslocal|tl \tdisplay the local translation table\n"); printf(" \ttransglobal|tg \tdisplay the global translation table\n"); - printf(" \tvis [dot|JSON] \tdisplay the VIS data in dot or JSON format\n"); + printf(" \tvis_server|vs [enable|disable] \tdisplay or modify the status of the VIS server\n"); + printf(" \tvis_data|vd [dot|JSON] \tdisplay the VIS data in dot or JSON format\n"); printf(" \taggregation|ag [0|1] \tdisplay or modify the packet aggregation setting\n"); printf("\n"); printf(" \tping|p <destination> \tping another batman adv host via layer 2\n"); @@ -121,10 +122,14 @@
ret = handle_proc_setting(argc - 1, argv + 1, PROC_ORIG_INTERVAL, orig_interval_usage);
- } else if (strcmp(argv[1], "vis") == 0) { + } else if ((strcmp(argv[1], "vis_server") == 0) || (strcmp(argv[1], "vs") == 0)) {
- ret = vis(argc - 1, argv + 1); + ret = handle_proc_setting(argc - 1, argv + 1, PROC_VIS_SERVER, vis_server_usage);
+ } else if ((strcmp(argv[1], "vis_data") == 0) || (strcmp(argv[1], "vd") == 0)) { + + ret = vis_data(argc - 1, argv + 1); + } else if ((strcmp(argv[1], "aggregation") == 0) || (strcmp(argv[1], "ag") == 0)) {
ret = handle_proc_setting(argc - 1, argv + 1, PROC_AGGR, aggregation_usage);
Modified: trunk/batctl/proc.c =================================================================== --- trunk/batctl/proc.c 2009-12-29 13:02:17 UTC (rev 1513) +++ trunk/batctl/proc.c 2009-12-29 13:02:18 UTC (rev 1514) @@ -102,9 +102,9 @@ printf(" \t -h print this help\n"); }
-void vis_format_usage(void) +void vis_server_usage(void) { - printf("Usage: batctl [options] visformat \n"); + printf("Usage: batctl [options] vis_server \n"); printf("options:\n"); printf(" \t -h print this help\n"); }
Modified: trunk/batctl/proc.h =================================================================== --- trunk/batctl/proc.h 2009-12-29 13:02:17 UTC (rev 1513) +++ trunk/batctl/proc.h 2009-12-29 13:02:18 UTC (rev 1514) @@ -28,8 +28,8 @@ #define PROC_GATEWAYS "gateways" #define PROC_TRANSTABLE_LOCAL "transtable_local" #define PROC_TRANSTABLE_GLOBAL "transtable_global" -#define PROC_VIS "vis" -#define PROC_VIS_FORMAT "vis_format" +#define PROC_VIS_SERVER "vis_server" +#define PROC_VIS_DATA "vis_data" #define PROC_AGGR "aggregate_ogm"
@@ -39,7 +39,7 @@ void trans_local_usage(void); void trans_global_usage(void); void orig_interval_usage(void); -void vis_format_usage(void); +void vis_server_usage(void); void aggregation_usage(void); int handle_table(int argc, char **argv, char *file_path, void table_usage(void)); int handle_proc_setting(int argc, char **argv, char *file_path, void setting_usage(void));
Modified: trunk/batctl/vis.c =================================================================== --- trunk/batctl/vis.c 2009-12-29 13:02:17 UTC (rev 1513) +++ trunk/batctl/vis.c 2009-12-29 13:02:18 UTC (rev 1514) @@ -40,7 +40,7 @@ typedef void (*print_header_t)(void); typedef void (*print_footer_t)(void);
-struct funcs +struct funcs { print_tq_t print_tq; print_HNA_t print_HNA; @@ -54,7 +54,7 @@ static bool with_2nd = true; static bool with_names = true;
-static void +static void usage(void) { printf("batctl vis dot {--no-HNA|-h} {--no-2nd|-2} {--numbers|-n}\n"); @@ -62,25 +62,25 @@ printf("batctl vis json {--no-HNA|-h} {--no-2nd|-2} {--numbers|-n}\n"); }
-static void +static void dot_print_tq(char * orig, char * from, const long tq) { int int_part = TQ_MAX_VALUE / tq; int frac_part = (1000 * TQ_MAX_VALUE / tq) - (int_part * 1000); - + printf("\t"%s" -> ", get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0))); - printf(""%s" [label="%d.%d"]\n", + printf(""%s" [label="%d.%d"]\n", get_name_by_macstr(from, (with_names ? USE_BAT_HOSTS : 0)), int_part, frac_part); }
-static void +static void dot_print_HNA(char * orig, char * from) { printf("\t"%s" -> ", get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0))); - printf(""%s" [label="HNA"]\n", + printf(""%s" [label="HNA"]\n", get_name_by_macstr(from, (with_names ? USE_BAT_HOSTS : 0))); }
@@ -107,18 +107,18 @@ }
static void -dot_print_header(void) +dot_print_header(void) { printf("digraph {\n"); }
static void -dot_print_footer(void) +dot_print_footer(void) { printf("}\n"); }
-const struct funcs dot_funcs = +const struct funcs dot_funcs = { dot_print_tq, dot_print_HNA, dot_print_1st, @@ -127,25 +127,25 @@ dot_print_footer };
-static void +static void json_print_tq(char * orig, char * from, const long tq) { int int_part = TQ_MAX_VALUE / tq; int frac_part = (1000 * TQ_MAX_VALUE / tq) - (int_part * 1000); - + printf("\t{ router : "%s", ", get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0))); - printf("neighbor : "%s", label : "%d.%d" }\n", + printf("neighbor : "%s", label : "%d.%d" }\n", get_name_by_macstr(from, (with_names ? USE_BAT_HOSTS : 0)), int_part, frac_part); }
-static void +static void json_print_HNA(char * orig, char * from) { printf("\t{ router : "%s", ", get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0))); - printf("gateway : "%s", label : "HNA" }\n", + printf("gateway : "%s", label : "HNA" }\n", get_name_by_macstr(from, (with_names ? USE_BAT_HOSTS : 0))); }
@@ -166,7 +166,7 @@ get_name_by_macstr(orig, (with_names ? USE_BAT_HOSTS : 0))); }
-const struct funcs json_funcs = +const struct funcs json_funcs = { json_print_tq, json_print_HNA, json_print_1st, @@ -176,21 +176,21 @@ };
static FILE * -open_vis(void) +open_vis(void) { char full_path[500]; - + if (check_proc_dir("/proc") != EXIT_SUCCESS) return NULL;
strncpy(full_path, PROC_ROOT_PATH, strlen(PROC_ROOT_PATH)); full_path[strlen(PROC_ROOT_PATH)] = '\0'; - strncat(full_path, "vis", sizeof(full_path) - strlen(full_path)); + strncat(full_path, PROC_VIS_DATA, sizeof(full_path) - strlen(full_path));
return fopen(full_path, "r"); }
-static int +static int format(const struct funcs *funcs) { size_t len = 0; @@ -204,15 +204,15 @@ char * value; long tq; char * flag; - - FILE * fp = open_vis();
+ FILE * fp = open_vis(); + if (!fp) return EXIT_FAILURE; - + if (funcs->print_header) funcs->print_header(); - + while ((read = getline(&line, &len, fp)) != -1) { /* First MAC address is the originator */ orig = strtok_r(line, ",", &line_save_ptr); @@ -220,7 +220,7 @@ duplet_save_ptr = line_save_ptr; while ((duplet = strtok_r(NULL, ",", &duplet_save_ptr)) != NULL) { flag = strtok(duplet, " "); - if (!flag) + if (!flag) continue; if (!strcmp(flag, "TQ")) { from = strtok(NULL, " "); @@ -231,7 +231,7 @@ } if (!strcmp(flag, "HNA")) { /* We have an HNA record */ - if (!with_HNA) + if (!with_HNA) continue; from = strtok(NULL, " "); funcs->print_HNA(orig, from); @@ -248,17 +248,17 @@ } } } - + if (funcs->print_footer) funcs->print_footer(); - + if (line) free(line); return EXIT_SUCCESS; }
-int -vis(int argc, char *argv[]) +int +vis_data(int argc, char *argv[]) { bool dot = false; bool json = false; @@ -268,22 +268,22 @@ usage(); return EXIT_FAILURE; } - + /* Do we know the requested format? */ if (strcmp(argv[1], "dot") == 0) dot=true; if (strcmp(argv[1], "json") == 0) json=true; - + if (!dot && !json) { usage(); return EXIT_FAILURE; } - + /* Move over the output format */ argc--; argv++; - + while (1) { int option_index = 0; static struct option long_options[] = { @@ -292,11 +292,11 @@ {"numbers", 0, 0, 'n'}, {0, 0, 0, 0} }; - + c = getopt_long(argc, argv, "h2n", long_options, &option_index); if (c == -1) break; - + switch(c) { case 'h': with_HNA = false; @@ -312,13 +312,13 @@ return -1; } } - + if (with_names) bat_hosts_init(); - - if (dot) + + if (dot) return format(&dot_funcs); - + if (json) return format(&json_funcs);
Modified: trunk/batctl/vis.h =================================================================== --- trunk/batctl/vis.h 2009-12-29 13:02:17 UTC (rev 1513) +++ trunk/batctl/vis.h 2009-12-29 13:02:18 UTC (rev 1514) @@ -17,5 +17,5 @@ * */
-int vis(int argc, char * argv[]); +int vis_data(int argc, char * argv[]);