383 |
383 |
|
384 |
384 |
static void tp_meter_usage(void)
|
385 |
385 |
{
|
386 |
|
fprintf(stderr, "Usage: batctl tp [parameters] <MAC>\n");
|
|
386 |
fprintf(stderr, "Usage: batctl tp [parameters] mac|bat-host|host_name|IPv4_address\n");
|
387 |
387 |
fprintf(stderr, "Parameters:\n");
|
388 |
388 |
fprintf(stderr, "\t -t <time> test length in milliseconds\n");
|
389 |
389 |
fprintf(stderr, "\t -n don't convert addresses to bat-host names\n");
|
|
390 |
fprintf(stderr, " \t -T don't try to translate mac to originator address\n");
|
390 |
391 |
}
|
391 |
392 |
|
392 |
393 |
int tp_meter(char *mesh_iface, int argc, char **argv)
|
... | ... | |
396 |
397 |
char *dst_string;
|
397 |
398 |
int ret = EXIT_FAILURE;
|
398 |
399 |
int found_args = 1, read_opt = USE_BAT_HOSTS;
|
|
400 |
int disable_translate_mac = 0;
|
399 |
401 |
uint32_t time = 0;
|
400 |
402 |
int optchar;
|
401 |
403 |
struct nl_sock *listen_sock = NULL;
|
... | ... | |
412 |
414 |
.found = false,
|
413 |
415 |
};
|
414 |
416 |
|
415 |
|
while ((optchar = getopt(argc, argv, "t:n")) != -1) {
|
|
417 |
while ((optchar = getopt(argc, argv, "t:nT")) != -1) {
|
416 |
418 |
switch (optchar) {
|
417 |
419 |
case 't':
|
418 |
420 |
found_args += 2;
|
... | ... | |
422 |
424 |
read_opt &= ~USE_BAT_HOSTS;
|
423 |
425 |
found_args += 1;
|
424 |
426 |
break;
|
|
427 |
case 'T':
|
|
428 |
disable_translate_mac = 1;
|
|
429 |
found_args += 1;
|
|
430 |
break;
|
425 |
431 |
default:
|
426 |
432 |
tp_meter_usage();
|
427 |
433 |
return EXIT_FAILURE;
|
... | ... | |
443 |
449 |
dst_mac = &bat_host->mac_addr;
|
444 |
450 |
|
445 |
451 |
if (!dst_mac) {
|
446 |
|
dst_mac = ether_aton(dst_string);
|
|
452 |
dst_mac = resolve_mac(dst_string);
|
447 |
453 |
|
448 |
454 |
if (!dst_mac) {
|
449 |
|
printf("Error - the tp meter destination is not a mac address or bat-host name: %s\n",
|
|
455 |
printf("Error - mac address of the tp meter destination could not be resolved and is not a bat-host name %s\n",
|
450 |
456 |
dst_string);
|
451 |
457 |
goto out;
|
452 |
458 |
}
|
453 |
459 |
}
|
454 |
460 |
|
455 |
461 |
|
|
462 |
if (!disable_translate_mac)
|
|
463 |
dst_mac = translate_mac(mesh_iface, dst_mac);
|
|
464 |
|
456 |
465 |
if (bat_host && (read_opt & USE_BAT_HOSTS))
|
457 |
466 |
dst_string = bat_host->name;
|
458 |
467 |
else
|
459 |
|
-
|