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

Function parse_args

dpdk/examples/l3fwd/main.c:775–996  ·  view source on GitHub ↗

Parse the argument given in the command line of the application */

Source from the content-addressed store, hash-verified

773
774/* Parse the argument given in the command line of the application */
775static int
776parse_args(int argc, char **argv)
777{
778 int opt, ret;
779 char **argvopt;
780 int option_index;
781 char *prgname = argv[0];
782 uint8_t lcore_params = 0;
783#ifdef RTE_LIB_EVENTDEV
784 uint8_t eventq_sched = 0;
785 uint8_t eth_rx_q = 0;
786 struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc();
787#endif
788
789 argvopt = argv;
790
791 /* Error or normal output strings. */
792 while ((opt = getopt_long(argc, argvopt, short_options,
793 lgopts, &option_index)) != EOF) {
794
795 switch (opt) {
796 /* portmask */
797 case 'p':
798 enabled_port_mask = parse_portmask(optarg);
799 if (enabled_port_mask == 0) {
800 fprintf(stderr, "Invalid portmask\n");
801 print_usage(prgname);
802 return -1;
803 }
804 break;
805
806 case 'P':
807 promiscuous_on = 1;
808 break;
809
810 case 'E':
811 if (lookup_mode != L3FWD_LOOKUP_DEFAULT) {
812 fprintf(stderr, "Only one lookup mode is allowed at a time!\n");
813 return -1;
814 }
815 lookup_mode = L3FWD_LOOKUP_EM;
816 break;
817
818 case 'L':
819 if (lookup_mode != L3FWD_LOOKUP_DEFAULT) {
820 fprintf(stderr, "Only one lookup mode is allowed at a time!\n");
821 return -1;
822 }
823 lookup_mode = L3FWD_LOOKUP_LPM;
824 break;
825
826 /* long options */
827 case CMD_LINE_OPT_CONFIG_NUM:
828 ret = parse_config(optarg);
829 if (ret) {
830 fprintf(stderr, "Invalid config\n");
831 print_usage(prgname);
832 return -1;

Callers 1

mainFunction · 0.70

Calls 15

l3fwd_get_eventdev_rsrcFunction · 0.85
getopt_longFunction · 0.85
parse_queue_sizeFunction · 0.85
parse_modeFunction · 0.85
parse_eventq_schedFunction · 0.85
strtolFunction · 0.85
l3fwd_set_rule_ipv4_nameFunction · 0.85
l3fwd_set_rule_ipv6_nameFunction · 0.85
l3fwd_set_algFunction · 0.85
parse_portmaskFunction · 0.70
print_usageFunction · 0.70

Tested by

no test coverage detected