From 456365366c80c9c0fcd52cf82a33022b5a2ca29f Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 22 Jul 2013 22:31:10 +0200 Subject: [PATCH] Decode the IrDA device address as little endian. This is only a cosmetic change, to make the IrDA device address on Windows consistent with the address Linux. There is no functional difference because the address is always serialized and deserialized internally, and applications shouldn't care about the actual number. Anyway, the difference in endianness is easy to notice because the Uwatec Smart family of devices use the serial number as the IrDA device address. On Linux, the address was identical to the serial number, while on Windows the byte order was reversed. --- src/irda.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/irda.c b/src/irda.c index 078c79e..4b6b77b 100644 --- a/src/irda.c +++ b/src/irda.c @@ -250,7 +250,7 @@ irda_socket_discover (irda_t *device, irda_callback_t callback, void *userdata) if (callback) { #ifdef _WIN32 for (unsigned int i = 0; i < list->numDevice; ++i) { - unsigned int address = array_uint32_be (list->Device[i].irdaDeviceID); + unsigned int address = array_uint32_le (list->Device[i].irdaDeviceID); unsigned int hints = (list->Device[i].irdaDeviceHints1 << 8) + list->Device[i].irdaDeviceHints2; @@ -302,10 +302,10 @@ irda_socket_connect_name (irda_t *device, unsigned int address, const char *name #ifdef _WIN32 SOCKADDR_IRDA peer; peer.irdaAddressFamily = AF_IRDA; - peer.irdaDeviceID[0] = (address >> 24) & 0xFF; - peer.irdaDeviceID[1] = (address >> 16) & 0xFF; - peer.irdaDeviceID[2] = (address >> 8) & 0xFF; - peer.irdaDeviceID[3] = (address ) & 0xFF; + peer.irdaDeviceID[0] = (address ) & 0xFF; + peer.irdaDeviceID[1] = (address >> 8) & 0xFF; + peer.irdaDeviceID[2] = (address >> 16) & 0xFF; + peer.irdaDeviceID[3] = (address >> 24) & 0xFF; if (name) strncpy (peer.irdaServiceName, name, 25); else @@ -339,10 +339,10 @@ irda_socket_connect_lsap (irda_t *device, unsigned int address, unsigned int lsa #ifdef _WIN32 SOCKADDR_IRDA peer; peer.irdaAddressFamily = AF_IRDA; - peer.irdaDeviceID[0] = (address >> 24) & 0xFF; - peer.irdaDeviceID[1] = (address >> 16) & 0xFF; - peer.irdaDeviceID[2] = (address >> 8) & 0xFF; - peer.irdaDeviceID[3] = (address ) & 0xFF; + peer.irdaDeviceID[0] = (address ) & 0xFF; + peer.irdaDeviceID[1] = (address >> 8) & 0xFF; + peer.irdaDeviceID[2] = (address >> 16) & 0xFF; + peer.irdaDeviceID[3] = (address >> 24) & 0xFF; snprintf (peer.irdaServiceName, 25, "LSAP-SEL%u", lsap); #else struct sockaddr_irda peer;