Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
aa47b4be
提交
aa47b4be
authored
12月 09, 2016
作者:
colm
提交者:
Mike Jerris
1月 25, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-9775: Match up datatypes, alloc node_t, remove ks_dht_bucket.h
上级
c8c2dc87
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
329 行增加
和
456 行删除
+329
-456
Makefile.am
libs/libks/Makefile.am
+1
-1
ks_dht.h
libs/libks/src/dht/ks_dht.h
+55
-4
ks_dht_bucket.c
libs/libks/src/dht/ks_dht_bucket.c
+273
-343
ks_dht_bucket.h
libs/libks/src/dht/ks_dht_bucket.h
+0
-108
没有找到文件。
libs/libks/Makefile.am
浏览文件 @
aa47b4be
...
...
@@ -30,7 +30,7 @@ library_include_HEADERS += src/include/ks_dso.h src/include/ks_platform.h src/in
library_include_HEADERS
+=
src/include/ks_printf.h src/include/ks_hash.h src/include/ks_ssl.h src/include/kws.h
library_include_HEADERS
+=
src/utp/utp_internal.h src/utp/utp.h src/utp/utp_types.h src/utp/utp_callbacks.h src/utp/utp_templates.h
library_include_HEADERS
+=
src/utp/utp_hash.h src/utp/utp_packedsockaddr.h src/utp/utp_utils.h src/include/ks_utp.h
library_include_HEADERS
+=
src/dht/ks_dht.h src/dht/ks_dht-int.h
src/dht/ks_dht_bucket.h
library_include_HEADERS
+=
src/dht/ks_dht.h src/dht/ks_dht-int.h
tests
:
libks.la
$(MAKE)
-C
test
tests
...
...
libs/libks/src/dht/ks_dht.h
浏览文件 @
aa47b4be
...
...
@@ -3,7 +3,6 @@
#include "ks.h"
#include "ks_bencode.h"
#include "ks_dht_bucket.h"
KS_BEGIN_EXTERN_C
...
...
@@ -25,7 +24,9 @@ typedef struct ks_dht_nodeid_s ks_dht_nodeid_t;
typedef
struct
ks_dht_message_s
ks_dht_message_t
;
typedef
struct
ks_dht_endpoint_s
ks_dht_endpoint_t
;
typedef
struct
ks_dht_transaction_s
ks_dht_transaction_t
;
typedef
struct
ks_dht_node_s
ks_dht_node_t
;
typedef
struct
ks_dhtrt_routetable_s
ks_dhtrt_routetable_t
;
typedef
struct
ks_dhtrt_querynodes_s
ks_dhtrt_querynodes_t
;
typedef
ks_status_t
(
*
ks_dht_message_callback_t
)(
ks_dht_t
*
dht
,
ks_dht_message_t
*
message
);
...
...
@@ -36,6 +37,29 @@ struct ks_dht_nodeid_s {
uint8_t
id
[
KS_DHT_NODEID_SIZE
];
};
enum
ipfamily
{
ifv4
=
AF_INET
,
ifv6
=
AF_INET6
,
ifboth
=
AF_INET
+
AF_INET6
};
struct
ks_dht_node_s
{
ks_dht_nodeid_t
nodeid
;
ks_sockaddr_t
addr
;
enum
ipfamily
family
;
/* in: AF_INET or AF_INET6 or both */
ks_dhtrt_routetable_t
*
table
;
};
struct
ks_dhtrt_routetable_s
{
void
*
internal
;
ks_pool_t
*
pool
;
ks_logger_t
logger
;
};
struct
ks_dhtrt_querynodes_s
{
ks_dht_nodeid_t
nodeid
;
/* in: id to query */
enum
ipfamily
family
;
/* in: AF_INET or AF_INET6 or both */
uint8_t
max
;
/* in: maximum to return */
uint8_t
count
;
/* out: number returned */
ks_dht_node_t
*
nodes
[
KS_DHT_MESSAGE_QUERY_MAX_SIZE
];
/* out: array of peers (ks_dht_node_t* nodes[incount]) */
};
struct
ks_dht_message_s
{
ks_pool_t
*
pool
;
ks_dht_endpoint_t
*
endpoint
;
...
...
@@ -91,8 +115,8 @@ struct ks_dht_s {
volatile
uint32_t
transactionid_next
;
ks_hash_t
*
transactions_hash
;
ks_dhtrt_routetable
*
rt_ipv4
;
ks_dhtrt_routetable
*
rt_ipv6
;
ks_dhtrt_routetable
_t
*
rt_ipv4
;
ks_dhtrt_routetable
_t
*
rt_ipv6
;
};
/**
...
...
@@ -156,6 +180,33 @@ KS_DECLARE(ks_status_t) ks_dht_transaction_init(ks_dht_transaction_t *transactio
uint32_t
transactionid
,
ks_dht_message_callback_t
callback
);
KS_DECLARE
(
ks_status_t
)
ks_dht_transaction_deinit
(
ks_dht_transaction_t
*
transaction
);
/**
* route table methods
*
*/
KS_DECLARE
(
ks_dhtrt_routetable_t
*
)
ks_dhtrt_initroute
(
ks_pool_t
*
pool
,
ks_dht_nodeid_t
nodeid
);
KS_DECLARE
(
void
)
ks_dhtrt_deinitroute
(
ks_dhtrt_routetable_t
*
table
);
KS_DECLARE
(
ks_status_t
)
ks_dhtrt_create_node
(
ks_dhtrt_routetable_t
*
table
,
ks_dht_nodeid_t
nodeid
,
char
*
ip
,
unsigned
short
port
,
ks_dht_node_t
**
node
);
KS_DECLARE
(
ks_status_t
)
ks_dhtrt_delete_node
(
ks_dhtrt_routetable_t
*
table
,
ks_dht_node_t
*
node
);
KS_DECLARE
(
ks_status_t
)
ks_dhtrt_touch_node
(
ks_dhtrt_routetable_t
*
table
,
ks_dht_nodeid_t
nodeid
);
KS_DECLARE
(
ks_status_t
)
ks_dhtrt_expire_node
(
ks_dhtrt_routetable_t
*
table
,
ks_dht_nodeid_t
nodeid
);
KS_DECLARE
(
uint8_t
)
ks_dhtrt_findclosest_nodes
(
ks_dhtrt_routetable_t
*
table
,
ks_dhtrt_querynodes_t
*
query
);
KS_DECLARE
(
ks_dht_node_t
*
)
ks_dhtrt_find_node
(
ks_dhtrt_routetable_t
*
table
,
ks_dht_nodeid_t
id
);
KS_DECLARE
(
void
)
ks_dhtrt_process_table
(
ks_dhtrt_routetable_t
*
table
);
/* debugging aids */
KS_DECLARE
(
void
)
ks_dhtrt_dump
(
ks_dhtrt_routetable_t
*
table
,
int
level
);
KS_END_EXTERN_C
...
...
libs/libks/src/dht/ks_dht_bucket.c
浏览文件 @
aa47b4be
差异被折叠。
点击展开。
libs/libks/src/dht/ks_dht_bucket.h
deleted
100644 → 0
浏览文件 @
c8c2dc87
/*
* Copyright (c) 2016 Colm Quinn
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _KS_DHT_BUCKETS_H_
#define _KS_DHT_BUCKETS_H_
#ifdef __cplusplus
#define KS_BEGIN_EXTERN_C extern "C" {
#define KS_END_EXTERN_C }
#else
#define KS_BEGIN_EXTERN_C
#define KS_END_EXTERN_C
#endif
#include "ks.h"
KS_BEGIN_EXTERN_C
/* @todo: temporary - replace with real definiton when available */
typedef
void
ks_dht_node_t
;
enum
ks_dhtrt_nodestate_t
{
DHTRT_UNKNOWN
,
DHTRT_ACTIVE
,
DHTRT_SUSPECT
,
DHTRT_EXPIRED
};
typedef
ks_status_t
(
*
ks_dhtrt_callback
)(
ks_dht_node_t
*
,
enum
ks_dhtrt_nodestate_t
);
/* for testing */
#define KS_DHT_BUCKETSIZE 20
#define KS_DHT_IDSIZE 20
typedef
struct
ks_dhtrt_node_s
{
unsigned
char
id
[
KS_DHT_IDSIZE
];
ks_dht_node_t
*
handle
;
}
ks_dhtrt_node
;
typedef
struct
ks_dhtrt_routetable_s
{
void
*
internal
;
/* ks_dhtrt_internal */
ks_pool_t
*
pool
;
/* */
ks_logger_t
logger
;
}
ks_dhtrt_routetable
;
typedef
struct
ks_dhtrt_querynodes_s
{
unsigned
char
id
[
KS_DHT_IDSIZE
];
/* in: id to query */
uint8_t
max
;
/* in: maximum to return */
uint8_t
count
;
/* out: number returned */
ks_dht_node_t
*
nodes
[
KS_DHT_BUCKETSIZE
];
/* out: array of peers (ks_dht_node_t* peer[incount]) */
}
ks_dhtrt_querynodes
;
typedef
unsigned
char
ks_dhtrt_nodeid
[
KS_DHT_IDSIZE
];
/* methods */
ks_dhtrt_routetable
*
ks_dhtrt_initroute
(
ks_pool_t
*
pool
,
ks_dhtrt_nodeid
localid
);
ks_status_t
ks_dhtrt_registercallback
(
ks_dhtrt_callback
,
enum
ks_dhtrt_nodestate_t
);
void
ks_dhtrt_deinitroute
(
ks_dhtrt_routetable
*
table
);
ks_dhtrt_node
*
ks_dhtrt_create_node
(
ks_dhtrt_routetable
*
table
,
ks_dhtrt_nodeid
nodeid
,
ks_dht_node_t
*
node
);
ks_status_t
ks_dhtrt_delete_node
(
ks_dhtrt_routetable
*
table
,
ks_dhtrt_node
*
node
);
ks_status_t
ks_dhtrt_touch_node
(
ks_dhtrt_routetable
*
table
,
ks_dhtrt_nodeid
nodeid
);
ks_status_t
ks_dhtrt_expire_node
(
ks_dhtrt_routetable
*
table
,
ks_dhtrt_nodeid
nodeid
);
uint8_t
ks_dhtrt_findclosest_nodes
(
ks_dhtrt_routetable
*
table
,
ks_dhtrt_querynodes
*
query
);
ks_dht_node_t
*
ks_dhtrt_find_node
(
ks_dhtrt_routetable
*
table
,
ks_dhtrt_nodeid
id
);
/* debugging aids */
void
ks_dhtrt_dump
(
ks_dhtrt_routetable
*
table
,
int
level
);
void
ks_dhtrt_process_table
(
ks_dhtrt_routetable
*
table
);
KS_END_EXTERN_C
#endif
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论