| 355 | } |
| 356 | |
| 357 | static void |
| 358 | parse_opts(int argc, char **argv) |
| 359 | { |
| 360 | int opt, ret; |
| 361 | char *endptr; |
| 362 | |
| 363 | while ((opt = getopt(argc, argv, "f:t:n:d:l:r:6b:vpc")) != -1) { |
| 364 | switch (opt) { |
| 365 | case 'f': |
| 366 | config.rules_file = optarg; |
| 367 | break; |
| 368 | case 't': |
| 369 | config.tuples_file = optarg; |
| 370 | break; |
| 371 | case 'n': |
| 372 | errno = 0; |
| 373 | config.nb_rules = strtoul(optarg, &endptr, 10); |
| 374 | if ((errno != 0) || (config.nb_rules == 0) || |
| 375 | (endptr[0] != 0)) { |
| 376 | print_usage(); |
| 377 | rte_exit(-EINVAL, "Invalid option -n\n"); |
| 378 | } |
| 379 | break; |
| 380 | case 'd': |
| 381 | ret = parse_distrib(optarg); |
| 382 | if (ret != 0) { |
| 383 | print_usage(); |
| 384 | rte_exit(-EINVAL, "Invalid option -d\n"); |
| 385 | } |
| 386 | break; |
| 387 | case 'b': |
| 388 | errno = 0; |
| 389 | config.burst_sz = strtoul(optarg, &endptr, 10); |
| 390 | if ((errno != 0) || (config.burst_sz == 0) || |
| 391 | (config.burst_sz > BURST_SZ_MAX) || |
| 392 | (endptr[0] != 0)) { |
| 393 | print_usage(); |
| 394 | rte_exit(-EINVAL, "Invalid option -b\n"); |
| 395 | } |
| 396 | break; |
| 397 | case 'l': |
| 398 | errno = 0; |
| 399 | config.nb_tuples = strtoul(optarg, &endptr, 10); |
| 400 | if ((errno != 0) || (config.nb_tuples == 0) || |
| 401 | (endptr[0] != 0)) { |
| 402 | print_usage(); |
| 403 | rte_exit(-EINVAL, "Invalid option -l\n"); |
| 404 | } |
| 405 | break; |
| 406 | case 'r': |
| 407 | errno = 0; |
| 408 | config.fract_rnd_tuples = strtoul(optarg, &endptr, 10); |
| 409 | if ((errno != 0) || (config.fract_rnd_tuples == 0) || |
| 410 | (config.fract_rnd_tuples >= 100) || |
| 411 | (endptr[0] != 0)) { |
| 412 | print_usage(); |
| 413 | rte_exit(-EINVAL, "Invalid option -r\n"); |
| 414 | } |
no test coverage detected