Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
gdut-drcom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
gdut-drcom
Commits
25965dbb
Commit
25965dbb
authored
Nov 07, 2016
by
chenhaowen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed up some warning
parent
093ebc75
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
42 deletions
+50
-42
src/Makefile
src/Makefile
+1
-1
src/auth.c
src/auth.c
+43
-39
src/config.c
src/config.c
+1
-1
src/gdut-drcom.c
src/gdut-drcom.c
+5
-1
No files found.
src/Makefile
View file @
25965dbb
#CC:=gcc
CFLAGS
+=
-DDEBUG
CFLAGS
+=
-Wall
-DDEBUG
-DVERSION
=
\"
1.5-4b
\"
objects
=
gdut-drcom.o config.o auth.o
...
...
src/auth.c
View file @
25965dbb
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#ifdef WIN32
#include <winsock2.h>
...
...
@@ -47,20 +49,20 @@
#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_alive1_pkt1
(
uint8_t
*
buf
,
uint8_t
cnt
);
static
int
make_keep_alive1_pkt2
(
uint8_t
*
buf
,
uint8_t
*
seed
,
\
uint8_t
*
host_ip
,
uint8_t
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
make_keep_alive2_pkt1
(
uint8_t
*
buf
,
uint8_t
cnt
,
uint8_t
*
flag
,
\
uint8_t
*
rand
,
uint8_t
*
key
);
static
int
make_keep_alive2_pkt2
(
uint8_t
*
buf
,
uint8_t
cnt
,
uint8_t
*
flag
,
\
uint8_t
*
rand
,
uint8_t
*
key
,
uint8_t
*
host_ip
);
static
void
gen_ka1_checksum
(
char
*
checksum
,
char
*
seed
,
unsigned
char
mode
);
static
void
gen_ka2_checksum
(
char
*
data
,
int
len
,
char
*
checksum
);
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
void
print_as_hex
(
u
nsigned
char
*
buf
,
int
len
);
//
static int32_t drcomCRC32(char *data, int len);
static
void
print_as_hex
(
u
int8_t
*
buf
,
int
len
);
/****local functions****/
...
...
@@ -76,21 +78,21 @@ int auth(void)
#endif
/*variavles of packets*/
u
nsigned
char
pkt_data
[
1024
]
=
{
0
};
//packet data buf
u
int8_t
pkt_data
[
1024
]
=
{
0
};
//packet data buf
int
length
;
//packet data length
/*variavles of packets*/
/*variables used in keep alive1 paket*/
u
nsigned
char
seed
[
4
];
u
nsigned
char
host_ip
[
4
];
u
nsigned
char
kp1_cnt
=
0x01
;
u
int8_t
seed
[
4
];
u
int8_t
host_ip
[
4
];
u
int8_t
kp1_cnt
=
0x01
;
/*variables used in keep alive1 paket*/
/*variables used in keep alive2 paket*/
u
nsigned
char
kp2_cnt
=
0x01
;
u
nsigned
char
ka2_key
[
4
]
=
{
0
};
u
nsigned
char
ka2_flag
[
2
]
=
{
0
};
u
nsigned
char
rand_num
[
2
]
=
{
0
};
u
int8_t
kp2_cnt
=
0x01
;
u
int8_t
ka2_key
[
4
]
=
{
0
};
u
int8_t
ka2_flag
[
2
]
=
{
0
};
u
int8_t
rand_num
[
2
]
=
{
0
};
/*variables used in keep alive2 paket*/
struct
sockaddr_in
remote_addr
;
...
...
@@ -123,7 +125,7 @@ int auth(void)
return
-
1
;
}
in
t
sin_size
;
socklen_
t
sin_size
;
sin_size
=
sizeof
(
struct
sockaddr_in
);
bind
(
client_sockfd
,
(
struct
sockaddr
*
)
&
local_addr
,
sin_size
);
#ifdef WIN32
...
...
@@ -310,7 +312,7 @@ HEART_BEAT_START:
return
0
;
}
static
void
print_as_hex
(
u
nsigned
char
*
buf
,
int
len
)
static
void
print_as_hex
(
u
int8_t
*
buf
,
int
len
)
{
int
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
...
...
@@ -323,6 +325,8 @@ static void print_as_hex(unsigned char *buf, int len)
fflush
(
stdout
);
}
/* unused*/
/*
static int32_t drcomCRC32(char *data, int len)
{
int ret = 0;
...
...
@@ -334,11 +338,12 @@ static int32_t drcomCRC32(char *data, int len)
}
return ret;
}
*/
static
int
make_keep_alive1_pkt1
(
char
*
buf
,
unsigned
char
cnt
)
static
int
make_keep_alive1_pkt1
(
uint8_t
*
buf
,
uint8_t
cnt
)
{
buf
[
0
]
=
0x07
;
buf
[
1
]
=
(
char
)
cnt
;
buf
[
1
]
=
cnt
;
buf
[
2
]
=
0x08
;
buf
[
3
]
=
0x00
;
buf
[
4
]
=
0x01
;
...
...
@@ -349,21 +354,20 @@ static int make_keep_alive1_pkt1(char *buf, unsigned char cnt)
return
8
;
}
static
int
make_keep_alive1_pkt2
(
char
*
buf
,
char
*
seed
,
\
char
*
host_ip
,
unsigned
char
cnt
)
static
int
make_keep_alive1_pkt2
(
uint8_t
*
buf
,
uint8_t
*
seed
,
\
uint8_t
*
host_ip
,
uint8_t
cnt
)
{
int
index
=
0
;
static
int
is_first
=
1
;
int
temp_num
;
u
nsigned
char
check_mode
=
seed
[
0
]
&
0x03
;
u
int8_t
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
++
]
=
cnt
;
//id
buf
[
index
++
]
=
0x60
;
//length
buf
[
index
++
]
=
0x00
;
//length
buf
[
index
++
]
=
0x03
;
//type
...
...
@@ -400,7 +404,7 @@ static int make_keep_alive1_pkt2(char *buf, char *seed,\
memcpy(buf+index, "\x00\x00\x00\x00", 4);
index += 4;
*/
char
checksum
[
8
]
=
{
0
};
uint8_t
checksum
[
8
]
=
{
0
};
gen_ka1_checksum
(
checksum
,
seed
,
check_mode
);
#ifdef DEBUG
fprintf
(
stdout
,
"checksum: "
);
...
...
@@ -415,17 +419,17 @@ static int make_keep_alive1_pkt2(char *buf, char *seed,\
return
index
+
16
*
4
;
}
static
void
gen_ka1_checksum
(
char
*
checksum
,
char
*
seed
,
unsigned
char
mode
)
static
void
gen_ka1_checksum
(
uint8_t
*
checksum
,
uint8_t
*
seed
,
uint8_t
mode
)
{
char
checksum_t
[
32
]
=
{
0
};
uint8_t
checksum_t
[
32
]
=
{
0
};
int32_t
temp_num
;
switch
(
mode
)
{
case
0
:
temp_num
=
20000711
;
memcpy
(
checksum
,
(
char
*
)
&
temp_num
,
4
);
memcpy
(
checksum
,
(
uint8_t
*
)
&
temp_num
,
4
);
temp_num
=
126
;
memcpy
(
checksum
+
4
,
(
char
*
)
&
temp_num
,
4
);
memcpy
(
checksum
+
4
,
(
uint8_t
*
)
&
temp_num
,
4
);
break
;
case
1
:
//md5
...
...
@@ -469,8 +473,8 @@ static void gen_ka1_checksum(char *checksum, char *seed, unsigned char mode)
}
int
make_keep_alive2_pkt1
(
char
*
buf
,
unsigned
char
cnt
,
char
*
flag
,
\
char
*
rand
,
char
*
key
)
int
make_keep_alive2_pkt1
(
uint8_t
*
buf
,
uint8_t
cnt
,
uint8_t
*
flag
,
\
uint8_t
*
rand
,
uint8_t
*
key
)
{
int
index
=
0
;
*
(
buf
+
index
++
)
=
0x07
;
...
...
@@ -499,8 +503,8 @@ int make_keep_alive2_pkt1(char *buf, unsigned char cnt, char *flag,\
return
index
;
}
int
make_keep_alive2_pkt2
(
char
*
buf
,
unsigned
char
cnt
,
char
*
flag
,
\
char
*
rand
,
char
*
key
,
char
*
host_ip
)
int
make_keep_alive2_pkt2
(
uint8_t
*
buf
,
uint8_t
cnt
,
uint8_t
*
flag
,
\
uint8_t
*
rand
,
uint8_t
*
key
,
uint8_t
*
host_ip
)
{
int
index
=
0
;
*
(
buf
+
index
++
)
=
0x07
;
...
...
@@ -543,7 +547,7 @@ int make_keep_alive2_pkt2(char *buf, unsigned char cnt, char *flag,\
return
index
;
}
void
gen_ka2_checksum
(
char
*
data
,
int
len
,
char
*
checksum
)
void
gen_ka2_checksum
(
uint8_t
*
data
,
int
len
,
uint8_t
*
checksum
)
{
int16_t
*
p
=
(
int16_t
*
)
data
;
int
i
;
...
...
@@ -554,6 +558,6 @@ void gen_ka2_checksum(char *data, int len, char *checksum)
}
checksum_tmp
&=
0xffff
;
checksum_tmp
*=
0x2c7
;
memcpy
(
checksum
,
(
char
*
)
&
checksum_tmp
,
4
);
memcpy
(
checksum
,
(
uint8_t
*
)
&
checksum_tmp
,
4
);
}
src/config.c
View file @
25965dbb
...
...
@@ -56,7 +56,7 @@ int parse_config(char *conf_file_name)
static
int
parse_line
(
char
*
buf
,
int
size
)
{
char
*
p
;
struct
option_s
opt
=
{
0
};
struct
option_s
opt
=
{
{
0
}
};
//comment
p
=
strchr
(
buf
,
'#'
);
...
...
src/gdut-drcom.c
View file @
25965dbb
...
...
@@ -5,6 +5,10 @@
#include "auth.h"
#include "config.h"
#ifndef VERSION
#define VERSION "unkown"
#endif
static
void
print_help
(
char
*
name
);
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -87,7 +91,7 @@ static void print_help(char *name)
" /___/ "
);
fprintf
(
stdout
,
"A third-party drcom client for gdut.
\n
"
);
fprintf
(
stdout
,
"A third-party drcom client for gdut.
version %s
\n
"
,
VERSION
);
fprintf
(
stdout
,
"usage:
\n
"
);
fprintf
(
stdout
,
" %s
\n
"
,
name
);
fprintf
(
stdout
,
" --remote-ip <ip addr> The server ip.
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment