]> git.droids-corp.org - dpdk.git/blobdiff - lib/librte_cryptodev/rte_cryptodev.c
cryptodev: add algorithm string parsers
[dpdk.git] / lib / librte_cryptodev / rte_cryptodev.c
index fedb9d09972bec5b3e430b0f2b6f4b75c60e7276..f15f65ba2a8020016d315bf5f509ef61d34ecf9a 100644 (file)
@@ -187,6 +187,40 @@ rte_crypto_auth_algorithm_strings[] = {
        [RTE_CRYPTO_AUTH_ZUC_EIA3]      = "zuc-eia3"
 };
 
+int
+rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
+               const char *algo_string)
+{
+       unsigned int i;
+
+       for (i = 1; i < RTE_DIM(rte_crypto_cipher_algorithm_strings); i++) {
+               if (strcmp(algo_string, rte_crypto_cipher_algorithm_strings[i]) == 0) {
+                       *algo_enum = (enum rte_crypto_cipher_algorithm) i;
+                       return 0;
+               }
+       }
+
+       /* Invalid string */
+       return -1;
+}
+
+int
+rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
+               const char *algo_string)
+{
+       unsigned int i;
+
+       for (i = 1; i < RTE_DIM(rte_crypto_auth_algorithm_strings); i++) {
+               if (strcmp(algo_string, rte_crypto_auth_algorithm_strings[i]) == 0) {
+                       *algo_enum = (enum rte_crypto_auth_algorithm) i;
+                       return 0;
+               }
+       }
+
+       /* Invalid string */
+       return -1;
+}
+
 /**
  * The crypto auth operation strings identifiers.
  * It could be used in application command line.