Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
61e22e8b
提交
61e22e8b
authored
4月 22, 2014
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-6476 --resolve
上级
25c9b619
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
432 行增加
和
132 行删除
+432
-132
ws.c
libs/sofia-sip/libsofia-sip-ua/tport/ws.c
+24
-8
ws.h
libs/sofia-sip/libsofia-sip-ua/tport/ws.h
+1
-0
ws.c
src/mod/xml_int/mod_xml_rpc/ws.c
+368
-103
ws.h
src/mod/xml_int/mod_xml_rpc/ws.h
+39
-21
没有找到文件。
libs/sofia-sip/libsofia-sip-ua/tport/ws.c
浏览文件 @
61e22e8b
...
@@ -318,17 +318,26 @@ int ws_handshake(wsh_t *wsh)
...
@@ -318,17 +318,26 @@ int ws_handshake(wsh_t *wsh)
ssize_t
ws_raw_read
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
)
ssize_t
ws_raw_read
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
)
{
{
ssize_t
r
;
ssize_t
r
;
int
x
=
0
;
int
err
=
0
;
if
(
wsh
->
ssl
)
{
if
(
wsh
->
ssl
)
{
do
{
do
{
r
=
SSL_read
(
wsh
->
ssl
,
data
,
bytes
);
r
=
SSL_read
(
wsh
->
ssl
,
data
,
bytes
);
#ifndef _MSC_VER
#ifndef _MSC_VER
if
(
x
++
)
usleep
(
10000
);
if
(
wsh
->
x
++
)
usleep
(
10000
);
#else
#else
if
(
x
++
)
Sleep
(
10
);
if
(
wsh
->
x
++
)
Sleep
(
10
);
#endif
#endif
}
while
(
r
==
-
1
&&
SSL_get_error
(
wsh
->
ssl
,
r
)
==
SSL_ERROR_WANT_READ
&&
x
<
100
);
if
(
r
==
-
1
)
{
err
=
SSL_get_error
(
wsh
->
ssl
,
r
);
if
(
wsh
->
handshake
&&
err
==
SSL_ERROR_WANT_READ
)
{
r
=
-
2
;
goto
end
;
}
}
}
while
(
r
==
-
1
&&
err
==
SSL_ERROR_WANT_READ
&&
wsh
->
x
<
100
);
goto
end
;
goto
end
;
}
}
...
@@ -336,13 +345,13 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes)
...
@@ -336,13 +345,13 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes)
do
{
do
{
r
=
recv
(
wsh
->
sock
,
data
,
bytes
,
0
);
r
=
recv
(
wsh
->
sock
,
data
,
bytes
,
0
);
#ifndef _MSC_VER
#ifndef _MSC_VER
if
(
x
++
)
usleep
(
10000
);
if
(
wsh
->
x
++
)
usleep
(
10000
);
#else
#else
if
(
x
++
)
Sleep
(
10
);
if
(
wsh
->
x
++
)
Sleep
(
10
);
#endif
#endif
}
while
(
r
==
-
1
&&
xp_is_blocking
(
xp_errno
())
&&
x
<
100
);
}
while
(
r
==
-
1
&&
xp_is_blocking
(
xp_errno
())
&&
wsh
->
x
<
100
);
if
(
x
>=
100
)
{
if
(
wsh
->
x
>=
100
)
{
r
=
-
1
;
r
=
-
1
;
}
}
...
@@ -352,6 +361,10 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes)
...
@@ -352,6 +361,10 @@ ssize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes)
*
((
char
*
)
data
+
r
)
=
'\0'
;
*
((
char
*
)
data
+
r
)
=
'\0'
;
}
}
if
(
r
>=
0
)
{
wsh
->
x
=
0
;
}
return
r
;
return
r
;
}
}
...
@@ -621,6 +634,9 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
...
@@ -621,6 +634,9 @@ ssize_t ws_read_frame(wsh_t *wsh, ws_opcode_t *oc, uint8_t **data)
}
}
if
((
wsh
->
datalen
=
ws_raw_read
(
wsh
,
wsh
->
buffer
,
9
))
<
0
)
{
if
((
wsh
->
datalen
=
ws_raw_read
(
wsh
,
wsh
->
buffer
,
9
))
<
0
)
{
if
(
wsh
->
datalen
==
-
2
)
{
return
-
2
;
}
return
ws_close
(
wsh
,
WS_PROTO_ERR
);
return
ws_close
(
wsh
,
WS_PROTO_ERR
);
}
}
...
...
libs/sofia-sip/libsofia-sip-ua/tport/ws.h
浏览文件 @
61e22e8b
...
@@ -88,6 +88,7 @@ typedef struct wsh_s {
...
@@ -88,6 +88,7 @@ typedef struct wsh_s {
int
sanity
;
int
sanity
;
int
secure_established
;
int
secure_established
;
int
logical_established
;
int
logical_established
;
int
x
;
}
wsh_t
;
}
wsh_t
;
ssize_t
ws_send_buf
(
wsh_t
*
wsh
,
ws_opcode_t
oc
);
ssize_t
ws_send_buf
(
wsh_t
*
wsh
,
ws_opcode_t
oc
);
...
...
src/mod/xml_int/mod_xml_rpc/ws.c
浏览文件 @
61e22e8b
差异被折叠。
点击展开。
src/mod/xml_int/mod_xml_rpc/ws.h
浏览文件 @
61e22e8b
...
@@ -13,30 +13,40 @@
...
@@ -13,30 +13,40 @@
#include <sys/socket.h>
#include <sys/socket.h>
#else
#else
#pragma warning(disable:4996)
#pragma warning(disable:4996)
#define snprintf _snprintf
#endif
#endif
#include <string.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <string.h>
#include <stdint.h>
#include <stdint.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <assert.h>
#include <assert.h>
#include <errno.h>
#include <errno.h>
//#include "sha1.h"
#include <openssl/ssl.h>
#include <openssl/ssl.h>
#include <../lib/abyss/src/session.h>
#include <../lib/abyss/src/conn.h>
typedef
TSession
ws_tsession_t
;
#ifdef _MSC_VER
typedef
int
issize_t
;
#define strncasecmp _strnicmp
#define snprintf _snprintf
#ifdef _WIN64
#define WS_SSIZE_T __int64
#elif _MSC_VER >= 1400
#define WS_SSIZE_T __int32 __w64
#else
#define WS_SSIZE_T __int32
#endif
typedef
WS_SSIZE_T
ssize_t
;
#endif
struct
globals_s
{
struct
ws_
globals_s
{
const
SSL_METHOD
*
ssl_method
;
const
SSL_METHOD
*
ssl_method
;
SSL_CTX
*
ssl_ctx
;
SSL_CTX
*
ssl_ctx
;
char
cert
[
512
];
char
cert
[
512
];
char
key
[
512
];
char
key
[
512
];
};
};
// extern struct globals_s
globals;
extern
struct
ws_globals_s
ws_
globals
;
typedef
int
ws_socket_t
;
typedef
int
ws_socket_t
;
#define ws_sock_invalid -1
#define ws_sock_invalid -1
...
@@ -59,36 +69,44 @@ typedef enum {
...
@@ -59,36 +69,44 @@ typedef enum {
}
ws_opcode_t
;
}
ws_opcode_t
;
typedef
struct
wsh_s
{
typedef
struct
wsh_s
{
ws_
tsession_t
*
tsession
;
ws_
socket_t
sock
;
char
buffer
[
65536
];
char
buffer
[
65536
];
char
wbuffer
[
65536
];
char
wbuffer
[
65536
];
size_t
buflen
;
size_t
buflen
;
i
ssize_t
datalen
;
ssize_t
datalen
;
i
ssize_t
wdatalen
;
ssize_t
wdatalen
;
char
*
payload
;
char
*
payload
;
i
ssize_t
plen
;
ssize_t
plen
;
i
ssize_t
rplen
;
ssize_t
rplen
;
SSL
*
ssl
;
SSL
*
ssl
;
int
handshake
;
int
handshake
;
uint8_t
down
;
uint8_t
down
;
int
secure
;
int
secure
;
uint8_t
close_sock
;
uint8_t
close_sock
;
SSL_CTX
*
ssl_ctx
;
int
block
;
int
sanity
;
int
secure_established
;
int
logical_established
;
int
x
;
}
wsh_t
;
}
wsh_t
;
i
ssize_t
ws_send_buf
(
wsh_t
*
wsh
,
ws_opcode_t
oc
);
ssize_t
ws_send_buf
(
wsh_t
*
wsh
,
ws_opcode_t
oc
);
i
ssize_t
ws_feed_buf
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
ssize_t
ws_feed_buf
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
i
ssize_t
ws_raw_read
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
ssize_t
ws_raw_read
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
i
ssize_t
ws_raw_write
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
ssize_t
ws_raw_write
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
i
ssize_t
ws_read_frame
(
wsh_t
*
wsh
,
ws_opcode_t
*
oc
,
uint8_t
**
data
);
ssize_t
ws_read_frame
(
wsh_t
*
wsh
,
ws_opcode_t
*
oc
,
uint8_t
**
data
);
i
ssize_t
ws_write_frame
(
wsh_t
*
wsh
,
ws_opcode_t
oc
,
void
*
data
,
size_t
bytes
);
ssize_t
ws_write_frame
(
wsh_t
*
wsh
,
ws_opcode_t
oc
,
void
*
data
,
size_t
bytes
);
wsh_t
*
ws_init
(
ws_tsession_t
*
tsession
);
int
ws_init
(
wsh_t
*
wsh
,
ws_socket_t
sock
,
SSL_CTX
*
ssl_ctx
,
int
close_sock
,
int
block
);
i
ssize_t
ws_close
(
wsh_t
*
wsh
,
int16_t
reason
);
ssize_t
ws_close
(
wsh_t
*
wsh
,
int16_t
reason
);
void
ws_destroy
(
wsh_t
*
wsh
);
void
ws_destroy
(
wsh_t
*
wsh
);
void
init_ssl
(
void
);
void
init_ssl
(
void
);
void
deinit_ssl
(
void
);
void
deinit_ssl
(
void
);
int
ws_handshake_kvp
(
wsh_t
*
wsh
,
char
*
key
,
char
*
version
,
char
*
proto
);
int
xp_errno
(
void
);
int
xp_is_blocking
(
int
errcode
);
#ifndef _MSC_VER
#ifndef _MSC_VER
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论