batctl: fix wrong header lines number for local translation table
PATCH 1/3 batctl: fix wrong header lines number for local translation table
A commit in batman-adv has added a second header line to the local translation table output.
Introduced by 59cb0861498776c62bd17584c31f34477fa301a0 ("batman-adv: improve local translation table output")
--- debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
debug.c +1 -1
@@ -45,7 +45,7 @@ const struct debug_table_data batctl_debug_tables[BATCTL_TABLE_NUM] = { .opt_long = "translocal", .opt_short = "tl", .debugfs_name = "transtable_local", - .header_lines = 1, + .header_lines = 2, }, { .opt_long = "transglobal",
Signature · 1 line
1.7.10.4
PATCH 2/3 batctl: add switch for setting multicast_mode
This patch adds a switch for the new multicast_mode setting in batman-adv.
--- README | 7 +++++++ man/batctl.8 | 4 ++++ sys.c | 6 ++++++ sys.h | 1 + 4 files changed, 18 insertions(+)
README +7 -0
@@ -392,6 +392,13 @@ Usage: batctl network_coding|nc [0|1] Note that network coding requires a working promiscuous mode on all interfaces. +batctl multicast_mode +===================== + +display or modify the multicast mode setting + +Usage: batctl multicast_mode|mm [0|1] + batctl aggregation ==================
man/batctl.8 +4 -0
@@ -88,6 +88,10 @@ disable fragmentation. If no parameter is given the current network coding mode setting is displayed. Otherwise the parameter is used to enable or disable network coding. .br +.IP "\fBmulticast_mode\fP|\fBmm\fP [\fB0\fP|\fB1\fP]" +If no parameter is given the current multicast mode setting is displayed. Otherwise the parameter is used to enable or +disable multicast optimizations (i.e. disabling means always sending own multicast frames via classic flooding). +.br .IP "\fBloglevel\fP|\fBll\fP [\fBlevel\fP[ \fBlevel\fP[ \fBlevel\fP]] \fB...\fP]" If no parameter is given the current log level settings are displayed otherwise the parameter(s) is/are used to set the log level. Level 'none' disables all verbose logging. Level 'batman' enables messages related to routing / flooding / broadcasting.
sys.c +6 -0
@@ -96,6 +96,12 @@ const struct settings_data batctl_settings[BATCTL_SETTINGS_NUM] = { .opt_short = "nc", .sysfs_name = "network_coding", .params = sysfs_param_enable, + }, + { + .opt_long = "multicast_mode", + .opt_short = "mm", + .sysfs_name = "multicast_mode", + .params = sysfs_param_enable, } };
sys.h +1 -0
@@ -46,6 +46,7 @@ enum batctl_settings_list {BATCTL_SETTINGS_BONDING ,BATCTL_SETTINGS_FRAGMENTATION ,BATCTL_SETTINGS_NETWORK_CODING , +BATCTL_SETTINGS_MULTICAST_MODE , BATCTL_SETTINGS_NUM, };
Signature · 1 line
1.7.10.4
PATCH 3/3 batctl: add unicast/multicast address filter option for TT output
In reply to Linus LüssingThis patch adds the new "-u" and "-m" options for the local and global translation table output to only display announced unicast or multicast mac addresses to enhance readability.
--- debug.c | 27 ++++++++++++++++++++++++++- functions.c | 16 ++++++++++++++++ functions.h | 2 ++ man/batctl.8 | 2 ++ 4 files changed, 46 insertions(+), 1 deletion(-)
debug.c +26 -1
@@ -91,6 +91,11 @@ static void debug_table_usage(int debug_table)if (debug_table ==BATCTL_TABLE_ORIGINATORS )fprintf (stderr," \t -t timeout interval - don't print originators not seen for x.y seconds \n" ); +if (debug_table ==BATCTL_TABLE_TRANSLOCAL || + debug_table ==BATCTL_TABLE_TRANSGLOBAL ) { +fprintf (stderr," \t -u print unicast mac addresses only\n" ); +fprintf (stderr," \t -m print multicast mac addresses only\n" ); + } }int handle_debug_table (char *mesh_iface,int debug_table,int argc,char **argv)
@@ -102,7 +107,7 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)float watch_interval =1 ; opterr =0 ; -while ((optchar =getopt (argc, argv,"hnw:t:H" )) !=-1 ) { +while ((optchar =getopt (argc, argv,"hnw:t:Hum" )) !=-1 ) {switch (optchar) {case 'h' :debug_table_usage (debug_table);
@@ -138,6 +143,26 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)case 'H' : read_opt |=SKIP_HEADER ;break ; +case 'u' : +if (debug_table !=BATCTL_TABLE_TRANSLOCAL && + debug_table !=BATCTL_TABLE_TRANSGLOBAL ) { +fprintf (stderr,"Error - unrecognised option '-%c'\n" , optchar); +debug_table_usage (debug_table); +return EXIT_FAILURE ; + } + + read_opt |=UNICAST_ONLY ; +break ; +case 'm' : +if (debug_table !=BATCTL_TABLE_TRANSLOCAL && + debug_table !=BATCTL_TABLE_TRANSGLOBAL ) { +fprintf (stderr,"Error - unrecognised option '-%c'\n" , optchar); +debug_table_usage (debug_table); +return EXIT_FAILURE ; + } + + read_opt |=MULTICAST_ONLY ; +break ;case '?' :if (optopt =='t' )fprintf (stderr,"Error - option '-t' needs a number as argument\n" );
functions.c +16 -0
@@ -224,6 +224,22 @@ read: && (last_seen > orig_timeout))continue ; +/* translation table: skip multicast */ +if (line > header_lines && + read_opt &UNICAST_ONLY && +strlen (line_ptr) >strlen (" * xx:xx:xx:" ) && + (!strncmp (line_ptr+3 ,"33:33:" ,strlen ("33:33:" )) || + !strncmp (line_ptr+3 ,"01:00:5e:" ,strlen ("01:00:5e:" )))) +continue ; + +/* translation table: skip unicast */ +if (line > header_lines && + read_opt &MULTICAST_ONLY && +strlen (line_ptr) >strlen (" * xx:xx:xx:" ) && +strncmp (line_ptr+3 ,"33:33:" ,strlen ("33:33:" )) && +strncmp (line_ptr+3 ,"01:00:5e:" ,strlen ("01:00:5e:" ))) +continue ; +if (!(read_opt &USE_BAT_HOSTS )) {printf ("%s" , line_ptr);continue ;
functions.h +2 -0
@@ -57,6 +57,8 @@ enum {NO_OLD_ORIGS =0x40 ,COMPAT_FILTER =0x80 ,SKIP_HEADER =0x100 , +UNICAST_ONLY =0x200 , + MULTICAST_ONLY = 0x400, };#endif
man/batctl.8 +2 -0
@@ -178,6 +178,8 @@ All of the debug tables support the following options: The originator table also supports the "\-t" filter option to remove all originators from the output that have not been seen for the specified amount of seconds (with optional decimal places). +The local and global translation tables also support the "\-u" and "\-m" option to only display unicast or multicast translation table announcements respectively. + List of debug tables: .RS 10 \- originators|o
Signature · 1 line
1.7.10.4
Quoted 7 lines · Linus Lüssing
A commit in batman-adv has added a second header line to the local translation table output.
Introduced by
59cb0861498776c62bd17584c31f34477fa301a0("batman-adv: improve local translation table output")Signed-off-by Linus Lüssing <[email protected]>
Nice catch! I think we should use the "-H" option a bit more often :)
Signature · 1 line
Antonio Quartulli
Re: [B.A.T.M.A.N.] [PATCH 3/3] batctl: add unicast/multicast address filter option for TT output
In reply to Linus LüssingQuoted 14 lines · Linus Lüssing
debug.c +10
-0@@ -138,6 +143,26 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv)case 'H' : read_opt |=SKIP_HEADER ;break ; +case 'u' : +if (debug_table !=BATCTL_TABLE_TRANSLOCAL && + debug_table !=BATCTL_TABLE_TRANSGLOBAL ) { +fprintf (stderr,"Error - unrecognised option '-%c'\n" , optchar); +debug_table_usage (debug_table); +return EXIT_FAILURE ; + } + + read_opt |=UNICAST_ONLY ; +break ;
debug.c int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv) · line 165
Quoted 10 lines
debug.c +10
-0+case 'm' : +if (debug_table !=BATCTL_TABLE_TRANSLOCAL && + debug_table !=BATCTL_TABLE_TRANSGLOBAL ) { +fprintf (stderr,"Error - unrecognised option '-%c'\n" , optchar); +debug_table_usage (debug_table); +return EXIT_FAILURE ; + } + + read_opt |=MULTICAST_ONLY ; +break ;
do we really want to allow the user to specify both flags? Or should we throw an error in that case? I think the second option would be better, no?
Quoted 17 lines
debug.c +0
-0case '?' :if (optopt =='t' )fprintf (stderr,"Error - option '-t' needs a number as argument\n" );functions.c +6
-0@@ -224,6 +224,22 @@ read: && (last_seen > orig_timeout))continue ; +/* translation table: skip multicast */ +if (line > header_lines && + read_opt &UNICAST_ONLY && +strlen (line_ptr) >strlen (" * xx:xx:xx:" ) && + (!strncmp (line_ptr+3 ,"33:33:" ,strlen ("33:33:" )) || + !strncmp (line_ptr+3 ,"01:00:5e:" ,strlen ("01:00:5e:" ))))
functions.c read: · line 242
Quoted 10 lines
functions.c +10
-0+continue ; + +/* translation table: skip unicast */ +if (line > header_lines && + read_opt &MULTICAST_ONLY && +strlen (line_ptr) >strlen (" * xx:xx:xx:" ) && +strncmp (line_ptr+3 ,"33:33:" ,strlen ("33:33:" )) && +strncmp (line_ptr+3 ,"01:00:5e:" ,strlen ("01:00:5e:" ))) +continue ; +
why not just converting to an integer the first octect of the MAC address and checking for the multicast bit being set or not? Wouldn't that be more elegant and generic?
Cheers,
Signature · 1 line
Antonio Quartulli