* The application specific arguments follow the DPDK-specific * arguments which are stripped by the DPDK init. This function * processes these application arguments, printing usage info * on error. */
| 120 | * on error. |
| 121 | */ |
| 122 | int |
| 123 | parse_app_args(uint8_t max_ports, int argc, char *argv[]) |
| 124 | { |
| 125 | int option_index, opt; |
| 126 | char **argvopt = argv; |
| 127 | static struct option lgopts[] = { /* no long options */ |
| 128 | {NULL, 0, 0, 0 } |
| 129 | }; |
| 130 | progname = argv[0]; |
| 131 | |
| 132 | while ((opt = getopt_long(argc, argvopt, "n:f:p:", lgopts, |
| 133 | &option_index)) != EOF) { |
| 134 | switch (opt) { |
| 135 | case 'p': |
| 136 | if (parse_portmask(max_ports, optarg) != 0) { |
| 137 | usage(); |
| 138 | return -1; |
| 139 | } |
| 140 | break; |
| 141 | case 'n': |
| 142 | if (parse_num_nodes(optarg) != 0) { |
| 143 | usage(); |
| 144 | return -1; |
| 145 | } |
| 146 | break; |
| 147 | case 'f': |
| 148 | if (parse_num_flows(optarg) != 0) { |
| 149 | usage(); |
| 150 | return -1; |
| 151 | } |
| 152 | break; |
| 153 | default: |
| 154 | printf("ERROR: Unknown option '%c'\n", opt); |
| 155 | usage(); |
| 156 | return -1; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | if (info->num_ports == 0 || num_nodes == 0) { |
| 161 | usage(); |
| 162 | return -1; |
| 163 | } |
| 164 | |
| 165 | if (info->num_ports % 2 != 0) { |
| 166 | printf("ERROR: application requires an even " |
| 167 | "number of ports to use\n"); |
| 168 | return -1; |
| 169 | } |
| 170 | return 0; |
| 171 | } |
no test coverage detected