Skip to content

Commit 1e5c7c4

Browse files
committed
Merge branch 'nos3#850' into nos3-dev
2 parents 309c1c4 + 8725a7d commit 1e5c7c4

4 files changed

Lines changed: 32 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ option(KEY_VALIDATION "Validate existance of key duplication" OFF)
6464
option(KMC_MDB_RH "KMC-MDB-RedHat-Integration-Testing" OFF) #Disabled by default, enable with: -DKMC_MDB_RH=ON
6565
option(KMC_MDB_DB "KMC-MDB-Debian-Integration-Testing" OFF) #Disabled by default, enable with: -DKMC_MDB_DB=ON
6666
option(CRYPTO_EPROC "Enables the building and use of Extended Procedures" OFF) #Disabled by default, enable with -DCRYPTO_EPROC=ON
67-
option(STANDALONE_TCP "Enables TCP support for standalone" OFF)
67+
# option(STANDALONE_TCP "Enables TCP support for standalone" OFF)
6868

6969
option(MAC_SIZE "The size of the max MAC buffer in bytes")
7070
option(IV_SIZE "The size of the max IV buffer in bytes")

support/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ find_package(Threads REQUIRED)
2121
include_directories("./standalone")
2222
add_executable(standalone
2323
./standalone/standalone.c)
24-
target_compile_definitions(standalone PUBLIC
25-
$<$<BOOL:${STANDALONE_TCP}>:STANDALONE_TCP=1>
26-
$<$<NOT:$<BOOL:${STANDALONE_TCP}>>:STANDALONE_TCP=0>
27-
)
24+
# target_compile_definitions(standalone PUBLIC
25+
# $<$<BOOL:${STANDALONE_TCP}>:STANDALONE_TCP=1>
26+
# $<$<NOT:$<BOOL:${STANDALONE_TCP}>>:STANDALONE_TCP=0>
27+
# )
2828
target_link_libraries(standalone crypto pthread)

support/standalone/standalone.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static volatile uint8_t tc_seq_num = 0;
3333
static volatile uint8_t tc_vcid = CRYPTO_STANDALONE_FRAMING_VCID;
3434
static volatile uint8_t tc_debug = 1;
3535
static volatile uint8_t tm_debug = 0;
36-
static volatile uint8_t crypto_use_tcp = STANDALONE_TCP ? 1 : 0;
36+
// static volatile uint8_t crypto_use_tcp = STANDALONE_TCP ? 1 : 0;
37+
static volatile uint8_t crypto_use_tcp = 0;
3738

3839
/*
3940
** Functions
@@ -421,7 +422,8 @@ int32_t crypto_standalone_socket_init(udp_info_t *sock, int32_t port, uint8_t bi
421422
}
422423
else
423424
{
424-
if (crypto_use_tcp == 0 && bind_sock == 1 && sock->port == TM_PROCESS_PORT)
425+
// if (crypto_use_tcp == 0 && bind_sock == 1 && sock->port == TM_PROCESS_PORT)
426+
if (crypto_use_tcp == 0 && bind_sock == 1)
425427
{
426428
status = bind(sock->sockfd, (struct sockaddr *)&sock->saddr, sizeof(sock->saddr));
427429
if (status != 0)
@@ -915,12 +917,28 @@ int main(int argc, char *argv[])
915917
int num_input_tokens;
916918
int cmd;
917919
char *token_ptr;
920+
char *tcp_var = getenv("STANDALONE_TCP");
921+
if (tcp_var != NULL) {
922+
crypto_use_tcp = atoi(tcp_var);
923+
} else {
924+
crypto_use_tcp = 1; // Default to TCP if the variable is not defined
925+
}
918926

919927
udp_interface_t tc_apply;
920928
udp_interface_t tm_process;
921929

922930
pthread_t tc_apply_thread;
923931
pthread_t tm_process_thread;
932+
char *CRYPTOLIB_HOSTNAME;
933+
CRYPTOLIB_HOSTNAME = getenv("CRYPTO_HOST");
934+
if (CRYPTOLIB_HOSTNAME == NULL) {
935+
CRYPTOLIB_HOSTNAME = "0.0.0.0"; //only using this if cant find hostname env variable
936+
}
937+
char *GSW_HOSTNAME;
938+
GSW_HOSTNAME = getenv("GSWALIAS");
939+
if (GSW_HOSTNAME == NULL) {
940+
GSW_HOSTNAME = "cosmos"; //default if env var not specified
941+
}
924942

925943
tc_apply.read.ip_address = CRYPTOLIB_HOSTNAME;
926944
tc_apply.read.port = TC_APPLY_PORT;
@@ -929,6 +947,9 @@ int main(int argc, char *argv[])
929947
tm_process.read.ip_address = CRYPTOLIB_HOSTNAME;
930948
tm_process.read.port = TM_PROCESS_PORT;
931949
tm_process.write.ip_address = GSW_HOSTNAME;
950+
if(strcmp(tm_process.write.ip_address, "yamcs")==0 && strcmp(CRYPTOLIB_HOSTNAME, "cryptolib2")==0){
951+
tm_process.read.port = 8013;
952+
}
932953
tm_process.write.port = TM_PROCESS_FWD_PORT;
933954

934955
printf("Starting CryptoLib in standalone mode! \n");
@@ -977,7 +998,8 @@ int main(int argc, char *argv[])
977998
if (keepRunning == CRYPTO_LIB_SUCCESS)
978999
{
9791000
status =
980-
crypto_standalone_socket_init(&tm_process.read, TM_PROCESS_PORT, 1, crypto_use_tcp); // tcp, accept() 8011
1001+
// crypto_standalone_socket_init(&tm_process.read, TM_PROCESS_PORT, 1, crypto_use_tcp); // tcp, accept() 8011
1002+
crypto_standalone_socket_init(&tm_process.read, tm_process.read.port, 1, crypto_use_tcp); // tcp, accept() 8011 or 8013
9811003
if (status != CRYPTO_LIB_SUCCESS)
9821004
{
9831005
printf("crypto_standalone_socket_init tm_apply.read failed with status %d \n", status);

support/standalone/standalone.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ extern "C"
4646
/*
4747
** Configuration
4848
*/
49-
#define CRYPTOLIB_HOSTNAME "cryptolib"
50-
#define GSW_HOSTNAME "cosmos"
49+
// #define CRYPTOLIB_HOSTNAME "cryptolib" //pulling from env variable
50+
// #define GSW_HOSTNAME "cosmos" //pulling form env variable
5151
#define SC_HOSTNAME "radio-sim"
5252

5353
#ifndef CRYPTO_RX_GROUND_PORT

0 commit comments

Comments
 (0)