diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/vnf_common/config_parse.c | 21 | ||||
-rw-r--r-- | common/vnf_common/version.h | 35 |
2 files changed, 52 insertions, 4 deletions
diff --git a/common/vnf_common/config_parse.c b/common/vnf_common/config_parse.c index eeb547e6..48921f46 100644 --- a/common/vnf_common/config_parse.c +++ b/common/vnf_common/config_parse.c @@ -30,6 +30,7 @@ #include <rte_string_fns.h> #include "app.h" +#include "version.h" #include "parser.h" /** @@ -201,8 +202,8 @@ struct app_pipeline_params default_pipeline_params = { }; static const char app_usage[] = - "Usage: %s [-f CONFIG_FILE] [-s SCRIPT_FILE] [-p PORT_MASK] " - "[-l LOG_LEVEL] [--preproc PREPROCESSOR] [--preproc-args ARGS]\n" + "Usage: %s [--version] [-f CONFIG_FILE] [-s SCRIPT_FILE] [-p PORT_MASK] " + "[-l LOG_LEVEL] [--disable-hw-csum] [--preproc PREPROCESSOR] [--preproc-args ARGS]\n" "\n" "Arguments:\n" "\t-f CONFIG_FILE: Default config file is %s\n" @@ -210,6 +211,7 @@ static const char app_usage[] = "config file when not provided)\n" "\t-s SCRIPT_FILE: No CLI script file is run when not specified\n" "\t-l LOG_LEVEL: 0 = NONE, 1 = HIGH PRIO (default), 2 = LOW PRIO\n" + "\t--version application version\n" "\t--disable-hw-csum Disable TCP/UDP HW checksum\n" "\t--preproc PREPROCESSOR: Configuration file pre-processor\n" "\t--preproc-args ARGS: Arguments to be passed to pre-processor\n" @@ -3231,7 +3233,7 @@ app_config_args(struct app_params *app, int argc, char **argv) { const char *optname; int opt, option_index; - int f_present, s_present, p_present, l_present; + int f_present, s_present, p_present, l_present, v_present; int preproc_present, preproc_params_present, disable_csum_present; int hwlb_present; int flow_dir_present; @@ -3243,6 +3245,7 @@ app_config_args(struct app_params *app, int argc, char **argv) { "preproc-args", 1, 0, 0 }, { "hwlb", 1, 0, 0 }, { "flow_dir", 0, 0, 0 }, + { "version", 0, 0, 0 }, { NULL, 0, 0, 0 } }; @@ -3252,6 +3255,7 @@ app_config_args(struct app_params *app, int argc, char **argv) f_present = 0; s_present = 0; p_present = 0; + v_present = 0; l_present = 0; disable_csum_present = 0; preproc_present = 0; @@ -3261,7 +3265,7 @@ app_config_args(struct app_params *app, int argc, char **argv) flow_dir_present = 0; - while ((opt = getopt_long(argc, argv, "f:s:p:l:", lgopts, + while ((opt = getopt_long(argc, argv, "f:v:s:p:l:", lgopts, &option_index)) != EOF) switch (opt) { case 'f': @@ -3332,6 +3336,15 @@ app_config_args(struct app_params *app, int argc, char **argv) case 0: optname = lgopts[option_index].name; + if (strcmp(optname, "version") == 0) { + if (v_present) + rte_panic("Error: VERSION is provided " + "more than once\n"); + v_present = 1; + printf("Version: %s\n", VERSION_STR); + exit(0); + } + if (strcmp(optname, "hwlb") == 0) { if (hwlb_present) rte_panic("Error: hwlb argument " diff --git a/common/vnf_common/version.h b/common/vnf_common/version.h new file mode 100644 index 00000000..00d8f458 --- /dev/null +++ b/common/vnf_common/version.h @@ -0,0 +1,35 @@ +/* +// Copyright (c) 2017 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ + +#ifndef __INCLUDE_VER_H__ +#define __INCLUDE_VER_H__ + +#define STRINGIFY(s) #s +#define SSTR(s) STRINGIFY(s) + +/* PROGRAM_NAME defined through Makefile */ +#define VERSION_MAJOR 0 +#define VERSION_MINOR 39 +#define VERSION_REV 0 + +#if VERSION_REV > 0 +#define VERSION_STR "v" SSTR(VERSION_MAJOR) "." SSTR(VERSION_MINOR) "." SSTR(VERSION_REV) +#else +#define VERSION_STR "v" SSTR(VERSION_MAJOR) "." SSTR(VERSION_MINOR) +#endif + + +#endif |