int verify_args()

in src/util.c [124:211]


int verify_args(struct lagscope_test *test)
{
	if (test->server_role && test->client_role) {
		PRINT_ERR("both sender and receiver roles provided");
		return ERROR_ARGS;
	}

	if (test->domain == AF_INET6 && !strstr(test->bind_address, ":")) {
		PRINT_ERR("invalid ipv6 address provided");
		return ERROR_ARGS;
	}

	if (test->domain == AF_INET && !strstr(test->bind_address, ".")) {
		PRINT_ERR("invalid ipv4 address provided");
		return ERROR_ARGS;
	}

	if (test->protocol == UDP) {
		PRINT_ERR("UDP is not supported so far");
		return ERROR_ARGS;
	}

	if (!test->server_role && !test->client_role) {
		PRINT_INFO("no role specified; use receiver role");
		test->server_role = true;
	}

	if (test->server_role) {
		if (test->hist) {
			PRINT_ERR("histogram report is not supported in receiver side; ignored.");
		}
	}
	if (test->server_role) {
		if (test->perc) {
			PRINT_ERR("percentile report is not supported on receiver side; ignored.");
		}
	}

	if (test->server_role) {
		if (test->raw_dump)
			PRINT_ERR("dumping latencies into a file not supported on receiver side; ignored");
	}

	if (test->client_role) {
		if (0 == strcmp(test->bind_address, "0.0.0.0")) {
			// This is needed due to behaviour if Win socket in client mode
			test->bind_address = "127.0.0.1";
		}
		if (test->client_port > 0 && test->client_port <= 1024) {
			test->client_port = DEFAULT_SRC_PORT;
			PRINT_ERR("source port is too small. use the default value");
		}
		if (test->hist_start < 0) {
			PRINT_ERR("histogram interval start value provided is invalid; use default value.");
			test->hist_start = HIST_DEFAULT_START_AT;
		}
		if (test->hist_count > HIST_MAX_INTERVAL_COUNT_USER) {
			PRINT_ERR("count of histogram intervals is too big; use the max allowed value.");
			test->hist_start = HIST_MAX_INTERVAL_COUNT_USER;
		}
		if (test->hist_count < 1) {
			PRINT_ERR("count of histogram intervals is too small; use the default value.");
			test->hist_start = HIST_DEFAULT_INTERVAL_COUNT;
		}
	}

	/* Interop with latte.exe:
	 * latte needs minimum 4 bytes of data */
	if (test->msg_size < 4) {
		PRINT_INFO("invalid message size. use default value.");
		test->msg_size = DEFAULT_MESSAGE_SIZE_BYTES;
	}

	if (test->test_mode == TIME_DURATION && test->duration < 1) {
		PRINT_INFO("invalid test duration; use default value.");
		test->duration  = DEFAULT_TEST_DURATION_SEC;
	}

	if (test->test_mode == PING_ITERATION && test->iteration < 1) {
		PRINT_INFO("invalid ping iteration; use default value.");
		test->iteration = DEFAULT_TEST_ITERATION;
	}

	if (test->domain == AF_INET6 && strcmp(test->bind_address, "0.0.0.0") == 0)
		test->bind_address = "::";

	return NO_ERR;
}