Parse the argument given in the command line of the application */
| 718 | |
| 719 | /* Parse the argument given in the command line of the application */ |
| 720 | static int |
| 721 | parse_args(int argc, char **argv) |
| 722 | { |
| 723 | int opt; |
| 724 | char **argvopt; |
| 725 | int option_index; |
| 726 | char *prgname = argv[0]; |
| 727 | static struct option lgopts[] = { |
| 728 | {NULL, 0, 0, 0} |
| 729 | }; |
| 730 | |
| 731 | argvopt = argv; |
| 732 | enable_lcore_rx_distributor = false; |
| 733 | while ((opt = getopt_long(argc, argvopt, "cp:", |
| 734 | lgopts, &option_index)) != EOF) { |
| 735 | |
| 736 | switch (opt) { |
| 737 | /* portmask */ |
| 738 | case 'p': |
| 739 | enabled_port_mask = parse_portmask(optarg); |
| 740 | if (enabled_port_mask == 0) { |
| 741 | printf("invalid portmask\n"); |
| 742 | print_usage(prgname); |
| 743 | return -1; |
| 744 | } |
| 745 | break; |
| 746 | |
| 747 | case 'c': |
| 748 | enable_lcore_rx_distributor = true; |
| 749 | break; |
| 750 | |
| 751 | default: |
| 752 | print_usage(prgname); |
| 753 | return -1; |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | if (optind <= 1) { |
| 758 | print_usage(prgname); |
| 759 | return -1; |
| 760 | } |
| 761 | |
| 762 | argv[optind-1] = prgname; |
| 763 | |
| 764 | optind = 1; /* reset getopt lib */ |
| 765 | return 0; |
| 766 | } |
| 767 | |
| 768 | /* Main function, does initialization and calls the per-lcore functions */ |
| 769 | int |
no test coverage detected