Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ find_package(Threads REQUIRED)
include_directories("./standalone")
add_executable(standalone
./standalone/standalone.c)
target_compile_definitions(standalone PUBLIC
$<$<BOOL:${STANDALONE_TCP}>:STANDALONE_TCP=1>
$<$<NOT:$<BOOL:${STANDALONE_TCP}>>:STANDALONE_TCP=0>
)
# target_compile_definitions(standalone PUBLIC
# $<$<BOOL:${STANDALONE_TCP}>:STANDALONE_TCP=1>
# $<$<NOT:$<BOOL:${STANDALONE_TCP}>>:STANDALONE_TCP=0>
# )
target_link_libraries(standalone crypto pthread)
28 changes: 25 additions & 3 deletions support/standalone/standalone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions support/standalone/standalone.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading