hooklib: add adapter_hook_override to allow specifying network adapter id

This commit is contained in:
Will Xyen
2020-01-28 04:15:47 -05:00
parent a5fdecef61
commit c2e202f8b0
5 changed files with 108 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
#include "cconfig/cconfig-util.h"
#include "hooklib/config-adapter.h"
#include "util/log.h"
#define HOOKLIB_CONFIG_ADAPTER_OVERRIDE_IP_KEY "adapter.override_ip"
#define HOOKLIB_CONFIG_ADAPTER_DEFAULT_OVERRIDE_IP_VALUE ""
void hooklib_config_adapter_init(struct cconfig *config)
{
cconfig_util_set_str(
config,
HOOKLIB_CONFIG_ADAPTER_OVERRIDE_IP_KEY,
HOOKLIB_CONFIG_ADAPTER_DEFAULT_OVERRIDE_IP_VALUE,
"IP of adapter to force override with");
}
void hooklib_config_adapter_get(struct hooklib_config_adapter *config_adapter, struct cconfig *config)
{
if (!cconfig_util_get_str(
config,
HOOKLIB_CONFIG_ADAPTER_OVERRIDE_IP_KEY,
config_adapter->override_ip,
sizeof(config_adapter->override_ip),
HOOKLIB_CONFIG_ADAPTER_DEFAULT_OVERRIDE_IP_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
HOOKLIB_CONFIG_ADAPTER_OVERRIDE_IP_KEY,
HOOKLIB_CONFIG_ADAPTER_DEFAULT_OVERRIDE_IP_VALUE);
}
}