aboutsummaryrefslogtreecommitdiffstats
path: root/ctrl/libhicnctrl/src/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl/libhicnctrl/src/cli.c')
-rw-r--r--ctrl/libhicnctrl/src/cli.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/ctrl/libhicnctrl/src/cli.c b/ctrl/libhicnctrl/src/cli.c
index fc81139d6..064eb77e3 100644
--- a/ctrl/libhicnctrl/src/cli.c
+++ b/ctrl/libhicnctrl/src/cli.c
@@ -48,6 +48,9 @@ foreach_object
#undef _
} hc_object_t;
+#define HICNLIGHT_PARAM "hicnlight"
+#define VPP_PARAM "vpp"
+
void
usage_header()
{
@@ -247,7 +250,7 @@ usage_connection(const char * prog, bool header, bool verbose)
void usage(const char * prog)
{
- fprintf(stderr, "Usage: %s [ [-d] [-f|-l|-c|-r] PARAMETERS | [-F|-L|-C|-R] ]\n", prog);
+ fprintf(stderr, "Usage: %s [ -z forwarder (hicnlight | vpp) ] [ [-d] [-f|-l|-c|-r] PARAMETERS | [-F|-L|-C|-R] ]\n", prog);
fprintf(stderr, "\n");
fprintf(stderr, "High-level commands\n");
fprintf(stderr, "\n");
@@ -319,15 +322,25 @@ foreach_face_type
int
-parse_options(int argc, char *argv[], hc_command_t * command)
+parse_options(int argc, char *argv[], hc_command_t * command, forwarder_t *forwarder)
{
command->object = OBJECT_UNDEFINED;
command->action = ACTION_CREATE;
int opt;
int family;
- while ((opt = getopt(argc, argv, "dflcrFLCRSh")) != -1) {
+ while ((opt = getopt(argc, argv, "dflcrFLCRShz:")) != -1) {
switch (opt) {
+ case 'z' :
+ if (strncmp(optarg, VPP_PARAM, strlen(VPP_PARAM)) == 0) {
+ *forwarder = VPP;
+ } else if (strncmp(optarg, HICNLIGHT_PARAM, strlen(HICNLIGHT_PARAM))) {
+ *forwarder = HICNLIGHT;
+ } else {
+ usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ break;
case 'd':
command->action = ACTION_DELETE;
break;
@@ -380,7 +393,7 @@ parse_options(int argc, char *argv[], hc_command_t * command)
switch(command->action) {
case ACTION_CREATE:
if ((argc - optind != 5) && (argc - optind != 6)) {
- usage_face_create(argv[0], true, false);
+ usage_face_create(argv[0], true, false);
goto ERR_PARAM;
}
/* NAME will be autogenerated (and currently not used) */
@@ -693,10 +706,12 @@ int main(int argc, char *argv[])
char buf_route[MAXSZ_HC_ROUTE];
char buf_strategy[MAXSZ_HC_STRATEGY];
- if (parse_options(argc, argv, &command) < 0)
+ forwarder_t forwarder = HICNLIGHT;
+
+ if (parse_options(argc, argv, &command, &forwarder) < 0)
die(OPTIONS, "Bad arguments");
- hc_sock_t * s = hc_sock_create();
+ hc_sock_t * s = hc_sock_create_forwarder(forwarder);
if (!s)
die(SOCKET, "Error creating socket.");