Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d3efe9d8
提交
d3efe9d8
authored
5月 20, 2007
作者:
Michael Jerris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup
git-svn-id:
http://svn.openzap.org/svn/openzap/trunk@50
a93c3328-9c30-0410-af19-c9cd2b2d52af
上级
7b34a53f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
226 行删除
+10
-226
sangoma_tdm_api.h
libs/openzap/src/include/sangoma_tdm_api.h
+10
-226
没有找到文件。
libs/openzap/src/include/sangoma_tdm_api.h
浏览文件 @
d3efe9d8
...
...
@@ -146,52 +146,7 @@ void tdmv_api_close_socket(sng_fd_t *sp)
}
#ifdef __WINDOWS__
#if 0
static int wanpipe_api_ioctl(sng_fd_t fd, wan_cmd_api_t *api_cmd)
{
DWORD ln;
unsigned char id = 0;
int err = 0;
wan_udp.wan_udphdr_request_reply = 0x01;
wan_udp.wan_udphdr_id = id;
wan_udp.wan_udphdr_return_code = WAN_UDP_TIMEOUT_CMD;
wan_udp.wan_udphdr_command = SIOC_WANPIPE_API;
wan_udp.wan_udphdr_data_len = sizeof(wan_cmd_api_t);
//copy data from caller's buffer to driver's buffer
memcpy( wan_udp.wan_udphdr_data,
(void*)api_cmd,
sizeof(wan_cmd_api_t));
if(DeviceIoControl(
fd,
IoctlManagementCommand,
(LPVOID)&wan_udp,
sizeof(wan_udp_hdr_t),
(LPVOID)&wan_udp,
sizeof(wan_udp_hdr_t),
(LPDWORD)(&ln),
(LPOVERLAPPED)NULL
) == FALSE){
err = 1;
return err;
}else{
err = 0;
}
if(wan_udp.wan_udphdr_return_code != WAN_CMD_OK){
return 2;
}
//copy data from driver's buffer to caller's buffer
memcpy( (void*)api_cmd,
wan_udp.wan_udphdr_data,
sizeof(wan_cmd_api_t));
return 0;
}
#endif
// Blocking read command. If used after DoApiPollCommand(),
// it will return immediatly, without blocking.
static
...
...
@@ -247,186 +202,6 @@ DoWriteCommand(
}
}
// Blocking API Poll command.
static
USHORT
DoApiPollCommand
(
sng_fd_t
drv
,
API_POLL_STRUCT
*
api_poll_ptr
)
{
DWORD
ln
;
if
(
DeviceIoControl
(
drv
,
IoctlApiPoll
,
(
LPVOID
)
NULL
,
0L
,
(
LPVOID
)
api_poll_ptr
,
sizeof
(
API_POLL_STRUCT
),
(
LPDWORD
)(
&
ln
),
(
LPOVERLAPPED
)
NULL
)
==
FALSE
){
return
1
;
}
else
{
return
0
;
}
}
static
int
DoManagementCommand
(
sng_fd_t
drv
,
wan_udp_hdr_t
*
wan_udp
)
{
DWORD
ln
;
static
unsigned
char
id
=
0
;
wan_udp
->
wan_udphdr_request_reply
=
0x01
;
wan_udp
->
wan_udphdr_id
=
id
++
;
wan_udp
->
wan_udphdr_return_code
=
WAN_UDP_TIMEOUT_CMD
;
if
(
DeviceIoControl
(
drv
,
IoctlManagementCommand
,
(
LPVOID
)
wan_udp
,
sizeof
(
wan_udp_hdr_t
),
(
LPVOID
)
wan_udp
,
sizeof
(
wan_udp_hdr_t
),
(
LPDWORD
)(
&
ln
),
(
LPOVERLAPPED
)
NULL
)
==
FALSE
){
return
1
;
}
else
{
return
0
;
}
}
///////////////////////////////////////////////////////////////////////////
//
//structures and definitions used for queueing data
//
typedef
struct
{
void
*
previous
;
TX_RX_DATA_STRUCT
tx_rx_data
;
}
api_queue_element_t
;
#define API_Q_MUTEX_TIMEOUT 1000//1 second
#define API_Q_MAX_SIZE 100//optimal length. for short data may need longer queue
enum
API_Q_STATUS
{
API_Q_SUCCESS
=
0
,
API_Q_GEN_FAILURE
,
API_Q_MEM_ALLOC_FAILURE
,
API_Q_FULL
,
API_Q_EMPTY
};
typedef
struct
{
//number of nodes in the list
USHORT
size
;
//insert at tail
api_queue_element_t
*
tail
;
//remove from head
api_queue_element_t
*
head
;
//mutex for synchronizing access to the queue
sng_fd_t
api_queue_mutex
;
}
api_queue_t
;
static
__inline
int
api_enqueue
(
api_queue_t
*
api_queue
,
unsigned
char
*
buffer
,
unsigned
short
length
)
{
api_queue_element_t
*
element
;
DWORD
mresult
;
mresult
=
WaitForSingleObject
(
api_queue
->
api_queue_mutex
,
API_Q_MUTEX_TIMEOUT
);
if
(
mresult
!=
WAIT_OBJECT_0
)
{
return
API_Q_GEN_FAILURE
;
}
if
(
api_queue
->
size
==
API_Q_MAX_SIZE
){
ReleaseMutex
(
api_queue
->
api_queue_mutex
);
return
API_Q_FULL
;
}
element
=
malloc
(
sizeof
(
api_queue_element_t
));
if
(
element
==
NULL
){
ReleaseMutex
(
api_queue
->
api_queue_mutex
);
return
API_Q_MEM_ALLOC_FAILURE
;
}
//now copy everything in to the element
memcpy
(
element
->
tx_rx_data
.
data
,
buffer
,
length
);
element
->
tx_rx_data
.
api_header
.
data_length
=
length
;
element
->
tx_rx_data
.
api_header
.
operation_status
=
SANG_STATUS_TX_TIMEOUT
;
//insert element at the tail of the queue
element
->
previous
=
NULL
;
if
(
api_queue
->
size
==
0
){
//special case of a previously empty queue
api_queue
->
head
=
element
;
api_queue
->
tail
=
element
;
}
else
{
api_queue
->
tail
->
previous
=
element
;
api_queue
->
tail
=
element
;
}
api_queue
->
size
++
;
ReleaseMutex
(
api_queue
->
api_queue_mutex
);
return
API_Q_SUCCESS
;
}
static
__inline
int
api_dequeue
(
api_queue_t
*
api_queue
,
TX_RX_DATA_STRUCT
*
destination
)
{
api_queue_element_t
*
element
;
DWORD
mresult
;
mresult
=
WaitForSingleObject
(
api_queue
->
api_queue_mutex
,
API_Q_MUTEX_TIMEOUT
);
if
(
mresult
!=
WAIT_OBJECT_0
)
{
return
API_Q_GEN_FAILURE
;
}
if
(
api_queue
->
size
==
0
){
//tx queue is empty
ReleaseMutex
(
api_queue
->
api_queue_mutex
);
return
API_Q_EMPTY
;
}
//remove from the head of the queue
element
=
api_queue
->
head
;
api_queue
->
head
=
element
->
previous
;
//now copy everything in to the user buffer
memcpy
(
destination
,
&
element
->
tx_rx_data
,
sizeof
(
TX_DATA_STRUCT
));
free
(
element
);
api_queue
->
size
--
;
if
(
api_queue
->
size
==
0
){
api_queue
->
head
=
NULL
;
api_queue
->
tail
=
NULL
;
}
ReleaseMutex
(
api_queue
->
api_queue_mutex
);
return
API_Q_SUCCESS
;
}
//remove all elements from the queue
static
__inline
void
empty_api_queue
(
api_queue_t
*
api_queue
)
{
TX_DATA_STRUCT
tx_rx_data
;
while
(
api_dequeue
(
api_queue
,
&
tx_rx_data
)
==
0
){
;
}
}
///////////////////////////////////////////////////////////////////////////
#endif
#if defined(__WINDOWS__)
...
...
@@ -438,6 +213,7 @@ static __inline void empty_api_queue(api_queue_t* api_queue)
int
tdmv_api_wait_socket
(
sng_fd_t
fd
,
int
timeout
,
int
flags
)
{
#if defined(__WINDOWS__)
DWORD
ln
;
API_POLL_STRUCT
api_poll
;
memset
(
&
api_poll
,
0x00
,
sizeof
(
API_POLL_STRUCT
));
...
...
@@ -445,7 +221,15 @@ int tdmv_api_wait_socket(sng_fd_t fd, int timeout, int flags)
api_poll
.
user_flags_bitmap
=
flags
;
api_poll
.
timeout
=
timeout
;
if
(
DoApiPollCommand
(
fd
,
&
api_poll
))
{
if
(
!
DeviceIoControl
(
fd
,
IoctlApiPoll
,
(
LPVOID
)
NULL
,
0L
,
(
LPVOID
)
&
api_poll
,
sizeof
(
API_POLL_STRUCT
),
(
LPDWORD
)(
&
ln
),
(
LPOVERLAPPED
)
NULL
))
{
return
-
1
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论