MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parse_opts

Function parse_opts

dpdk/app/dumpcap/main.c:335–472  ·  view source on GitHub ↗

* Parse command line options. * These are chosen to be similar to dumpcap command. */

Source from the content-addressed store, hash-verified

333 * These are chosen to be similar to dumpcap command.
334 */
335static void parse_opts(int argc, char **argv)
336{
337 static const struct option long_options[] = {
338 { "autostop", required_argument, NULL, 'a' },
339 { "capture-comment", required_argument, NULL, 0 },
340 { "file-prefix", required_argument, NULL, 0 },
341 { "help", no_argument, NULL, 'h' },
342 { "ifdescr", required_argument, NULL, 0 },
343 { "ifname", required_argument, NULL, 0 },
344 { "interface", required_argument, NULL, 'i' },
345 { "list-interfaces", no_argument, NULL, 'D' },
346 { "no-promiscuous-mode", no_argument, NULL, 'p' },
347 { "output-file", required_argument, NULL, 'w' },
348 { "ring-buffer", required_argument, NULL, 'b' },
349 { "snapshot-length", required_argument, NULL, 's' },
350 { "temp-dir", required_argument, NULL, 0 },
351 { "version", no_argument, NULL, 'v' },
352 { NULL },
353 };
354 int option_index, c;
355 struct interface *last_intf = NULL;
356 uint32_t len;
357
358 for (;;) {
359 c = getopt_long(argc, argv, "a:b:c:dDf:ghi:nN:pPqSs:vw:",
360 long_options, &option_index);
361 if (c == -1)
362 break;
363
364 switch (c) {
365 case 0: {
366 const char *longopt
367 = long_options[option_index].name;
368
369 if (!strcmp(longopt, "capture-comment")) {
370 capture_comment = optarg;
371 } else if (!strcmp(longopt, "file-prefix")) {
372 file_prefix = optarg;
373 } else if (!strcmp(longopt, "temp-dir")) {
374 tmp_dir = optarg;
375 } else if (!strcmp(longopt, "ifdescr")) {
376 if (last_intf == NULL)
377 rte_exit(EXIT_FAILURE,
378 "--ifdescr must be specified after a -i option\n");
379 last_intf->ifdescr = optarg;
380 } else if (!strcmp(longopt, "ifname")) {
381 if (last_intf == NULL)
382 rte_exit(EXIT_FAILURE,
383 "--ifname must be specified after a -i option\n");
384 last_intf->ifname = optarg;
385 } else {
386 usage();
387 exit(1);
388 }
389 break;
390 }
391 case 'a':
392 auto_stop(optarg);

Callers 1

mainFunction · 0.70

Calls 9

getopt_longFunction · 0.85
strcmpFunction · 0.85
rte_exitFunction · 0.85
auto_stopFunction · 0.85
get_uintFunction · 0.85
add_interfaceFunction · 0.85
usageFunction · 0.70
versionFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected