| 2026 | |
| 2027 | |
| 2028 | int totem_config_validate ( |
| 2029 | struct totem_config *totem_config, |
| 2030 | const char **error_string) |
| 2031 | { |
| 2032 | static char local_error_reason[512]; |
| 2033 | char parse_error[512]; |
| 2034 | const char *error_reason = local_error_reason; |
| 2035 | int i; |
| 2036 | uint32_t u32; |
| 2037 | int num_configured = 0; |
| 2038 | unsigned int interface_max = INTERFACE_MAX; |
| 2039 | |
| 2040 | for (i = 0; i < INTERFACE_MAX; i++) { |
| 2041 | if (totem_config->interfaces[i].configured) { |
| 2042 | num_configured++; |
| 2043 | } |
| 2044 | } |
| 2045 | if (num_configured == 0) { |
| 2046 | error_reason = "No interfaces defined"; |
| 2047 | goto parse_error; |
| 2048 | } |
| 2049 | |
| 2050 | /* Check we found a local node name */ |
| 2051 | if (icmap_get_uint32("nodelist.local_node_pos", &u32) != CS_OK) { |
| 2052 | error_reason = "No valid name found for local host"; |
| 2053 | goto parse_error; |
| 2054 | } |
| 2055 | |
| 2056 | for (i = 0; i < INTERFACE_MAX; i++) { |
| 2057 | /* |
| 2058 | * Some error checking of parsed data to make sure its valid |
| 2059 | */ |
| 2060 | |
| 2061 | struct totem_ip_address null_addr; |
| 2062 | |
| 2063 | if (!totem_config->interfaces[i].configured) { |
| 2064 | continue; |
| 2065 | } |
| 2066 | |
| 2067 | memset (&null_addr, 0, sizeof (struct totem_ip_address)); |
| 2068 | |
| 2069 | if ((totem_config->transport_number == TOTEM_TRANSPORT_UDP) && |
| 2070 | memcmp (&totem_config->interfaces[i].mcast_addr, &null_addr, |
| 2071 | sizeof (struct totem_ip_address)) == 0) { |
| 2072 | snprintf (local_error_reason, sizeof(local_error_reason), |
| 2073 | "No multicast address specified for interface %u", i); |
| 2074 | goto parse_error; |
| 2075 | } |
| 2076 | |
| 2077 | if (totem_config->interfaces[i].ip_port == 0) { |
| 2078 | snprintf (local_error_reason, sizeof(local_error_reason), |
| 2079 | "No multicast port specified for interface %u", i); |
| 2080 | goto parse_error; |
| 2081 | } |
| 2082 | |
| 2083 | if (totem_config->interfaces[i].ttl > 255) { |
| 2084 | snprintf (local_error_reason, sizeof(local_error_reason), |
| 2085 | "Invalid TTL (should be 0..255) for interface %u", i); |
no test coverage detected