Added support for gateway ipv6 & cmd for sending unsollicited neighbor advertisement
[samplevnf.git] / VNFs / DPPD-PROX / cmd_parser.c
index 23cd8d4..1f2d5fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-// Copyright (c) 2010-2017 Intel Corporation
+// Copyright (c) 2010-2020 Intel Corporation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -52,6 +52,8 @@
 #include "handle_cgnat.h"
 #include "handle_impair.h"
 #include "rx_pkt.h"
+#include "prox_compat.h"
+#include "igmp.h"
 
 static int core_task_is_valid(int lcore_id, int task_id)
 {
@@ -76,24 +78,13 @@ static int cores_task_are_valid(unsigned int *lcores, int task_id, unsigned int
        unsigned int lcore_id;
        for (unsigned int i = 0; i < nb_cores; i++) {
                lcore_id = lcores[i];
-               if (lcore_id >= RTE_MAX_LCORE) {
-                       plog_err("Invalid core id %u (lcore ID above %d)\n", lcore_id, RTE_MAX_LCORE);
+               if (core_task_is_valid(lcore_id, task_id) == 0)
                        return 0;
-               }
-               else if (!prox_core_active(lcore_id, 0)) {
-                       plog_err("Invalid core id %u (lcore is not active)\n", lcore_id);
-                       return 0;
-               }
-               else if (task_id >= lcore_cfg[lcore_id].n_tasks_all) {
-                       plog_err("Invalid task id (valid task IDs for core %u are below %u)\n",
-                               lcore_id, lcore_cfg[lcore_id].n_tasks_all);
-                       return 0;
-               }
        }
        return 1;
 }
 
-static int parse_core_task(const char *str, uint32_t *lcore_id, uint32_t *task_id, unsigned int *nb_cores)
+static int parse_cores_task(const char *str, uint32_t *lcore_id, uint32_t *task_id, unsigned *nb_cores)
 {
        char str_lcore_id[128];
        int ret;
@@ -110,6 +101,29 @@ static int parse_core_task(const char *str, uint32_t *lcore_id, uint32_t *task_i
        return 0;
 }
 
+static int parse_cores_tasks(const char *str, uint32_t *lcore_id, uint32_t *task_id, unsigned *nb_cores, unsigned *nb_tasks)
+{
+       char str_lcore_id[128], str_task_id[128];
+       int ret;
+
+       if (2 != sscanf(str, "%s %s", str_lcore_id, str_task_id))
+               return -1;
+
+       if ((ret = parse_list_set(lcore_id, str_lcore_id, RTE_MAX_LCORE)) <= 0) {
+               plog_err("Invalid core while parsing command (%s)\n", get_parse_err());
+               return -1;
+       }
+       *nb_cores = ret;
+
+       if ((ret = parse_list_set(task_id, str_task_id, MAX_TASKS_PER_CORE)) <= 0) {
+               plog_err("Invalid task while parsing command (%s)\n", get_parse_err());
+               return -1;
+       }
+       *nb_tasks = ret;
+
+       return 0;
+}
+
 static const char *strchr_skip_twice(const char *str, int chr)
 {
        str = strchr(str, chr);
@@ -207,7 +221,7 @@ static int parse_cmd_trace(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], task_id, nb_packets, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -226,7 +240,7 @@ static int parse_cmd_dump_rx(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], task_id, nb_packets, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -273,7 +287,7 @@ static int parse_cmd_dump_tx(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], task_id, nb_packets, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -327,9 +341,9 @@ static int parse_cmd_rate(const char *str, struct input *input)
 
 int task_is_mode_and_submode(uint32_t lcore_id, uint32_t task_id, const char *mode, const char *sub_mode)
 {
-       struct task_init *t = lcore_cfg[lcore_id].targs[task_id].task_init;
+       struct task_args *targs = &lcore_cfg[lcore_id].targs[task_id];
 
-       return !strcmp(t->mode_str, mode) && !strcmp(t->sub_mode_str, sub_mode);
+       return !strcmp(targs->task_init->mode_str, mode) && !strcmp(targs->sub_mode_str, sub_mode);
 }
 
 int task_is_mode(uint32_t lcore_id, uint32_t task_id, const char *mode)
@@ -341,9 +355,9 @@ int task_is_mode(uint32_t lcore_id, uint32_t task_id, const char *mode)
 
 int task_is_sub_mode(uint32_t lcore_id, uint32_t task_id, const char *sub_mode)
 {
-       struct task_init *t = lcore_cfg[lcore_id].targs[task_id].task_init;
+       struct task_args *targs = &lcore_cfg[lcore_id].targs[task_id];
 
-       return !strcmp(t->sub_mode_str, sub_mode);
+       return !strcmp(targs->sub_mode_str, sub_mode);
 }
 
 static void log_pkt_count(uint32_t count, uint32_t lcore_id, uint32_t task_id)
@@ -360,7 +374,7 @@ static int parse_cmd_count(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, count, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -370,7 +384,7 @@ static int parse_cmd_count(const char *str, struct input *input)
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                                plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
                        }
                        else {
@@ -384,27 +398,79 @@ static int parse_cmd_count(const char *str, struct input *input)
        return 0;
 }
 
-static int parse_cmd_set_probability(const char *str, struct input *input)
+static int parse_cmd_set_proba_no_drop(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
-       float probability;
+       float proba_no_drop;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
-       if (sscanf(str, "%f", &probability) != 1)
+       if (sscanf(str, "%f", &proba_no_drop) != 1)
                return -1;
 
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){
+                       if (!task_is_mode(lcore_id, task_id, "impair")) {
                                plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id);
-                               return -1;
+                       } else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               task_impair_set_proba_no_drop(tbase, proba_no_drop);
+                       }
+               }
+       }
+       return 0;
+}
+
+static int parse_cmd_set_proba_delay(const char *str, struct input *input)
+{
+       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+       float proba_delay;
+
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
+               return -1;
+       if (!(str = strchr_skip_twice(str, ' ')))
+               return -1;
+       if (sscanf(str, "%f", &proba_delay) != 1)
+               return -1;
+
+       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
+               for (unsigned int i = 0; i < nb_cores; i++) {
+                       lcore_id = lcores[i];
+                       if (!task_is_mode(lcore_id, task_id, "impair")) {
+                               plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id);
+                       } else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               task_impair_set_proba_delay(tbase, proba_delay);
+                       }
+               }
+       }
+       return 0;
+}
+
+static int parse_cmd_set_proba_duplicate(const char *str, struct input *input)
+{
+       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+       float proba_duplicate;
+
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
+               return -1;
+       if (!(str = strchr_skip_twice(str, ' ')))
+               return -1;
+       if (sscanf(str, "%f", &proba_duplicate) != 1)
+               return -1;
+
+       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
+               for (unsigned int i = 0; i < nb_cores; i++) {
+                       lcore_id = lcores[i];
+                       if (!task_is_mode(lcore_id, task_id, "impair")) {
+                               plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id);
+                       } else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               task_impair_set_proba_duplicate(tbase, proba_duplicate);
                        }
