Просмотр исходного кода

defect 833
Rabbe reported that the encoding of the ipv4 address in SaClmNodeAddressT is incorrect


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@804 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 20 лет назад
Родитель
Сommit
478307dfed
2 измененных файлов с 6 добавлено и 5 удалено
  1. 4 4
      exec/clm.c
  2. 2 1
      test/testclm.c

+ 4 - 4
exec/clm.c

@@ -199,10 +199,10 @@ static int clm_exec_init_fn (struct openais_config *openais_config)
 	 * Build local cluster node data structure
 	 */
 	thisClusterNode.nodeId = this_ip->sin_addr.s_addr;
-	memcpy (&thisClusterNode.nodeAddress.value, &this_ip->sin_addr,
-		sizeof (struct in_addr));
-	thisClusterNode.nodeAddress.length = sizeof (struct in_addr);
-	strcpy ((char *)thisClusterNode.nodeName.value, (char *)inet_ntoa (this_ip->sin_addr));
+	sprintf (thisClusterNode.nodeAddress.value, "%s", inet_ntoa (this_ip->sin_addr));
+	thisClusterNode.nodeAddress.length = strlen (thisClusterNode.nodeAddress.value);
+	thisClusterNode.nodeAddress.family = SA_CLM_AF_INET;
+	sprintf (thisClusterNode.nodeName.value, "%s", inet_ntoa (this_ip->sin_addr));
 	thisClusterNode.nodeName.length = strlen ((char *)thisClusterNode.nodeName.value);
 	thisClusterNode.member = 1;
 	{

+ 2 - 1
test/testclm.c

@@ -48,8 +48,9 @@
 void printSaClmNodeAddressT (SaClmNodeAddressT *nodeAddress) {
 	int i;
 
+	printf ("family=%d - address=", nodeAddress->family);
 	for (i = 0; i < nodeAddress->length; i++) {
-		printf ("%d.", nodeAddress->value[i]);
+		printf ("%c", nodeAddress->value[i]);
 	}
 }