Преглед изворни кода

Clean up endian swabbing for cpg service.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1162 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake пре 19 година
родитељ
комит
8cb23508df
2 измењених фајлова са 18 додато и 7 уклоњено
  1. 7 3
      exec/cpg.c
  2. 11 4
      include/mar_cpg.h

+ 7 - 3
exec/cpg.c

@@ -1,5 +1,6 @@
 /*
 /*
  * Copyright (c) 2006 Red Hat, Inc.
  * Copyright (c) 2006 Red Hat, Inc.
+ * Copyright (c) 2006 Sun Microsystems, Inc.
  *
  *
  * All rights reserved.
  * All rights reserved.
  *
  *
@@ -610,7 +611,7 @@ static void exec_cpg_procjoin_endian_convert (void *msg)
 	struct req_exec_cpg_procjoin *req_exec_cpg_procjoin = (struct req_exec_cpg_procjoin *)msg;
 	struct req_exec_cpg_procjoin *req_exec_cpg_procjoin = (struct req_exec_cpg_procjoin *)msg;
 
 
 	req_exec_cpg_procjoin->pid = swab32(req_exec_cpg_procjoin->pid);
 	req_exec_cpg_procjoin->pid = swab32(req_exec_cpg_procjoin->pid);
-	req_exec_cpg_procjoin->group_name.length = swab32(req_exec_cpg_procjoin->group_name.length);
+	swab_mar_cpg_name_t (&req_exec_cpg_procjoin->group_name);
 	req_exec_cpg_procjoin->reason = swab32(req_exec_cpg_procjoin->reason);
 	req_exec_cpg_procjoin->reason = swab32(req_exec_cpg_procjoin->reason);
 }
 }
 
 
@@ -619,9 +620,11 @@ static void exec_cpg_joinlist_endian_convert (void *msg)
 	mar_res_header_t *res = (mar_res_header_t *)msg;
 	mar_res_header_t *res = (mar_res_header_t *)msg;
 	struct join_list_entry *jle = (struct join_list_entry *)(msg + sizeof(mar_res_header_t));
 	struct join_list_entry *jle = (struct join_list_entry *)(msg + sizeof(mar_res_header_t));
 
 
+	/* XXX shouldn't mar_res_header be swabbed? */
+
 	while ((void*)jle < msg + res->size) {
 	while ((void*)jle < msg + res->size) {
 		jle->pid = swab32(jle->pid);
 		jle->pid = swab32(jle->pid);
-		jle->group_name.length = swab32(jle->group_name.length);
+		swab_mar_cpg_name_t (&jle->group_name);
 		jle++;
 		jle++;
 	}
 	}
 }
 }
@@ -630,9 +633,10 @@ static void exec_cpg_mcast_endian_convert (void *msg)
 {
 {
 	struct req_exec_cpg_mcast *req_exec_cpg_mcast = (struct req_exec_cpg_mcast *)msg;
 	struct req_exec_cpg_mcast *req_exec_cpg_mcast = (struct req_exec_cpg_mcast *)msg;
 
 
+	swab_mar_req_header_t (&req_exec_cpg_mcast->header);
+	swab_mar_cpg_name_t (&req_exec_cpg_mcast->group_name);
 	req_exec_cpg_mcast->pid = swab32(req_exec_cpg_mcast->pid);
 	req_exec_cpg_mcast->pid = swab32(req_exec_cpg_mcast->pid);
 	req_exec_cpg_mcast->msglen = swab32(req_exec_cpg_mcast->msglen);
 	req_exec_cpg_mcast->msglen = swab32(req_exec_cpg_mcast->msglen);
-	req_exec_cpg_mcast->group_name.length = swab32(req_exec_cpg_mcast->group_name.length);
 
 
 }
 }
 
 

+ 11 - 4
include/mar_cpg.h

@@ -1,9 +1,10 @@
 /*
 /*
  * Copyright (c) 2006 Red Hat, Inc.
  * Copyright (c) 2006 Red Hat, Inc.
+ * Author: Patrick Caulfield (pcaulfie@redhat.com)
  *
  *
- * All rights reserved.
+ * Copyright (c) 2006 Sun Microsystems, Inc.
  *
  *
- * Author: Patrick Caulfield (pcaulfie@redhat.com)
+ * All rights reserved.
  *
  *
  * This software licensed under BSD license, the text of which follows:
  * This software licensed under BSD license, the text of which follows:
  *
  *
@@ -35,12 +36,18 @@
 #define MAR_CPG_H_DEFINED
 #define MAR_CPG_H_DEFINED
 
 
 #include "cpg.h"
 #include "cpg.h"
+#include "swab.h"
 
 
 typedef struct {
 typedef struct {
-	uint32_t length __attribute((aligned(8)));
-	char value[CPG_MAX_NAME_LENGTH] __attribute((aligned(8)));
+	uint32_t length __attribute__((aligned(8)));
+	char value[CPG_MAX_NAME_LENGTH] __attribute__((aligned(8)));
 } mar_cpg_name_t;
 } mar_cpg_name_t;
 
 
+static inline void swab_mar_cpg_name_t (mar_cpg_name_t *to_swab)
+{
+	swab_mar_uint32_t (&to_swab->length);
+}
+
 static inline void marshall_from_mar_cpg_name_t (
 static inline void marshall_from_mar_cpg_name_t (
 	struct cpg_name *dest,
 	struct cpg_name *dest,
 	mar_cpg_name_t *src)
 	mar_cpg_name_t *src)