You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
921 B
30 lines
921 B
#include "utun_test_hooks.h" |
|
#include "utun_instance.h" |
|
#include "../lib/debug_config.h" |
|
|
|
// Add test category if not already defined |
|
#ifndef DEBUG_CATEGORY_TEST |
|
#define DEBUG_CATEGORY_TEST (1 << 30) // High bit for test category |
|
#endif |
|
|
|
// Global test hooks - NULL in production |
|
struct utun_test_hooks* g_utun_test_hooks = NULL; |
|
|
|
#ifdef TEST_BUILD |
|
void utun_test_hooks_set(struct utun_test_hooks* hooks) { |
|
if (!hooks) { |
|
DEBUG_ERROR(DEBUG_CATEGORY_TEST, "Attempt to set NULL test hooks"); |
|
return; |
|
} |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_TEST, "Setting test hooks: sendto=%p, recvfrom=%p, tun_create=%p", |
|
hooks->sendto_override, hooks->recvfrom_override, hooks->tun_create_override); |
|
|
|
g_utun_test_hooks = hooks; |
|
} |
|
|
|
void utun_test_hooks_clear(void) { |
|
DEBUG_INFO(DEBUG_CATEGORY_TEST, "Clearing test hooks (was: %p)", g_utun_test_hooks); |
|
g_utun_test_hooks = NULL; |
|
} |
|
#endif |