Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
779592a9
提交
779592a9
authored
12月 12, 2016
作者:
colm
提交者:
Mike Jerris
1月 25, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-9775: Updates for latest dht_bucket changes
上级
0842616a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
58 行增加
和
53 行删除
+58
-53
ks_dht.c
libs/libks/src/dht/ks_dht.c
+13
-13
testbuckets.c
libs/libks/test/testbuckets.c
+45
-40
没有找到文件。
libs/libks/src/dht/ks_dht.c
浏览文件 @
779592a9
...
@@ -534,7 +534,7 @@ KS_DECLARE(ks_status_t) ks_dht_bind(ks_dht_t *dht, const ks_dht_nodeid_t *nodeid
...
@@ -534,7 +534,7 @@ KS_DECLARE(ks_status_t) ks_dht_bind(ks_dht_t *dht, const ks_dht_nodeid_t *nodeid
if
(
!
dht
->
rt_ipv4
&&
(
ret
=
ks_dhtrt_initroute
(
&
dht
->
rt_ipv4
,
dht
->
pool
))
!=
KS_STATUS_SUCCESS
)
goto
done
;
if
(
!
dht
->
rt_ipv4
&&
(
ret
=
ks_dhtrt_initroute
(
&
dht
->
rt_ipv4
,
dht
->
pool
))
!=
KS_STATUS_SUCCESS
)
goto
done
;
if
((
ret
=
ks_dhtrt_create_node
(
dht
->
rt_ipv4
,
if
((
ret
=
ks_dhtrt_create_node
(
dht
->
rt_ipv4
,
ep
->
nodeid
,
ep
->
nodeid
,
ks_dht_local_t
,
KS_DHT_LOCAL
,
ep
->
addr
.
host
,
ep
->
addr
.
host
,
ep
->
addr
.
port
,
ep
->
addr
.
port
,
&
ep
->
node
))
!=
KS_STATUS_SUCCESS
)
goto
done
;
&
ep
->
node
))
!=
KS_STATUS_SUCCESS
)
goto
done
;
...
@@ -542,7 +542,7 @@ KS_DECLARE(ks_status_t) ks_dht_bind(ks_dht_t *dht, const ks_dht_nodeid_t *nodeid
...
@@ -542,7 +542,7 @@ KS_DECLARE(ks_status_t) ks_dht_bind(ks_dht_t *dht, const ks_dht_nodeid_t *nodeid
if
(
!
dht
->
rt_ipv6
&&
(
ret
=
ks_dhtrt_initroute
(
&
dht
->
rt_ipv6
,
dht
->
pool
))
!=
KS_STATUS_SUCCESS
)
goto
done
;
if
(
!
dht
->
rt_ipv6
&&
(
ret
=
ks_dhtrt_initroute
(
&
dht
->
rt_ipv6
,
dht
->
pool
))
!=
KS_STATUS_SUCCESS
)
goto
done
;
if
((
ret
=
ks_dhtrt_create_node
(
dht
->
rt_ipv6
,
if
((
ret
=
ks_dhtrt_create_node
(
dht
->
rt_ipv6
,
ep
->
nodeid
,
ep
->
nodeid
,
ks_dht_local_t
,
KS_DHT_LOCAL
,
ep
->
addr
.
host
,
ep
->
addr
.
host
,
ep
->
addr
.
port
,
ep
->
addr
.
port
,
&
ep
->
node
))
!=
KS_STATUS_SUCCESS
)
goto
done
;
&
ep
->
node
))
!=
KS_STATUS_SUCCESS
)
goto
done
;
...
@@ -1326,7 +1326,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_query_ping(ks_dht_t *dht, ks_dht_message_
...
@@ -1326,7 +1326,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_query_ping(ks_dht_t *dht, ks_dht_message_
// @todo touch here, or only create if not exists?
// @todo touch here, or only create if not exists?
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
routetable
,
*
id
,
ks_dht_remote_t
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
ks_dhtrt_create_node
(
routetable
,
*
id
,
KS_DHT_REMOTE
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
}
}
ks_log
(
KS_LOG_DEBUG
,
"Message query ping is valid
\n
"
);
ks_log
(
KS_LOG_DEBUG
,
"Message query ping is valid
\n
"
);
...
@@ -1363,7 +1363,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_ping(ks_dht_t *dht, ks_dht_messa
...
@@ -1363,7 +1363,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_ping(ks_dht_t *dht, ks_dht_messa
routetable
=
message
->
endpoint
->
node
->
table
;
routetable
=
message
->
endpoint
->
node
->
table
;
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
routetable
,
*
id
,
ks_dht_remote_t
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
ks_dhtrt_create_node
(
routetable
,
*
id
,
KS_DHT_REMOTE
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
}
}
ks_log
(
KS_LOG_DEBUG
,
"Message response ping is reached
\n
"
);
ks_log
(
KS_LOG_DEBUG
,
"Message response ping is reached
\n
"
);
...
@@ -1436,14 +1436,14 @@ KS_DECLARE(ks_status_t) ks_dht_process_query_findnode(ks_dht_t *dht, ks_dht_mess
...
@@ -1436,14 +1436,14 @@ KS_DECLARE(ks_status_t) ks_dht_process_query_findnode(ks_dht_t *dht, ks_dht_mess
routetable
=
message
->
endpoint
->
node
->
table
;
routetable
=
message
->
endpoint
->
node
->
table
;
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
routetable
,
*
id
,
ks_dht_remote_t
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
ks_dhtrt_create_node
(
routetable
,
*
id
,
KS_DHT_REMOTE
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
}
}
ks_log
(
KS_LOG_DEBUG
,
"Message query find_node is valid
\n
"
);
ks_log
(
KS_LOG_DEBUG
,
"Message query find_node is valid
\n
"
);
query
.
nodeid
=
*
target
;
query
.
nodeid
=
*
target
;
query
.
type
=
ks_dht_remote_t
;
query
.
type
=
KS_DHT_REMOTE
;
query
.
max
=
8
;
// should be like KS_DHTRT_BUCKET_SIZE
query
.
max
=
8
;
// should be like KS_DHTRT_BUCKET_SIZE
if
(
want4
)
{
if
(
want4
)
{
query
.
family
=
AF_INET
;
query
.
family
=
AF_INET
;
...
@@ -1537,7 +1537,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_findnode(ks_dht_t *dht, ks_dht_m
...
@@ -1537,7 +1537,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_findnode(ks_dht_t *dht, ks_dht_m
routetable
=
message
->
endpoint
->
node
->
table
;
routetable
=
message
->
endpoint
->
node
->
table
;
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
routetable
,
*
id
,
ks_dht_remote_t
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
ks_dhtrt_create_node
(
routetable
,
*
id
,
KS_DHT_REMOTE
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
}
}
while
(
nodes_len
<
nodes_size
)
{
while
(
nodes_len
<
nodes_size
)
{
...
@@ -1554,7 +1554,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_findnode(ks_dht_t *dht, ks_dht_m
...
@@ -1554,7 +1554,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_findnode(ks_dht_t *dht, ks_dht_m
addr
.
port
);
addr
.
port
);
if
(
ks_dhtrt_touch_node
(
dht
->
rt_ipv4
,
nid
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
dht
->
rt_ipv4
,
nid
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
dht
->
rt_ipv4
,
nid
,
ks_dht_remote_t
,
addr
.
host
,
addr
.
port
,
&
node
);
ks_dhtrt_create_node
(
dht
->
rt_ipv4
,
nid
,
KS_DHT_REMOTE
,
addr
.
host
,
addr
.
port
,
&
node
);
}
}
}
}
...
@@ -1572,7 +1572,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_findnode(ks_dht_t *dht, ks_dht_m
...
@@ -1572,7 +1572,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_findnode(ks_dht_t *dht, ks_dht_m
addr
.
port
);
addr
.
port
);
if
(
ks_dhtrt_touch_node
(
dht
->
rt_ipv6
,
nid
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
dht
->
rt_ipv6
,
nid
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
dht
->
rt_ipv6
,
nid
,
ks_dht_remote_t
,
addr
.
host
,
addr
.
port
,
&
node
);
ks_dhtrt_create_node
(
dht
->
rt_ipv6
,
nid
,
KS_DHT_REMOTE
,
addr
.
host
,
addr
.
port
,
&
node
);
}
}
}
}
// @todo repeat above for ipv6 table
// @todo repeat above for ipv6 table
...
@@ -1632,7 +1632,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_query_get(ks_dht_t *dht, ks_dht_message_t
...
@@ -1632,7 +1632,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_query_get(ks_dht_t *dht, ks_dht_message_t
routetable
=
message
->
endpoint
->
node
->
table
;
routetable
=
message
->
endpoint
->
node
->
table
;
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
routetable
,
*
id
,
ks_dht_remote_t
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
ks_dhtrt_create_node
(
routetable
,
*
id
,
KS_DHT_REMOTE
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
}
}
ks_log
(
KS_LOG_DEBUG
,
"Message query get is valid
\n
"
);
ks_log
(
KS_LOG_DEBUG
,
"Message query get is valid
\n
"
);
...
@@ -1700,7 +1700,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_get(ks_dht_t *dht, ks_dht_messag
...
@@ -1700,7 +1700,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_get(ks_dht_t *dht, ks_dht_messag
routetable
=
message
->
endpoint
->
node
->
table
;
routetable
=
message
->
endpoint
->
node
->
table
;
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
routetable
,
*
id
,
ks_dht_remote_t
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
ks_dhtrt_create_node
(
routetable
,
*
id
,
KS_DHT_REMOTE
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
}
}
// @todo add/touch bucket entries for other nodes/nodes6 returned
// @todo add/touch bucket entries for other nodes/nodes6 returned
...
@@ -1729,7 +1729,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_query_put(ks_dht_t *dht, ks_dht_message_t
...
@@ -1729,7 +1729,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_query_put(ks_dht_t *dht, ks_dht_message_t
routetable
=
message
->
endpoint
->
node
->
table
;
routetable
=
message
->
endpoint
->
node
->
table
;
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
routetable
,
*
id
,
ks_dht_remote_t
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
ks_dhtrt_create_node
(
routetable
,
*
id
,
KS_DHT_REMOTE
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
}
}
ks_log
(
KS_LOG_DEBUG
,
"Message query put is valid
\n
"
);
ks_log
(
KS_LOG_DEBUG
,
"Message query put is valid
\n
"
);
...
@@ -1766,7 +1766,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_put(ks_dht_t *dht, ks_dht_messag
...
@@ -1766,7 +1766,7 @@ KS_DECLARE(ks_status_t) ks_dht_process_response_put(ks_dht_t *dht, ks_dht_messag
routetable
=
message
->
endpoint
->
node
->
table
;
routetable
=
message
->
endpoint
->
node
->
table
;
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
if
(
ks_dhtrt_touch_node
(
routetable
,
*
id
)
!=
KS_STATUS_SUCCESS
)
{
ks_dhtrt_create_node
(
routetable
,
*
id
,
ks_dht_remote_t
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
ks_dhtrt_create_node
(
routetable
,
*
id
,
KS_DHT_REMOTE
,
message
->
raddr
.
host
,
message
->
raddr
.
port
,
&
node
);
}
}
ks_log
(
KS_LOG_DEBUG
,
"Message response put is reached
\n
"
);
ks_log
(
KS_LOG_DEBUG
,
"Message response put is reached
\n
"
);
...
...
libs/libks/test/testbuckets.c
浏览文件 @
779592a9
...
@@ -8,7 +8,7 @@ ks_dhtrt_routetable_t* rt;
...
@@ -8,7 +8,7 @@ ks_dhtrt_routetable_t* rt;
ks_pool_t
*
pool
;
ks_pool_t
*
pool
;
int
doquery
(
ks_dhtrt_routetable_t
*
rt
,
uint8_t
*
id
,
enum
ks_dht_nodetype_t
type
,
enum
ipfamily
family
)
int
doquery
(
ks_dhtrt_routetable_t
*
rt
,
uint8_t
*
id
,
enum
ks_dht_nodetype_t
type
,
enum
ks_afflags_t
family
)
{
{
ks_dhtrt_querynodes_t
query
;
ks_dhtrt_querynodes_t
query
;
memset
(
&
query
,
0
,
sizeof
(
query
));
memset
(
&
query
,
0
,
sizeof
(
query
));
...
@@ -35,9 +35,10 @@ void test01()
...
@@ -35,9 +35,10 @@ void test01()
char
ip
[]
=
"192.168.100.100"
;
char
ip
[]
=
"192.168.100.100"
;
unsigned
short
port
=
7000
;
unsigned
short
port
=
7000
;
ks_dht_node_t
*
peer
;
ks_dht_node_t
*
peer
;
ks_dht_node_t
*
peer1
;
ks_status_t
status
;
ks_status_t
status
;
status
=
ks_dhtrt_create_node
(
rt
,
homeid
,
ks_dht_local_t
,
ip
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
homeid
,
KS_DHT_LOCAL
,
ip
,
port
,
&
peer
);
if
(
status
==
KS_STATUS_FAIL
)
{
if
(
status
==
KS_STATUS_FAIL
)
{
printf
(
"*** ks_dhtrt_create_node test01 failed
\n
"
);
printf
(
"*** ks_dhtrt_create_node test01 failed
\n
"
);
exit
(
101
);
exit
(
101
);
...
@@ -49,11 +50,15 @@ void test01()
...
@@ -49,11 +50,15 @@ void test01()
exit
(
102
);
exit
(
102
);
}
}
status
=
ks_dhtrt_create_node
(
rt
,
homeid
,
ks_dht_local_t
,
ip
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
homeid
,
KS_DHT_LOCAL
,
ip
,
port
,
&
peer1
);
if
(
status
!
=
KS_STATUS_FAIL
)
{
if
(
status
=
=
KS_STATUS_FAIL
)
{
printf
(
"*** ks_dhtrt_create_node test01
allowed duplicate
!!
\n
"
);
printf
(
"*** ks_dhtrt_create_node test01
did allow duplicate createnodes
!!
\n
"
);
exit
(
103
);
exit
(
103
);
}
}
if
(
peer
!=
peer1
)
{
printf
(
"*** ks_dhtrt_create_node duplicate createnode did not return the same node!
\n
"
);
exit
(
104
);
}
status
=
ks_dhtrt_delete_node
(
rt
,
peer
);
status
=
ks_dhtrt_delete_node
(
rt
,
peer
);
if
(
status
==
KS_STATUS_FAIL
)
{
if
(
status
==
KS_STATUS_FAIL
)
{
...
@@ -73,52 +78,52 @@ void test02()
...
@@ -73,52 +78,52 @@ void test02()
char
ipv6
[]
=
"1234:1234:1234:1234"
;
char
ipv6
[]
=
"1234:1234:1234:1234"
;
char
ipv4
[]
=
"123.123.123.123"
;
char
ipv4
[]
=
"123.123.123.123"
;
unsigned
short
port
=
7000
;
unsigned
short
port
=
7000
;
enum
ipfamily
both
=
ifboth
;
enum
ks_afflags_t
both
=
ifboth
;
ks_status_t
status
;
ks_status_t
status
;
nodeid
.
id
[
0
]
=
1
;
nodeid
.
id
[
0
]
=
1
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_local_t
,
ipv6
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_LOCAL
,
ipv6
,
port
,
&
peer
);
nodeid
.
id
[
0
]
=
2
;
nodeid
.
id
[
0
]
=
2
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv6
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv6
,
port
,
&
peer
);
nodeid
.
id
[
0
]
=
3
;
nodeid
.
id
[
0
]
=
3
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv6
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv6
,
port
,
&
peer
);
nodeid
.
id
[
0
]
=
4
;
nodeid
.
id
[
0
]
=
4
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_local_t
,
ipv6
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_LOCAL
,
ipv6
,
port
,
&
peer
);
nodeid
.
id
[
1
]
=
1
;
nodeid
.
id
[
1
]
=
1
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv6
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv6
,
port
,
&
peer
);
nodeid
.
id
[
19
]
=
1
;
nodeid
.
id
[
19
]
=
1
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv4
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv4
,
port
,
&
peer
);
nodeid
.
id
[
19
]
=
2
;
nodeid
.
id
[
19
]
=
2
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv4
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv4
,
port
,
&
peer
);
nodeid
.
id
[
19
]
=
3
;
nodeid
.
id
[
19
]
=
3
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv4
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv4
,
port
,
&
peer
);
nodeid
.
id
[
19
]
=
4
;
nodeid
.
id
[
19
]
=
4
;
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_local_t
,
ipv4
,
port
,
&
peer
);
status
=
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_LOCAL
,
ipv4
,
port
,
&
peer
);
int
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_local_t
,
both
);
int
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_LOCAL
,
both
);
printf
(
"
\n
*** local query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** local query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_remote_t
,
both
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_REMOTE
,
both
);
printf
(
"
\n
*** remote query count expected 6, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** remote query count expected 6, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_both_t
,
both
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_BOTH
,
both
);
printf
(
"
\n
*** both query count expected 9, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** both query count expected 9, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_local_t
,
ifv4
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_LOCAL
,
ifv4
);
printf
(
"
\n
*** local AF_INET query count expected 1, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** local AF_INET query count expected 1, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_local_t
,
ifv6
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_LOCAL
,
ifv6
);
printf
(
"
\n
*** local AF_INET6 query count expected 2, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** local AF_INET6 query count expected 2, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_both_t
,
ifv6
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_BOTH
,
ifv6
);
printf
(
"
\n
*** AF_INET6 count expected 5, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** AF_INET6 count expected 5, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_remote_t
,
ifv4
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_REMOTE
,
ifv4
);
printf
(
"
\n
*** remote AF_INET query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** remote AF_INET query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_remote_t
,
ifv6
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_REMOTE
,
ifv6
);
printf
(
"
\n
*** remote AF_INET6 query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** remote AF_INET6 query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_both_t
,
ifv4
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_BOTH
,
ifv4
);
printf
(
"
\n
*** AF_INET count expected 4, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** AF_INET count expected 4, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
return
;
return
;
...
@@ -135,7 +140,7 @@ void test03()
...
@@ -135,7 +140,7 @@ void test03()
char
ipv6
[]
=
"1234:1234:1234:1234"
;
char
ipv6
[]
=
"1234:1234:1234:1234"
;
char
ipv4
[]
=
"123.123.123.123"
;
char
ipv4
[]
=
"123.123.123.123"
;
unsigned
short
port
=
7000
;
unsigned
short
port
=
7000
;
enum
ipfamily
both
=
ifboth
;
enum
ks_afflags_t
both
=
ifboth
;
ks_status_t
status
;
ks_status_t
status
;
...
@@ -146,7 +151,7 @@ void test03()
...
@@ -146,7 +151,7 @@ void test03()
else
{
else
{
++
nodeid
.
id
[
1
];
++
nodeid
.
id
[
1
];
}
}
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv4
,
port
,
&
peer
);
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv4
,
port
,
&
peer
);
}
}
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
...
@@ -157,7 +162,7 @@ void test03()
...
@@ -157,7 +162,7 @@ void test03()
++
nodeid
.
id
[
1
];
++
nodeid
.
id
[
1
];
}
}
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_local_t
,
ipv4
,
port
,
&
peer
);
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_LOCAL
,
ipv4
,
port
,
&
peer
);
}
}
for
(
int
i
=
0
;
i
<
201
;
++
i
)
{
for
(
int
i
=
0
;
i
<
201
;
++
i
)
{
...
@@ -167,31 +172,31 @@ void test03()
...
@@ -167,31 +172,31 @@ void test03()
else
{
else
{
++
nodeid
.
id
[
1
];
++
nodeid
.
id
[
1
];
}
}
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv6
,
port
,
&
peer
);
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv6
,
port
,
&
peer
);
}
}
int
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_local_t
,
both
);
int
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_LOCAL
,
both
);
printf
(
"
\n
** local query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
** local query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_remote_t
,
both
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_REMOTE
,
both
);
printf
(
"
\n
*** remote query count expected 6, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** remote query count expected 6, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_both_t
,
both
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_BOTH
,
both
);
printf
(
"
\n
*** both query count expected 9, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** both query count expected 9, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_local_t
,
ifv4
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_LOCAL
,
ifv4
);
printf
(
"
\n
*** local AF_INET query count expected 1, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** local AF_INET query count expected 1, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_local_t
,
ifv6
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_LOCAL
,
ifv6
);
printf
(
"
\n
*** local AF_INET6 query count expected 2, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** local AF_INET6 query count expected 2, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_both_t
,
ifv6
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_BOTH
,
ifv6
);
printf
(
"
\n
*** AF_INET6 count expected 5, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** AF_INET6 count expected 5, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_remote_t
,
ifv4
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_REMOTE
,
ifv4
);
printf
(
"
\n
** remote AF_INET query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
** remote AF_INET query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_remote_t
,
ifv6
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_REMOTE
,
ifv6
);
printf
(
"
\n
*** remote AF_INET6 query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** remote AF_INET6 query count expected 3, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_both_t
,
ifv4
);
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_BOTH
,
ifv4
);
printf
(
"
\n
*** AF_INET count expected 4, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
printf
(
"
\n
*** AF_INET count expected 4, actual %d
\n
"
,
qcount
);
fflush
(
stdout
);
return
;
return
;
...
@@ -206,7 +211,7 @@ void test04()
...
@@ -206,7 +211,7 @@ void test04()
char
ipv6
[]
=
"1234:1234:1234:1234"
;
char
ipv6
[]
=
"1234:1234:1234:1234"
;
char
ipv4
[]
=
"123.123.123.123"
;
char
ipv4
[]
=
"123.123.123.123"
;
unsigned
short
port
=
7000
;
unsigned
short
port
=
7000
;
enum
ipfamily
both
=
ifboth
;
enum
ks_afflags_t
both
=
ifboth
;
ks_status_t
status
;
ks_status_t
status
;
...
@@ -223,13 +228,13 @@ void test04()
...
@@ -223,13 +228,13 @@ void test04()
else
{
else
{
++
nodeid
.
id
[
1
];
++
nodeid
.
id
[
1
];
}
}
ks_dhtrt_create_node
(
rt
,
nodeid
,
ks_dht_remote_t
,
ipv4
,
port
,
&
peer
);
ks_dhtrt_create_node
(
rt
,
nodeid
,
KS_DHT_REMOTE
,
ipv4
,
port
,
&
peer
);
}
}
memset
(
nodeid
.
id
,
0x2f
,
KS_DHT_NODEID_SIZE
);
memset
(
nodeid
.
id
,
0x2f
,
KS_DHT_NODEID_SIZE
);
ks_time_t
t0
=
ks_time_now
();
ks_time_t
t0
=
ks_time_now
();
int
qcount
=
doquery
(
rt
,
nodeid
.
id
,
ks_dht_both_t
,
ifv4
);
int
qcount
=
doquery
(
rt
,
nodeid
.
id
,
KS_DHT_BOTH
,
ifv4
);
ks_time_t
t1
=
ks_time_now
();
ks_time_t
t1
=
ks_time_now
();
int
tx
=
t1
-
t0
;
int
tx
=
t1
-
t0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论