cdsk: fix big endian problem
authorHauke Mehrtens <hauke.mehrtens@lantiq.com>
Mon, 8 Jun 2015 20:03:19 +0000 (22:03 +0200)
committerErich Keane <erich.keane@intel.com>
Tue, 9 Jun 2015 19:38:53 +0000 (19:38 +0000)
Without this patch the client will endianes swap the port number when
sending the detailed request after it got the answer for his multicast
get. Use the same method for storing the port number in the address
array in ever part of the code and do not use memcpy and manual
bytewise coping mixed over the code. memcpy was used once and byte wise
copy was used twice so I choose the majority.
This was tested on MIPS BE 32 Bit.

Change-Id: Ib486171987004d10209d2bbf6b1d9ada75235651
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1220
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Doug Hudson <douglas.hudson@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/stack/src/ocstack.c

index c17b752..4e2ad39 100644 (file)
@@ -746,7 +746,8 @@ OCStackResult UpdateResponseAddr(OCDevAddr *address, const CARemoteEndpoint_t* e
         address->addr[i] = atoi(tok);
     }
 
-    memcpy(&address->addr[4], &endPoint->addressInfo.IP.port, sizeof(uint16_t));
+    address->addr[4] = (uint8_t)endPoint->addressInfo.IP.port;
+    address->addr[5] = (uint8_t)(endPoint->addressInfo.IP.port >> 8);
     ret = OC_STACK_OK;
 
 exit: