int parse_arguments()

in src/util.c [249:355]


int parse_arguments(struct lagscope_test *test, int argc, char **argv)
{
	int flag;

	while ((flag = getopt2(argc, argv, "r::s::Df:6up:o:b:z:t:n:i:R::P::Ha:l:c:Vh")) != -1) {
		switch (flag) {
		case 'r':
			test->server_role = true;
			if (optarg2)
				test->bind_address = optarg2;
			break;

		case 's':
			test->client_role = true;
			if (optarg2)
				test->bind_address = optarg2;
			break;

		case 'D':
			test->daemon = true;
			break;

		case 'f':
			test->cpu_affinity = atoi(optarg2);
			break;

		case '6':
			test->domain = AF_INET6;
			break;

		case 'u':
			test->protocol = UDP;
			break;

		case 'p':
			test->server_port = atoi(optarg2);
			break;

		case 'o':
			test->client_port = atoi(optarg2);
			break;

		case 'b':
			test->recv_buf_size = atoi(optarg2);
			test->send_buf_size = atoi(optarg2);
			break;

		case 'z':
			test->msg_size = atoi(optarg2);
			break;

		case 't':
			test->duration = atoi(optarg2);
			test->test_mode = TIME_DURATION;
			break;

		case 'n':
			test->iteration = atoi(optarg2);
			break;

		case 'i':
			test->interval = atoi(optarg2);
			break;

		case 'H':
			test->hist = true;
			break;

		case 'a':
			test->hist_start = atoi(optarg2);
			break;

		case 'l':
			test->hist_len = atoi(optarg2);
			break;

		case 'c':
			test->hist_count = atoi(optarg2);
			break;

		case 'V':
			test->verbose = true;
			break;

		case 'P':
			test->perc = true;
			if(optarg2)
			{
				test->freq_table_dump = true;
				test->json_file_name = optarg2;
			}
			break;

		case 'R':
			test->raw_dump = true;
			if(optarg2)
				test->csv_file_name = optarg2;
			break;

		case 'h':
		default:
			print_usage();
			exit(ERROR_ARGS);
		}
	}
	return NO_ERR;
}