mirror of
https://github.com/CHN-beta/xmurp-ua.git
synced 2024-10-22 19:38:44 +08:00
avoid unnecessary memory copy.
This commit is contained in:
parent
e8487aa35b
commit
6a7ec2411f
2
Makefile
2
Makefile
@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
include $(INCLUDE_DIR)/kernel.mk
|
include $(INCLUDE_DIR)/kernel.mk
|
||||||
|
|
||||||
PKG_NAME:=xmurp-ua
|
PKG_NAME:=xmurp-ua
|
||||||
PKG_RELEASE:=28
|
PKG_RELEASE:=29
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
@ -181,6 +181,24 @@ unsigned int hook_funcion(void *priv, struct sk_buff *skb, const struct nf_hook_
|
|||||||
return NF_ACCEPT;
|
return NF_ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 决定是否发送到下一层
|
||||||
|
if(catch_next_frag && iph->saddr == saddr && iph->daddr == daddr &&
|
||||||
|
tcph->seq == seq && tcph->source == sport && tcph->dest == dport)
|
||||||
|
jump_to_next_function = 1;
|
||||||
|
else if(data_end - data_start > 3)
|
||||||
|
if(memcmp(data_start, "GET", 3) == 0 || memcmp(data_start, "POST", 4) == 0)
|
||||||
|
{
|
||||||
|
if(catch_next_frag)
|
||||||
|
{
|
||||||
|
n_ua_modify_faild++;
|
||||||
|
char_scan(0);
|
||||||
|
catch_next_frag = 0;
|
||||||
|
}
|
||||||
|
jump_to_next_function = 1;
|
||||||
|
}
|
||||||
|
if(!jump_to_next_function)
|
||||||
|
return NF_ACCEPT;
|
||||||
|
|
||||||
// 确保 skb 可以被修改,或者不可以被修改的话把它变得可修改
|
// 确保 skb 可以被修改,或者不可以被修改的话把它变得可修改
|
||||||
if(skb_ensure_writable(skb, (char*)data_end - (char*)skb -> data))
|
if(skb_ensure_writable(skb, (char*)data_end - (char*)skb -> data))
|
||||||
{
|
{
|
||||||
@ -201,25 +219,6 @@ unsigned int hook_funcion(void *priv, struct sk_buff *skb, const struct nf_hook_
|
|||||||
data_start = (char *)tcph + tcph->doff * 4;
|
data_start = (char *)tcph + tcph->doff * 4;
|
||||||
data_end = (char *)tcph + ntohs(iph->tot_len) - iph->ihl * 4;
|
data_end = (char *)tcph + ntohs(iph->tot_len) - iph->ihl * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 决定是否发送到下一层
|
|
||||||
if(catch_next_frag && iph->saddr == saddr && iph->daddr == daddr &&
|
|
||||||
tcph->seq == seq && tcph->source == sport && tcph->dest == dport)
|
|
||||||
jump_to_next_function = 1;
|
|
||||||
else if(data_end - data_start > 3)
|
|
||||||
if(memcmp(data_start, "GET", 3) == 0 || memcmp(data_start, "POST", 4) == 0)
|
|
||||||
{
|
|
||||||
if(catch_next_frag)
|
|
||||||
{
|
|
||||||
n_ua_modify_faild++;
|
|
||||||
char_scan(0);
|
|
||||||
catch_next_frag = 0;
|
|
||||||
}
|
|
||||||
jump_to_next_function = 1;
|
|
||||||
}
|
|
||||||
if(!jump_to_next_function)
|
|
||||||
return NF_ACCEPT;
|
|
||||||
|
|
||||||
// 发送到下一层,并回收数据
|
// 发送到下一层,并回收数据
|
||||||
ret = skb_scan(data_start, data_end);
|
ret = skb_scan(data_start, data_end);
|
||||||
|
Loading…
Reference in New Issue
Block a user