backport a few usb device ids from 2.6.21 for airprime
[openwrt-10.03/.git] / tools / firmware-utils / src / airlink.c
index 5a396f357f91f683e7d5a546fe6f5322c99d7da5..657c971761f6960b4a54303c4b5197994ee609f6 100644 (file)
@@ -245,7 +245,7 @@ int main(int argc, char **argv)
        u32 sum, l0;
        u32 MagicS = 0x474d544b;
        u32 MagicE = 0x4152524e;
-       if (htonl(*((u32 *) buf)) == MagicS) {
+       if (ntohl(*((u32 *) buf)) == MagicS) {
                fprintf(stderr,
                        "Image without extra 8 bytes - Standard header\n");
                buf[0x10] = len & 0xff;
@@ -255,8 +255,8 @@ int main(int argc, char **argv)
                lseek(fd, 0x10, SEEK_SET);
                write(fd, buf + 0x10, 0x4);
                EHDR = 0;
-       } else if ((htonl(*((u32 *) (buf + 0x8))) == MagicS)
-                  && ((htonl(*((u32 *) (buf + 0x4))) == MagicE))) {
+       } else if ((ntohl(*((u32 *) (buf + 0x8))) == MagicS)
+                  && ((ntohl(*((u32 *) (buf + 0x4))) == MagicE))) {
                fprintf(stderr,
                        "Image with extra 8 bytes - Extended header\n");
                *((u32 *) (buf + 0x18)) = len - 8;
@@ -319,14 +319,10 @@ int main(int argc, char **argv)
                unsigned long sum2 = buf[-0x8] | ((u32)buf[-0x7] << 8) | ((u32)buf[-0x6] << 16) | ((u32)buf[-0x5] << 24);
                *((u32 *) & buf[-0x8]) = 0L;
                sum = crc32(buf - 0x4, len - 0x4);
-               sum = htonl(sum);
                printf("CRC32 sum2 - (%x, %x, %x)\n", sum, sum2,
                       len - 0x4);
                lseek(fd, 0, SEEK_SET);
-               buf[-0x8] = sum & 0xff;
-               buf[-0x7] = (sum >> 8) & 0xff;
-               buf[-0x6] = (sum >> 16) & 0xff;
-               buf[-0x5] = (sum >> 24) & 0xff;
+               *((u32 *) & buf[-0x8]) = htonl(sum);
                write(fd, &buf[-0x8], 0x4);
                buf -= 8;
        }