Skip to content

Commit

Permalink
Utility functions and validation for IPv6 LAN configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
LaMont Jones committed Apr 4, 2017
1 parent bd83b85 commit 442b4f7
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ipmi-config/ipmi-config-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,35 @@ ip_address_source_string (uint8_t value)
return "";
}

int
ipv6_ipv4_addressing_enables_number (const char *string)
{
assert (string);

if (same (string, "IPv6_Disabled"))
return (IPMI_IPV6_IPV4_ADDRESSING_ENABLES_IPV6_DISABLED);
if (same (string, "IPv6_Only"))
return (IPMI_IPV6_IPV4_ADDRESSING_ENABLES_IPV6_ONLY);
if (same (string, "IPv6_and_IPv4"))
return (IPMI_IPV6_IPV4_ADDRESSING_ENABLES_IPV6_AND_IPV4);
return (-1);
}

char *
ipv6_ipv4_addressing_enables_string (uint8_t value)
{
switch (value)
{
case IPMI_IPV6_IPV4_ADDRESSING_ENABLES_IPV6_DISABLED:
return "IPv6_Disabled";
case IPMI_IPV6_IPV4_ADDRESSING_ENABLES_IPV6_ONLY:
return "IPv6_Only";
case IPMI_IPV6_IPV4_ADDRESSING_ENABLES_IPV6_AND_IPV4:
return "IPv6_and_IPv4";
}
return "";
}

int
power_restore_policy_number (const char *string)
{
Expand Down
4 changes: 4 additions & 0 deletions ipmi-config/ipmi-config-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ int ip_address_source_number (const char *source);

char *ip_address_source_string (uint8_t source);

int ipv6_ipv4_addressing_enables_number (const char *source);

char *ipv6_ipv4_addressing_enables_string (uint8_t source);

int power_restore_policy_number (const char *string);

char *power_restore_policy_string (uint8_t value);
Expand Down
12 changes: 12 additions & 0 deletions ipmi-config/ipmi-config-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,3 +645,15 @@ get_sol_channel_number (ipmi_config_state_data_t *state_data,
return (rv);
}

ipmi_config_err_t
read_only_commit (ipmi_config_state_data_t *state_data,
const char *section_name,
const struct ipmi_config_keyvalue *kv)
{
/* Read only parameter */
pstdout_fprintf (state_data->pstate,
stderr,
"Ignoring attempt to set read-only configuration variable.\n");
return (IPMI_CONFIG_ERR_SUCCESS);
}

4 changes: 4 additions & 0 deletions ipmi-config/ipmi-config-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,8 @@ ipmi_config_err_t get_sol_channel_number (ipmi_config_state_data_t *state_data,
const char *section_name,
uint8_t *channel_number);

ipmi_config_err_t read_only_commit (ipmi_config_state_data_t *state_data,
const char *section_name,
const struct ipmi_config_keyvalue *kv);

#endif /* IPMI_CONFIG_UTILS_H */
34 changes: 34 additions & 0 deletions ipmi-config/ipmi-config-validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,24 @@ ip_address_validate (ipmi_config_state_data_t *state_data,
return (IPMI_CONFIG_VALIDATE_INVALID_VALUE);
}

ipmi_config_validate_t
ipv6_address_validate (ipmi_config_state_data_t *state_data,
const char *section_name,
const char *key_name,
const char *value)
{
struct in6_addr a;

assert (state_data);
assert (section_name);
assert (key_name);
assert (value);

if (inet_pton (AF_INET6, value, &a))
return (IPMI_CONFIG_VALIDATE_VALID_VALUE);
return (IPMI_CONFIG_VALIDATE_INVALID_VALUE);
}

ipmi_config_validate_t
mac_address_validate (ipmi_config_state_data_t *state_data,
const char *section_name,
Expand Down Expand Up @@ -335,6 +353,22 @@ ip_address_source_number_validate (ipmi_config_state_data_t *state_data,
return (IPMI_CONFIG_VALIDATE_INVALID_VALUE);
}

ipmi_config_validate_t
ipv6_ipv4_addressing_enables_validate (ipmi_config_state_data_t *state_data,
const char *section_name,
const char *key_name,
const char *value)
{
assert (state_data);
assert (section_name);
assert (key_name);
assert (value);

if (ipv6_ipv4_addressing_enables_number (value) >= 0)
return (IPMI_CONFIG_VALIDATE_VALID_VALUE);
return (IPMI_CONFIG_VALIDATE_INVALID_VALUE);
}

ipmi_config_validate_t
power_restore_policy_number_validate (ipmi_config_state_data_t *state_data,
const char *section_name,
Expand Down
10 changes: 10 additions & 0 deletions ipmi-config/ipmi-config-validate.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ ipmi_config_validate_t ip_address_validate (ipmi_config_state_data_t *state_data
const char *key_name,
const char *value);

ipmi_config_validate_t ipv6_address_validate (ipmi_config_state_data_t *state_data,
const char *section_name,
const char *key_name,
const char *value);

ipmi_config_validate_t mac_address_validate (ipmi_config_state_data_t *state_data,
const char *section_name,
const char *key_name,
Expand Down Expand Up @@ -109,6 +114,11 @@ ipmi_config_validate_t ip_address_source_number_validate (ipmi_config_state_data
const char *key_name,
const char *value);

ipmi_config_validate_t ipv6_ipv4_addressing_enables_validate (ipmi_config_state_data_t *state_data,
const char *section_name,
const char *key_name,
const char *value);

ipmi_config_validate_t power_restore_policy_number_validate (ipmi_config_state_data_t *state_data,
const char *section_name,
const char *key_name,
Expand Down

0 comments on commit 442b4f7

Please sign in to comment.