examples/l2fwd-crypto: fix length of random IV/AAD
[dpdk.git] / examples / l2fwd-crypto / main.c
index 2722b0d..c323b55 100644 (file)
@@ -643,7 +643,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
                                port_cparams[i].aad.phys_addr = options->aad.phys_addr;
                                if (!options->aad_param)
                                        generate_random_key(port_cparams[i].aad.data,
-                                               sizeof(port_cparams[i].aad.length));
+                                               port_cparams[i].aad.length);
 
                        }
 
@@ -661,7 +661,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
                        port_cparams[i].iv.phys_addr = options->iv.phys_addr;
                        if (!options->iv_param)
                                generate_random_key(port_cparams[i].iv.data,
-                                               sizeof(port_cparams[i].iv.length));
+                                               port_cparams[i].iv.length);
 
                        port_cparams[i].cipher_algo = options->cipher_xform.cipher.algo;
                }
@@ -789,8 +789,8 @@ l2fwd_crypto_usage(const char *prgname)
        printf("%s [EAL options] --\n"
                "  -p PORTMASK: hexadecimal bitmask of ports to configure\n"
                "  -q NQ: number of queue (=ports) per lcore (default is 1)\n"
-               "  -s manage all ports from single lcore"
-               "  -t PERIOD: statistics will be refreshed each PERIOD seconds"
+               "  -s manage all ports from single lcore\n"
+               "  -T PERIOD: statistics will be refreshed each PERIOD seconds"
                " (0 to disable, 10 default, 86400 maximum)\n"
 
                "  --cdev_type HW / SW / ANY\n"
@@ -859,6 +859,9 @@ parse_cipher_algo(enum rte_crypto_cipher_algorithm *algo, char *optarg)
        } else if (strcmp("AES_GCM", optarg) == 0) {
                *algo = RTE_CRYPTO_CIPHER_AES_GCM;
                return 0;
+       } else if (strcmp("NULL", optarg) == 0) {
+               *algo = RTE_CRYPTO_CIPHER_NULL;
+               return 0;
        } else if (strcmp("SNOW3G_UEA2", optarg) == 0) {
                *algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
                return 0;
@@ -910,9 +913,15 @@ parse_key(uint8_t *data, char *input_arg)
 static int
 parse_auth_algo(enum rte_crypto_auth_algorithm *algo, char *optarg)
 {
-       if (strcmp("MD5_HMAC", optarg) == 0) {
+       if (strcmp("AES_GCM", optarg) == 0) {
+               *algo = RTE_CRYPTO_AUTH_AES_GCM;
+               return 0;
+       } else if (strcmp("MD5_HMAC", optarg) == 0) {
                *algo = RTE_CRYPTO_AUTH_MD5_HMAC;
                return 0;
+       } else if (strcmp("NULL", optarg) == 0) {
+               *algo = RTE_CRYPTO_AUTH_NULL;
+               return 0;
        } else if (strcmp("SHA1_HMAC", optarg) == 0) {
                *algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
                return 0;
@@ -959,8 +968,12 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,
 {
        int retval;
 
-       if (strcmp(lgopts[option_index].name, "cdev_type") == 0)
-               return parse_cryptodev_type(&options->type, optarg);
+       if (strcmp(lgopts[option_index].name, "cdev_type") == 0) {
+               retval = parse_cryptodev_type(&options->type, optarg);
+               if (retval == 0)
+                       strcpy(options->string_type, optarg);
+               return retval;
+       }
 
        else if (strcmp(lgopts[option_index].name, "chain") == 0)
                return parse_crypto_opt_chain(options, optarg);
@@ -1211,7 +1224,7 @@ l2fwd_crypto_parse_args(struct l2fwd_crypto_options *options,
                        break;
 
                /* timer period */
-               case 't':
+               case 'T':
                        retval = l2fwd_crypto_parse_timer_period(options,
                                        optarg);
                        if (retval < 0) {