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

Function parse_app_args

dpdk/examples/server_node_efd/efd_server/args.c:122–171  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

120 * on error.
121 */
122int
123parse_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}

Callers 1

initFunction · 0.70

Calls 6

getopt_longFunction · 0.85
parse_num_nodesFunction · 0.85
parse_num_flowsFunction · 0.85
parse_portmaskFunction · 0.70
usageFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected