Commit 838f6cdc authored by chenhaowen's avatar chenhaowen

first commit for version 1.4

parents
test
log
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/package.mk
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
PKG_NAME:=gdut-drcom
# Version: 1.0-1
PKG_VERSION:=1.4
PKG_RELEASE:=1
PKG_MAINTAINER:=CHW
# PKG_SOURCE_URL:=
define Package/gdut-drcom
SECTION:=utils
CATEGORY:=Utilities
DEFAULT:=y
TITLE:=xdh3c -- a h3c client for linux
# DEPENDS:=+libgcrypt
DEPENDS:=+libopenssl
endef
define Build/Prepare
@echo "############## Build/Prepare"
$(Build/Prepare/Default)
$(CP) ./src/* $(PKG_BUILD_DIR)
endef
define Build/Compile
@echo "############## Build/Compile"
export CFLAGS="$CFLAGS -DDEBUG"
$(call Build/Compile/Default, cryptlib=openssl)
endef
define Package/gdut-drcom/postinst
#!/bin/sh
echo "post install: patching ppp.sh"
sed -i '/proto_run_command/i username=$$(echo -e "\\r\\n$$username") #added by gdut-drcom!' /lib/netifd/proto/ppp.sh
echo "patched!"
endef
define Package/gdut-drcom/prerm
#!/bin/sh
echo "pre remove: unpatching ppp.sh!"
sed -i '/#added by gdut-drcom/d' /lib/netifd/proto/ppp.sh
echo "unpatched!"
endef
define Package/gdut-drcom/install
@echo "############## Package/gdut-drcom/install"
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/gdut-drcom $(1)/usr/bin
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) $(PKG_BUILD_DIR)/etc/gdut-drcom.conf $(1)/etc
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/etc/init.d/gdut-drcom $(1)/etc/init.d
endef
$(eval $(call BuildPackage,gdut-drcom))
#CC:=gcc
CFLAGS+=-DDEBUG
#cryptlib=openssl
#ifeq ($(lib), openssl)
# CFLAGS+=-D_WITH_OPENSSL_
# LIBS:=-lcrypto
#else
# LIBS:=-lpolarssl
#endif
ifeq ($(cryptlib), polarssl)
CFLAGS+=-D__WITH_POLARSSL__
LIBS:=-lpolarssl
else ifeq ($(cryptlib), gcrypt)
CFLAGS+=-D__WITH_GCRYPT__
LIBS:=-lgcrypt
else
LIBS:=-lcrypto
endif
all: gdut-drcom
@echo gdut-drcom
gdut-drcom: gdut-drcom.o config.o auth.o
$(CC) gdut-drcom.o config.o auth.o -o gdut-drcom $(CFLAGS) $(LIBS)
gdut-drcom.o: gdut-drcom.c
$(CC) $(CFLAGS) -c $<
config.o: config.c config.h
$(CC) $(CFLAGS) -c $<
auth.o: auth.c config.h
$(CC) $(CFLAGS) -c $<
clean:
rm -f gdut-drcom *.o
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
/*
#ifdef _WITH_OPENSSL_
#include <openssl/md5.h>
#include <openssl/md4.h>
#include <openssl/sha.h>
#define _MD5 MD5
#define _MD4 MD4
#define _SHA1 SHA1
#else
#include <polarssl/md5.h>
#include <polarssl/md4.h>
#include <polarssl/sha1.h>
#define _MD5 md5
#define _MD4 md4
#define _SHA1 sha1
#endif
*/
#ifdef __WITH_POLARSSL__
#include <polarssl/md5.h>
#include <polarssl/md4.h>
#include <polarssl/sha1.h>
#define _MD5(data, len, _md5) md5(data, len, _md5)
#define _MD4(data, len, _md4) md4(data, len, _md4)
#define _SHA1(data, len, _sha1) sha1(data, len, _sha1)
#elif __WITH_GCRYPT__
#include <gcrypt.h>
#define _MD5(data, len, _md5) gcry_md_hash_buffer(GCRY_MD_MD5, _md5, data, len)
#define _MD4(data, len, _md4) gcry_md_hash_buffer(GCRY_MD_MD4, _md4, data, len)
#define _SHA1(data, len, _sha1) gcry_md_hash_buffer(GCRY_MD_SHA1, _sha1, data, len)
#else
#include <openssl/md5.h>
#include <openssl/md4.h>
#include <openssl/sha.h>
#define _MD5(data, len, _md5) MD5(data, len, _md5)
#define _MD4(data, len, _md4) MD4(data, len, _md4)
#define _SHA1(data, len, _sha1) SHA1(data, len, _sha1)
#endif
#include "config.h"
/****local functions****/
static int make_keep_alive1_pkt1(char *buf, unsigned char cnt);
static int make_keep_alive1_pkt2(char *buf, char *seed,\
char *host_ip, unsigned char cnt);
static int make_keep_alive2_pkt1(char *buf, unsigned char cnt, char *flag,\
char *rand, char *key);
static int make_keep_alive2_pkt2(char *buf, unsigned char cnt, char *flag,\
char *rand, char *key, char *host_ip);
static int gen_ka1_checksum(char *checksum, char *seed, unsigned char mode);
static void gen_ka2_checksum(char *data, int len, char *checksum);
static int32_t drcomCRC32(char *data, int len);
static void print_as_hex(char *buf, int len);
/****local functions****/
int auth(void)
{
/*variavles of packets*/
unsigned char buf[1024] = {0}; //packet data buf
int length; //packet data length
/*variavles of packets*/
/*variables used in keep alive1 paket*/
unsigned char seed[4];
unsigned char host_ip[4];
unsigned char kp1_cnt = 0x01;
/*variables used in keep alive1 paket*/
/*variables used in keep alive2 paket*/
unsigned char kp2_cnt = 0x01;
unsigned char ka2_key[4] = {0};
unsigned char ka2_flag[2] = {0};
unsigned char rand[2] = {0};
/*variables used in keep alive2 paket*/
struct sockaddr_in remote_addr;
struct sockaddr_in local_addr;
int retry_cnt;
memset(&remote_addr, 0, sizeof(remote_addr));
remote_addr.sin_family = AF_INET;
remote_addr.sin_addr.s_addr = inet_addr(drcom_config.remote_ip);
remote_addr.sin_port=htons(drcom_config.remote_port);
memset(&local_addr, 0, sizeof(local_addr));
local_addr.sin_family = AF_INET;
local_addr.sin_addr.s_addr = inet_addr("0.0.0.0");
local_addr.sin_port=htons(drcom_config.remote_port);
int client_sockfd;
if ((client_sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
fprintf(stderr, "error!\n");
fflush(stderr);
return -1;
}
int sin_size;
sin_size = sizeof(struct sockaddr_in);
bind(client_sockfd, (struct sockaddr *) &local_addr, sin_size);
struct timeval timeout;
timeout.tv_sec=2;
timeout.tv_usec=0;
setsockopt(client_sockfd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(struct timeval));
HEART_BEAT_START:
fprintf(stdout, "gdut-drcom heart-beat started!\n\n");
fflush(stdout);
kp1_cnt = 1;
kp2_cnt = 0;
srandom((unsigned int)time(NULL));
while (1)
{
retry_cnt = 1;
while (1)
{
length = make_keep_alive1_pkt1(buf, kp1_cnt);
sendto(client_sockfd, buf, length, 0,\
(struct sockaddr *) &remote_addr, sizeof(remote_addr));
fprintf(stdout, "<==[sended kap1_1 request %d] len = %d\n",\
kp1_cnt, length);
fflush(stdout);
print_as_hex(buf, length);
if (retry_cnt > 5)
{
goto HEART_BEAT_START;
}
memset(buf, 0x00, 1024);
if ((length = recvfrom(client_sockfd, buf, 1024, 0,\
(struct sockaddr *) &remote_addr, &sin_size)) == -1)
{
fprintf(stdout, "recv kap1_1 timeout, retry %d!\n", retry_cnt++);
fflush(stdout);
}
else
{
break;
}
}
retry_cnt = 0;
fprintf(stdout, "==>[recieved kap1_1 response %d] len = %d\n",\
kp1_cnt, length);
fflush(stdout);
print_as_hex(buf,length);
memcpy(seed, buf+8, 4);
memcpy(host_ip, buf+12, 4);
// memcpy(drcom_config.host_ip, buf+12, 4);
kp1_cnt++;
retry_cnt = 1;
while (1)
{
length = make_keep_alive1_pkt2(buf, seed, host_ip, kp1_cnt);
sendto(client_sockfd, buf, length, 0,\
(struct sockaddr *) &remote_addr, sizeof(remote_addr));
fprintf(stdout, "<==[sended kap1_2 request %d] len = %d\n",\
kp1_cnt, length);
fflush(stdout);
print_as_hex(buf, length);
length = 0;
if (retry_cnt > 5)
{
goto HEART_BEAT_START;
}
if ((length = recvfrom(client_sockfd, buf, 1024, 0, \
(struct sockaddr *) &remote_addr, &sin_size)) == -1)
{
fprintf(stdout, "recv kap1_2 timeout, retry %d!\n", retry_cnt++);
fflush(stdout);
}
else
{
break;
}
}
retry_cnt = 0;
fprintf(stdout, "==>[recieved kap1_2 response %d] len = %d\n",\
kp1_cnt, length);
fflush(stdout);
print_as_hex(buf,length);
kp1_cnt++;
retry_cnt = 0;
int16_t rand_tmp = random() % 0x10000;
rand[0] = rand_tmp / 0x100;
rand[1] = rand_tmp % 0x100;
sleep(3);
while (1)
{
length = make_keep_alive2_pkt1(buf, kp2_cnt, ka2_flag, rand, ka2_key);
sendto(client_sockfd, buf, length, 0,\
(struct sockaddr *) &remote_addr, sizeof(remote_addr));
fprintf(stdout, "<==[sended kap2_1 request %d] len = %d\n",\
kp2_cnt, length);
fflush(stdout);
print_as_hex(buf, length);
if (retry_cnt > 5)
{
goto HEART_BEAT_START;
}
memset(buf, 0x00, 1024);
if ((length = recvfrom(client_sockfd, buf, 1024, 0,\
(struct sockaddr *) &remote_addr, &sin_size)) == -1)
{
fprintf(stdout, "recv kap2_1 timeout, retry %d!\n", retry_cnt++);
fflush(stdout);
}
else
{
if (buf[0] == 0x07 && buf[2] == 0x10)
{
memcpy(ka2_flag, buf+6, 2);
fprintf(stdout, "==>[recieved kap2_1 response %d] len = %d\n",\
kp2_cnt, length);
fflush(stdout);
print_as_hex(buf,length);
kp2_cnt++;
continue;
}
break;
}
}
fprintf(stdout, "==>[recieved kap2_1 response %d] len = %d\n",\
kp2_cnt, length);
fflush(stdout);
print_as_hex(buf,length);
memcpy(ka2_key, buf+16, 4);
kp2_cnt++;
while (1)
{
length = make_keep_alive2_pkt2(buf, kp2_cnt, ka2_flag, rand, ka2_key, host_ip);
sendto(client_sockfd, buf, length, 0,\
(struct sockaddr *) &remote_addr, sizeof(remote_addr));
fprintf(stdout, "<==[sended kap2_2 request %d] len = %d\n", \
kp2_cnt, length);
fflush(stdout);
print_as_hex(buf, length);
if (retry_cnt > 5)
{
goto HEART_BEAT_START;
}
memset(buf, 0x00, 1024);
if ((length = recvfrom(client_sockfd, buf, 1024, 0,\
(struct sockaddr *) &remote_addr, &sin_size)) == -1)
{
fprintf(stdout, "recv kap2_2 timeout, retry %d!\n", retry_cnt++);
fflush(stdout);
}
else
{
break;
}
}
fprintf(stdout, "==>[recieved kap2_2 response %d] len = %d\n",\
kp2_cnt, length);
fflush(stdout);
print_as_hex(buf,length);
kp2_cnt++;
sleep(17);
}
close(client_sockfd);
return 0;
}
static void print_as_hex(char *buf, int len)
{
int i;
for (i=0; i<len; i++)
{
if (i%16 == 0 && i!=0)
fprintf(stdout, "\n");
fprintf(stdout, "%02hhx ", *(buf+i));
}
fprintf(stdout, "\n\n");
fflush(stdout);
}
static int32_t drcomCRC32(char *data, int len)
{
int ret = 0;
int i;
for (i=0; i<len; i+=4)
{
ret ^= *(int *)(data+i);
ret &= 0xffffffff;
}
return ret;
}
static int make_keep_alive1_pkt1(char *buf, unsigned char cnt)
{
buf[0] = 0x07;
buf[1] = (char) cnt;
buf[2] = 0x08;
buf[3] = 0x00;
buf[4] = 0x01;
buf[5] = 0x00;
buf[6] = 0x00;
buf[7] = 0x00;
return 8;
}
static int make_keep_alive1_pkt2(char *buf, char *seed,\
char *host_ip, unsigned char cnt)
{
int index = 0;
static int is_first = 1;
int temp_num;
unsigned char check_mode = seed[0] & 0x03;
#ifdef DEBUG
fprintf(stdout, "check mode: %d\n", check_mode);
fflush(stdout);
#endif
buf[index++] = 0x07; //code
buf[index++] = (char) cnt; //id
buf[index++] = 0x60; //length
buf[index++] = 0x00; //length
buf[index++] = 0x03; //type
buf[index++] = 0x00; //uid length
memcpy(buf+index, "\x00\x00\x00\x00\x00\x00", 6);
index += 6;
memcpy(buf+index, host_ip, 4);
index += 4;
if (is_first)
{
memcpy(buf+index, "\x00\x62\x00", 3);
*(buf+index+3) = drcom_config.keep_alive1_flag;
is_first = 0;
}
else
{
memcpy(buf+index, "\x00\x63\x00", 3);
*(buf+index+3) = drcom_config.keep_alive1_flag;
}
index += 4;
memcpy(buf+index, seed, 4);
index += 4;
/*
temp_num = 20000711;
memcpy(buf+index, (char *)&temp_num, 4);
index += 4;
temp_num = 126;
memcpy(buf+index, (char *)&temp_num, 4);
index += 4;
temp_num = (drcomCRC32(buf, index) * 19680126) & 0xffffffff;
index -= 8;
memcpy(buf+index, (char *)&temp_num, 4);
index += 4;
memcpy(buf+index, "\x00\x00\x00\x00", 4);
index += 4;
*/
char checksum[8] = {0};
gen_ka1_checksum(checksum, seed, check_mode);
#ifdef DEBUG
fprintf(stdout, "checksum: ");
fflush(stdout);
print_as_hex(checksum, 8);
#endif
memcpy(buf+index, checksum, 8);
index += 8;
memset(buf+index, 0x00, 16*4);
return index + 16*4;
}
static int gen_ka1_checksum(char *checksum, char *seed, unsigned char mode)
{
char checksum_t[32] = {0};
int32_t temp_num;
switch (mode)
{
case 0:
temp_num = 20000711;
memcpy(checksum, (char *)&temp_num, 4);
temp_num = 126;
memcpy(checksum+4, (char *)&temp_num, 4);
break;
case 1:
//md5
_MD5(seed, 4, checksum_t);
checksum[0] = checksum_t[2];
checksum[1] = checksum_t[3];
checksum[2] = checksum_t[8];
checksum[3] = checksum_t[9];
checksum[4] = checksum_t[5];
checksum[5] = checksum_t[6];
checksum[6] = checksum_t[13];
checksum[7] = checksum_t[14];
break;
case 2:
//md4
_MD4(seed, 4, checksum_t);
checksum[0] = checksum_t[1];
checksum[1] = checksum_t[2];
checksum[2] = checksum_t[8];
checksum[3] = checksum_t[9];
checksum[4] = checksum_t[4];
checksum[5] = checksum_t[5];
checksum[6] = checksum_t[11];
checksum[7] = checksum_t[12];
break;
case 3:
//sha1
_SHA1(seed, 4, checksum_t);
checksum[0] = checksum_t[2];
checksum[1] = checksum_t[3];
checksum[2] = checksum_t[9];
checksum[3] = checksum_t[10];
checksum[4] = checksum_t[5];
checksum[5] = checksum_t[6];
checksum[6] = checksum_t[15];
checksum[7] = checksum_t[16];
break;
default:
break;
}
return 0;
}
int make_keep_alive2_pkt1(char *buf, unsigned char cnt, char *flag,\
char * rand, char *key)
{
int index = 0;
*(buf + index++) = 0x07;
*(buf + index++) = cnt;
*(buf + index++) = 0x28; //length
memcpy(buf+index, "\x00\x0b\x01", 3);
index += 3;
// *(buf + index++) = 0xdc;
// *(buf + index++) = 0x02;
memcpy(buf+index, flag, 2);
index += 2;
memcpy(buf + index, rand, 2);
index += 2;
memset(buf+index, 0, 6);
index += 6;
memcpy(buf+index, key, 4);
index += 4;
memset(buf+index, 0, 20);
index += 20;
return index;
}
int make_keep_alive2_pkt2(char *buf, unsigned char cnt, char *flag,\
char *rand, char *key, char *host_ip)
{
int index = 0;
*(buf + index++) = 0x07;
*(buf + index++) = cnt;
*(buf + index++) = 0x28; //length
memcpy(buf+index, "\x00\x0b\x03", 3);
index += 3;
memcpy(buf+index, flag, 2);
index += 2;
memcpy(buf + index, rand, 2);
index += 2;
memset(buf+index, 0, 6);
index += 6;
memcpy(buf+index, key, 4);
index += 4;
memset(buf+index, 0, 4);
index += 4;
gen_ka2_checksum(buf, index, buf+index);
index += 4;
memcpy(buf+index, host_ip, 4);
index += 4;
memset(buf+index, 0, 8);
index +=8;
return index;
}
void gen_ka2_checksum(char *data, int len, char *checksum)
{
int16_t * p = (int16_t *)data;
int i;
int32_t checksum_tmp = 0;
for (i=0; i<len/2; i++)
{
checksum_tmp ^= *(p + i);
}
checksum_tmp &= 0xffff;
checksum_tmp *= 0x2c7;
memcpy(checksum, (char*)&checksum, 4);
}
#ifdef __AUTH_H__
#define __AUTH_H__
int auth(void);
#endif //__AUTH_H__
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
struct option_s {
char key[256];
char value[256];
};
/* extern variables */
struct config_s drcom_config = {
.remote_port = 61440,
};
/* extern variables */
/* locale functions */
static int parse_line(char *buf, int size);
static void strstrip(char *s, char *chars);
/* locale functions */
int parse_config(char *conf_file_name)
{
// char conf_file_name[256] = "/etc/gdut-drcom.conf";
char line_buf[1024];
#ifdef DEBUG
fprintf(stdout, "conf_file_name = %s\n", conf_file_name);
fflush(stdout);
#endif
FILE *fp = fopen(conf_file_name, "r");
if (fp == NULL)
{
fprintf(stderr, "open %s failed!\n", conf_file_name);
fflush(stderr);
exit(-1);
}
while(!feof(fp))
{
memset(line_buf, 0, sizeof(line_buf));
fgets(line_buf, sizeof(line_buf)-1, fp);
if (strlen(line_buf) > 0)
{
parse_line(line_buf, sizeof(line_buf));
}
}
fclose(fp);
return 0;
}
static int parse_line(char *buf, int size)
{
char *p;
struct option_s opt = {0};
//comment
p = strchr(buf, '#');
if (p)
*p = '\0';
p = strchr(buf, '=');
if (p == NULL)
return 1;
strncpy(opt.key, buf, p - buf);
strstrip(opt.key, " \n\r\t");
if ((opt.key[0]=='"' && opt.key[strlen(opt.key)-1]=='"') ||
(opt.key[0]=='\'' && opt.key[strlen(opt.key)-1]=='\''))
strstrip(opt.key, "\"'");
strncpy(opt.value, p+1, strlen(p));
strstrip(opt.value, " \r\t\n");
if ((opt.value[0]=='"' && opt.value[strlen(opt.value)-1]=='"') ||
(opt.value[0]=='\'' && opt.value[strlen(opt.value)-1]=='\''))
strstrip(opt.value, "\"'");
if (strcmp(opt.key, "remote_ip") == 0)
{
strcpy(drcom_config.remote_ip, opt.value);
}
else if (strcmp(opt.key, "remote_port") == 0)
{
drcom_config.remote_port = atoi(opt.value);
}
else if(strcmp(opt.key, "keep_alive1_flag") == 0)
{
sscanf(opt.value, "%02hhx", &drcom_config.keep_alive1_flag);
}
/* else if(strcmp(opt.key, "keep_alive2_flag") == 0)
{
sscanf(opt.value, "%02hhx", &drcom_config.keep_alive2_flag);
}*/
return 0;
}
static void strstrip(char *s, char *chars)
{
int i;
char *p;
p = s;
while (strchr(chars, *p)!=NULL && *p!='\0')
{
p++;
}
strcpy(s, p);
i = strlen(s) - 1;
while (strchr(chars, s[i])!=NULL && i>=0)
{
s[i] = '\0';
i--;
}
}
#ifndef __CONFIG_H__
#define __CONFIG_H__
struct config_s {
char remote_ip[20];
int remote_port;
unsigned char keep_alive1_flag;
};
extern struct config_s drcom_config;
int parse_config(char * conf_file_name);
#endif //__CONFIG_H__
remote_ip = 10.0.3.2
keep_alive1_flag = 2a
#!/bin/sh /etc/rc.common
#(c) 2010 ivan_wl
START=99
start() {
service_start /usr/bin/gdut-drcom -c /etc/gdut-drcom.conf 1> /tmp/gdut-drcom.log 2>/tmp/gdut-drcom_error.log&
}
stop()
{
service_stop /usr/bin/gdut-drcom
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "auth.h"
#include "config.h"
static void print_help(char * name);
int main(int argc, char *argv[])
{
char conf_file_name[256] = {0};
if (argc == 1)
{
print_help(argv[0]);
exit(-1);
}
int opt;
while (1)
{
int option_index = 0;
static struct option long_options[] =
{
{"help", no_argument, 0, 'h'},
{"config-file", required_argument, 0, 'c'},
{"remote-ip", required_argument, 0, 0},
{"remote-port", required_argument, 0, 1},
{"keep-alive1-flag", required_argument, 0, 2},
{0, 0, 0, 0},
};
opt = getopt_long(argc, argv, "hc:", long_options, &option_index);
if (opt == -1)
{
break;
}
switch (opt)
{
case 0: //remote-ip
strcpy(drcom_config.remote_ip, optarg);
break;
case 1: //remote_port
drcom_config.remote_port = atoi(optarg);
break;
case 2: //keep_alive1_flag
sscanf(optarg, "%02hhx", &drcom_config.keep_alive1_flag);
break;
case 'c':
strcpy(conf_file_name, optarg);
parse_config(conf_file_name);
break;
case 'h':
print_help(argv[0]);
exit(0);
break;
case '?':
break;
default:
break;
}
}
// if (!conf_file_name[0] == '\0')
// {
// parse_config(conf_file_name);
// }
#ifdef DEBUG
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);
fflush(stdout);
#endif
auth();
return 0;
}
static void print_help(char *name)
{
fprintf(stdout, "gdut-drcom\n");
fprintf(stdout, " A third-partydrcom client for gdut.\n\n");
fprintf(stdout, "usage:\n");
fprintf(stdout, " %s\n", name);
fprintf(stdout, " --remote-ip <ip addr>\t\tThe server ip.\n");
fprintf(stdout, "\n");
fprintf(stdout, " [--remote-port <port>]\t\tThe server port, default as 61440.\n");
fprintf(stdout, " [--keep-alive1-flag <flag>]\t\tThe keep alive 1 packet's flag,"
"\t\t\t\t\t\t\t\t default as 00.\n");
fprintf(stdout, " [-c, --config-file <file>]\t\tThe path to config file. "
"\t\t\t\t\t\t\t\t default as /etc/gdut-drcom.conf\n");
fprintf(stdout, " [-h, --help]\t\t\tPrint this message.\n");
}
config gdut-drcom
option username '3114000294'
option password '166511'
option remote-ip '0.0.0.0'
option keep-alive1-flag '2a'
option enable '1'
module("luci.controller.gdut-drcom", package.seeall)
function index()
entry({"admin", "network", "gdut-drcom"}, cbi("gdut-drcom"), _("gdut-drcom client"), 100)
end
--[[
LuCI - Lua Configuration Interface
Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
]]--
require("luci.sys")
m = Map("gdut-drcom", translate("gdut-drcom Client"), translate("Configure gdut-drcom client."))
s = m:section(TypedSection, "gdut-drcom", "")
s.addremove = false
s.anonymous = true
enable = s:option(Flag, "enable", translate("Enable"))
remote_ip = s:option(Value, "remote-ip", translate("Remote ip"))
keep_alive_flag = s:option(Value, "keep-alive1-flag", translate("Keep alive1 flag"))
local apply = luci.http.formvalue("cbi.apply")
if apply then
io.popen("echo gdut-drcom apply >> /root/gdut-drcom.log")
end
return m
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