Przeglądaj źródła

totemconfig: totem_config_get_ip_version

Add totem_config_get_ip_version to get user configured ip version.
Make totem_config_read use this newly introduced function.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Jan Friesse 11 lat temu
rodzic
commit
10c80f454e
1 zmienionych plików z 20 dodań i 10 usunięć
  1. 20 10
      exec/totemconfig.c

+ 20 - 10
exec/totemconfig.c

@@ -391,6 +391,25 @@ static int totem_get_crypto(struct totem_config *totem_config)
 	return 0;
 }
 
+static int totem_config_get_ip_version(void)
+{
+	int res;
+	char *str;
+
+	res = AF_INET;
+	if (icmap_get_string("totem.ip_version", &str) == CS_OK) {
+		if (strcmp(str, "ipv4") == 0) {
+			res = AF_INET;
+		}
+		if (strcmp(str, "ipv6") == 0) {
+			res = AF_INET6;
+		}
+		free(str);
+	}
+
+	return (res);
+}
+
 static uint16_t generate_cluster_id (const char *cluster_name)
 {
 	int i;
@@ -710,16 +729,7 @@ extern int totem_config_read (
 		cluster_name = NULL;
 	}
 
-	totem_config->ip_version = AF_INET;
-	if (icmap_get_string("totem.ip_version", &str) == CS_OK) {
-		if (strcmp(str, "ipv4") == 0) {
-			totem_config->ip_version = AF_INET;
-		}
-		if (strcmp(str, "ipv6") == 0) {
-			totem_config->ip_version = AF_INET6;
-		}
-		free(str);
-	}
+	totem_config->ip_version = totem_config_get_ip_version();
 
 	if (icmap_get_string("totem.interface.0.bindnetaddr", &str) != CS_OK) {
 		/*