Browse Source

1

nodeinfo-routing-update
jeka 4 weeks ago
parent
commit
5816fbea70
  1. 2
      lib/debug_config.c
  2. 2
      lib/debug_config.h
  3. 2
      src/etcp.h
  4. 10
      src/secure_channel.c
  5. 2
      tests/test_pkt_normalizer_etcp.c
  6. 2
      tests/test_pkt_normalizer_standalone.c
  7. 2
      tests/test_u_async_performance.c

2
lib/debug_config.c

@ -269,7 +269,7 @@ void debug_output(debug_level_t level, debug_category_t category,
/* Add timestamp with microseconds: hh:mm:ss-xxx.yyy */ /* Add timestamp with microseconds: hh:mm:ss-xxx.yyy */
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); utun_gettimeofday(&tv, NULL);
time_t tv_sec = (time_t)tv.tv_sec; time_t tv_sec = (time_t)tv.tv_sec;
struct tm* tm_info = localtime(&tv_sec); struct tm* tm_info = localtime(&tv_sec);
char time_str[32]; char time_str[32];

2
lib/debug_config.h

@ -53,7 +53,7 @@ typedef uint64_t debug_category_t;
#define DEBUG_CATEGORY_CONTROL ((debug_category_t)1 << 14) // Control/monitoring server #define DEBUG_CATEGORY_CONTROL ((debug_category_t)1 << 14) // Control/monitoring server
#define DEBUG_CATEGORY_DUMP ((debug_category_t)1 << 15) // Packet dump/logging #define DEBUG_CATEGORY_DUMP ((debug_category_t)1 << 15) // Packet dump/logging
#define DEBUG_CATEGORY_COUNT 16 // Total number of categories #define DEBUG_CATEGORY_COUNT 16 // Total number of categories
#define DEBUG_CATEGORY_ALL ((debug_category_t)0xFFFFFFFFFFFFFFFFULL) #define DEBUG_CATEGORY_ALL ((debug_category_t)0xFFFFFFFFUL)
/* Debug configuration structure */ /* Debug configuration structure */
typedef struct { typedef struct {

2
src/etcp.h

@ -78,7 +78,7 @@ struct ETCP_CONN {
// Crypto and state // Crypto and state
struct secure_channel crypto_ctx; struct secure_channel crypto_ctx;
struct pn_pair* normalizer; struct PKTNORM* normalizer;
// Peer info // Peer info
uint64_t peer_node_id; // Peer node ID uint64_t peer_node_id; // Peer node ID

10
src/secure_channel.c

@ -4,6 +4,8 @@
#include <config.h> #include <config.h>
#endif #endif
#define OPENSSL_API_COMPAT 0x10100000L
#include "secure_channel.h" #include "secure_channel.h"
#include "../lib/debug_config.h" #include "../lib/debug_config.h"
#include "../lib/platform_compat.h" #include "../lib/platform_compat.h"
@ -141,7 +143,7 @@ static int sc_rng(uint8_t *dest, unsigned size) {
pid_t pid = getpid(); pid_t pid = getpid();
#endif #endif
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); utun_gettimeofday(&tv, NULL);
for (unsigned i = 0; i < size; i++) { for (unsigned i = 0; i < size; i++) {
dest[i] ^= ((pid >> (i % (sizeof(pid) * 8))) & 0xFF); dest[i] ^= ((pid >> (i % (sizeof(pid) * 8))) & 0xFF);
dest[i] ^= ((tv.tv_sec >> (i % (sizeof(tv.tv_sec) * 8))) & 0xFF); dest[i] ^= ((tv.tv_sec >> (i % (sizeof(tv.tv_sec) * 8))) & 0xFF);
@ -336,7 +338,7 @@ static void sc_build_nonce(uint64_t counter, uint8_t *nonce_out) {
if (!sc_urandom_initialized) { if (!sc_urandom_initialized) {
sc_init_random_seed(); sc_init_random_seed();
} }
gettimeofday(&tv, NULL); utun_gettimeofday(&tv, NULL);
memcpy(data, sc_urandom_seed, 8); memcpy(data, sc_urandom_seed, 8);
data[8] = (counter >> 0) & 0xFF; data[8] = (counter >> 0) & 0xFF;
data[9] = (counter >> 8) & 0xFF; data[9] = (counter >> 8) & 0xFF;
@ -515,7 +517,7 @@ static int sc_rng(uint8_t *dest, unsigned size)
pid_t pid = getpid(); pid_t pid = getpid();
#endif #endif
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); utun_gettimeofday(&tv, NULL);
for (unsigned i = 0; i < size; i++) { for (unsigned i = 0; i < size; i++) {
dest[i] ^= ((pid >> (i % (sizeof(pid) * 8))) & 0xFF); dest[i] ^= ((pid >> (i % (sizeof(pid) * 8))) & 0xFF);
dest[i] ^= ((tv.tv_sec >> (i % (sizeof(tv.tv_sec) * 8))) & 0xFF); dest[i] ^= ((tv.tv_sec >> (i % (sizeof(tv.tv_sec) * 8))) & 0xFF);
@ -666,7 +668,7 @@ static void sc_build_nonce(uint64_t counter, uint8_t *nonce_out)
sc_init_random_seed(); sc_init_random_seed();
} }
gettimeofday(&tv, NULL); utun_gettimeofday(&tv, NULL);
memcpy(data, sc_urandom_seed, 8); memcpy(data, sc_urandom_seed, 8);
data[8] = (counter >> 0) & 0xFF; data[8] = (counter >> 0) & 0xFF;

2
tests/test_pkt_normalizer_etcp.c

@ -25,6 +25,8 @@
#include "../lib/debug_config.h" #include "../lib/debug_config.h"
#include "../lib/mem.h" #include "../lib/mem.h"
extern int pn_packer_send(void* pn, const uint8_t* buffer, size_t size);
#define TEST_TIMEOUT_MS 3000 // 3 second timeout #define TEST_TIMEOUT_MS 3000 // 3 second timeout
#define TOTAL_PACKETS 100 // Total packets to send #define TOTAL_PACKETS 100 // Total packets to send
//#define MAX_QUEUE_SIZE 5 // Max packets in input queue //#define MAX_QUEUE_SIZE 5 // Max packets in input queue

2
tests/test_pkt_normalizer_standalone.c

@ -29,6 +29,8 @@ void etcp_conn_reinit(struct ETCP_CONN* etcp) {
#include "../src/utun_instance.h" #include "../src/utun_instance.h"
#include "../lib/mem.h" #include "../lib/mem.h"
extern int pn_packer_send(void* pn, const uint8_t* buffer, size_t size);
// Test state // Test state
static struct UTUN_INSTANCE mock_instance; static struct UTUN_INSTANCE mock_instance;
static struct ETCP_CONN mock_etcp; static struct ETCP_CONN mock_etcp;

2
tests/test_u_async_performance.c

@ -21,7 +21,7 @@
/* Performance measurement */ /* Performance measurement */
static uint64_t get_time_us(void) { static uint64_t get_time_us(void) {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); utun_gettimeofday(&tv, NULL);
return (uint64_t)tv.tv_sec * 1000000ULL + tv.tv_usec; return (uint64_t)tv.tv_sec * 1000000ULL + tv.tv_usec;
} }

Loading…
Cancel
Save