1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
16 static const char usage[] =
17 "%s EAL_ARGS -- [-h HOST] [-p PORT] [-s SCRIPT]\n";
19 static const char welcome[] =
21 "Welcome to IP Pipeline!\n"
24 static const char prompt[] = "pipeline> ";
26 static struct app_params {
27 struct conn_params conn;
35 .buf_size = 1024 * 1024,
36 .msg_in_len_max = 1024,
37 .msg_out_len_max = 1024 * 1024,
38 .msg_handle = cli_process,
44 parse_args(int argc, char **argv)
46 char *app_name = argv[0];
47 struct option lgopts[] = {
50 int opt, option_index;
51 int h_present, p_present, s_present, n_args, i;
53 /* Skip EAL input args */
55 for (i = 0; i < n_args; i++)
56 if (strcmp(argv[i], "--") == 0) {
70 while ((opt = getopt_long(argc, argv, "h:p:s:", lgopts, &option_index))
75 printf("Error: Multiple -h arguments\n");
80 if (!strlen(optarg)) {
81 printf("Error: Argument for -h not provided\n");
85 app.conn.addr = strdup(optarg);
86 if (app.conn.addr == NULL) {
87 printf("Error: Not enough memory\n");
94 printf("Error: Multiple -p arguments\n");
99 if (!strlen(optarg)) {
100 printf("Error: Argument for -p not provided\n");
104 app.conn.port = (uint16_t) atoi(optarg);
109 printf("Error: Multiple -s arguments\n");
114 if (!strlen(optarg)) {
115 printf("Error: Argument for -s not provided\n");
119 app.script_name = strdup(optarg);
120 if (app.script_name == NULL) {
121 printf("Error: Not enough memory\n");
127 printf(usage, app_name);
131 optind = 1; /* reset getopt lib */
137 main(int argc, char **argv)
142 /* Parse application arguments */
143 status = parse_args(argc, argv);
148 status = rte_eal_init(argc, argv);
150 printf("Error: EAL initialization failed (%d)\n", status);
155 conn = conn_init(&app.conn);
157 printf("Error: Connectivity initialization failed (%d)\n",
164 cli_script_process(app.script_name,
165 app.conn.msg_in_len_max,
166 app.conn.msg_out_len_max);
170 conn_poll_for_conn(conn);
172 conn_poll_for_msg(conn);