Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
97849ba2
提交
97849ba2
authored
1月 08, 2018
作者:
Steve Underwood
提交者:
Mike Jerris
1月 15, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A tweak to the PCAP file parsing code in spandsp to allow for 802.1Q headers in
Ethernet packets.
上级
bcf5a893
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
27 行增加
和
20 行删除
+27
-20
g722_tests.c
libs/spandsp/tests/g722_tests.c
+1
-0
pcap_parse.c
libs/spandsp/tests/pcap_parse.c
+26
-20
没有找到文件。
libs/spandsp/tests/g722_tests.c
浏览文件 @
97849ba2
...
...
@@ -593,6 +593,7 @@ int main(int argc, char *argv[])
exit
(
2
);
}
}
dec_state
=
NULL
;
if
(
decode
)
{
memset
(
&
info
,
0
,
sizeof
(
info
));
...
...
libs/spandsp/tests/pcap_parse.c
浏览文件 @
97849ba2
...
...
@@ -37,6 +37,7 @@
#if defined(HAVE_PCAP_H)
#include <pcap.h>
#include <pcap/sll.h>
#endif
#include <netinet/in.h>
#include <netinet/udp.h>
...
...
@@ -95,15 +96,6 @@ typedef struct _ether_hdr
uint16_t
ether_type
;
}
ether_hdr
;
typedef
struct
_linux_sll_hdr
{
uint16_t
packet_type
;
uint16_t
arphrd
;
uint16_t
slink_length
;
uint8_t
bytes
[
8
];
uint16_t
ether_type
;
}
linux_sll_hdr
;
typedef
struct
_null_hdr
{
uint32_t
pf_type
;
...
...
@@ -132,12 +124,13 @@ int pcap_scan_pkts(const char *file,
pcap_t
*
pcap
;
struct
pcap_pkthdr
*
pkthdr
;
uint8_t
*
pktdata
;
uint8_t
*
pktptr
;
const
uint8_t
*
body
;
int
body_len
;
int
total_pkts
;
uint32_t
pktlen
;
ether_hdr
*
ethhdr
;
linux_sll_hd
r
*
sllhdr
;
struct
sll_heade
r
*
sllhdr
;
null_hdr
*
nullhdr
;
struct
iphdr
*
iphdr
;
#if !defined(__CYGWIN__)
...
...
@@ -150,9 +143,10 @@ int pcap_scan_pkts(const char *file,
total_pkts
=
0
;
if
((
pcap
=
pcap_open_offline
(
file
,
errbuf
))
==
NULL
)
{
fprintf
(
stderr
,
"Can't open PCAP file
'%s'
\n
"
,
file
);
fprintf
(
stderr
,
"Can't open PCAP file
: %s
\n
"
,
errbuf
);
return
-
1
;
}
//printf("PCAP file version %d.%d\n", pcap_major_version(pcap), pcap_minor_version(pcap));
datalink
=
pcap_datalink
(
pcap
);
/* DLT_EN10MB seems to apply to all forms of ethernet, not just the 10MB kind. */
switch
(
datalink
)
...
...
@@ -185,11 +179,21 @@ int pcap_scan_pkts(const char *file,
while
((
pktdata
=
(
uint8_t
*
)
pcap_next
(
pcap
,
pkthdr
))
!=
NULL
)
{
#endif
pktptr
=
pktdata
;
switch
(
datalink
)
{
case
DLT_EN10MB
:
ethhdr
=
(
ether_hdr
*
)
pkt
data
;
ethhdr
=
(
ether_hdr
*
)
pkt
ptr
;
packet_type
=
ntohs
(
ethhdr
->
ether_type
);
pktptr
+=
sizeof
(
*
ethhdr
);
/* Check for a 802.1Q Virtual LAN entry we might need to step over */
if
(
packet_type
==
0x8100
)
{
/* Step over the 802.1Q stuff, to get to the next packet type */
pktptr
+=
sizeof
(
uint16_t
);
packet_type
=
ntohs
(
*
((
uint16_t
*
)
pktptr
));
pktptr
+=
sizeof
(
uint16_t
);
}
#if !defined(__CYGWIN__)
if
(
packet_type
!=
0x0800
/* IPv4 */
&&
...
...
@@ -200,11 +204,12 @@ int pcap_scan_pkts(const char *file,
{
continue
;
}
iphdr
=
(
struct
iphdr
*
)
((
uint8_t
*
)
ethhdr
+
sizeof
(
*
ethhdr
))
;
iphdr
=
(
struct
iphdr
*
)
pktptr
;
break
;
case
DLT_LINUX_SLL
:
sllhdr
=
(
linux_sll_hdr
*
)
pktdata
;
packet_type
=
ntohs
(
sllhdr
->
ether_type
);
sllhdr
=
(
struct
sll_header
*
)
pktptr
;
packet_type
=
ntohs
(
sllhdr
->
sll_protocol
);
pktptr
+=
sizeof
(
*
sllhdr
);
#if !defined(__CYGWIN__)
if
(
packet_type
!=
0x0800
/* IPv4 */
&&
...
...
@@ -215,13 +220,14 @@ int pcap_scan_pkts(const char *file,
{
continue
;
}
iphdr
=
(
struct
iphdr
*
)
((
uint8_t
*
)
sllhdr
+
sizeof
(
*
sllhdr
))
;
iphdr
=
(
struct
iphdr
*
)
pktptr
;
break
;
case
DLT_NULL
:
nullhdr
=
(
null_hdr
*
)
pktdata
;
nullhdr
=
(
null_hdr
*
)
pktptr
;
pktptr
+=
sizeof
(
*
nullhdr
);
if
(
nullhdr
->
pf_type
!=
PF_INET
&&
nullhdr
->
pf_type
!=
PF_INET6
)
continue
;
iphdr
=
(
struct
iphdr
*
)
((
uint8_t
*
)
nullhdr
+
sizeof
(
*
nullhdr
))
;
iphdr
=
(
struct
iphdr
*
)
pktptr
;
break
;
default:
continue
;
...
...
@@ -239,10 +245,10 @@ int pcap_scan_pkts(const char *file,
if
(
iphdr
&&
iphdr
->
version
==
6
)
{
/* ipv6 */
pktlen
=
(
uint32_t
)
pkthdr
->
len
-
sizeof
(
*
ethhdr
)
-
sizeof
(
*
ip6hdr
);
ip6hdr
=
(
ipv6_hdr
*
)
(
void
*
)
iphdr
;
if
(
ip6hdr
->
nxt_header
!=
IPPROTO_UDP
)
continue
;
pktlen
=
(
uint32_t
)
pkthdr
->
len
-
(
pktptr
-
pktdata
)
-
sizeof
(
*
ip6hdr
);
udphdr
=
(
struct
udphdr
*
)
((
uint8_t
*
)
ip6hdr
+
sizeof
(
*
ip6hdr
));
}
else
...
...
@@ -256,7 +262,7 @@ int pcap_scan_pkts(const char *file,
pktlen
=
(
uint32_t
)
ntohs
(
udphdr
->
uh_ulen
);
#elif defined ( __HPUX)
udphdr
=
(
struct
udphdr
*
)
((
uint8_t
*
)
iphdr
+
(
iphdr
->
ihl
<<
2
));
pktlen
=
(
uint32_t
)
pkthdr
->
len
-
sizeof
(
*
ethhdr
)
-
sizeof
(
*
iphdr
);
pktlen
=
(
uint32_t
)
pkthdr
->
len
-
(
pktptr
-
pktdata
)
-
sizeof
(
*
iphdr
);
#else
udphdr
=
(
struct
udphdr
*
)
((
uint8_t
*
)
iphdr
+
(
iphdr
->
ihl
<<
2
));
pktlen
=
(
uint32_t
)
ntohs
(
udphdr
->
len
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论