Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
f0a0e469
提交
f0a0e469
authored
7月 29, 2013
作者:
Seven Du
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ws
上级
4fc8bc76
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
870 行增加
和
0 行删除
+870
-0
ws.c
src/mod/xml_int/mod_xml_rpc/ws.c
+771
-0
ws.h
src/mod/xml_int/mod_xml_rpc/ws.h
+99
-0
没有找到文件。
src/mod/xml_int/mod_xml_rpc/ws.c
0 → 100644
浏览文件 @
f0a0e469
差异被折叠。
点击展开。
src/mod/xml_int/mod_xml_rpc/ws.h
0 → 100644
浏览文件 @
f0a0e469
#ifndef _WS_H
#define _WS_H
//#define WSS_STANDALONE 1
#define WEBSOCKET_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
#define B64BUFFLEN 1024
#include <sys/types.h>
#ifndef _MSC_VER
#include <arpa/inet.h>
#include <sys/wait.h>
#include <sys/socket.h>
#else
#pragma warning(disable:4996)
#endif
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
//#include "sha1.h"
#include <openssl/ssl.h>
#include <sofia-sip/su_types.h>
struct
globals_s
{
const
SSL_METHOD
*
ssl_method
;
SSL_CTX
*
ssl_ctx
;
char
cert
[
512
];
char
key
[
512
];
};
extern
struct
globals_s
globals
;
typedef
int
ws_socket_t
;
#define ws_sock_invalid -1
typedef
enum
{
WS_NONE
=
0
,
WS_NORMAL
=
1000
,
WS_PROTO_ERR
=
1002
,
WS_DATA_TOO_BIG
=
1009
}
ws_cause_t
;
typedef
enum
{
WSOC_CONTINUATION
=
0x0
,
WSOC_TEXT
=
0x1
,
WSOC_BINARY
=
0x2
,
WSOC_CLOSE
=
0x8
,
WSOC_PING
=
0x9
,
WSOC_PONG
=
0xA
}
ws_opcode_t
;
typedef
struct
wsh_s
{
ws_socket_t
sock
;
char
buffer
[
65536
];
char
wbuffer
[
65536
];
size_t
buflen
;
issize_t
datalen
;
issize_t
wdatalen
;
char
*
payload
;
issize_t
plen
;
issize_t
rplen
;
SSL
*
ssl
;
int
handshake
;
uint8_t
down
;
int
secure
;
uint8_t
close_sock
;
}
wsh_t
;
issize_t
ws_send_buf
(
wsh_t
*
wsh
,
ws_opcode_t
oc
);
issize_t
ws_feed_buf
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
issize_t
ws_raw_read
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
issize_t
ws_raw_write
(
wsh_t
*
wsh
,
void
*
data
,
size_t
bytes
);
issize_t
ws_read_frame
(
wsh_t
*
wsh
,
ws_opcode_t
*
oc
,
uint8_t
**
data
);
issize_t
ws_write_frame
(
wsh_t
*
wsh
,
ws_opcode_t
oc
,
void
*
data
,
size_t
bytes
);
int
ws_init
(
wsh_t
*
wsh
,
ws_socket_t
sock
,
SSL_CTX
*
ssl_ctx
,
int
close_sock
);
issize_t
ws_close
(
wsh_t
*
wsh
,
int16_t
reason
);
void
ws_destroy
(
wsh_t
*
wsh
);
void
init_ssl
(
void
);
void
deinit_ssl
(
void
);
#ifndef _MSC_VER
static
inline
uint64_t
get_unaligned_uint64
(
const
void
*
p
)
{
const
struct
{
uint64_t
d
;
}
__attribute__
((
packed
))
*
pp
=
p
;
return
pp
->
d
;
}
#endif
#endif
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论