-                       struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
-                       task_impair_set_proba(tbase, probability);
                }
        }
        return 0;
@@ -414,7 +480,7 @@ static int parse_cmd_delay_us(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, delay_us, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -424,12 +490,12 @@ static int parse_cmd_delay_us(const char *str, struct input *input)
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){
+                       if (!task_is_mode(lcore_id, task_id, "impair")) {
                                plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id);
-                               return -1;
+                       } else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               task_impair_set_delay_us(tbase, delay_us, 0);
                        }
-                       struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
-                       task_impair_set_delay_us(tbase, delay_us, 0);
                }
        }
        return 0;
@@ -439,7 +505,7 @@ static int parse_cmd_random_delay_us(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, delay_us, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -449,12 +515,12 @@ static int parse_cmd_random_delay_us(const char *str, struct input *input)
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){
+                       if (!task_is_mode(lcore_id, task_id, "impair")) {
                                plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id);
-                               return -1;
+                       } else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               task_impair_set_delay_us(tbase, 0, delay_us);
                        }
-                       struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
-                       task_impair_set_delay_us(tbase, 0, delay_us);
                }
        }
        return 0;
@@ -464,7 +530,7 @@ static int parse_cmd_bypass(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, pkt_size, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if ((prox_cfg.flags & DSF_ENABLE_BYPASS) == 0) {
                plog_err("enable bypass not set => command not supported\n");
@@ -485,7 +551,7 @@ static int parse_cmd_reconnect(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, pkt_size, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
@@ -501,7 +567,7 @@ static int parse_cmd_pkt_size(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, pkt_size, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -511,13 +577,53 @@ static int parse_cmd_pkt_size(const char *str, struct input *input)
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                                plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
+                       } else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               task_gen_set_pkt_size(tbase, pkt_size); /* error printed within function */
                        }
-                       struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+               }
+       }
+       return 0;
+}
 
-                       if (task_gen_set_pkt_size(tbase, pkt_size) != 0)
-                               return -1;
+static int parse_cmd_imix(const char *str, struct input *input)
+{
+       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+       uint32_t pkt_sizes[MAX_IMIX_PKTS], tmp;
+       uint32_t pkt_index = 0;
+
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
+               return -1;
+       if (!(str = strchr_skip_twice(str, ' ')))
+               return -1;
+       while (pkt_index < MAX_IMIX_PKTS) {
+               if (sscanf(str, "%d", &pkt_sizes[pkt_index]) != 1)
+                       break;
+               pkt_index++;
+               if ((str = strchr(str, ',')) == NULL)
+                       break;
+               str = str + 1;
+       }
+       if (pkt_index == 0) {
+               plog_err("No pkt size found\n");
+               return -1;
+       }
+       if ((pkt_index == MAX_IMIX_PKTS) && (str) && (sscanf(str, "%d", &tmp) == 1)) {
+               plog_err("Too many inputs - unexpected inputs starting at %s\n", str);
+               return -1;
+       }
+
+       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
+               for (unsigned int i = 0; i < nb_cores; i++) {
+                       lcore_id = lcores[i];
+                       if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                               plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
+                       } else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               task_gen_set_imix(tbase, pkt_index, pkt_sizes); /* error printed within function */
+                       }
                }
        }
        return 0;
@@ -529,7 +635,7 @@ static int parse_cmd_speed(const char *str, struct input *input)
        float speed;
        unsigned i;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -543,11 +649,11 @@ static int parse_cmd_speed(const char *str, struct input *input)
 
        for (i = 0; i < nb_cores; i++) {
                lcore_id = lcores[i];
-               if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                        plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
                }
