From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw1907.ocn.ad.jp (mogw1907.ocn.ad.jp [153.138.215.73]) by dpdk.org (Postfix) with ESMTP id 2531A1B1FC for ; Thu, 14 Feb 2019 03:47:29 +0100 (CET) Received: from mf-smf-ucb026c2 (mf-smf-ucb026c2.ocn.ad.jp [153.153.66.167]) by mogw1907.ocn.ad.jp (Postfix) with ESMTP id 7C885380238; Thu, 14 Feb 2019 11:47:27 +0900 (JST) Received: from ocn-vc-mts-103c1.ocn.ad.jp ([153.138.237.78]) by mf-smf-ucb026c2 with ESMTP id u6klgLB4s02JJu73fgQl9o; Thu, 14 Feb 2019 11:47:27 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.167]) by ocn-vc-mts-103c1.ocn.ad.jp with ESMTP id u73fgIQh2xmywu73fghAl8; Thu, 14 Feb 2019 11:47:27 +0900 Received: from localhost.localdomain (unknown [192.47.164.146]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Thu, 14 Feb 2019 11:47:27 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Thu, 14 Feb 2019 11:47:21 +0900 Message-Id: <20190214024726.40861-2-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214024726.40861-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20190214024726.40861-1-ogawa.yasufumi@lab.ntt.co.jp> Subject: [spp] [PATCH 1/6] spp_pcap: refactor app options X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Feb 2019 02:47:29 -0000 From: Yasufumi Ogawa Some of app options of spp_pcap are not user friendly or violating naming rule. This patch is to modify options, logs and help messages. * `-i` is changed to `-c` because `-i` is ambiguous for the purpose. * `--output` is changed to `--out-dir` because it is directory. * `--limit_file_size` is changed to `--fsize` because it should be used `-` instead of `_` and simpler name is enough. Signed-off-by: Yasufumi Ogawa --- src/pcap/spp_pcap.c | 48 ++++++++++++++++++++++----------------------- src/pcap/spp_proc.h | 6 +++--- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/pcap/spp_pcap.c b/src/pcap/spp_pcap.c index 2716c01..c69207b 100644 --- a/src/pcap/spp_pcap.c +++ b/src/pcap/spp_pcap.c @@ -167,17 +167,15 @@ usage(const char *progname) { RTE_LOG(INFO, SPP_PCAP, "Usage: %s [EAL args] --" " --client-id CLIENT_ID" - " -s SERVER_IP:SERVER_PORT" - " -i INPUT_PORT" - " [--output FILE_OUT_PUT_PATH]" - " [--limit_file_size LIMIT_FILE_SIZE]\n" - " --client-id CLIENT_ID : My client ID\n" - " -s SERVER_IP:SERVER_PORT : " - "Access information to the server\n" - " -i : capture port(phy,ring)\n" - " --output : file path(default:/tmp)\n" - " --limit_file_size : " - "file limit size(default:1073741824 Byte)\n" + " -s IPADDR:PORT" + " -c CAP_PORT" + " [--out-dir DIR_OUTPUT]" + " [--fsize MAX_FILE_SIZE]\n" + " --client-id CLIENT_ID: My client ID\n" + " -s IPADDR:PORT: IP addr and sec port for spp-ctl\n" + " -c: Captured port (e.g. 'phy:0' or 'ring:1')\n" + " --out-dir: Output dir (Default is /tmp)\n" + " --fsize: Maximum captured file size (Default is 1GiB)\n" , progname); } @@ -305,13 +303,13 @@ parse_args(int argc, char *argv[]) const char *progname = argv[0]; char port_str[PORT_STR_SIZE]; static struct option lgopts[] = { - { "client-id", required_argument, NULL, - SPP_LONGOPT_RETVAL_CLIENT_ID }, - { "output", required_argument, NULL, - SPP_LONGOPT_RETVAL_OUTPUT }, - { "limit_file_size", required_argument, NULL, - SPP_LONGOPT_RETVAL_LIMIT_FILE_SIZE}, - { 0 }, + { "client-id", required_argument, NULL, + SPP_LONGOPT_RETVAL_CLIENT_ID }, + { "out-dir", required_argument, NULL, + SPP_LONGOPT_RETVAL_OUT_DIR }, + { "fsize", required_argument, NULL, + SPP_LONGOPT_RETVAL_FILE_SIZE}, + { 0 }, }; /** * Save argv to argvopt to avoid losing the order of options @@ -331,7 +329,7 @@ parse_args(int argc, char *argv[]) /* Check options of application */ optind = 0; opterr = 0; - while ((opt = getopt_long(argc, argvopt, "i:s:", lgopts, + while ((opt = getopt_long(argc, argvopt, "c:s:", lgopts, &option_index)) != EOF) { switch (opt) { case SPP_LONGOPT_RETVAL_CLIENT_ID: @@ -343,7 +341,7 @@ parse_args(int argc, char *argv[]) } proc_flg = 1; break; - case SPP_LONGOPT_RETVAL_OUTPUT: + case SPP_LONGOPT_RETVAL_OUT_DIR: strcpy(g_pcap_option.compress_file_path, optarg); struct stat statBuf; if (g_pcap_option.compress_file_path[0] == '\0' || @@ -352,7 +350,7 @@ parse_args(int argc, char *argv[]) return SPP_RET_NG; } break; - case SPP_LONGOPT_RETVAL_LIMIT_FILE_SIZE: + case SPP_LONGOPT_RETVAL_FILE_SIZE: if (decode_limit_file_size(optarg, &g_pcap_option.file_limit) != SPP_RET_OK) { @@ -360,7 +358,7 @@ parse_args(int argc, char *argv[]) return SPP_RET_NG; } break; - case 'i': + case 'c': /* captured port */ strcpy(port_str, optarg); if (decode_capture_port(optarg, &g_pcap_option.port_cap.iface_type, @@ -371,7 +369,7 @@ parse_args(int argc, char *argv[]) } port_flg = 1; break; - case 's': + case 's': /* server addr */ if (parse_server_ip(optarg, g_startup_param.server_ip, &g_startup_param.server_port) != SPP_RET_OK) { @@ -393,8 +391,8 @@ parse_args(int argc, char *argv[]) } RTE_LOG(INFO, SPP_PCAP, - "app opts (client_id=%d,server=%s:%d," - "port=%s,output=%s,limit_file_size=%ld)\n", + "App opts: '--client-id %d', '-s %s:%d', " + "'-c %s', '--out-dir %s', '--fsize %ld'\n", g_startup_param.client_id, g_startup_param.server_ip, g_startup_param.server_port, diff --git a/src/pcap/spp_proc.h b/src/pcap/spp_proc.h index 6da5c5e..2265b21 100644 --- a/src/pcap/spp_proc.h +++ b/src/pcap/spp_proc.h @@ -90,9 +90,9 @@ enum SPP_LONGOPT_RETVAL { * Return value definition for getopt_long() * Only for long option */ - SPP_LONGOPT_RETVAL_CLIENT_ID, /* --client-id */ - SPP_LONGOPT_RETVAL_OUTPUT, /* --output */ - SPP_LONGOPT_RETVAL_LIMIT_FILE_SIZE /* --limit_file_size */ + SPP_LONGOPT_RETVAL_CLIENT_ID, /* --client-id */ + SPP_LONGOPT_RETVAL_OUT_DIR, /* --out-dir */ + SPP_LONGOPT_RETVAL_FILE_SIZE /* --fsize */ }; /* Interface information structure */ -- 2.17.1