Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mozi
rt-thread
提交
3e31d349
R
rt-thread
项目概览
Mozi
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3e31d349
编写于
1月 31, 2015
作者:
B
bernard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[lwIP] fix the pbuf q=NULL issue in ip_nat_input.
上级
72298bac
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
21 addition
and
13 deletion
+21
-13
components/net/lwip-1.4.1/src/lwipopts.h
components/net/lwip-1.4.1/src/lwipopts.h
+2
-2
components/net/lwip_nat/ipv4_nat.c
components/net/lwip_nat/ipv4_nat.c
+19
-11
未找到文件。
components/net/lwip-1.4.1/src/lwipopts.h
浏览文件 @
3e31d349
...
...
@@ -162,9 +162,9 @@
#define SYS_LIGHTWEIGHT_PROT (NO_SYS==0)
#ifdef LWIP_USING_NAT
#define
LWIP_NAT
1
#define
IP_NAT
1
#else
#define
LWIP_NAT
0
#define
IP_NAT
0
#endif
/* ---------- TCP options ---------- */
...
...
components/net/lwip_nat/ipv4_nat.c
浏览文件 @
3e31d349
...
...
@@ -117,9 +117,10 @@
#define LWIP_NAT_TTL_INFINITE (INT_MAX)
#define LWIP_NAT_DEFAULT_TTL_SECONDS (128)
#define LWIP_NAT_FORWARD_HEADER_SIZE_MIN (sizeof(struct eth_hdr))
#define LWIP_NAT_DEFAULT_STATE_TABLES_ICMP (2)
#define LWIP_NAT_DEFAULT_STATE_TABLES_TCP (16)
#define LWIP_NAT_DEFAULT_STATE_TABLES_UDP (16)
#define LWIP_NAT_DEFAULT_STATE_TABLES_ICMP (4)
#define LWIP_NAT_DEFAULT_STATE_TABLES_TCP (32)
#define LWIP_NAT_DEFAULT_STATE_TABLES_UDP (32)
#define LWIP_NAT_DEFAULT_TCP_SOURCE_PORT (40000)
#define LWIP_NAT_DEFAULT_UDP_SOURCE_PORT (40000)
...
...
@@ -538,6 +539,7 @@ ip_nat_input(struct pbuf *p)
q
=
pbuf_alloc
(
PBUF_LINK
,
0
,
PBUF_RAM
);
if
(
q
==
NULL
)
{
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
"ip_nat_input: no pbuf for outgoing header
\n
"
));
// rt_kprintf("ip_nat_input: no pbuf for outgoing header\n");
/* @todo: stats? */
pbuf_free
(
p
);
p
=
NULL
;
...
...
@@ -549,11 +551,13 @@ ip_nat_input(struct pbuf *p)
/* restore p->payload to IP header */
if
(
pbuf_header
(
p
,
-
PBUF_LINK_HLEN
))
{
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
"ip_nat_input: restoring header failed
\n
"
));
// rt_kprintf("ip_nat_input: restoring header failed\n");
/* @todo: stats? */
pbuf_free
(
p
);
p
=
NULL
;
return
1
;
}
else
q
=
p
;
}
/* if we come here, q is the pbuf to send (either points to p or to a chain) */
in_if
=
nat_entry
.
cmn
->
cfg
->
entry
.
in_if
;
...
...
@@ -572,6 +576,7 @@ ip_nat_input(struct pbuf *p)
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
"ip_nat_input: failed to send rewritten packet. link layer returned %d
\n
"
,
err
));
// rt_kprintf("ip_nat_input: failed to send rewritten packet. link layer returned %d\n", err);
}
/* now that q (and/or p) is sent (or not), give up the reference to it
this frees the input pbuf (p) as we have consumed it. */
...
...
@@ -736,6 +741,7 @@ ip_nat_out(struct pbuf *p)
if
(
err
!=
ERR_OK
)
{
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
"ip_nat_out: failed to send rewritten packet. link layer returned %d
\n
"
,
err
));
// rt_kprintf("ip_nat_out: failed to send rewritten packet. link layer returned %d\n", err);
}
else
{
sent
=
1
;
}
...
...
@@ -842,6 +848,7 @@ ip_nat_udp_lookup_outgoing(ip_nat_conf_t *nat_config, const struct ip_hdr *iphdr
nat_entry
.
udp
);
}
else
{
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
"ip_nat_udp_lookup_outgoing: no more NAT entries available
\n
"
));
// rt_kprintf("ip_nat_udp_lookup_outgoing: no more NAT entries available\n");
}
}
}
...
...
@@ -926,6 +933,7 @@ ip_nat_tcp_lookup_outgoing(ip_nat_conf_t *nat_config, const struct ip_hdr *iphdr
nat_entry
.
tcp
);
}
else
{
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
"ip_nat_udp_lookup_outgoing: no more NAT entries available
\n
"
));
// rt_kprintf("ip_nat_udp_lookup_outgoing: no more NAT entries available\n");
}
}
}
...
...
@@ -1005,9 +1013,9 @@ ip_nat_dbg_dump(const char *msg, const struct ip_hdr *iphdr)
LWIP_ASSERT
(
"NULL != msg"
,
NULL
!=
msg
);
LWIP_ASSERT
(
"NULL != iphdr"
,
NULL
!=
iphdr
);
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
"%s: IP: ("
,
msg
));
ip_nat_dbg_dump_ip
(
&
iphdr
->
src
);
ip_nat_dbg_dump_ip
(
(
ip_addr_t
*
)
&
(
iphdr
->
src
)
);
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
" --> "
));
ip_nat_dbg_dump_ip
(
&
iphdr
->
dest
);
ip_nat_dbg_dump_ip
(
(
ip_addr_t
*
)
&
(
iphdr
->
dest
)
);
LWIP_DEBUGF
(
LWIP_NAT_DEBUG
,
(
" id=%"
U16_F
", chksum=%"
U16_F
")
\n
"
,
ntohs
(
IPH_ID
(
iphdr
)),
ntohs
(
IPH_CHKSUM
(
iphdr
))));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录