Commit da947aa9 authored by chenhaowen's avatar chenhaowen

fix bytes order of ar71xx/brcm63xx

parent a20a6282
......@@ -6,7 +6,7 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_NAME:=gdut-drcom
# Version: 1.0-1
PKG_VERSION:=1.5
PKG_RELEASE:=5
PKG_RELEASE:=5b
PKG_MAINTAINER:=CHW
# PKG_SOURCE_URL:=
define Package/gdut-drcom
......
#CC:=gcc
CFLAGS+= -Wall -DDEBUG -DVERSION=\"1.5-5\"
CFLAGS+= -Wall -DDEBUG -DVERSION=\"1.5-5b\"
objects=gdut-drcom.o config.o auth.o
......
......@@ -4,6 +4,9 @@
#include <stdlib.h>
#include <stdint.h>
#include <sys/time.h>
#include <time.h>
#include <endian.h>
#ifdef WIN32
#include <winsock2.h>
typedef int socklen_t;
......@@ -62,7 +65,7 @@ static int make_keep_alive2_pkt2(uint8_t *buf, uint8_t cnt, uint8_t *flag,\
static void gen_ka1_checksum(uint8_t *checksum, uint8_t *seed, uint8_t mode);
static void gen_ka2_checksum(uint8_t *data, int len, uint8_t *checksum);
static int32_t drcomCRC32(char *data, int len);
static uint32_t drcomCRC32(uint8_t *data, int len);
static void print_as_hex(uint8_t *buf, int len);
/****local functions****/
......@@ -326,13 +329,13 @@ static void print_as_hex(uint8_t *buf, int len)
fflush(stdout);
}
static int32_t drcomCRC32(char *data, int len)
static uint32_t drcomCRC32(uint8_t *data, int len)
{
int ret = 0;
uint32_t ret = 0;
int i;
for (i=0; i<len; i+=4)
{
ret ^= *(int *)(data+i);
ret ^= *(uint32_t *)(data+i);
ret &= 0xffffffff;
}
return ret;
......@@ -390,15 +393,15 @@ static int make_keep_alive1_pkt2(uint8_t *buf, uint8_t *seed,\
index += 4;
/**/
int32_t temp_num;
temp_num = 20000711;
memcpy(buf+index, (char *)&temp_num, 4);
temp_num = htole32(20000711);
memcpy(buf+index, (uint8_t*)&temp_num, 4);
index += 4;
temp_num = 126;
memcpy(buf+index, (char *)&temp_num, 4);
temp_num = htole32(126);
memcpy(buf+index, (uint8_t*)&temp_num, 4);
index += 4;
temp_num = (drcomCRC32(buf, index) * 19680126) & 0xffffffff;
temp_num = htole32(le32toh(drcomCRC32(buf, index)) * 19680126) & 0xffffffff;
index -= 8;
memcpy(buf+index, (char *)&temp_num, 4);
memcpy(buf+index, (uint8_t *)&temp_num, 4);
index += 4;
memcpy(buf+index, "\x00\x00\x00\x00", 4);
index += 4;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment