diff --git a/CMakeLists.txt b/CMakeLists.txt index b367015d..85c0b656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ option(KEY_VALIDATION "Validate existance of key duplication" OFF) option(KMC_MDB_RH "KMC-MDB-RedHat-Integration-Testing" OFF) #Disabled by default, enable with: -DKMC_MDB_RH=ON option(KMC_MDB_DB "KMC-MDB-Debian-Integration-Testing" OFF) #Disabled by default, enable with: -DKMC_MDB_DB=ON option(CRYPTO_EPROC "Enables the building and use of Extended Procedures" OFF) #Disabled by default, enable with -DCRYPTO_EPROC=ON -option(STANDALONE_TCP "Enables TCP support for standalone" OFF) +# option(STANDALONE_TCP "Enables TCP support for standalone" OFF) option(MAC_SIZE "The size of the max MAC buffer in bytes") option(IV_SIZE "The size of the max IV buffer in bytes") diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index 86061045..2720be8c 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -21,8 +21,8 @@ find_package(Threads REQUIRED) include_directories("./standalone") add_executable(standalone ./standalone/standalone.c) -target_compile_definitions(standalone PUBLIC - $<$:STANDALONE_TCP=1> - $<$>:STANDALONE_TCP=0> -) +# target_compile_definitions(standalone PUBLIC +# $<$:STANDALONE_TCP=1> +# $<$>:STANDALONE_TCP=0> +# ) target_link_libraries(standalone crypto pthread) diff --git a/support/standalone/standalone.c b/support/standalone/standalone.c index b4c53e9e..ae7f9a88 100644 --- a/support/standalone/standalone.c +++ b/support/standalone/standalone.c @@ -33,7 +33,8 @@ static volatile uint8_t tc_seq_num = 0; static volatile uint8_t tc_vcid = CRYPTO_STANDALONE_FRAMING_VCID; static volatile uint8_t tc_debug = 1; static volatile uint8_t tm_debug = 0; -static volatile uint8_t crypto_use_tcp = STANDALONE_TCP ? 1 : 0; +// static volatile uint8_t crypto_use_tcp = STANDALONE_TCP ? 1 : 0; +static volatile uint8_t crypto_use_tcp = 0; /* ** Functions @@ -421,7 +422,8 @@ int32_t crypto_standalone_socket_init(udp_info_t *sock, int32_t port, uint8_t bi } else { - if (crypto_use_tcp == 0 && bind_sock == 1 && sock->port == TM_PROCESS_PORT) + // if (crypto_use_tcp == 0 && bind_sock == 1 && sock->port == TM_PROCESS_PORT) + if (crypto_use_tcp == 0 && bind_sock == 1) { status = bind(sock->sockfd, (struct sockaddr *)&sock->saddr, sizeof(sock->saddr)); if (status != 0) @@ -915,12 +917,28 @@ int main(int argc, char *argv[]) int num_input_tokens; int cmd; char *token_ptr; + char *tcp_var = getenv("STANDALONE_TCP"); + if (tcp_var != NULL) { + crypto_use_tcp = atoi(tcp_var); + } else { + crypto_use_tcp = 1; // Default to TCP if the variable is not defined + } udp_interface_t tc_apply; udp_interface_t tm_process; pthread_t tc_apply_thread; pthread_t tm_process_thread; + char *CRYPTOLIB_HOSTNAME; + CRYPTOLIB_HOSTNAME = getenv("CRYPTO_HOST"); + if (CRYPTOLIB_HOSTNAME == NULL) { + CRYPTOLIB_HOSTNAME = "0.0.0.0"; //only using this if cant find hostname env variable + } + char *GSW_HOSTNAME; + GSW_HOSTNAME = getenv("GSWALIAS"); + if (GSW_HOSTNAME == NULL) { + GSW_HOSTNAME = "cosmos"; //default if env var not specified + } tc_apply.read.ip_address = CRYPTOLIB_HOSTNAME; tc_apply.read.port = TC_APPLY_PORT; @@ -929,6 +947,9 @@ int main(int argc, char *argv[]) tm_process.read.ip_address = CRYPTOLIB_HOSTNAME; tm_process.read.port = TM_PROCESS_PORT; tm_process.write.ip_address = GSW_HOSTNAME; + if(strcmp(tm_process.write.ip_address, "yamcs")==0 && strcmp(CRYPTOLIB_HOSTNAME, "cryptolib2")==0){ + tm_process.read.port = 8013; + } tm_process.write.port = TM_PROCESS_FWD_PORT; printf("Starting CryptoLib in standalone mode! \n"); @@ -977,7 +998,8 @@ int main(int argc, char *argv[]) if (keepRunning == CRYPTO_LIB_SUCCESS) { status = - crypto_standalone_socket_init(&tm_process.read, TM_PROCESS_PORT, 1, crypto_use_tcp); // tcp, accept() 8011 + // crypto_standalone_socket_init(&tm_process.read, TM_PROCESS_PORT, 1, crypto_use_tcp); // tcp, accept() 8011 + crypto_standalone_socket_init(&tm_process.read, tm_process.read.port, 1, crypto_use_tcp); // tcp, accept() 8011 or 8013 if (status != CRYPTO_LIB_SUCCESS) { printf("crypto_standalone_socket_init tm_apply.read failed with status %d \n", status); diff --git a/support/standalone/standalone.h b/support/standalone/standalone.h index c4857b5b..44e91f98 100644 --- a/support/standalone/standalone.h +++ b/support/standalone/standalone.h @@ -46,8 +46,8 @@ extern "C" /* ** Configuration */ -#define CRYPTOLIB_HOSTNAME "cryptolib" -#define GSW_HOSTNAME "cosmos" +// #define CRYPTOLIB_HOSTNAME "cryptolib" //pulling from env variable +// #define GSW_HOSTNAME "cosmos" //pulling form env variable #define SC_HOSTNAME "radio-sim" #ifndef CRYPTO_RX_GROUND_PORT