-               else if (speed > 400.0f || speed < 0.0f) {
-                       plog_err("Speed out of range (must be betweeen 0%% and 100%%)\n");
+               else if (speed > 1000.0f || speed < 0.0f) {     // Up to 100 Gbps
+                       plog_err("Speed out of range (must be betweeen 0%% and 1000%%)\n");
                }
                else {
                        struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
@@ -566,7 +672,7 @@ static int parse_cmd_speed_byte(const char *str, struct input *input)
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
        uint64_t bps;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -577,11 +683,11 @@ static int parse_cmd_speed_byte(const char *str, struct input *input)
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
 
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                                plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
                        }
-                       else if (bps > 1250000000) {
-                               plog_err("Speed out of range (must be <= 1250000000)\n");
+                       else if (bps > 12500000000) {   // Up to 100Gbps
+                               plog_err("Speed out of range (must be <= 12500000000)\n");
                        }
                        else {
                                struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
@@ -603,7 +709,7 @@ static int parse_cmd_reset_randoms_all(const char *str, struct input *input)
        unsigned task_id, lcore_id = -1;
        while (prox_core_next(&lcore_id, 0) == 0) {
                for (task_id = 0; task_id < lcore_cfg[lcore_id].n_tasks_all; task_id++) {
-                       if ((task_is_mode_and_submode(lcore_id, task_id, "gen", "")) || (task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                                struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
                                uint32_t n_rands = task_gen_get_n_randoms(tbase);
 
@@ -624,7 +730,7 @@ static int parse_cmd_reset_values_all(const char *str, struct input *input)
        unsigned task_id, lcore_id = -1;
        while (prox_core_next(&lcore_id, 0) == 0) {
                for (task_id = 0; task_id < lcore_cfg[lcore_id].n_tasks_all; task_id++) {
-                       if ((task_is_mode_and_submode(lcore_id, task_id, "gen", "")) || (task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                                struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
 
                                plog_info("Resetting values on core %d task %d\n", lcore_id, task_id);
@@ -639,13 +745,13 @@ static int parse_cmd_reset_values(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
 
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                                plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
                        }
                        else {
@@ -665,7 +771,7 @@ static int parse_cmd_set_value(const char *str, struct input *input)
        unsigned short offset;
        uint8_t value_len;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -676,12 +782,10 @@ static int parse_cmd_set_value(const char *str, struct input *input)
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                                plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
                        }
-                       else if (offset > ETHER_MAX_LEN) {
-                               plog_err("Offset out of range (must be less then %u)\n", ETHER_MAX_LEN);
-                       }
+                       // do not check offset here - gen knows better than us the maximum frame size
                        else if (value_len > 4) {
                                plog_err("Length out of range (must be less then 4)\n");
                        }
@@ -689,7 +793,7 @@ static int parse_cmd_set_value(const char *str, struct input *input)
                                struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
 
                                if (task_gen_set_value(tbase, value, offset, value_len))
-                                       plog_info("Unable to set Byte %"PRIu16" to %"PRIu8" - too many value set\n", offset, value);
+                                       plog_info("Unable to set Byte %"PRIu16" to %"PRIu8" - invalid offset/len\n", offset, value);
                                else
                                        plog_info("Setting Byte %"PRIu16" to %"PRIu32"\n", offset, value);
                        }
@@ -706,7 +810,7 @@ static int parse_cmd_set_random(const char *str, struct input *input)
        char rand_str[64];
        int16_t rand_id = -1;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -717,11 +821,11 @@ static int parse_cmd_set_random(const char *str, struct input *input)
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
                for (unsigned int i = 0; i < nb_cores; i++) {
                        lcore_id = lcores[i];
-                       if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) {
+                       if (!task_is_mode(lcore_id, task_id, "gen")) {
                                plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id);
                        }
-                       else if (offset > ETHER_MAX_LEN) {
-                               plog_err("Offset out of range (must be less then %u)\n", ETHER_MAX_LEN);
+                       else if (offset > PROX_RTE_ETHER_MAX_LEN) {
+                               plog_err("Offset out of range (must be less then %u)\n", PROX_RTE_ETHER_MAX_LEN);
                        }
                        else if (value_len > 4) {
                                plog_err("Length out of range (must be less then 4)\n");
@@ -741,7 +845,7 @@ static int parse_cmd_thread_info(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        for (unsigned int i = 0; i < nb_cores; i++) {
                cmd_thread_info(lcores[i], task_id);
@@ -770,7 +874,7 @@ static int parse_cmd_arp_add(const char *str, struct input *input)
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
        struct rte_ring *ring;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -804,7 +908,7 @@ static int parse_cmd_rule_add(const char *str, struct input *input)
        struct rte_ring *ring;
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -812,7 +916,7 @@ static int parse_cmd_rule_add(const char *str, struct input *input)
                return -1;
        char *fields[9];
        char str_cpy[255];
-       strncpy(str_cpy, str, 255);
+       prox_strncpy(str_cpy, str, 255);
        // example add rule command: rule add 15 0 1&0x0fff 1&0x0fff 0&0 128.0.0.0/1 128.0.0.0/1 5000-5000 5000-5000 allow
        int ret = rte_strsplit(str_cpy, 255, fields, 9, ' ');
        if (ret != 8) {
@@ -848,7 +952,7 @@ static int parse_cmd_gateway_ip(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, ip[4], nb_cores, i;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -877,7 +981,7 @@ static int parse_cmd_local_ip(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, ip[4], nb_cores, i;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -909,7 +1013,7 @@ static int parse_cmd_route_add(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, prefix, next_hop_idx, ip[4], nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -1242,6 +1346,31 @@ static int parse_cmd_tot_imissed_tot(const char *str, struct input *input)
        return 0;
 }
 
+static int parse_cmd_enable_multicast(const char *str, struct input *input)
+{
+       uint8_t port_id;
+       prox_rte_ether_addr mac;
+
+       if (sscanf(str, "%hhu %hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &port_id, mac.addr_bytes, mac.addr_bytes + 1, mac.addr_bytes + 2, mac.addr_bytes + 3, mac.addr_bytes + 4, mac.addr_bytes + 5 ) != 7) {
+                return -1;
+        }
+       cmd_multicast(port_id, 1, &mac);
+       return 0;
+}
+
+static int parse_cmd_disable_multicast(const char *str, struct input *input)
+{
+       uint8_t port_id;
+       prox_rte_ether_addr mac;
+
+       if (sscanf(str, "%hhu %hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &port_id, mac.addr_bytes, mac.addr_bytes + 1, mac.addr_bytes + 2, mac.addr_bytes + 3, mac.addr_bytes + 4, mac.addr_bytes + 5 ) != 7) {
+                return -1;
+        }
+
+       cmd_multicast(port_id, 0, &mac);
+       return 0;
+}
+
 static int parse_cmd_reset_port(const char *str, struct input *input)
 {
        uint32_t port_id;
@@ -1480,7 +1609,7 @@ static int parse_cmd_stats(const char *str, struct input *input)
        char *ret = ret2;
        int list = 0;
 
-       strncpy(buf, str, sizeof(buf) - 1);
+       prox_strncpy(buf, str, sizeof(buf) - 1);
        char *tok;
        uint64_t stat_val;
 
@@ -1542,7 +1671,7 @@ static int parse_cmd_ring_info(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], task_id, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
 
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
@@ -1583,11 +1712,54 @@ static int parse_cmd_port_stats(const char *str, struct input *input)
        return 0;
 }
 
+static int parse_cmd_multi_port_stats(const char *str, struct input *input)
+{
+       uint32_t ports[PROX_MAX_PORTS];
+       int nb_ports = parse_list_set(ports, str, PROX_MAX_PORTS);
+       if (nb_ports <= 0) {
+               return -1;
+       }
+
+       char buf[PROX_MAX_PORTS * (11+5*21) + 1], *pbuf = buf;
+       int left = sizeof(buf);
+       for (int i = 0; i < nb_ports; ++i) {
+               struct get_port_stats s;
+               if (stats_port(ports[i], &s)) {
+                       plog_err("Invalid port %u\n", ports[i]);
+                       return 0;
+               }
+
+               int len = snprintf(pbuf, left,
+                               "%u,"
+                               "%"PRIu64",%"PRIu64","
+                               "%"PRIu64",%"PRIu64","
+                               "%"PRIu64";",
+                               //TODO: adjust buf size above when adding fields
+                               ports[i],
+                               s.rx_tot, s.tx_tot,
+                               s.no_mbufs_tot, s.ierrors_tot + s.imissed_tot,
+                               s.last_tsc);
+               if ((len < 0) || (len >= left)) {
+                       plog_err("Cannot print stats for port %u\n", ports[i]);
+                       return 0;
+               }
+               pbuf += len;
+               left -= len;
+       }
+       pbuf--;
+       *pbuf = '\n';
+
+       plog_info("%s", buf);
+       if (input->reply)
+               input->reply(input, buf, sizeof(buf) - left);
+       return 0;
+}
+
 static int parse_cmd_core_stats(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
 
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
@@ -1614,121 +1786,248 @@ static int parse_cmd_core_stats(const char *str, struct input *input)
        return 0;
 }
 
-static int parse_cmd_lat_stats(const char *str, struct input *input)
+typedef void (*parser_handler)(unsigned, unsigned, struct input *);
+static int handle_cores_tasks(const char *str, struct input *input, const char *mode_str, const char *mode_name, parser_handler f)
 {
-       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+       // This function either outputs a single line, in case of syntax error on the lists of cores and/or tasks
+       // or outputs (nb_cores * nb_tasks) lines, one line for each core/task pair:
+       // - if the core/task pair is invalid, the output line reports an error
+       // - otherwise, the output line provides the latency statistics for the core/task pair
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       unsigned lcores[RTE_MAX_LCORE], tasks[MAX_TASKS_PER_CORE], lcore_id, task_id, nb_cores, nb_tasks;
+       if (parse_cores_tasks(str, lcores, tasks, &nb_cores, &nb_tasks)) {
+               if (input->reply) {
+                       char buf[128];
+                       snprintf(buf, sizeof(buf), "error: invalid syntax\n");
+                       input->reply(input, buf, strlen(buf));
+               }
                return -1;
+       }
 
-       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
-               for (unsigned int i = 0; i < nb_cores; i++) {
+       for (unsigned int i = 0; i < nb_cores; i++) {
+               for (unsigned int j = 0; j < nb_tasks; j++) {
                        lcore_id = lcores[i];
-                       if (!task_is_mode(lcore_id, task_id, "lat")) {
-                               plog_err("Core %u task %u is not measuring latency\n", lcore_id, task_id);
-                       }
-                       else {
-                               struct stats_latency *stats = stats_latency_find(lcore_id, task_id);
-                               struct stats_latency *tot = stats_latency_tot_find(lcore_id, task_id);
-
-                               uint64_t last_tsc = stats_core_task_last_tsc(lcore_id, task_id);
-                               uint64_t lat_min_usec = time_unit_to_usec(&stats->min.time);
-                               uint64_t lat_max_usec = time_unit_to_usec(&stats->max.time);
-                               uint64_t tot_lat_min_usec = time_unit_to_usec(&tot->min.time);
-                               uint64_t tot_lat_max_usec = time_unit_to_usec(&tot->max.time);
-                               uint64_t lat_avg_usec = time_unit_to_usec(&stats->avg.time);
-
+                       task_id = tasks[j];
+                       if (core_task_is_valid(lcore_id, task_id) == 0) {
                                if (input->reply) {
                                        char buf[128];
-                                       snprintf(buf, sizeof(buf),
-                                               "%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64"\n",
-                                                lat_min_usec,
-                                                lat_max_usec,
-                                                lat_avg_usec,
-                                                tot_lat_min_usec,
-                                                tot_lat_max_usec,
-                                                last_tsc,
-                                                rte_get_tsc_hz());
+                                       snprintf(buf, sizeof(buf), "error: invalid core %u, task %u\n", lcore_id, task_id);
                                        input->reply(input, buf, strlen(buf));
+                               } else {
+                                       plog_info("error: invalid core %u, task %u\n", lcore_id, task_id);
                                }
-                               else {
-                                       plog_info("min: %"PRIu64", max: %"PRIu64", avg: %"PRIu64", min since reset: %"PRIu64", max since reset: %"PRIu64"\n",
-                                                 lat_min_usec,
-                                                 lat_max_usec,
-                                                 lat_avg_usec,
-                                                 tot_lat_min_usec,
-                                                 tot_lat_max_usec);
+                               continue;
+                       }
+                       if ((mode_str) && (!task_is_mode(lcore_id, task_id, mode_str))) {
+                               if (input->reply) {
+                                       char buf[128];
+                                       snprintf(buf, sizeof(buf), "error: core %u task %u is not measuring %s\n", lcore_id, task_id, mode_name);
+                                       input->reply(input, buf, strlen(buf));
+                               } else {
+                                       plog_info("error: core %u task %u is not measuring %s\n", lcore_id, task_id, mode_name);
                                }
+                               continue;
                        }
+                       f(lcore_id, task_id, input);
                }
        }
        return 0;
 }
 
-static int parse_cmd_irq(const char *str, struct input *input)
+static void handle_dp_core_stats(unsigned lcore_id, unsigned task_id, struct input *input)
 {
-       unsigned int i, c;
-       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+       uint64_t tot_rx = stats_core_task_tot_rx(lcore_id, task_id);
+       uint64_t tot_tx = stats_core_task_tot_tx(lcore_id, task_id);
+       uint64_t tot_tx_fail = stats_core_task_tot_tx_fail(lcore_id, task_id);
+       uint64_t tot_rx_non_dp = stats_core_task_tot_rx_non_dp(lcore_id, task_id);
+       uint64_t tot_tx_non_dp = stats_core_task_tot_tx_non_dp(lcore_id, task_id);
+       uint64_t tot_drop = stats_core_task_tot_drop(lcore_id, task_id);
+       uint64_t last_tsc = stats_core_task_last_tsc(lcore_id, task_id);
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
-               return -1;
-
-       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
-               for (c = 0; c < nb_cores; c++) {
-                       lcore_id = lcores[c];
-                       if (!task_is_mode(lcore_id, task_id, "irq")) {
-                               plog_err("Core %u task %u is not in irq mode\n", lcore_id, task_id);
-                       } else {
-                               struct task_irq *task_irq = (struct task_irq *)(lcore_cfg[lcore_id].tasks_all[task_id]);
+       if (input->reply) {
+               char buf[128];
+               snprintf(buf, sizeof(buf),
+                       "%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%u,%u\n",
+                       tot_rx, tot_tx, tot_rx_non_dp, tot_tx_non_dp, tot_drop, tot_tx_fail, last_tsc, rte_get_tsc_hz(), lcore_id, task_id);
+               input->reply(input, buf, strlen(buf));
+       }
+       else {
+               plog_info("core: %u, task: %u, RX: %"PRIu64", TX: %"PRIu64", RX_NON_DP: %"PRIu64", TX_NON_DP: %"PRIu64", DROP: %"PRIu64", TX_FAIL: %"PRIu64"\n",
+                       lcore_id, task_id, tot_rx, tot_tx, tot_rx_non_dp, tot_tx_non_dp, tot_drop, tot_tx_fail);
+       }
+}
 
-                               task_irq_show_stats(task_irq, input);
-                       }
+static void handle_lat_stats(unsigned lcore_id, unsigned task_id, struct input *input)
+{
+       struct stats_latency *stats = stats_latency_find(lcore_id, task_id);
+       struct stats_latency *tot = stats_latency_tot_find(lcore_id, task_id);
+       if (!stats || !tot) {
+               if (input->reply) {
+                       char buf[128];
+                       snprintf(buf, sizeof(buf),
+                                "error: core %u task %u stats = %p tot = %p\n",
+                                lcore_id, task_id, stats, tot);
+                       input->reply(input, buf, strlen(buf));
+               } else {
+                       plog_info("error: core %u task %u stats = %p tot = %p\n",
+                                 lcore_id, task_id, stats, tot);
                }
+               return;
+       }
+
+       uint64_t last_tsc = stats_core_task_last_tsc(lcore_id, task_id);
+       uint64_t lat_min_usec = time_unit_to_usec(&stats->min.time);
+       uint64_t lat_max_usec = time_unit_to_usec(&stats->max.time);
+       uint64_t tot_lat_min_usec = time_unit_to_usec(&tot->min.time);
+       uint64_t tot_lat_max_usec = time_unit_to_usec(&tot->max.time);
+       uint64_t lat_avg_usec = time_unit_to_usec(&stats->avg.time);
+
+       if (input->reply) {
+               char buf[128];
+               snprintf(buf, sizeof(buf),
+                        "%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%u,%u\n",
+                        lat_min_usec,
+                        lat_max_usec,
+                        lat_avg_usec,
+                        tot_lat_min_usec,
+                        tot_lat_max_usec,
+                        last_tsc,
+                        rte_get_tsc_hz(),
+                        lcore_id,
+                        task_id);
+               input->reply(input, buf, strlen(buf));
+       }
+       else {
+               plog_info("core: %u, task: %u, min: %"PRIu64", max: %"PRIu64", avg: %"PRIu64", min since reset: %"PRIu64", max since reset: %"PRIu64"\n",
+                         lcore_id,
+                         task_id,
+                         lat_min_usec,
+                         lat_max_usec,
+                         lat_avg_usec,
+                         tot_lat_min_usec,
+                         tot_lat_max_usec);
        }
-       return 0;
 }
 
-static void task_lat_show_latency_histogram(uint8_t lcore_id, uint8_t task_id, struct input *input)
-{
 #ifdef LATENCY_HISTOGRAM
+static void handle_latency_histogram(unsigned lcore_id, unsigned task_id, struct input *input)
+{
        uint64_t *buckets;
 
        stats_core_lat_histogram(lcore_id, task_id, &buckets);
 
-       if (buckets == NULL)
+       if (buckets == NULL) {
+               if (input->reply) {
+                       char buf[128];
+                       snprintf(buf, sizeof(buf), "error: unexpected NULL bucket\n");
+                       input->reply(input, buf, strlen(buf));
+               }
                return;
+       }
 
        if (input->reply) {
                char buf[4096] = {0};
-               for (size_t i = 0; i < 128; i++)
+               for (size_t i = 0; i < LAT_BUCKET_COUNT; i++)
                        sprintf(buf+strlen(buf), "Bucket [%zu]: %"PRIu64"\n", i, buckets[i]);
                input->reply(input, buf, strlen(buf));
        }
        else {
-               for (size_t i = 0; i < 128; i++)
+               for (size_t i = 0; i < LAT_BUCKET_COUNT; i++)
                        if (buckets[i])
                                plog_info("Bucket [%zu]: %"PRIu64"\n", i, buckets[i]);
        }
-#else
-       plog_info("LATENCY_DETAILS disabled\n");
+}
+
+static void handle_stats_and_packets(unsigned lcore_id, unsigned task_id, struct input *input)
+{
+       handle_lat_stats(lcore_id, task_id, input);
+       handle_latency_histogram(lcore_id, task_id, input);
+}
 #endif
+
+static int parse_cmd_dp_core_stats(const char *str, struct input *input)
+{
+       handle_cores_tasks(str, input, NULL, NULL, handle_dp_core_stats);
+       return 0;
+}
+
+static int parse_cmd_lat_stats(const char *str, struct input *input)
+{
+       handle_cores_tasks(str, input, "lat", "latency", handle_lat_stats);
+       return 0;
 }
 
 static int parse_cmd_lat_packets(const char *str, struct input *input)
 {
+#ifdef LATENCY_HISTOGRAM
+       handle_cores_tasks(str, input, "lat", "latency", handle_latency_histogram);
+#else
+       if (input->reply) {
+               char buf[128];
+               snprintf(buf, sizeof(buf), "error: invalid syntax (LATENCY_HISTOGRAM disabled)\n");
+               input->reply(input, buf, strlen(buf));
+       } else {
+               plog_info("LATENCY_HISTOGRAMS disabled\n");
+       }
+#endif
+       return 0;
+}
+
+static int parse_cmd_lat_stats_and_packets(const char *str, struct input *input)
+{
+#ifdef LATENCY_HISTOGRAM
+       handle_cores_tasks(str, input, "lat", "latency", handle_stats_and_packets);
+#else
+       if (input->reply) {
+               char buf[128];
+               snprintf(buf, sizeof(buf), "error: invalid syntax (LATENCY_HISTOGRAMS disabled)\n");
+               input->reply(input, buf, strlen(buf));
+       } else {
+               plog_info("LATENCY_HISTOGRAMS disabled\n");
+       }
+#endif
+       return 0;
+}
+
+static int parse_cmd_show_irq_buckets(const char *str, struct input *input)
+{
+       char buf[4096] = {0};
+       unsigned int i, c;
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
 
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
-               for (unsigned int i = 0; i < nb_cores; i++) {
-                       lcore_id = lcores[i];
-                       if (!task_is_mode(lcore_id, task_id, "lat")) {
-                               plog_err("Core %u task %u is not measuring latency\n", lcore_id, task_id);
-                       }
-                       else {
-                               task_lat_show_latency_histogram(lcore_id, task_id, input);
+               for (c = 0; c < nb_cores; c++) {
+                       lcore_id = lcores[c];
+                       get_irq_buckets_by_core_task(buf, lcore_id, task_id);
+                       plog_info("%s", buf);
+                       if (input->reply)
+                               input->reply(input, buf, strlen(buf));
+                       buf[0] = 0;
+               }
+       }
+       return 0;
+}
+
+static int parse_cmd_irq(const char *str, struct input *input)
+{
+       unsigned int i, c;
+       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
+               return -1;
+
+       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
+               for (c = 0; c < nb_cores; c++) {
+                       lcore_id = lcores[c];
+                       if (!task_is_mode(lcore_id, task_id, "irq")) {
+                               plog_err("Core %u task %u is not in irq mode\n", lcore_id, task_id);
+                       } else {
+                               struct task_irq *task_irq = (struct task_irq *)(lcore_cfg[lcore_id].tasks_all[task_id]);
+
+                               task_irq_show_stats(task_irq, input);
                        }
                }
        }
@@ -1739,7 +2038,7 @@ static int parse_cmd_cgnat_public_hash(const char *str, struct input *input)
 {
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
 
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
@@ -1763,7 +2062,7 @@ static int parse_cmd_cgnat_private_hash(const char *str, struct input *input)
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
        uint32_t val;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
 
        if (cores_task_are_valid(lcores, task_id, nb_cores)) {
@@ -1787,7 +2086,7 @@ static int parse_cmd_accuracy(const char *str, struct input *input)
        unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
        uint32_t val;
 
-       if (parse_core_task(str, lcores, &task_id, &nb_cores))
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
                return -1;
        if (!(str = strchr_skip_twice(str, ' ')))
                return -1;
@@ -1811,6 +2110,81 @@ static int parse_cmd_accuracy(const char *str, struct input *input)
        return 0;
 }
 
+static int parse_cmd_leave_igmp(const char *str, struct input *input)
+{
+       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
+               return -1;
+
+       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
+               for (unsigned int i = 0; i < nb_cores; i++) {
+                       lcore_id = lcores[i];
+
+                       if (!task_is_mode(lcore_id, task_id, "swap")) {
+                               plog_err("Core %u task %u is not running swap\n", lcore_id, task_id);
+                       }
+                       else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               igmp_leave_group(tbase);
+                       }
+               }
+       }
+       return 0;
+}
+
+static int parse_cmd_join_igmp(const char *str, struct input *input)
+{
+       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+       uint32_t igmp_ip;
+       uint8_t *igmp_bytes = (uint8_t *)&igmp_ip;
+
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
+               return -1;
+       if (!(str = strchr_skip_twice(str, ' ')))
+               return -1;
+       if (sscanf(str, "%hhu.%hhu.%hhu.%hhu", igmp_bytes, igmp_bytes + 1, igmp_bytes + 2, igmp_bytes + 3) != 4) {
+               return -1;
+       }
+       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
+               for (unsigned int i = 0; i < nb_cores; i++) {
+                       lcore_id = lcores[i];
+
+                       if (!task_is_mode(lcore_id, task_id, "swap")) {
+                               plog_err("Core %u task %u is not running swap\n", lcore_id, task_id);
+                       }
+                       else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               igmp_join_group(tbase, igmp_ip);
+                       }
+               }
+       }
+       return 0;
+}
+
+static int parse_cmd_send_unsollicited_na(const char *str, struct input *input)
+{
+       unsigned lcores[RTE_MAX_LCORE], lcore_id, task_id, nb_cores;
+
+       if (parse_cores_task(str, lcores, &task_id, &nb_cores))
+               return -1;
+
+       if (cores_task_are_valid(lcores, task_id, nb_cores)) {
+               for (unsigned int i = 0; i < nb_cores; i++) {
+                       lcore_id = lcores[i];
+
+                       if (!task_is_sub_mode(lcore_id, task_id, "ndp")) {
+                               plog_err("Core %u task %u is not running ndp\n", lcore_id, task_id);
+                       }
+                       else {
+                               struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id];
+                               send_unsollicited_neighbour_advertisement(tbase);
+                       }
+               }
+       }
+       return 0;
+}
+
 static int parse_cmd_rx_tx_info(const char *str, struct input *input)
 {
        if (strcmp(str, "") != 0) {
@@ -1885,6 +2259,7 @@ static struct cmd_str cmd_strings[] = {
        {"bypass", "<core_id> <task_id>", "Bypass task", parse_cmd_bypass},
        {"reconnect", "<core_id> <task_id>", "Reconnect task", parse_cmd_reconnect},
        {"pkt_size", "<core_id> <task_id> <pkt_size>", "Set the packet size to <pkt_size>", parse_cmd_pkt_size},
+       {"imix", "<core_id> <task_id> <pkt_size,pkt_size ... >", "Set the packet sizes to <pkt_size>", parse_cmd_imix},
        {"speed", "<core_id> <task_id> <speed percentage>", "Change the speed to <speed percentage> at which packets are being generated on core <core_id> in task <task_id>.", parse_cmd_speed},
        {"speed_byte", "<core_id> <task_id> <speed>", "Change speed to <speed>. The speed is specified in units of bytes per second.", parse_cmd_speed_byte},
        {"set value", "<core_id> <task_id> <offset> <value> <value_len>", "Set <value_len> bytes to <value> at offset <offset> in packets generated on <core_id> <task_id>", parse_cmd_set_value},
@@ -1907,10 +2282,14 @@ static struct cmd_str cmd_strings[] = {
        {"tot imissed tot", "", "Print total number of imissed since reset", parse_cmd_tot_imissed_tot},
        {"lat stats", "<core id> <task id>", "Print min,max,avg latency as measured during last sampling interval", parse_cmd_lat_stats},
        {"irq stats", "<core id> <task id>", "Print irq related infos", parse_cmd_irq},
+       {"show irq buckets", "<core id> <task id>", "Print irq buckets", parse_cmd_show_irq_buckets},
        {"lat packets", "<core id> <task id>", "Print the latency for each of the last set of packets", parse_cmd_lat_packets},
+       {"lat all stats", "<core id> <task id>", "Print the latency for each of the last set of packets as well as latency distribution", parse_cmd_lat_stats_and_packets},
        {"accuracy limit", "<core id> <task id> <nsec>", "Only consider latency of packets that were measured with an error no more than <nsec>", parse_cmd_accuracy},
        {"core stats", "<core id> <task id>", "Print rx/tx/drop for task <task id> running on core <core id>", parse_cmd_core_stats},
+       {"dp core stats", "<core id> <task id>", "Print rx/tx/non_dp_rx/non_dp_tx/drop for task <task id> running on core <core id>", parse_cmd_dp_core_stats},
        {"port_stats", "<port id>", "Print rate for no_mbufs, ierrors + imissed, rx_bytes, tx_bytes, rx_pkts, tx_pkts; totals for RX, TX, no_mbufs, ierrors + imissed for port <port id>", parse_cmd_port_stats},
+       {"multi port stats", "<port list>", "Get stats for multiple ports, semi-colon separated: port id, total for rx_pkts, tx_pkts, no_mbufs, ierrors + imissed, last_tsc", parse_cmd_multi_port_stats},
        {"read reg", "", "Read register", parse_cmd_read_reg},
        {"write reg", "", "Read register", parse_cmd_write_reg},
        {"set vlan offload", "", "Set Vlan offload", parse_cmd_set_vlan_offload},
@@ -1921,7 +2300,9 @@ static struct cmd_str cmd_strings[] = {
        {"set cache class", "<core id> <class>", "Set cache class", parse_cmd_set_cache_class},
        {"get cache class", "<core id>", "Get cache class", parse_cmd_get_cache_class},
        {"get cache mask", "<core id>", "Get cache mask", parse_cmd_get_cache_mask},
-       {"reset port", "", "Reset port", parse_cmd_reset_port},
+       {"reset port", "<port id>", "Reset port", parse_cmd_reset_port},
+       {"enable multicast", "<port id> <MAC>", "Enable multicast", parse_cmd_enable_multicast},
+       {"disable multicast", "<port id> <MAC>", "Disable multicast", parse_cmd_disable_multicast},
        {"ring info all", "", "Get information about ring, such as ring size and number of elements in the ring", parse_cmd_ring_info_all},
        {"ring info", "<core id> <task id>", "Get information about ring on core <core id> in task <task id>, such as ring size and number of elements in the ring", parse_cmd_ring_info},
        {"port info", "<port id> [brief?]", "Get port related information, such as MAC address, socket, number of descriptors..., . Adding \"brief\" after command prints short version of output.", parse_cmd_port_info},
@@ -1929,13 +2310,21 @@ static struct cmd_str cmd_strings[] = {
        {"port down", "<port id>", "Set the port down", parse_cmd_port_down},
        {"port link state", "<port id>", "Get link state (up or down) for port", parse_cmd_port_link_state},
        {"port xstats", "<port id>", "Get extra statistics for the port", parse_cmd_xstats},
-       {"stats", "<stats_path>", "Get stats as sepcified by <stats_path>. A comma-separated list of <stats_path> can be supplied", parse_cmd_stats},
+       {"stats", "<stats_path>", "Get stats as specified by <stats_path>. A comma-separated list of <stats_path> can be supplied", parse_cmd_stats},
        {"cgnat dump public hash", "<core id> <task id>", "Dump cgnat public hash table", parse_cmd_cgnat_public_hash},
        {"cgnat dump private hash", "<core id> <task id>", "Dump cgnat private hash table", parse_cmd_cgnat_private_hash},
        {"delay_us", "<core_id> <task_id> <delay_us>", "Set the delay in usec for the impair mode to <delay_us>", parse_cmd_delay_us},
        {"random delay_us", "<core_id> <task_id> <random delay_us>", "Set the delay in usec for the impair mode to <random delay_us>", parse_cmd_random_delay_us},
-       {"probability", "<core_id> <task_id> <probability>", "Set the percent of forwarded packets for the impair mode", parse_cmd_set_probability},
+       {"probability", "<core_id> <task_id> <probability>", "Old - Use <proba no drop> instead. Set the percent of forwarded packets for the impair mode", parse_cmd_set_proba_no_drop}, // old - backward compatibility
+       {"proba no drop", "<core_id> <task_id> <probability>", "Set the percent of forwarded packets for the impair mode", parse_cmd_set_proba_no_drop},
+       {"proba delay", "<core_id> <task_id> <probability>", "Set the percent of delayed packets for the impair mode", parse_cmd_set_proba_delay},
+#if RTE_VERSION >= RTE_VERSION_NUM(19,11,0,0)
+       {"proba duplicate", "<core_id> <task_id> <probability>", "Set the percent of duplicate packets for the impair mode", parse_cmd_set_proba_duplicate},
+#endif
        {"version", "", "Show version", parse_cmd_version},
+       {"join igmp", "<core_id> <task_id> <ip>", "Send igmp membership report for group <ip>", parse_cmd_join_igmp},
+       {"leave igmp", "<core_id> <task_id>", "Send igmp leave group", parse_cmd_leave_igmp},
+       {"send unsollicited na", "<core_id> <task_id>", "Send Unsollicited Neighbor Advertisement", parse_cmd_send_unsollicited_na},
        {0,0,0,0},
 };
 
@@ -1979,7 +2368,7 @@ static int parse_cmd_help(const char *str, struct input *input)
 
                if (strlen(cmd_strings[i].args)) {
                        char tmp[256] = {0};
-                       strncpy(tmp, cmd_strings[i].args, 128);
+                       prox_strncpy(tmp, cmd_strings[i].args, 128);
                        snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "Arguments: %s\n", tmp);
                        len2 = len;
                        if (strlen(cmd_strings[i].help)) {
@@ -2011,6 +2400,9 @@ static int parse_cmd_help(const char *str, struct input *input)
                                                len3 = max_len;
                                }
 
+                               // Use strncpy here and not prox_strncpy. The dest (tmp) has been initialized with 0.
+                               // The fact that we are copying 80 characters potentially not null terminated is hence not an issue.
+                               // Using prox_strncpy here might cause a PROX_PANIC
                                strncpy(tmp, h, len3);
                                h += len3;
                                while (h[0] == ' ' && strlen(h))