1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /*********************************************************************** 3 * Copyright (c) 2017-2018, Intel Corporation 4 * 5 * All rights reserved. 6 ***********************************************************************/ 7 #ifndef TEST_OPTIONS_H 8 #define TEST_OPTIONS_H 9 10 #include <stdint.h> 11 12 /* Default TCTI */ 13 #define TCTI_DEFAULT SOCKET_TCTI 14 #define TCTI_DEFAULT_STR "socket" 15 16 /* Defaults for Device TCTI */ 17 #define DEVICE_PATH_DEFAULT "/dev/tpm0" 18 19 /* Defaults for Socket TCTI connections */ 20 #define HOSTNAME_DEFAULT "127.0.0.1" 21 #define PORT_DEFAULT 2321 22 23 /* environment variables holding TCTI config */ 24 #define ENV_TCTI_NAME "TPM20TEST_TCTI_NAME" 25 #define ENV_DEVICE_FILE "TPM20TEST_DEVICE_FILE" 26 #define ENV_SOCKET_ADDRESS "TPM20TEST_SOCKET_ADDRESS" 27 #define ENV_SOCKET_PORT "TPM20TEST_SOCKET_PORT" 28 29 typedef enum { 30 UNKNOWN_TCTI, 31 DEVICE_TCTI, 32 SOCKET_TCTI, 33 FUZZING_TCTI, 34 N_TCTI, 35 } TCTI_TYPE; 36 37 typedef struct { 38 TCTI_TYPE tcti_type; 39 const char *device_file; 40 const char *socket_address; 41 uint16_t socket_port; 42 } test_opts_t; 43 44 /* functions to get test options from the user and to print helpful stuff */ 45 const char *tcti_name_from_type(TCTI_TYPE tcti_type); 46 TCTI_TYPE tcti_type_from_name(char const *tcti_str); 47 int get_test_opts_from_env(test_opts_t * opts); 48 int sanity_check_test_opts(test_opts_t * opts); 49 void dump_test_opts(test_opts_t * opts); 50 51 #endif /* TEST_OPTIONS_H */ 52