Commit 32b878c0 authored by chenhaowen's avatar chenhaowen

add: option of enable crypt of keep alive1 packet2

parent 88f3e7c0
......@@ -5,8 +5,8 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_NAME:=gdut-drcom
# Version: 1.0-1
PKG_VERSION:=1.5
PKG_RELEASE:=5b
PKG_VERSION:=1.6
PKG_RELEASE:=0
PKG_MAINTAINER:=CHW
# PKG_SOURCE_URL:=
define Package/gdut-drcom
......
#CC:=gcc
CFLAGS+= -Wall -DDEBUG -DVERSION=\"1.5-5b\"
CFLAGS+= -Wall -DDEBUG -DVERSION=\"1.6-0\"
objects=gdut-drcom.o config.o auth.o
......
......@@ -392,7 +392,10 @@ static int make_keep_alive1_pkt2(uint8_t *buf, uint8_t *seed,\
index += 4;
memcpy(buf+index, seed, 4);
index += 4;
/**/
if (drcom_config.enable_crypt == 0)
{
/*disable crypt*/
int32_t temp_num;
temp_num = htole32(20000711);
memcpy(buf+index, (uint8_t*)&temp_num, 4);
......@@ -406,9 +409,11 @@ static int make_keep_alive1_pkt2(uint8_t *buf, uint8_t *seed,\
index += 4;
memcpy(buf+index, "\x00\x00\x00\x00", 4);
index += 4;
/**/
/*
/*disable crypt*/
}
else
{
/*enable crypt*/
uint8_t checksum[8] = {0};
gen_ka1_checksum(checksum, seed, check_mode);
#ifdef DEBUG
......@@ -418,7 +423,8 @@ static int make_keep_alive1_pkt2(uint8_t *buf, uint8_t *seed,\
#endif
memcpy(buf+index, checksum, 8);
index += 8;
*/
/*enable crypt*/
}
memset(buf+index, 0x00, 16*4);
......
......@@ -5,6 +5,7 @@ struct config_s {
char remote_ip[20];
int remote_port;
unsigned char keep_alive1_flag;
int enable_crypt;
};
extern struct config_s drcom_config;
......
......@@ -32,6 +32,7 @@ int main(int argc, char *argv[])
{"remote-ip", required_argument, 0, 0},
{"remote-port", required_argument, 0, 1},
{"keep-alive1-flag", required_argument, 0, 2},
{"enable-crypt", no_argument, 0, 3},
{0, 0, 0, 0},
};
opt = getopt_long(argc, argv, "hc:", long_options, &option_index);
......@@ -50,6 +51,9 @@ int main(int argc, char *argv[])
case 2: //keep_alive1_flag
sscanf(optarg, "%02hhx", &drcom_config.keep_alive1_flag);
break;
case 3:
drcom_config.enable_crypt = 1;
break;
case 'c':
strcpy(conf_file_name, optarg);
parse_config(conf_file_name);
......@@ -72,6 +76,7 @@ int main(int argc, char *argv[])
fprintf(stdout, "drcom_config.remote_ip = %s\n", drcom_config.remote_ip);
fprintf(stdout, "drcom_config.remote_port = %d\n", drcom_config.remote_port);
fprintf(stdout, "drcom_config.keep_alive1_flag = %02hhx\n", drcom_config.keep_alive1_flag);
fprintf(stdout, "drcom_config.enable_crypt = %d\n", drcom_config.enable_crypt);
fflush(stdout);
#endif
......@@ -99,6 +104,7 @@ static void print_help(char *name)
fprintf(stdout, " [--remote-port <port>] The server port, default as 61440.\n");
fprintf(stdout, " [--keep-alive1-flag <flag>] The keep alive 1 packet's flag.\n"
" default as 00.\n");
fprintf(stdout, " [--enable-crypt] Enable crypt of keep alive1 packet2\n");
fprintf(stdout, " [-c, --config-file <file>] The path to config file.\n");
fprintf(stdout, " [-h, --help] Print this message.\n");
}
......
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