214 const char **list_str,
int machine_parseable_str,
215 const char *error_string_prefix,
const char **error_string)
218 struct knet_crypto_info crypto_list[16];
220 static char local_error_str[512];
221 static char local_list_str[256];
224 if (list_str != NULL) {
225 *list_str = local_list_str;
228 memset(local_error_str, 0,
sizeof(local_error_str));
229 memset(local_list_str, 0,
sizeof(local_list_str));
231 safe_strcat(local_error_str,
sizeof(local_error_str), error_string_prefix);
233 if (knet_get_crypto_list(NULL, &entries) != 0) {
234 *error_string =
"internal error - cannot get knet crypto list";
238 if (entries >
sizeof(crypto_list) /
sizeof(crypto_list[0])) {
239 *error_string =
"internal error - too many knet crypto list entries";
243 if (knet_get_crypto_list(crypto_list, &entries) != 0) {
244 *error_string =
"internal error - cannot get knet crypto list";
248 for (zi = 0; zi < entries; zi++) {
250 }
else if (zi == entries - 1) {
251 if (machine_parseable_str) {
252 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" ");
254 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" or ");
257 if (machine_parseable_str) {
258 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" ");
260 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
", ");
264 (void)safe_strcat(local_list_str,
sizeof(local_list_str), crypto_list[zi].name);
266 if (val != NULL && strcmp(val, crypto_list[zi].name) == 0) {
272 (void)safe_strcat(local_error_str,
sizeof(local_error_str), local_list_str);
273 *error_string = local_error_str;
276 return (model_found);
280 const char **list_str,
int machine_parseable_str,
281 const char *error_string_prefix,
const char **error_string)
284 struct knet_compress_info compress_list[16];
286 static char local_error_str[512];
287 static char local_list_str[256];
290 if (list_str != NULL) {
291 *list_str = local_list_str;
294 memset(local_error_str, 0,
sizeof(local_error_str));
295 memset(local_list_str, 0,
sizeof(local_list_str));
297 safe_strcat(local_error_str,
sizeof(local_error_str), error_string_prefix);
299 if (knet_get_compress_list(NULL, &entries) != 0) {
300 *error_string =
"internal error - cannot get knet compress list";
304 if (entries >
sizeof(compress_list) /
sizeof(compress_list[0])) {
305 *error_string =
"internal error - too many knet compress list entries";
309 if (knet_get_compress_list(compress_list, &entries) != 0) {
310 *error_string =
"internal error - cannot get knet compress list";
314 for (zi = 0; zi < entries; zi++) {
316 }
else if (zi == entries - 1) {
317 if (machine_parseable_str) {
318 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" ");
320 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" or ");
323 if (machine_parseable_str) {
324 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
" ");
326 (void)safe_strcat(local_list_str,
sizeof(local_list_str),
", ");
330 (void)safe_strcat(local_list_str,
sizeof(local_list_str), compress_list[zi].name);
332 if (val != NULL && strcmp(val, compress_list[zi].name) == 0) {
338 (void)safe_strcat(local_error_str,
sizeof(local_error_str), local_list_str);
339 *error_string = local_error_str;
342 return (model_found);
int util_is_valid_knet_crypto_model(const char *val, const char **list_str, int machine_parseable_str, const char *error_string_prefix, const char **error_string)
const char * short_service_name_get(uint32_t service_id, char *buf, size_t buf_size)
Get the short name of a service from the service_id.
int util_is_valid_knet_compress_model(const char *val, const char **list_str, int machine_parseable_str, const char *error_string_prefix, const char **error_string)