- memcpy(buf + p->offsets[2] - EDIMAX_HDR_LEN, buf + p->offsets[2], length - p->offsets[2]);
- p->crc32 = crc32buf((char *) &p->flag_version, length - offsetof(struct trx_header, flag_version));
+ memcpy(buf + LOAD32_LE(p->offsets[2]) - EDIMAX_HDR_LEN, buf + LOAD32_LE(p->offsets[2]), length - LOAD32_LE(p->offsets[2]));
+ /* recompute the crc32 check */
+ p->crc32 = STORE32_LE(crc32buf((char *) &p->flag_version, length - offsetof(struct trx_header, flag_version)));
+
+ eh.sign = STORE32_LE(EDIMAX_PS16);
+ eh.length = STORE32_LE(length);
+ eh.start_addr = STORE32_LE(0x80500000);