[spice-gtk][PATCH 2/4] ppc: Fix header endianess

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 gtk/spice-channel.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 4e7d8b7..e7460a6 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -371,9 +371,9 @@ static inline void spice_header_set_msg_type(uint8_t *header, gboolean is_mini_h
                                              uint16_t type)
 {
     if (is_mini_header) {
-        ((SpiceMiniDataHeader *)header)->type = type;
+        ((SpiceMiniDataHeader *)header)->type = GUINT16_TO_LE(type);
     } else {
-        ((SpiceDataHeader *)header)->type = type;
+        ((SpiceDataHeader *)header)->type = GUINT16_TO_LE(type);
     }
 }
 
@@ -381,9 +381,9 @@ static inline void spice_header_set_msg_size(uint8_t *header, gboolean is_mini_h
                                              uint32_t size)
 {
     if (is_mini_header) {
-        ((SpiceMiniDataHeader *)header)->size = size;
+        ((SpiceMiniDataHeader *)header)->size = GUINT32_TO_LE(size);
     } else {
-        ((SpiceDataHeader *)header)->size = size;
+        ((SpiceDataHeader *)header)->size = GUINT32_TO_LE(size);
     }
 }
 
@@ -391,9 +391,9 @@ G_GNUC_INTERNAL
 uint16_t spice_header_get_msg_type(uint8_t *header, gboolean is_mini_header)
 {
     if (is_mini_header) {
-        return ((SpiceMiniDataHeader *)header)->type;
+        return GUINT16_FROM_LE(((SpiceMiniDataHeader *)header)->type);
     } else {
-        return ((SpiceDataHeader *)header)->type;
+        return GUINT16_FROM_LE(((SpiceDataHeader *)header)->type);
     }
 }
 
@@ -401,9 +401,9 @@ G_GNUC_INTERNAL
 uint32_t spice_header_get_msg_size(uint8_t *header, gboolean is_mini_header)
 {
     if (is_mini_header) {
-        return ((SpiceMiniDataHeader *)header)->size;
+        return GUINT32_FROM_LE(((SpiceMiniDataHeader *)header)->size);
     } else {
-        return ((SpiceDataHeader *)header)->size;
+        return GUINT32_FROM_LE(((SpiceDataHeader *)header)->size);
     }
 }
 
@@ -416,7 +416,7 @@ static inline void spice_header_set_msg_serial(uint8_t *header, gboolean is_mini
                                                uint64_t serial)
 {
     if (!is_mini_header) {
-        ((SpiceDataHeader *)header)->serial = serial;
+        ((SpiceDataHeader *)header)->serial = GUINT64_TO_LE(serial);
     }
 }
 
@@ -455,7 +455,7 @@ static inline uint32_t spice_header_get_msg_sub_list(uint8_t *header, gboolean i
     if (is_mini_header) {
         return 0;
     } else {
-        return ((SpiceDataHeader *)header)->sub_list;
+        return GUINT32_FROM_LE(((SpiceDataHeader *)header)->sub_list);
     }
 }
 
@@ -1146,6 +1146,9 @@ static void spice_channel_send_link(SpiceChannel *channel)
         return;
     }
 
+    c->link_hdr.major_version = GUINT32_TO_LE(c->link_hdr.major_version);
+    c->link_hdr.minor_version = GUINT32_TO_LE(c->link_hdr.minor_version);
+
     c->link_msg.connection_id = spice_session_get_connection_id(c->session);
     c->link_msg.channel_type  = c->channel_type;
     c->link_msg.channel_id    = c->channel_id;
@@ -1159,6 +1162,8 @@ static void spice_channel_send_link(SpiceChannel *channel)
     buffer = g_malloc0(sizeof(c->link_hdr) + c->link_hdr.size);
     p = buffer;
 
+    c->link_hdr.size = GUINT32_TO_LE(c->link_hdr.size);
+
     memcpy(p, &c->link_hdr, sizeof(c->link_hdr)); p += sizeof(c->link_hdr);
     memcpy(p, &c->link_msg, sizeof(c->link_msg)); p += sizeof(c->link_msg);
 
@@ -1196,13 +1201,19 @@ static gboolean spice_channel_recv_link_hdr(SpiceChannel *channel)
         goto error;
     }
 
-    CHANNEL_DEBUG(channel, "Peer version: %d:%d", c->peer_hdr.major_version, c->peer_hdr.minor_version);
+    CHANNEL_DEBUG(channel, "Peer version: %d:%d",
+                  GUINT32_FROM_LE(c->peer_hdr.major_version),
+                  GUINT32_FROM_LE(c->peer_hdr.minor_version));
     if (c->peer_hdr.major_version != c->link_hdr.major_version) {
         g_warning("major mismatch (got %d, expected %d)",
                   c->peer_hdr.major_version, c->link_hdr.major_version);
         goto error;
     }
 
+    c->peer_hdr.major_version = GUINT32_FROM_LE(c->peer_hdr.major_version);
+    c->peer_hdr.minor_version = GUINT32_FROM_LE(c->peer_hdr.minor_version);
+    c->peer_hdr.size = GUINT32_FROM_LE(c->peer_hdr.size);
+
     c->peer_msg = g_malloc0(c->peer_hdr.size);
     if (c->peer_msg == NULL) {
         g_warning("invalid peer header size: %u", c->peer_hdr.size);
-- 
2.4.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]