#include "port-bonding.h"
#include "string.h"
-const struct nw_string_table nw_port_bonding_mode[] = {
+const nw_string_table_t nw_port_bonding_mode[] = {
{ NW_BONDING_MODE_ROUNDROBIN, "round-robin" },
{ NW_BONDING_MODE_ACTIVEBACKUP, "active-backup" },
{ NW_BONDING_MODE_XOR, "xor" },
NW_STRING_TABLE_LOOKUP(nw_port_bonding_mode_t, nw_port_bonding_mode)
-static int nw_port_bonding_read_mode(nw_config* config, const char* key, void* data) {
- int* mode = (int*)data;
-
- const char* value = nw_config_get(config, key);
- if (value) {
- *mode = nw_port_bonding_mode_from_string(value);
- if (!*mode)
- return -errno;
- }
-
- return 0;
-}
-
-static int nw_port_bonding_write_mode(nw_config* config, const char* key, const void* data) {
- const int* mode = (int*)data;
-
- return nw_config_set(config, key, nw_port_bonding_mode_to_string(*mode));
-}
-
static int nw_port_bonding_setup(nw_port* port) {
int r;
// Mode
- r = NW_CONFIG_OPTION(port->config, "BONDING_MODE", &port->bonding.mode,
- nw_port_bonding_read_mode, nw_port_bonding_write_mode);
+ r = NW_CONFIG_OPTION_STRING_TABLE(port->config,
+ "BONDING_MODE", &port->bonding.mode, nw_port_bonding_mode);
if (r < 0)
return r;