| 426 | } |
| 427 | |
| 428 | static void |
| 429 | args_parse(int argc, char **argv) |
| 430 | { |
| 431 | char **argvopt; |
| 432 | int n, opt; |
| 433 | int opt_idx; |
| 434 | |
| 435 | static const struct option lgopts[] = { |
| 436 | /* Control */ |
| 437 | { "help", 0, 0, 0 }, |
| 438 | { "inbound", 0, 0, 0 }, |
| 439 | { "nb-sess", 1, 0, 0 }, |
| 440 | { NULL, 0, 0, 0 } |
| 441 | }; |
| 442 | |
| 443 | argvopt = argv; |
| 444 | |
| 445 | while ((opt = getopt_long(argc, argvopt, "", |
| 446 | lgopts, &opt_idx)) != EOF) { |
| 447 | switch (opt) { |
| 448 | case 0: |
| 449 | if (strcmp(lgopts[opt_idx].name, "help") == 0) { |
| 450 | usage(argv[0]); |
| 451 | exit(EXIT_SUCCESS); |
| 452 | } |
| 453 | |
| 454 | if (strcmp(lgopts[opt_idx].name, "nb-sess") == 0) { |
| 455 | n = atoi(optarg); |
| 456 | if (n >= 0) |
| 457 | ctx.nb_sess = n; |
| 458 | else |
| 459 | rte_exit(EXIT_FAILURE, |
| 460 | "nb-sess should be >= 0\n"); |
| 461 | printf("nb-sess %d / ", ctx.nb_sess); |
| 462 | } else if (strcmp(lgopts[opt_idx].name, "inbound") == |
| 463 | 0) { |
| 464 | ctx.is_inbound = true; |
| 465 | printf("inbound / "); |
| 466 | } |
| 467 | |
| 468 | break; |
| 469 | |
| 470 | default: |
| 471 | usage(argv[0]); |
| 472 | rte_exit(EXIT_FAILURE, "Invalid option: %s\n", |
| 473 | argv[opt_idx - 1]); |
| 474 | break; |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | printf("\n\n"); |
| 479 | } |
| 480 | |
| 481 | int |
| 482 | main(int argc, char **argv) |