On 24/02/14 05:11, Linus Lüssing wrote:
@@ -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;
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?
case '?': if (optopt == 't') fprintf(stderr, "Error - option '-t' needs a number as argument\n");
diff --git a/functions.c b/functions.c index 36804bd..41eabb2 100644 --- a/functions.c +++ b/functions.c @@ -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;
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,