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

Endian cleanup for the clm service.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1156 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake 19 лет назад
Родитель
Сommit
2228f8b4ff
2 измененных файлов с 27 добавлено и 13 удалено
  1. 4 8
      exec/clm.c
  2. 23 5
      include/mar_clm.h

+ 4 - 8
exec/clm.c

@@ -1,10 +1,11 @@
 /*
  * Copyright (c) 2002-2006 MontaVista Software, Inc.
  * Copyright (c) 2006 Red Hat, Inc.
+ * Copyright (C) 2006 Sun Microsystems, Inc.
  *
  * All rights reserved.
  *
- * Author: Steven Dake (sdake@mvista.com)
+ * Author: Steven Dake (sdake@redhat.com)
  *
  * This software licensed under BSD license, the text of which follows:
  * 
@@ -70,7 +71,6 @@
 #include "ipc.h"
 #include "mempool.h"
 #include "service.h"
-#include "../include/swab.h"
 #include "print.h"
 
 enum clm_message_req_types {
@@ -575,12 +575,8 @@ static void exec_clm_nodejoin_endian_convert (void *msg)
 {
 	struct req_exec_clm_nodejoin *node_join = msg;
 
-	node_join->cluster_node.node_id = swab32(node_join->cluster_node.node_id);
-	node_join->cluster_node.node_address.family = swab32(node_join->cluster_node.node_address.family);
-	node_join->cluster_node.node_address.length = swab16(node_join->cluster_node.node_address.length);
-	node_join->cluster_node.initial_view_number = swab64(node_join->cluster_node.initial_view_number);
-	node_join->cluster_node.boot_timestamp = swab64(node_join->cluster_node.boot_timestamp);
-
+	swab_mar_req_header_t (&node_join->header);
+	swab_mar_clm_cluster_node_t (&node_join->cluster_node);
 }
 
 static void message_handler_req_exec_clm_nodejoin (

+ 23 - 5
include/mar_clm.h

@@ -1,9 +1,10 @@
 /*
  * Copyright (C) 2006 Red Hat, Inc.
+ * Copyright (C) 2006 Sun Microsystems, Inc.
  *
  * All rights reserved.
  *
- * Author: Steven Dake (sdake@mvista.com)
+ * Author: Steven Dake (sdake@redhat.com)
  *
  * This software licensed under BSD license, the text of which follows:
  * 
@@ -35,6 +36,7 @@
 #ifndef AIS_MAR_CLM_H_DEFINED
 #define AIS_MAR_CLM_H_DEFINED
 
+#include "swab.h"
 #include "saAis.h"
 #include "saClm.h"
 #include "mar_gen.h"
@@ -55,6 +57,12 @@ typedef struct {
 	unsigned char value[MAR_CLM_MAX_ADDRESS_LENGTH] __attribute__((aligned(8)));
 } mar_clm_node_address_t;
 
+static inline void swab_mar_clm_node_address_t(mar_clm_node_address_t *to_swab)
+{
+	swab_mar_uint16_t (&to_swab->length);
+	swab_mar_uint32_t (&to_swab->family);
+}
+
 static inline void marshall_from_mar_clm_node_address_t (
 	SaClmNodeAddressT *dest,
 	mar_clm_node_address_t *src)
@@ -77,14 +85,24 @@ static inline void marshall_to_mar_clm_node_address_t (
  * Marshalling the SaClmClusterNodeT data structure
  */
 typedef struct {
-	unsigned int node_id __attribute__((aligned(8)));
+	mar_uint32_t node_id __attribute__((aligned(8)));
 	mar_clm_node_address_t node_address __attribute__((aligned(8)));
 	mar_name_t node_name __attribute__((aligned(8)));
-	unsigned int member __attribute__((aligned(8)));
-	unsigned long long boot_timestamp __attribute__((aligned(8)));
-	unsigned long long initial_view_number __attribute__((aligned(8)));
+	mar_uint32_t member __attribute__((aligned(8)));
+	mar_uint64_t boot_timestamp __attribute__((aligned(8)));
+	mar_uint64_t initial_view_number __attribute__((aligned(8)));
 } mar_clm_cluster_node_t;
 
+static inline void swab_mar_clm_cluster_node_t(mar_clm_cluster_node_t *to_swab)
+{
+	swab_mar_uint32_t (&to_swab->node_id);
+	swab_mar_uint32_t (&to_swab->member);
+	swab_mar_clm_node_address_t (&to_swab->node_address);
+	swab_mar_name_t (&to_swab->node_name);
+	swab_mar_uint64_t (&to_swab->boot_timestamp);
+	swab_mar_uint64_t (&to_swab->initial_view_number);
+}
+
 static inline void marshall_to_mar_clm_cluster_node_t (
 	mar_clm_cluster_node_t *dest,
 	SaClmClusterNodeT *src)