Repository : ssh://git@open-mesh.org/batctl
On branch : master
commit 6a0489b48854c18f983bcf13e9199c0d07988cba Author: Linus Lüssing linus.luessing@web.de Date: Tue Mar 11 21:04:32 2014 +0100
batctl: add switch for setting multicast_mode
This patch adds a switch for the new multicast_mode setting in batman-adv.
Signed-off-by: Linus Lüssing linus.luessing@web.de Signed-off-by: Marek Lindner mareklindner@neomailbox.ch
6a0489b48854c18f983bcf13e9199c0d07988cba README | 7 +++++++ debug.c | 33 ++++++++++++++++++++++++++++++++- functions.c | 22 ++++++++++++++++++++++ functions.h | 2 ++ man/batctl.8 | 6 ++++++ sys.c | 6 ++++++ sys.h | 1 + 7 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/README b/README index facc82e..b5fd259 100644 --- a/README +++ b/README @@ -417,6 +417,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 ==================
diff --git a/debug.c b/debug.c index 04b2c6d..e7f463d 100644 --- a/debug.c +++ b/debug.c @@ -94,6 +94,11 @@ static void debug_table_usage(int debug_table) fprintf(stderr, " \t -t timeout interval - don't print originators not seen for x.y seconds \n"); fprintf(stderr, " \t -i [interface] - show multiif originator table for a specific interface\n"); } + + if (debug_table == BATCTL_TABLE_TRANSLOCAL || + debug_table == BATCTL_TABLE_TRANSGLOBAL) { + fprintf(stderr, " \t -u|-m print unicast or multicast mac addresses only\n"); + } }
int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv) @@ -106,7 +111,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:Hi:")) != -1) { + while ((optchar = getopt(argc, argv, "hnw:t:Humi:")) != -1) { switch (optchar) { case 'h': debug_table_usage(debug_table); @@ -142,6 +147,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 'i': if (debug_table != BATCTL_TABLE_ORIGINATORS) { fprintf(stderr, "Error - unrecognised option '-%c'\n", optchar); @@ -173,6 +198,12 @@ int handle_debug_table(char *mesh_iface, int debug_table, int argc, char **argv) } }
+ if (read_opt & UNICAST_ONLY && read_opt & MULTICAST_ONLY) { + fprintf(stderr, "Error - '-u' and '-m' are exclusive options\n"); + debug_table_usage(debug_table); + return EXIT_FAILURE; + } + debugfs_mnt = debugfs_mount(NULL); if (!debugfs_mnt) { fprintf(stderr, "Error - can't mount or find debugfs\n"); diff --git a/functions.c b/functions.c index 36804bd..117dcff 100644 --- a/functions.c +++ b/functions.c @@ -175,6 +175,14 @@ static void file_open_problem_dbg(const char *dir, const char *fname, } }
+static int str_is_mcast_addr(char *addr) +{ + struct ether_addr *mac_addr = ether_aton(addr); + + return !mac_addr ? 0 : + mac_addr->ether_addr_octet[0] & 0x01; +} + int read_file(const char *dir, const char *fname, int read_opt, float orig_timeout, float watch_interval, size_t header_lines) { @@ -224,6 +232,20 @@ 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:") && + str_is_mcast_addr(line_ptr+3)) + continue; + + /* translation table: skip unicast */ + if (line > header_lines && + read_opt & MULTICAST_ONLY && + strlen(line_ptr) > strlen(" * xx:xx:xx:") && + !str_is_mcast_addr(line_ptr+3)) + continue; + if (!(read_opt & USE_BAT_HOSTS)) { printf("%s", line_ptr); continue; diff --git a/functions.h b/functions.h index 14ba525..43c3d9c 100644 --- a/functions.h +++ b/functions.h @@ -57,6 +57,8 @@ enum { NO_OLD_ORIGS = 0x40, COMPAT_FILTER = 0x80, SKIP_HEADER = 0x100, + UNICAST_ONLY = 0x200, + MULTICAST_ONLY = 0x400, };
#endif diff --git a/man/batctl.8 b/man/batctl.8 index 8ef1123..110020e 100644 --- a/man/batctl.8 +++ b/man/batctl.8 @@ -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. @@ -196,6 +200,8 @@ for the specified amount of seconds (with optional decimal places). It furthermo interface for which the originator table should be printed. If this parameter is not supplied, the default originator table is printed.
+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 diff --git a/sys.c b/sys.c index 14c3cf5..676bef1 100644 --- a/sys.c +++ b/sys.c @@ -103,6 +103,12 @@ const struct settings_data batctl_settings[BATCTL_SETTINGS_NUM] = { .sysfs_name = "isolation_mark", .params = NULL, }, + { + .opt_long = "multicast_mode", + .opt_short = "mm", + .sysfs_name = "multicast_mode", + .params = sysfs_param_enable, + }, };
static void interface_usage(void) diff --git a/sys.h b/sys.h index 8296bd4..3859253 100644 --- a/sys.h +++ b/sys.h @@ -47,6 +47,7 @@ enum batctl_settings_list { BATCTL_SETTINGS_FRAGMENTATION, BATCTL_SETTINGS_NETWORK_CODING, BATCTL_SETTINGS_ISOLATION_MARK, + BATCTL_SETTINGS_MULTICAST_MODE, BATCTL_SETTINGS_NUM, };