Project

General

Profile

Feature #310 » RFC-batctl-tp_meter-Translate-client-mac-and-IPs-to-orig.patch

Sven Eckelmann, 02/28/2018 10:16 AM

View differences:

man/batctl.8
333 333
given batctl will not replace the MAC addresses with bat\-host names in the output.
334 334
.RE
335 335
.br
336
.IP "\fBthroughputmeter\fP|\fBtp\fP \fBMAC\fP"
336
.IP "\fBthroughputmeter\fP|\fBtp\fP[\fB\-T\fP] \fBMAC_address\fP|\fBbat\-host_name\fP|\fBhost_name\fP|\fBIP_address\fP"
337 337
This command starts a throughput test entirely controlled by batman module in
338 338
kernel space: the computational resources needed to align memory and copy data
339 339
between user and kernel space that are required by other user space tools may
......
348 348
togheter with the experiment duration in millisecond and the amount of bytes
349 349
transferred. If too many packets are lost or the specified MAC address is not
350 350
reachable, a message notifing the error is returned instead of the result.
351

  
352
With "\-T" you can disable the automatic translation of a client MAC address to
353
the originator address which is responsible for this client.
351 354
.RE
352 355
.br
353 356
.SH FILES
tp_meter.c
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
- 
(2-2/2)